@stacksjs/types 0.72.77 → 0.72.79
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/commands.d.ts +130 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { CLI } from '@stacksjs/clapp';
|
|
2
|
+
/*.ts`).
|
|
3
|
+
*
|
|
4
|
+
* Only `default` is required. The two optional exports are the per-file
|
|
5
|
+
* equivalent of what the registry used to carry, so a command can declare them
|
|
6
|
+
* next to its own code rather than in a separate file.
|
|
7
|
+
*/
|
|
8
|
+
export declare interface CommandModule {
|
|
9
|
+
default: CommandFactory
|
|
10
|
+
enabled?: boolean
|
|
11
|
+
aliases?: string[]
|
|
12
|
+
}
|
|
13
|
+
/** A registry entry that needs more than a file name. */
|
|
14
|
+
export declare interface CommandConfig {
|
|
15
|
+
file: string
|
|
16
|
+
enabled?: boolean
|
|
17
|
+
aliases?: string[]
|
|
18
|
+
}
|
|
19
|
+
/** A command file the loader found, after the registry (if any) is applied. */
|
|
20
|
+
export declare interface ResolvedCommand {
|
|
21
|
+
file: string
|
|
22
|
+
path: string
|
|
23
|
+
signature?: string
|
|
24
|
+
aliases: string[]
|
|
25
|
+
enabled: boolean
|
|
26
|
+
source: 'auto' | 'registry'
|
|
27
|
+
}
|
|
28
|
+
/* -------------------------------------------------------------------------- */
|
|
29
|
+
/* Option typing */
|
|
30
|
+
/* -------------------------------------------------------------------------- */
|
|
31
|
+
/** How a single option behaves. A bare string is shorthand for its description. */
|
|
32
|
+
export declare interface CommandOptionConfig<TDefault = unknown, TParsed = unknown> {
|
|
33
|
+
description?: string
|
|
34
|
+
default?: TDefault
|
|
35
|
+
type?: Array<(value: string) => TParsed>
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The declarative form of a command.
|
|
39
|
+
*
|
|
40
|
+
* Everything the CLI needs is in one object, so the handler's `options` are
|
|
41
|
+
* inferred from the flags rather than restated as a hand-written interface.
|
|
42
|
+
*/
|
|
43
|
+
export declare interface CommandDefinition<TOptions extends CommandOptionsMap = CommandOptionsMap> {
|
|
44
|
+
name: string
|
|
45
|
+
description?: string
|
|
46
|
+
aliases?: string[]
|
|
47
|
+
options?: TOptions
|
|
48
|
+
examples?: CommandExample[]
|
|
49
|
+
usage?: string
|
|
50
|
+
allowUnknownOptions?: boolean
|
|
51
|
+
handle: (options: InferCommandOptions<TOptions>, ...args: string[]) => unknown
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Types for the commands an application defines in `app/Commands/`.
|
|
55
|
+
*
|
|
56
|
+
* These used to be hand-declared in every application's `app/Commands.ts`,
|
|
57
|
+
* which meant each app carried its own copy of `CommandConfig` /
|
|
58
|
+
* `CommandRegistry` and the framework had no way to improve them. They live
|
|
59
|
+
* here now, so a command file is typed by the framework that runs it.
|
|
60
|
+
*
|
|
61
|
+
* `app/Commands.ts` itself is optional: every `.ts` file under `app/Commands/`
|
|
62
|
+
* is discovered and registered automatically. The registry only exists for the
|
|
63
|
+
* things discovery cannot infer - turning a command off, or adding an alias
|
|
64
|
+
* without touching the command file.
|
|
65
|
+
*/
|
|
66
|
+
/**
|
|
67
|
+
* The default export of a command file: it receives the CLI and registers one
|
|
68
|
+
* or more commands on it.
|
|
69
|
+
*/
|
|
70
|
+
export type CommandFactory = (cli: CLI) => unknown;
|
|
71
|
+
/**
|
|
72
|
+
* The optional `app/Commands.ts` map: signature -> file name or config.
|
|
73
|
+
*
|
|
74
|
+
* Entries here layer configuration onto files that are discovered anyway; a
|
|
75
|
+
* file that is not listed still loads.
|
|
76
|
+
*/
|
|
77
|
+
export type CommandRegistry = Record<string, string | CommandConfig>;
|
|
78
|
+
/** A command's option map, keyed by raw flag (`'--dry-run, -d'`, `'--project <id>'`). */
|
|
79
|
+
export type CommandOptionsMap = Record<string, string | CommandOptionConfig<any, any>>;
|
|
80
|
+
declare type Trim<S extends string> = S extends ` ${infer R}` ? Trim<R> : S extends `${infer R} ` ? Trim<R> : S;
|
|
81
|
+
/** `'--project <id>'` -> `'--project'` */
|
|
82
|
+
declare type WithoutArgument<S extends string> = S extends `${infer Head} ${string}` ? Head : S;
|
|
83
|
+
/** Picks the long flag out of `'--two, -t'` / `'-t, --two'`, falling back to the short one. */
|
|
84
|
+
declare type FlagName<S extends string> = S extends `${infer Head},${infer Rest}`
|
|
85
|
+
? Trim<WithoutArgument<Head>> extends `--${infer Long}`
|
|
86
|
+
? Long
|
|
87
|
+
: FlagName<Trim<Rest>>
|
|
88
|
+
: Trim<WithoutArgument<S>> extends `--${infer Long}`
|
|
89
|
+
? Long
|
|
90
|
+
: Trim<WithoutArgument<S>> extends `-${infer Short}`
|
|
91
|
+
? Short
|
|
92
|
+
: Trim<WithoutArgument<S>>;
|
|
93
|
+
/** `--no-cache` parses into `cache: false`, so the key is the positive name. */
|
|
94
|
+
declare type Positive<S extends string> = S extends `no-${infer Name}` ? Name : S;
|
|
95
|
+
declare type CamelCase<S extends string> = S extends `${infer Head}-${infer Tail}`
|
|
96
|
+
? `${Head}${Capitalize<CamelCase<Tail>>}`
|
|
97
|
+
: S;
|
|
98
|
+
/** The property name a raw flag parses into: `'--dry-run'` -> `'dryRun'`. */
|
|
99
|
+
export type CommandOptionKey<S extends string> = CamelCase<Positive<FlagName<S>>>;
|
|
100
|
+
/** The value a raw flag parses into, before any declared default is considered. */
|
|
101
|
+
declare type ParsedFlagValue<S extends string> = S extends `${string}...${string}`
|
|
102
|
+
? string[]
|
|
103
|
+
: S extends `${string}<${string}`
|
|
104
|
+
? string
|
|
105
|
+
: S extends `${string}[${string}`
|
|
106
|
+
? string | true
|
|
107
|
+
: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* What the handler sees for one flag.
|
|
110
|
+
*
|
|
111
|
+
* A declared `type` wins over the shape of the flag (`type: [Number]` means a
|
|
112
|
+
* number, not the raw string), and a declared `default` means the property is
|
|
113
|
+
* always present.
|
|
114
|
+
*/
|
|
115
|
+
declare type CommandOptionValue<S extends string, TConfig> = TConfig extends { type: Array<(value: string) => infer TParsed> }
|
|
116
|
+
? TConfig extends { default: infer TDefault } ? TDefault | TParsed : TParsed | undefined
|
|
117
|
+
: TConfig extends { default: infer TDefault }
|
|
118
|
+
? TDefault | ParsedFlagValue<S>
|
|
119
|
+
: ParsedFlagValue<S> | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* The options object a handler receives, derived from the flags it declared.
|
|
122
|
+
*
|
|
123
|
+
* `'--dry-run': { default: false }` becomes `dryRun: boolean`, and
|
|
124
|
+
* `'--project <id>'` becomes `project: string | undefined`.
|
|
125
|
+
*/
|
|
126
|
+
export type InferCommandOptions<TOptions extends CommandOptionsMap> = {
|
|
127
|
+
[K in keyof TOptions & string as CommandOptionKey<K>]: CommandOptionValue<K, TOptions[K]>
|
|
128
|
+
}
|
|
129
|
+
/** A command example, either literal text or a function of the binary name. */
|
|
130
|
+
export type CommandExample = string | ((bin: string) => string);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function a(e){return typeof e==="object"&&e!==null&&"id"in e&&"userId"in e&&"clientId"in e&&"scopes"in e}function c(e){return a(e)&&"abilities"in e}function d(e){return typeof e==="object"&&e!==null&&"id"in e&&"name"in e&&"secret"in e&&"redirect"in e}var i;((t)=>{t.Second="* * * * * *";t.FiveSeconds="*/5 * * * * *";t.TenSeconds="*/10 * * * * *";t.ThirtySeconds="*/30 * * * * *";t.Minute="* * * * *";t.TwoMinutes="*/2 * * * *";t.FiveMinutes="*/5 * * * *";t.TenMinutes="*/10 * * * *";t.FifteenMinutes="*/15 * * * *";t.ThirtyMinutes="*/30 * * * *";t.Hour="0 * * * *";t.HalfHour="0,30 * * * *";t.Day="0 0 * * *";t.Week="0 0 * * 0";t.Weekday="0 0 * * 1-5";t.Weekend="0 0 * * 0,6";t.Month="0 0 1 * *";t.Year="0 0 1 1 *"})(i||={});var s;((r)=>{r.Bluesky="bluesky";r.Discord="discord";r.Facebook="facebook";r.GitHub="github";r.Instagram="instagram";r.LinkedIn="linkedin";r.Mastodon="mastodon";r.Slack="slack";r.Twitter="twitter";r.YouTube="youtube"})(s||={});var l;((n)=>{n[n.Success=0]="Success";n[n.FatalError=1]="FatalError";n[n.InvalidArgument=9]="InvalidArgument"})(l||={});import{toString as p}from"@stacksjs/strings";function
|
|
2
|
+
function a(e){return typeof e==="object"&&e!==null&&"id"in e&&"userId"in e&&"clientId"in e&&"scopes"in e}function c(e){return a(e)&&"abilities"in e}function d(e){return typeof e==="object"&&e!==null&&"id"in e&&"name"in e&&"secret"in e&&"redirect"in e}var i;((t)=>{t.Second="* * * * * *";t.FiveSeconds="*/5 * * * * *";t.TenSeconds="*/10 * * * * *";t.ThirtySeconds="*/30 * * * * *";t.Minute="* * * * *";t.TwoMinutes="*/2 * * * *";t.FiveMinutes="*/5 * * * *";t.TenMinutes="*/10 * * * *";t.FifteenMinutes="*/15 * * * *";t.ThirtyMinutes="*/30 * * * *";t.Hour="0 * * * *";t.HalfHour="0,30 * * * *";t.Day="0 0 * * *";t.Week="0 0 * * 0";t.Weekday="0 0 * * 1-5";t.Weekend="0 0 * * 0,6";t.Month="0 0 1 * *";t.Year="0 0 1 1 *"})(i||={});var s;((r)=>{r.Bluesky="bluesky";r.Discord="discord";r.Facebook="facebook";r.GitHub="github";r.Instagram="instagram";r.LinkedIn="linkedin";r.Mastodon="mastodon";r.Slack="slack";r.Twitter="twitter";r.YouTube="youtube"})(s||={});var l;((n)=>{n[n.Success=0]="Success";n[n.FatalError=1]="FatalError";n[n.InvalidArgument=9]="InvalidArgument"})(l||={});import{toString as p}from"@stacksjs/strings";function x(e){if(e===null)return"null";let o=p(e).slice(8,-1).toLowerCase();return typeof e==="object"||typeof e==="function"?o:typeof e}function h(e){return e}function T(e){return e}var C={development:{default:"sync",connections:{sync:{driver:"sync"}},failed:{driver:"database",table:"failed_jobs"}},production:{default:"redis",connections:{redis:{driver:"redis",prefix:"stacks:queue",concurrency:5,distributedLock:!0,metrics:{enabled:!0},defaultDeadLetterOptions:{enabled:!0,maxRetries:3}}},failed:{driver:"redis",prefix:"stacks:failed"},worker:{concurrency:5,shutdownTimeout:30000}},highPerformance:{default:"redis",connections:{redis:{driver:"redis",prefix:"stacks:queue",concurrency:20,distributedLock:!0,metrics:{enabled:!0,collectInterval:5000},horizontalScaling:{enabled:!0,maxWorkersPerInstance:20,jobsPerWorker:50},defaultDeadLetterOptions:{enabled:!0,maxRetries:5}}},failed:{driver:"redis",prefix:"stacks:failed"},worker:{concurrency:20,shutdownTimeout:60000}},database:{default:"database",connections:{database:{driver:"database",table:"jobs",queue:"default",retryAfter:90}},failed:{driver:"database",table:"failed_jobs"}}};var M={server:{development:{enabled:!0,mode:"server",debug:!0,server:{host:"localhost",port:6001,scheme:"ws",driver:"bun",rateLimit:{enabled:!1},healthCheck:{enabled:!0,path:"/health"}},channels:{public:!0,private:!0,presence:!0}},production:{enabled:!0,mode:"server",debug:!1,server:{host:"0.0.0.0",port:6001,scheme:"wss",driver:"bun",redis:{enabled:!0,prefix:"stacks:realtime:"},rateLimit:{enabled:!0,maxConnectionsPerIp:100,maxMessagesPerSecond:50,maxPayloadSize:65536},loadManagement:{maxConnections:1e4,backpressureThreshold:1000,messageQueueSize:1e4,gracefulShutdownTimeout:30000},autoScaling:{min:2,max:10,targetCPU:70},healthCheck:{enabled:!0,path:"/health",interval:30},metrics:{enabled:!0,port:9090,path:"/metrics"}},channels:{public:!0,private:!0,presence:!0}},highPerformance:{enabled:!0,mode:"server",server:{driver:"bun",redis:{enabled:!0,cluster:!0},rateLimit:{enabled:!0,maxConnectionsPerIp:500,maxMessagesPerSecond:200,maxPayloadSize:131072},loadManagement:{maxConnections:1e5,backpressureThreshold:5000,messageQueueSize:50000,gracefulShutdownTimeout:60000},autoScaling:{min:4,max:50,targetCPU:60}}},chat:{enabled:!0,mode:"server",server:{driver:"bun",redis:{enabled:!0},rateLimit:{enabled:!0,maxConnectionsPerIp:10,maxMessagesPerSecond:20},loadManagement:{maxConnections:50000}},channels:{public:!0,private:!0,presence:{enabled:!0,maxMembersPerChannel:500,memberInfoTtl:60}}},gaming:{enabled:!0,mode:"server",server:{driver:"bun",redis:{enabled:!0,cluster:!0},rateLimit:{enabled:!0,maxConnectionsPerIp:50,maxMessagesPerSecond:100},loadManagement:{maxConnections:50000,backpressureThreshold:2000,messageQueueSize:20000},autoScaling:{min:2,max:20,targetCPU:50}},channels:{public:!0,private:!0,presence:!0}}},serverless:{development:{enabled:!0,mode:"serverless",debug:!0,serverless:{connectionTimeout:3600,idleTimeout:600,stageName:"dev",memorySize:256,timeout:30},channels:{public:!0,private:!0,presence:!0}},production:{enabled:!0,mode:"serverless",debug:!1,serverless:{connectionTimeout:3600,idleTimeout:600,stageName:"production",memorySize:512,timeout:30,provisionedConcurrency:2},channels:{public:!0,private:!0,presence:!0}},notifications:{enabled:!0,mode:"serverless",serverless:{connectionTimeout:7200,idleTimeout:1800,memorySize:256,timeout:15},channels:{public:!0,private:!0,presence:!1}}}};var S={calendar:{github:"stacksjs/calendar",package:"@stacksjs/calendar",description:"Calendar links, ICS generation, and an STX calendar component"},table:{github:"stacksjs/table",package:"@stacksjs/table",description:"Typed table drivers and an STX data table component"}};export{i as Every,l as ExitCode,C as QueuePresets,M as RealtimePresets,s as SocialLinkIcon,h as defineModel,T as defineModels,x as getTypeName,a as isAccessToken,d as isOAuthClient,c as isPersonalAccessToken,S as stackExtensionRegistry};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/types",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.72.
|
|
4
|
+
"version": "0.72.79",
|
|
5
5
|
"description": "The Stacks framework types.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": [
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@stacksjs/validation": "0.72.
|
|
74
|
+
"@stacksjs/validation": "0.72.79",
|
|
75
75
|
"better-dx": "^0.2.24",
|
|
76
76
|
"meilisearch": "^0.59.0"
|
|
77
77
|
},
|