@peterlits/snek 0.0.0-stage → 0.2.0-alpha.3
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/index.d.ts +277 -0
- package/package.json +16 -4
- package/README.md +0 -3
package/index.d.ts
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
export interface ShellOutput {
|
|
2
|
+
stdout: string;
|
|
3
|
+
stderr: string;
|
|
4
|
+
exitCode: number | null;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A lazy command that runs once when awaited or consumed.
|
|
9
|
+
*
|
|
10
|
+
* Repeated waits share the result; execution errors reject the promise.
|
|
11
|
+
*/
|
|
12
|
+
export interface ShellCommand extends PromiseLike<void> {
|
|
13
|
+
/** Capture both streams; nonzero exits resolve, execution errors reject. */
|
|
14
|
+
nothrow(): Promise<ShellOutput>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Merge environment overrides for this command, preserving inherited variables.
|
|
18
|
+
* Snapshots all own properties; keys and values must be strings.
|
|
19
|
+
* Throws TypeError for invalid input or after the command is consumed.
|
|
20
|
+
*/
|
|
21
|
+
env(values: Record<string, string>): this;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Handle completion or failure, returning a Promise for the callback result.
|
|
25
|
+
*/
|
|
26
|
+
then<TResult1 = void, TResult2 = never>(
|
|
27
|
+
onfulfilled?: ((value: void) => TResult1 | PromiseLike<TResult1>) | null,
|
|
28
|
+
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null,
|
|
29
|
+
): Promise<TResult1 | TResult2>;
|
|
30
|
+
|
|
31
|
+
/** Handle execution failure, optionally recovering with a new value. */
|
|
32
|
+
catch<TResult = never>(
|
|
33
|
+
onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null,
|
|
34
|
+
): Promise<void | TResult>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Run after success or failure; preserve the outcome unless the callback
|
|
38
|
+
* fails.
|
|
39
|
+
*/
|
|
40
|
+
finally(onfinally?: (() => void) | null): Promise<void>;
|
|
41
|
+
|
|
42
|
+
/** Capture stdout as UTF-8 text, preserving trailing newlines. */
|
|
43
|
+
text(): Promise<string>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Capture stdout and parse it as JSON; invalid JSON rejects with SyntaxError.
|
|
47
|
+
*/
|
|
48
|
+
json<T = unknown>(): Promise<T>;
|
|
49
|
+
|
|
50
|
+
/** Capture stdout as immutable bytes with an empty MIME type. */
|
|
51
|
+
blob(): Promise<Blob>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Stream stdout lines; starts on first consumption, and early exit cancels
|
|
55
|
+
* the process.
|
|
56
|
+
*/
|
|
57
|
+
lines(): AsyncIterableIterator<string>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Create a command, inserting interpolated values as literal arguments. */
|
|
61
|
+
export declare function $(
|
|
62
|
+
strings: TemplateStringsArray,
|
|
63
|
+
...values: unknown[]
|
|
64
|
+
): ShellCommand;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Minimal immutable Blob; accepts an array of parts and snapshots mutable
|
|
68
|
+
* buffers.
|
|
69
|
+
*/
|
|
70
|
+
export declare class Blob {
|
|
71
|
+
constructor(parts?: readonly (string | ArrayBuffer | Uint8Array<ArrayBuffer> | Blob)[], options?: { type?: string });
|
|
72
|
+
readonly size: number;
|
|
73
|
+
readonly type: string;
|
|
74
|
+
text(): Promise<string>;
|
|
75
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
76
|
+
slice(start?: number, end?: number, contentType?: string): Blob;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Minimal UTF-8 Buffer, backed by Uint8Array. */
|
|
80
|
+
export interface Buffer extends Uint8Array<ArrayBuffer> {}
|
|
81
|
+
export declare const Buffer: {
|
|
82
|
+
new (length: number): Buffer;
|
|
83
|
+
new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
|
|
84
|
+
new (values: ArrayLike<number>): Buffer;
|
|
85
|
+
readonly prototype: Buffer;
|
|
86
|
+
/** Strings use UTF-8; Uint8Array inputs are copied; ArrayBuffer inputs share memory. */
|
|
87
|
+
from(value: string | ArrayBuffer | Uint8Array<ArrayBuffer>): Buffer;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export interface S3RequestOptions {
|
|
91
|
+
/** Positive safe integer milliseconds; defaults to the client timeout. */
|
|
92
|
+
timeoutMs?: number;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface S3ClientOptions extends S3RequestOptions {
|
|
96
|
+
accessKeyId: string;
|
|
97
|
+
secretAccessKey: string;
|
|
98
|
+
bucket: string;
|
|
99
|
+
/** Defaults to "us-east-1". Set "auto" explicitly for Cloudflare R2. */
|
|
100
|
+
region?: string;
|
|
101
|
+
/** HTTP(S) origin, without a path, query, fragment, or embedded credentials. */
|
|
102
|
+
endpoint?: string;
|
|
103
|
+
sessionToken?: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface S3PresignOptions {
|
|
107
|
+
/** Defaults to "GET". */
|
|
108
|
+
method?: "GET" | "PUT" | "HEAD" | "DELETE";
|
|
109
|
+
/** Integer seconds from 1 to 604800. Defaults to 86400 (24 hours). */
|
|
110
|
+
expiresIn?: number;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface S3WriteOptions extends S3RequestOptions {
|
|
114
|
+
ifNoneMatch?: "*";
|
|
115
|
+
metadata?: Record<string, string>;
|
|
116
|
+
contentEncoding?: string;
|
|
117
|
+
contentDisposition?: string;
|
|
118
|
+
cacheControl?: string;
|
|
119
|
+
/** Stored Content-Type; defaults to "application/octet-stream". */
|
|
120
|
+
type?: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface S3Stat {
|
|
124
|
+
size: number;
|
|
125
|
+
type: string;
|
|
126
|
+
etag: string;
|
|
127
|
+
lastModified: Date;
|
|
128
|
+
metadata: Record<string, string>;
|
|
129
|
+
contentEncoding?: string;
|
|
130
|
+
contentDisposition?: string;
|
|
131
|
+
cacheControl?: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export type S3WriteData = string | Uint8Array<ArrayBuffer> | ArrayBuffer | Blob;
|
|
135
|
+
|
|
136
|
+
export interface S3File {
|
|
137
|
+
text(options?: S3RequestOptions): Promise<string>;
|
|
138
|
+
json<T = unknown>(options?: S3RequestOptions): Promise<T>;
|
|
139
|
+
arrayBuffer(options?: S3RequestOptions): Promise<ArrayBuffer>;
|
|
140
|
+
bytes(options?: S3RequestOptions): Promise<Uint8Array<ArrayBuffer>>;
|
|
141
|
+
blob(options?: S3RequestOptions): Promise<Blob>;
|
|
142
|
+
/** One PUT; inputs are snapshotted. Conditional writes are never retried automatically. */
|
|
143
|
+
write(data: S3WriteData, options?: S3WriteOptions): Promise<number>;
|
|
144
|
+
stat(options?: S3RequestOptions): Promise<S3Stat>;
|
|
145
|
+
/** Only HTTP 404 becomes false; other failures reject. */
|
|
146
|
+
exists(options?: S3RequestOptions): Promise<boolean>;
|
|
147
|
+
delete(options?: S3RequestOptions): Promise<void>;
|
|
148
|
+
presign(options?: S3PresignOptions): string;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Explicitly configured, path-style S3 client. No environment credential lookup. */
|
|
152
|
+
export declare class S3Client {
|
|
153
|
+
constructor(options: S3ClientOptions);
|
|
154
|
+
/** Creates a lazy reference without I/O; keys contain 1–1024 UTF-8 bytes. */
|
|
155
|
+
file(key: string): S3File;
|
|
156
|
+
write(key: string, data: S3WriteData, options?: S3WriteOptions): Promise<number>;
|
|
157
|
+
stat(key: string, options?: S3RequestOptions): Promise<S3Stat>;
|
|
158
|
+
exists(key: string, options?: S3RequestOptions): Promise<boolean>;
|
|
159
|
+
delete(key: string, options?: S3RequestOptions): Promise<void>;
|
|
160
|
+
/** Signs locally and synchronously, without I/O. */
|
|
161
|
+
presign(key: string, options?: S3PresignOptions): string;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Read/write service and transport errors. Fields depend on the response. */
|
|
165
|
+
export interface S3Error extends Error {
|
|
166
|
+
name: "S3Error";
|
|
167
|
+
operation?: string;
|
|
168
|
+
key?: string;
|
|
169
|
+
status?: number;
|
|
170
|
+
code?: string;
|
|
171
|
+
requestId?: string;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Process arguments: absolute executable path, resolved script path, then user
|
|
176
|
+
* arguments.
|
|
177
|
+
*/
|
|
178
|
+
export declare const argv: string[];
|
|
179
|
+
|
|
180
|
+
export interface CliOptionConfig {
|
|
181
|
+
default?: string | boolean;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface CliParseResult {
|
|
185
|
+
args: string[];
|
|
186
|
+
options: Record<string, string | boolean | undefined>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface CliParseConfig {
|
|
190
|
+
run?: boolean;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface CliCommand {
|
|
194
|
+
option(flags: string, description: string, config?: CliOptionConfig): this;
|
|
195
|
+
alias(name: string): this;
|
|
196
|
+
action(callback: (...args: any[]) => any): this;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** A small command-line parser with an API inspired by cac. */
|
|
200
|
+
export declare class Cli {
|
|
201
|
+
constructor();
|
|
202
|
+
command(declaration: string, description?: string): CliCommand;
|
|
203
|
+
runMatchedCommand(): any;
|
|
204
|
+
args: string[];
|
|
205
|
+
options: Record<string, string | boolean | undefined>;
|
|
206
|
+
option(flags: string, description: string, config?: CliOptionConfig): this;
|
|
207
|
+
/**
|
|
208
|
+
* Register `-h` / `--help`. Output happens during parse; the script
|
|
209
|
+
* continues.
|
|
210
|
+
*/
|
|
211
|
+
help(): this;
|
|
212
|
+
/**
|
|
213
|
+
* Register `-v` / `--version`. Output happens during parse; the script
|
|
214
|
+
* continues.
|
|
215
|
+
*/
|
|
216
|
+
version(value: string): this;
|
|
217
|
+
/**
|
|
218
|
+
* Parse script arguments.
|
|
219
|
+
*/
|
|
220
|
+
parse(args?: string[], config?: CliParseConfig): CliParseResult;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare global {
|
|
224
|
+
interface ImportMeta {
|
|
225
|
+
dir: string;
|
|
226
|
+
file: string;
|
|
227
|
+
path: string;
|
|
228
|
+
url: string;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** Create a lazy local-file reference, resolving relative paths now. */
|
|
233
|
+
export declare function file(path: string): LocalFile;
|
|
234
|
+
|
|
235
|
+
export interface LocalFile {
|
|
236
|
+
text(): Promise<string>;
|
|
237
|
+
json<T = unknown>(): Promise<T>;
|
|
238
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
239
|
+
blob(): Promise<Blob>;
|
|
240
|
+
/** Create or replace the file; return bytes written. Does not create parents. */
|
|
241
|
+
write(data: string | Uint8Array<ArrayBuffer>): Promise<number>;
|
|
242
|
+
/** Create or append; return bytes written. Does not create parents. */
|
|
243
|
+
append(data: string | Uint8Array<ArrayBuffer>): Promise<number>;
|
|
244
|
+
/** False for missing paths; directories and other filesystem errors reject. */
|
|
245
|
+
exists(): Promise<boolean>;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface FileError extends Error {
|
|
249
|
+
name: "FileError";
|
|
250
|
+
operation: string;
|
|
251
|
+
path: string;
|
|
252
|
+
code: string;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface Process {
|
|
256
|
+
readonly argv: string[];
|
|
257
|
+
readonly execPath: string;
|
|
258
|
+
readonly pid: number;
|
|
259
|
+
readonly platform: string;
|
|
260
|
+
readonly arch: string;
|
|
261
|
+
readonly version: string;
|
|
262
|
+
readonly env: Record<string, string | undefined>;
|
|
263
|
+
cwd(): string;
|
|
264
|
+
chdir(path: string): void;
|
|
265
|
+
exit(code?: number): never;
|
|
266
|
+
/** Integer from 0 to 255; applied after pending work completes. */
|
|
267
|
+
exitCode: number;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export declare const process: Process;
|
|
271
|
+
|
|
272
|
+
export declare class Semver {
|
|
273
|
+
constructor(version: string);
|
|
274
|
+
bump(op: "major" | "minor" | "patch" | "release" | "alpha" | "beta" | "rc"): Semver;
|
|
275
|
+
bump(op: "premajor" | "preminor" | "prepatch", channel?: "alpha" | "beta" | "rc"): Semver;
|
|
276
|
+
toString(): string;
|
|
277
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peterlits/snek",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0-alpha.3",
|
|
4
|
+
"description": "TypeScript type declarations for the Snek runtime",
|
|
5
|
+
"types": "./index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"index.d.ts"
|
|
8
|
+
],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/PeterlitsZo/Snek.git",
|
|
12
|
+
"directory": "snek-types"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"registry": "https://registry.npmjs.org/"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/README.md
DELETED