@buildinternet/uploads 0.10.1 → 0.11.1

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,4 +1,4 @@
1
- import { type UploadsClient } from "./client.js";
1
+ import { type PutResult, type UploadsClient } from "./client.js";
2
2
  import { type CommandFlags } from "./cli-args.js";
3
3
  import { type ResolvedConfig } from "./config.js";
4
4
  import { type GhTarget } from "./github.js";
@@ -6,6 +6,11 @@ import { type CommandRunner } from "./github-gh.js";
6
6
  import { type OptimizeImageOptions, type OptimizeImageResult } from "./optimize.js";
7
7
  import { type FrameResult } from "./frame.js";
8
8
  import type { PutDefaults } from "./config-file.js";
9
+ /** Parallel fan-out for multi-file put/attach (matches files-sdk bulk default). */
10
+ export declare const UPLOAD_BATCH_CONCURRENCY = 8;
11
+ /** @deprecated Use UPLOAD_BATCH_CONCURRENCY. */
12
+ export declare const ATTACH_CONCURRENCY = 8;
13
+ export { formatUsageHuman } from "./format-usage.js";
9
14
  export interface CliContext {
10
15
  config: ResolvedConfig;
11
16
  client: UploadsClient;
@@ -41,6 +46,92 @@ export declare function syncAttachmentsComment(client: UploadsClient, target: Gh
41
46
  action: "created" | "updated" | "skipped";
42
47
  count: number;
43
48
  }>;
49
+ export type AttachUploadItem = PutResult & {
50
+ file: string;
51
+ markdown: string;
52
+ optimize: {
53
+ optimized: boolean;
54
+ skippedReason?: OptimizeImageResult["skippedReason"];
55
+ originalBytes: number;
56
+ outputBytes: number;
57
+ filename: string;
58
+ };
59
+ frame?: PreparedUpload["frame"];
60
+ };
61
+ export type AttachFailure = {
62
+ file: string;
63
+ error: {
64
+ message: string;
65
+ code?: string;
66
+ status?: number;
67
+ };
68
+ };
69
+ /**
70
+ * Prepare + put each path as a PR/issue attachment with bounded concurrency.
71
+ * Per-file errors collect in `failures` (does not throw). `firstError` is the
72
+ * original cause of the first failure — for rethrowing single-file CLI paths.
73
+ */
74
+ export declare function uploadAttachments(opts: {
75
+ client: UploadsClient;
76
+ target: GhTarget;
77
+ files: readonly string[];
78
+ contentType?: string;
79
+ optimize: OptimizeImageOptions;
80
+ frame: {
81
+ frameId?: string;
82
+ frameUrl?: string;
83
+ frameFit?: "cover" | "contain";
84
+ };
85
+ metadata?: Record<string, string>;
86
+ /** Provenance `client` field (default uploads-cli). */
87
+ provenanceClient?: string;
88
+ concurrency?: number;
89
+ }): Promise<{
90
+ uploads: AttachUploadItem[];
91
+ failures: AttachFailure[];
92
+ firstError?: unknown;
93
+ }>;
94
+ export type PutUploadItem = PutResult & {
95
+ file: string;
96
+ markdown: string;
97
+ optimize: AttachUploadItem["optimize"];
98
+ frame?: PreparedUpload["frame"];
99
+ };
100
+ /**
101
+ * Prepare + put each path with put-style key resolution and bounded concurrency.
102
+ * Same partial-failure shape as uploadAttachments.
103
+ */
104
+ export declare function uploadPuts(opts: {
105
+ client: UploadsClient;
106
+ files: readonly string[];
107
+ /** Single-file --name leaf override. */
108
+ nameOverride?: string;
109
+ /** Single-file --key. */
110
+ explicitKey?: string;
111
+ ghTarget?: GhTarget;
112
+ prefix?: string;
113
+ repo?: string;
114
+ ref?: string;
115
+ deriveRepoFromGit?: boolean;
116
+ contentType?: string;
117
+ dryRun?: boolean;
118
+ optimize: OptimizeImageOptions;
119
+ frame: {
120
+ frameId?: string;
121
+ frameUrl?: string;
122
+ frameFit?: "cover" | "contain";
123
+ };
124
+ metadata?: Record<string, string>;
125
+ provenanceClient?: string;
126
+ /** When set, used as alt for every file; else each file's basename. */
127
+ alt?: string;
128
+ width?: number;
129
+ concurrency?: number;
130
+ }): Promise<{
131
+ uploads: PutUploadItem[];
132
+ failures: AttachFailure[];
133
+ firstError?: unknown;
134
+ }>;
44
135
  export declare function runAttach(ctx: CliContext, args: string[], help?: boolean, run?: CommandRunner): Promise<number>;
45
136
  export declare function runPut(ctx: CliContext, args: string[], help?: boolean, run?: CommandRunner): Promise<number>;
46
137
  export declare function runGallery(ctx: CliContext, args: string[], help?: boolean): Promise<number>;