@peterlits/snek 0.0.0-stage → 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.
Files changed (3) hide show
  1. package/index.d.ts +160 -0
  2. package/package.json +16 -4
  3. package/README.md +0 -3
package/index.d.ts ADDED
@@ -0,0 +1,160 @@
1
+ /**
2
+ * A lazy command that runs once when awaited or consumed.
3
+ *
4
+ * Repeated waits share the result; execution errors reject the promise.
5
+ */
6
+ export interface ShellCommand extends PromiseLike<void> {
7
+ /**
8
+ * Handle completion or failure, returning a Promise for the callback result.
9
+ */
10
+ then<TResult1 = void, TResult2 = never>(
11
+ onfulfilled?: ((value: void) => TResult1 | PromiseLike<TResult1>) | null,
12
+ onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null,
13
+ ): Promise<TResult1 | TResult2>;
14
+
15
+ /** Handle execution failure, optionally recovering with a new value. */
16
+ catch<TResult = never>(
17
+ onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null,
18
+ ): Promise<void | TResult>;
19
+
20
+ /**
21
+ * Run after success or failure; preserve the outcome unless the callback
22
+ * fails.
23
+ */
24
+ finally(onfinally?: (() => void) | null): Promise<void>;
25
+
26
+ /** Capture stdout as UTF-8 text, preserving trailing newlines. */
27
+ text(): Promise<string>;
28
+
29
+ /**
30
+ * Capture stdout and parse it as JSON; invalid JSON rejects with SyntaxError.
31
+ */
32
+ json<T = unknown>(): Promise<T>;
33
+
34
+ /** Capture stdout as immutable bytes with an empty MIME type. */
35
+ blob(): Promise<Blob>;
36
+
37
+ /**
38
+ * Stream stdout lines; starts on first consumption, and early exit cancels
39
+ * the process.
40
+ */
41
+ lines(): AsyncIterableIterator<string>;
42
+ }
43
+
44
+ /** Create a command, inserting interpolated values as literal arguments. */
45
+ export declare function $(
46
+ strings: TemplateStringsArray,
47
+ ...values: unknown[]
48
+ ): ShellCommand;
49
+
50
+ /**
51
+ * Minimal immutable Blob; accepts an array of parts and snapshots mutable
52
+ * buffers.
53
+ */
54
+ export declare class Blob {
55
+ constructor(parts?: readonly (string | ArrayBuffer | Uint8Array<ArrayBuffer> | Blob)[], options?: { type?: string });
56
+ readonly size: number;
57
+ readonly type: string;
58
+ text(): Promise<string>;
59
+ arrayBuffer(): Promise<ArrayBuffer>;
60
+ slice(start?: number, end?: number, contentType?: string): Blob;
61
+ }
62
+
63
+ /** Minimal UTF-8 Buffer, backed by Uint8Array. */
64
+ export interface Buffer extends Uint8Array<ArrayBuffer> {}
65
+ export declare const Buffer: {
66
+ new (length: number): Buffer;
67
+ new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
68
+ new (values: ArrayLike<number>): Buffer;
69
+ readonly prototype: Buffer;
70
+ /** Strings use UTF-8; Uint8Array inputs are copied; ArrayBuffer inputs share memory. */
71
+ from(value: string | ArrayBuffer | Uint8Array<ArrayBuffer>): Buffer;
72
+ };
73
+
74
+ export interface S3ClientOptions {
75
+ accessKeyId: string;
76
+ secretAccessKey: string;
77
+ bucket: string;
78
+ /** Defaults to "us-east-1". Set "auto" explicitly for Cloudflare R2. */
79
+ region?: string;
80
+ /** HTTP(S) origin, without a path, query, fragment, or embedded credentials. */
81
+ endpoint?: string;
82
+ sessionToken?: string;
83
+ }
84
+
85
+ export interface S3PresignOptions {
86
+ /** Defaults to "GET". */
87
+ method?: "GET" | "PUT";
88
+ /** Integer seconds from 1 to 604800. Defaults to 86400 (24 hours). */
89
+ expiresIn?: number;
90
+ }
91
+
92
+ export interface S3WriteOptions {
93
+ /** Stored Content-Type; defaults to "application/octet-stream". */
94
+ type?: string;
95
+ }
96
+
97
+ export interface S3File {
98
+ /** Fresh GET, buffered in memory and decoded as UTF-8 with replacement. */
99
+ text(): Promise<string>;
100
+ /** Fresh GET parsed as JSON. Invalid JSON rejects with SyntaxError. */
101
+ json<T = unknown>(): Promise<T>;
102
+ /** Fresh GET, returning an independent ArrayBuffer. */
103
+ arrayBuffer(): Promise<ArrayBuffer>;
104
+ /** One PUT replacing the object. Snapshots input and resolves to its byte count. */
105
+ write(data: string | Uint8Array<ArrayBuffer>, options?: S3WriteOptions): Promise<number>;
106
+ }
107
+
108
+ /** Explicitly configured, path-style S3 client. No environment credential lookup. */
109
+ export declare class S3Client {
110
+ constructor(options: S3ClientOptions);
111
+ /** Creates a lazy reference without I/O; keys contain 1–1024 UTF-8 bytes. */
112
+ file(key: string): S3File;
113
+ /** Signs locally and synchronously, without I/O. */
114
+ presign(key: string, options?: S3PresignOptions): string;
115
+ }
116
+
117
+ /** Read/write service and transport errors. Fields depend on the response. */
118
+ export interface S3Error extends Error {
119
+ name: "S3Error";
120
+ status?: number;
121
+ code?: string;
122
+ requestId?: string;
123
+ }
124
+
125
+ /**
126
+ * Process arguments: absolute executable path, resolved script path, then user
127
+ * arguments.
128
+ */
129
+ export declare const argv: string[];
130
+
131
+ export interface CliOptionConfig {
132
+ default?: string | boolean;
133
+ }
134
+
135
+ export interface CliParseResult {
136
+ args: string[];
137
+ options: Record<string, string | boolean | undefined>;
138
+ }
139
+
140
+ /** A small command-line parser with an API inspired by cac. */
141
+ export declare class Cli {
142
+ constructor();
143
+ args: string[];
144
+ options: Record<string, string | boolean | undefined>;
145
+ option(flags: string, description: string, config?: CliOptionConfig): this;
146
+ /**
147
+ * Register `-h` / `--help`. Output happens during parse; the script
148
+ * continues.
149
+ */
150
+ help(): this;
151
+ /**
152
+ * Register `-v` / `--version`. Output happens during parse; the script
153
+ * continues.
154
+ */
155
+ version(value: string): this;
156
+ /**
157
+ * Parse script arguments.
158
+ */
159
+ parse(args?: string[]): CliParseResult;
160
+ }
package/package.json CHANGED
@@ -1,6 +1,18 @@
1
1
  {
2
2
  "name": "@peterlits/snek",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
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
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.