@pipelex/sdk 0.20.1 → 0.22.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.
- package/README.md +28 -1
- package/dist/artifacts.js +3 -1
- package/dist/artifacts.js.map +1 -1
- package/dist/client.d.ts +41 -1
- package/dist/client.js +50 -17
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +25 -7
- package/dist/errors.js +15 -7
- package/dist/errors.js.map +1 -1
- package/dist/hooks/claude-mthds-check.js +2 -2
- package/dist/hooks/claude-mthds-check.js.map +1 -1
- package/dist/hooks/validate-client.d.ts +12 -0
- package/dist/hooks/validate-client.js +15 -0
- package/dist/hooks/validate-client.js.map +1 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/product-models.d.ts +42 -1
- package/dist/product-models.js +1 -1
- package/dist/upload-grant.d.ts +60 -0
- package/dist/upload-grant.js +227 -0
- package/dist/upload-grant.js.map +1 -0
- package/dist/upload.d.ts +4 -3
- package/dist/upload.js +6 -5
- package/dist/upload.js.map +1 -1
- package/dist/user-agent.d.ts +66 -0
- package/dist/user-agent.js +153 -0
- package/dist/user-agent.js.map +1 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.js +7 -0
- package/dist/version.js.map +1 -0
- package/docs/architecture.md +8 -3
- package/docs/client-identification.md +54 -0
- package/docs/input-preparation.md +54 -5
- package/package.json +6 -1
package/dist/errors.js
CHANGED
|
@@ -57,18 +57,22 @@ export class InvalidLocalSourceError extends InputPreparationError {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
|
-
* The server refused the asset — most commonly a `413` past the
|
|
61
|
-
* size cap
|
|
62
|
-
*
|
|
60
|
+
* The server or storage refused the asset — most commonly a `413` past the
|
|
61
|
+
* service-defined size cap, or storage refusing an upload with a grant. The SDK
|
|
62
|
+
* does not impose a client-side cap; it surfaces the refusal. `filename` and
|
|
63
|
+
* `status` locate it, and `code` says why: the SDK sets it on every one it raises,
|
|
64
|
+
* so it is undefined only on one a caller constructs without it.
|
|
63
65
|
*/
|
|
64
66
|
export class RejectedAssetError extends InputPreparationError {
|
|
65
67
|
filename;
|
|
66
68
|
status;
|
|
69
|
+
code;
|
|
67
70
|
constructor(message, filename, status, options) {
|
|
68
71
|
super(message, options);
|
|
69
72
|
this.name = "RejectedAssetError";
|
|
70
73
|
this.filename = filename;
|
|
71
74
|
this.status = status;
|
|
75
|
+
this.code = options?.code;
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
78
|
/**
|
|
@@ -92,15 +96,19 @@ export class UploadAuthenticationError extends InputPreparationError {
|
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
98
|
/**
|
|
95
|
-
* A network or server fault reaching the upload route — an unreachable
|
|
96
|
-
* `5xx`,
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
+
* A network or server fault reaching the upload route or storage — an unreachable
|
|
100
|
+
* host, a `5xx`, a refused redirect, storage timing out on the body, or any other
|
|
101
|
+
* unexpected `upload()` failure. `status` is the HTTP status when a response
|
|
102
|
+
* produced it, and undefined when none did. From `uploadFile` the wrapped
|
|
103
|
+
* `ApiResponseError` is also reachable via `cause`; `uploadWithGrant` wraps no
|
|
104
|
+
* response, because storage's error body can echo the grant's credential.
|
|
99
105
|
*/
|
|
100
106
|
export class UploadTransportError extends InputPreparationError {
|
|
107
|
+
status;
|
|
101
108
|
constructor(message, options) {
|
|
102
109
|
super(message, options);
|
|
103
110
|
this.name = "UploadTransportError";
|
|
111
|
+
this.status = options?.status;
|
|
104
112
|
}
|
|
105
113
|
}
|
|
106
114
|
/**
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAItD,OAAO,EAAE,oBA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CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
*/
|
|
29
29
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
30
30
|
import { resolve as resolvePath } from "node:path";
|
|
31
|
-
import { PipelexApiClient } from "../client.js";
|
|
32
31
|
import { decideAfterLint, decideAfterValidate, encodeOutcome, extractCodexMthdsFiles, extractMthdsFilePath, extractVibeMthdsFilePath, mergeOutcomes, } from "./check-core.js";
|
|
33
32
|
import { gatherBundle } from "./bundle-gather.js";
|
|
33
|
+
import { createHookClient } from "./validate-client.js";
|
|
34
34
|
/** Per-request ceiling on the one network call — well under the hook's overall timeout. */
|
|
35
35
|
const VALIDATE_TIMEOUT_MS = 10_000;
|
|
36
36
|
async function readStdin() {
|
|
@@ -114,7 +114,7 @@ async function runValidateStage(filePath) {
|
|
|
114
114
|
return { status: "unavailable" };
|
|
115
115
|
}
|
|
116
116
|
try {
|
|
117
|
-
const client =
|
|
117
|
+
const client = createHookClient();
|
|
118
118
|
// The client owns the ceiling: on timeout it aborts the fetch itself, so the
|
|
119
119
|
// request does not keep running after the hook has given up on it.
|
|
120
120
|
const result = await client.validateFiles(gathered.files, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-mthds-check.js","sourceRoot":"","sources":["../../src/hooks/claude-mthds-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,UAAU,EAAE,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CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,6CAA6C;IACvD,CAAC;IAED,MAAM,QAAQ,GAAkB,EAAE,CAAC;IACnC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,QAAQ,CAAC,IAAI,CAAC,MAAM,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACtD,CAAC;IACD,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAED,IAAI,EAAE;KACH,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IACtB,kEAAkE;IAClE,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,IAAI,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAC;AAC7C,CAAC,CAAC;KACD,OAAO,CAAC,GAAG,EAAE;IACZ,0EAA0E;IAC1E,sEAAsE;IACtE,6BAA6B;IAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The API client the `.mthds` post-edit hook validates through, named for the
|
|
3
|
+
* `User-Agent` contract (`docs/specs/client-identification.md`): the hook
|
|
4
|
+
* identifies itself as `pipelex-mthds-check`, the registry token of the `hook`
|
|
5
|
+
* surface, in front of the SDK's own `pipelex-sdk-js` token.
|
|
6
|
+
*/
|
|
7
|
+
import { PipelexApiClient } from "../client.js";
|
|
8
|
+
import type { AppInfo } from "../user-agent.js";
|
|
9
|
+
/** The hook's identity — it ships inside this package, so it carries the SDK's version. */
|
|
10
|
+
export declare const HOOK_APP_INFO: AppInfo;
|
|
11
|
+
/** Build the client the hook's validate stage calls (key and base URL from the environment). */
|
|
12
|
+
export declare function createHookClient(): PipelexApiClient;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The API client the `.mthds` post-edit hook validates through, named for the
|
|
3
|
+
* `User-Agent` contract (`docs/specs/client-identification.md`): the hook
|
|
4
|
+
* identifies itself as `pipelex-mthds-check`, the registry token of the `hook`
|
|
5
|
+
* surface, in front of the SDK's own `pipelex-sdk-js` token.
|
|
6
|
+
*/
|
|
7
|
+
import { PipelexApiClient } from "../client.js";
|
|
8
|
+
import { SDK_VERSION } from "../version.js";
|
|
9
|
+
/** The hook's identity — it ships inside this package, so it carries the SDK's version. */
|
|
10
|
+
export const HOOK_APP_INFO = { name: "pipelex-mthds-check", version: SDK_VERSION };
|
|
11
|
+
/** Build the client the hook's validate stage calls (key and base URL from the environment). */
|
|
12
|
+
export function createHookClient() {
|
|
13
|
+
return new PipelexApiClient({ appInfo: HOOK_APP_INFO });
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=validate-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-client.js","sourceRoot":"","sources":["../../src/hooks/validate-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,2FAA2F;AAC3F,MAAM,CAAC,MAAM,aAAa,GAAY,EAAE,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AAE5F,gGAAgG;AAChG,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,gBAAgB,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;AAC1D,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,22 +7,26 @@
|
|
|
7
7
|
* errors. Consumers should import everything they need from `@pipelex/sdk`.
|
|
8
8
|
*/
|
|
9
9
|
/** Package version. Kept in sync with `package.json` — enforced by `tests/index.test.ts`. */
|
|
10
|
-
export
|
|
10
|
+
export { SDK_VERSION } from "./version.js";
|
|
11
11
|
export * from "mthds/protocol";
|
|
12
12
|
export { PipelexApiClient, DEFAULT_API_BASE_URL } from "./client.js";
|
|
13
|
+
export type { AppInfo } from "./user-agent.js";
|
|
13
14
|
export type { MthdsFile, PipelexApiRunExtensions, PipelexHostedRunExtensions, PipelexRunOptions, PipelexStartOptions, ValidateMethodSelector, ValidateFilesOptions, PipelexApiClientOptions, } from "./client.js";
|
|
14
15
|
export { methodSourceToContents } from "./method-source.js";
|
|
15
16
|
export { PipelexExecuteResult, resultsFromExecute } from "./execute-result.js";
|
|
16
17
|
export type { UploadableAsset, UploadFileOptions, UploadRecord } from "./upload.js";
|
|
18
|
+
export { uploadWithGrant } from "./upload-grant.js";
|
|
19
|
+
export type { GrantedUpload, UploadWithGrantOptions } from "./upload-grant.js";
|
|
17
20
|
export type { PrepareInputsBase, PrepareInputsClosure, PrepareInputsRequest, PreparedInputs, } from "./prepare-inputs.js";
|
|
18
21
|
export { collectArtifacts, artifactFilename, PIPELEX_STORAGE_SCHEME, BULK_RESOLVE_MAX_URIS, DEFAULT_ARTIFACT_MAX_BYTES, DEFAULT_ARTIFACT_TIMEOUT_MS, DEFAULT_DOWNLOAD_MAX_TOTAL_BYTES, DEFAULT_DOWNLOAD_CONCURRENCY, } from "./artifacts.js";
|
|
19
22
|
export type { ArtifactItemError, ArtifactScope, BulkResolveStorageUrlsInput, BulkResolvedStorageUrls, DownloadArtifactsOptions, DownloadArtifactsRequest, DownloadArtifactsResult, DownloadedArtifact, FetchArtifactOptions, ResolvedArtifact, } from "./artifacts.js";
|
|
20
23
|
export type { DiagnosticKind, DiagnosticRange, Diagnostic, LintResponse, FormatResponse, DictStuff, DictWorkingMemory, DictPipeOutput, DictRunResultExecute, MethodProvenance, PipelexRunResultStart, PipelexHostedToolingExtensions, DryRunStatus, ValidatedPipeEntry, LiftablePipeEntry, PipelexValidationReport, PipelexInvalidReport, PipelexValidationResult, ValidationErrorCategory, ValidationErrorItem, FixSafety, FixOpKind, TomlScalar, TomlValue, SetKeyOp, EnsureTableOp, DeleteKeyOp, DeleteTableOp, RenameTableKeyOp, MoveKeyOp, RemapValueOp, FixOp, SuggestedFix, ConceptRepresentationFormat, InputsTemplateFormat, MthdsFileItem, CrateRequestBase, BuildRequestBase, BuildInputsRequest, BuildOutputRequest, BuildRunnerRequest, ConceptRequest, PipeSpecRequest, CrateInvalidReport, BuildInputsValidReport, BuildOutputValidReport, BuildRunnerValidReport, GeneratedArtifact, RunnerStructures, BuildInputsResponse, BuildOutputResponse, BuildRunnerResponse, ConceptResponse, PipeSpecResponse, ResolveRequest, ResolveValidReport, ResolveResponse, CodegenKind, CodegenTarget, CodegenRequest, CodegenValidReport, CodegenResponse, } from "./models.js";
|
|
21
24
|
export { runCodegenCheck, isStampableArtifactPath, STAMPABLE_ARTIFACT_SUFFIXES, CodegenLockError, } from "./codegen-check.js";
|
|
22
25
|
export type { CodegenCheckInput, CodegenCheckReport, CodegenDrift, CodegenDriftCategory, CodegenTreeFile, } from "./codegen-check.js";
|
|
23
|
-
export type { UserProfile, ListMethodsQuery, MethodData, MethodDeletionAccepted, MethodDeletionState, MethodPage, MethodSummary, MethodWriteInput, Membership, MembershipsResponse, SubscriptionResponse, PlanView, InvoiceView, CheckoutResponse, ChangePlanResponse, BillingPortalResponse, PipelexApiKey, PipelexApiKeyCreated, PipelexApiKeyList, GatewayApiKey, GatewayApiKeyStatus, OnboardingRole, OnboardingCurrentTool, OnboardingInputType, OnboardingHeardFrom, OnboardingSubmission, ResolvedStorageUrl, UploadInput, UploadedFile, PipeStatus, ListRunsQuery, PipelineRun, RunDetail, RunErrorReport, RunPage, UpdateRunInput, } from "./product-models.js";
|
|
26
|
+
export type { UserProfile, ListMethodsQuery, MethodData, MethodDeletionAccepted, MethodDeletionState, MethodPage, MethodSummary, MethodWriteInput, Membership, MembershipsResponse, SubscriptionResponse, PlanView, InvoiceView, CheckoutResponse, ChangePlanResponse, BillingPortalResponse, PipelexApiKey, PipelexApiKeyCreated, PipelexApiKeyList, GatewayApiKey, GatewayApiKeyStatus, OnboardingRole, OnboardingCurrentTool, OnboardingInputType, OnboardingHeardFrom, OnboardingSubmission, ResolvedStorageUrl, UploadInput, UploadedFile, UploadGrantInput, UploadGrant, PipeStatus, ListRunsQuery, PipelineRun, RunDetail, RunErrorReport, RunPage, UpdateRunInput, } from "./product-models.js";
|
|
24
27
|
export { isTerminalRunStatus, isSuccessRunStatus } from "./runs.js";
|
|
25
28
|
export type { RunStatus, RunPublic, RunRead, RunResults, RunResultState, TokensUsageRecord, WaitForResultOptions, } from "./runs.js";
|
|
26
29
|
export { summarizeUsage } from "./usage.js";
|
|
27
30
|
export type { PipeUsageSummary, RunUsagePair, UsageSummary, UsageSummaryState, UsageTokenTotals, } from "./usage.js";
|
|
28
31
|
export { ApiResponseError, ApiUnreachableError, ClientAuthenticationError, MissingMainStuffError, PipelineExecuteTimeoutError, RunFailedError, RunTimeoutError, RunStillRunningError, RunLifecycleUnavailableError, InputPreparationError, EmptyMethodSourceError, InvalidLocalSourceError, RejectedAssetError, UnsupportedUploadCapabilityError, UploadAuthenticationError, UploadTransportError, ArtifactOperationError, ArtifactAuthenticationError, ArtifactFetchError, ScopeUnavailableError, } from "./errors.js";
|
|
32
|
+
export type { RejectedAssetCode } from "./errors.js";
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* errors. Consumers should import everything they need from `@pipelex/sdk`.
|
|
8
8
|
*/
|
|
9
9
|
/** Package version. Kept in sync with `package.json` — enforced by `tests/index.test.ts`. */
|
|
10
|
-
export
|
|
10
|
+
export { SDK_VERSION } from "./version.js";
|
|
11
11
|
// ── Pure MTHDS Protocol surface (re-exported from the `mthds/protocol` subpath) ──
|
|
12
12
|
// The standard's interface, wire models, request/options surface, abstract domain
|
|
13
13
|
// shapes, and the protocol-base `PipelineRequestError`. Re-exported so apps have a
|
|
@@ -20,6 +20,9 @@ export { methodSourceToContents } from "./method-source.js";
|
|
|
20
20
|
// The blocking `execute()` result — a `DictRunResultExecute` with a resolved `.main_stuff` — and
|
|
21
21
|
// the lift from it onto `RunResults`, for a caller who drives `execute()` itself.
|
|
22
22
|
export { PipelexExecuteResult, resultsFromExecute } from "./execute-result.js";
|
|
23
|
+
// Except the upload grant's sender, which is standalone so the holder of the bytes needs
|
|
24
|
+
// no client. It is also the browser-safe `@pipelex/sdk/upload` entry.
|
|
25
|
+
export { uploadWithGrant } from "./upload-grant.js";
|
|
23
26
|
// ── Artifacts (the download twin of input preparation) ──────────────
|
|
24
27
|
// `collectArtifacts` and `artifactFilename` are pure and standalone; the network
|
|
25
28
|
// operations (`resolveArtifacts` / `fetchArtifact` / `downloadArtifacts`) are client
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,6FAA6F;AAC7F,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,6FAA6F;AAC7F,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,oFAAoF;AACpF,kFAAkF;AAClF,mFAAmF;AACnF,wBAAwB;AACxB,cAAc,gBAAgB,CAAC;AAE/B,wEAAwE;AACxE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAarE,+FAA+F;AAC/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,iGAAiG;AACjG,kFAAkF;AAClF,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAK/E,yFAAyF;AACzF,sEAAsE;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AASpD,uEAAuE;AACvE,iFAAiF;AACjF,qFAAqF;AACrF,0EAA0E;AAC1E,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA2B,EAC3B,gCAAgC,EAChC,4BAA4B,GAC7B,MAAM,gBAAgB,CAAC;AAgFxB,+EAA+E;AAC/E,4EAA4E;AAC5E,iFAAiF;AACjF,0EAA0E;AAC1E,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,2BAA2B,EAC3B,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAmD5B,wEAAwE;AACxE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAWpE,oFAAoF;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAS5C,+EAA+E;AAC/E,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,EACrB,2BAA2B,EAC3B,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,4BAA4B,EAC5B,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,gCAAgC,EAChC,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,EAC3B,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAC"}
|
package/dist/product-models.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Pipelex-product wire models — the snake_case JSON shapes the hosted-product
|
|
3
3
|
* routes (`/v1/me`, `/v1/methods`, `/v1/organizations`, `/v1/billing/*`,
|
|
4
4
|
* `/v1/pipelex-api-keys`, `/v1/gateway-api-key`, `/v1/onboarding/submit`,
|
|
5
|
-
* `/v1/resolve-storage-url`, `/v1/upload`, `/v1/runs`) speak.
|
|
5
|
+
* `/v1/resolve-storage-url`, `/v1/upload`, `/v1/upload/grant`, `/v1/runs`) speak.
|
|
6
6
|
*
|
|
7
7
|
* These are the management surface a consumer (today `pipelex-app`) hand-rolls.
|
|
8
8
|
* The wire is snake_case; any camelCase remap is a consumer's UI concern and
|
|
@@ -235,6 +235,47 @@ export interface UploadedFile {
|
|
|
235
235
|
uri: string;
|
|
236
236
|
filename: string;
|
|
237
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* What an upload grant is requested for — `POST /v1/upload/grant`. The file is
|
|
240
|
+
* described, never sent: its bytes go to storage with the grant, from wherever
|
|
241
|
+
* they are held.
|
|
242
|
+
*/
|
|
243
|
+
export interface UploadGrantInput {
|
|
244
|
+
/** The original filename with its extension; the stored object keeps the extension. */
|
|
245
|
+
filename: string;
|
|
246
|
+
/**
|
|
247
|
+
* MIME type, signed into the grant so the upload must carry it. Omitted, `null`
|
|
248
|
+
* or empty, none is signed — a browser's `File.type` is empty for a type it
|
|
249
|
+
* does not know, and means the same.
|
|
250
|
+
*/
|
|
251
|
+
content_type?: string | null;
|
|
252
|
+
/** The file's exact size in bytes. The grant accepts a body of this size and no other. */
|
|
253
|
+
size: number;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* A presigned, create-only `PUT` for one new object in the caller's organization,
|
|
257
|
+
* and the `pipelex-storage://` URI that object will carry. A bearer capability
|
|
258
|
+
* until `expires_at`: whoever holds it can write that one object, once, so it is
|
|
259
|
+
* never logged. `uploadWithGrant` (also on the browser-safe `@pipelex/sdk/upload`
|
|
260
|
+
* entry) is the sender.
|
|
261
|
+
*/
|
|
262
|
+
export interface UploadGrant {
|
|
263
|
+
/** The reference the object carries — it names nothing until the `PUT` has succeeded. */
|
|
264
|
+
uri: string;
|
|
265
|
+
/** Where to `PUT` the file, as the raw request body. */
|
|
266
|
+
url: string;
|
|
267
|
+
/**
|
|
268
|
+
* The signed headers to send unchanged: `If-None-Match: *`, the `Content-Type`
|
|
269
|
+
* when one was declared, and the provenance `x-amz-meta-*` values. `Content-Length`
|
|
270
|
+
* is signed too but is not listed — the body sets it, so the body must be
|
|
271
|
+
* exactly the declared size.
|
|
272
|
+
*/
|
|
273
|
+
headers: Record<string, string>;
|
|
274
|
+
/** ISO-8601 UTC instant after which storage refuses the `PUT`. */
|
|
275
|
+
expires_at: string;
|
|
276
|
+
/** The largest file any grant allows, in bytes (the service's upload cap). */
|
|
277
|
+
max_bytes: number;
|
|
278
|
+
}
|
|
238
279
|
/** Per-pipe progress marker surfaced in a run's `pipe_statuses` map. */
|
|
239
280
|
export type PipeStatus = "scheduled" | "running" | "succeeded" | "failed" | "skipped";
|
|
240
281
|
/**
|
package/dist/product-models.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Pipelex-product wire models — the snake_case JSON shapes the hosted-product
|
|
3
3
|
* routes (`/v1/me`, `/v1/methods`, `/v1/organizations`, `/v1/billing/*`,
|
|
4
4
|
* `/v1/pipelex-api-keys`, `/v1/gateway-api-key`, `/v1/onboarding/submit`,
|
|
5
|
-
* `/v1/resolve-storage-url`, `/v1/upload`, `/v1/runs`) speak.
|
|
5
|
+
* `/v1/resolve-storage-url`, `/v1/upload`, `/v1/upload/grant`, `/v1/runs`) speak.
|
|
6
6
|
*
|
|
7
7
|
* These are the management surface a consumer (today `pipelex-app`) hand-rolls.
|
|
8
8
|
* The wire is snake_case; any camelCase remap is a consumer's UI concern and
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `uploadWithGrant` — send one file straight to Pipelex storage with an upload
|
|
3
|
+
* grant (`PipelexApiClient.requestUploadGrant`, `POST /v1/upload/grant`). The
|
|
4
|
+
* side that holds the credential requests the grant; the side that holds the
|
|
5
|
+
* bytes, typically a browser page, sends them with this. See
|
|
6
|
+
* `docs/input-preparation.md`.
|
|
7
|
+
*
|
|
8
|
+
* **This module is the browser-safe entry, `@pipelex/sdk/upload`.** Its runtime
|
|
9
|
+
* import graph must never reach a Node builtin, `undici` or the client: a page
|
|
10
|
+
* bundles it as is, with nothing marked external. It imports the error classes
|
|
11
|
+
* and the wire types only, and `tests/upload-grant.test.ts` bundles it for the
|
|
12
|
+
* browser with esbuild to hold it to that.
|
|
13
|
+
*/
|
|
14
|
+
import type { UploadGrant } from "./product-models.js";
|
|
15
|
+
export type { UploadGrant, UploadGrantInput } from "./product-models.js";
|
|
16
|
+
export { InputPreparationError, RejectedAssetError, UploadTransportError } from "./errors.js";
|
|
17
|
+
export type { RejectedAssetCode } from "./errors.js";
|
|
18
|
+
/** Per-call options for {@link uploadWithGrant}. */
|
|
19
|
+
export interface UploadWithGrantOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Cancels the upload. A caller's abort propagates as the signal's own reason,
|
|
22
|
+
* never wrapped, so it stays distinguishable from a failure.
|
|
23
|
+
*/
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
}
|
|
26
|
+
/** What a successful {@link uploadWithGrant} stored. */
|
|
27
|
+
export interface GrantedUpload {
|
|
28
|
+
/** The grant's `pipelex-storage://` reference, which now names the stored object. */
|
|
29
|
+
uri: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* `PUT` a file to storage with an upload grant, and return the reference it now
|
|
33
|
+
* carries. The file goes as the raw body with the grant's signed headers
|
|
34
|
+
* unchanged; the body sets `Content-Length`, which the grant signed, so the file
|
|
35
|
+
* must be exactly the size the grant was requested for.
|
|
36
|
+
*
|
|
37
|
+
* Storage's refusals map onto the input-preparation errors, so a caller that
|
|
38
|
+
* already handles `uploadFile` needs no new case:
|
|
39
|
+
*
|
|
40
|
+
* - `RejectedAssetError` (`status` is storage's, `code` says why) — a `412` when
|
|
41
|
+
* the grant was already used (`grant_used`: a grant writes one object, once); a
|
|
42
|
+
* `403` when the file's size, type or metadata differ from what the grant signed
|
|
43
|
+
* (`signature_mismatch`), when the request carried a header the grant did not sign
|
|
44
|
+
* (`unsigned_header`), or when the grant has expired (`grant_expired`); any other
|
|
45
|
+
* `4xx` (`store_refused`). Each asks for a new grant, or for the file the grant
|
|
46
|
+
* was requested for.
|
|
47
|
+
* - `UploadTransportError` (`status` is storage's when it answered) — storage
|
|
48
|
+
* unreachable, a `5xx`, storage timing out on the body (`400 RequestTimeout`,
|
|
49
|
+
* which wrote nothing), or a redirect, which is refused rather than followed. In a
|
|
50
|
+
* browser a refused cross-origin request looks like an unreachable host, so the
|
|
51
|
+
* message names that too. A grant whose `url` is not an absolute `http(s)` URL
|
|
52
|
+
* free of user info is refused the same way, before anything is sent.
|
|
53
|
+
*
|
|
54
|
+
* A `5xx` leaves it unknown whether the object was written: retrying with the same
|
|
55
|
+
* grant either stores it or answers the `412` of a used grant, and then the grant's
|
|
56
|
+
* `uri` may already name the file. The grant is a bearer capability: nothing here
|
|
57
|
+
* logs it, and no error this throws carries its URL, storage's error body or a
|
|
58
|
+
* runtime error that could hold either.
|
|
59
|
+
*/
|
|
60
|
+
export declare function uploadWithGrant(grant: UploadGrant, file: Blob, options?: UploadWithGrantOptions): Promise<GrantedUpload>;
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `uploadWithGrant` — send one file straight to Pipelex storage with an upload
|
|
3
|
+
* grant (`PipelexApiClient.requestUploadGrant`, `POST /v1/upload/grant`). The
|
|
4
|
+
* side that holds the credential requests the grant; the side that holds the
|
|
5
|
+
* bytes, typically a browser page, sends them with this. See
|
|
6
|
+
* `docs/input-preparation.md`.
|
|
7
|
+
*
|
|
8
|
+
* **This module is the browser-safe entry, `@pipelex/sdk/upload`.** Its runtime
|
|
9
|
+
* import graph must never reach a Node builtin, `undici` or the client: a page
|
|
10
|
+
* bundles it as is, with nothing marked external. It imports the error classes
|
|
11
|
+
* and the wire types only, and `tests/upload-grant.test.ts` bundles it for the
|
|
12
|
+
* browser with esbuild to hold it to that.
|
|
13
|
+
*/
|
|
14
|
+
import { RejectedAssetError, UploadTransportError } from "./errors.js";
|
|
15
|
+
// The classes `uploadWithGrant` raises, so a page can branch on them without the main entry.
|
|
16
|
+
export { InputPreparationError, RejectedAssetError, UploadTransportError } from "./errors.js";
|
|
17
|
+
/**
|
|
18
|
+
* `PUT` a file to storage with an upload grant, and return the reference it now
|
|
19
|
+
* carries. The file goes as the raw body with the grant's signed headers
|
|
20
|
+
* unchanged; the body sets `Content-Length`, which the grant signed, so the file
|
|
21
|
+
* must be exactly the size the grant was requested for.
|
|
22
|
+
*
|
|
23
|
+
* Storage's refusals map onto the input-preparation errors, so a caller that
|
|
24
|
+
* already handles `uploadFile` needs no new case:
|
|
25
|
+
*
|
|
26
|
+
* - `RejectedAssetError` (`status` is storage's, `code` says why) — a `412` when
|
|
27
|
+
* the grant was already used (`grant_used`: a grant writes one object, once); a
|
|
28
|
+
* `403` when the file's size, type or metadata differ from what the grant signed
|
|
29
|
+
* (`signature_mismatch`), when the request carried a header the grant did not sign
|
|
30
|
+
* (`unsigned_header`), or when the grant has expired (`grant_expired`); any other
|
|
31
|
+
* `4xx` (`store_refused`). Each asks for a new grant, or for the file the grant
|
|
32
|
+
* was requested for.
|
|
33
|
+
* - `UploadTransportError` (`status` is storage's when it answered) — storage
|
|
34
|
+
* unreachable, a `5xx`, storage timing out on the body (`400 RequestTimeout`,
|
|
35
|
+
* which wrote nothing), or a redirect, which is refused rather than followed. In a
|
|
36
|
+
* browser a refused cross-origin request looks like an unreachable host, so the
|
|
37
|
+
* message names that too. A grant whose `url` is not an absolute `http(s)` URL
|
|
38
|
+
* free of user info is refused the same way, before anything is sent.
|
|
39
|
+
*
|
|
40
|
+
* A `5xx` leaves it unknown whether the object was written: retrying with the same
|
|
41
|
+
* grant either stores it or answers the `412` of a used grant, and then the grant's
|
|
42
|
+
* `uri` may already name the file. The grant is a bearer capability: nothing here
|
|
43
|
+
* logs it, and no error this throws carries its URL, storage's error body or a
|
|
44
|
+
* runtime error that could hold either.
|
|
45
|
+
*/
|
|
46
|
+
export async function uploadWithGrant(grant, file, options = {}) {
|
|
47
|
+
const label = fileLabel(grant, file);
|
|
48
|
+
const { signal } = options;
|
|
49
|
+
// A caller's abort wins over a grant this would refuse, as it does over a failed request.
|
|
50
|
+
if (signal?.aborted)
|
|
51
|
+
throw signal.reason;
|
|
52
|
+
const target = storageTarget(grant, label);
|
|
53
|
+
let response;
|
|
54
|
+
try {
|
|
55
|
+
response = await fetch(grant.url, {
|
|
56
|
+
method: "PUT",
|
|
57
|
+
headers: grant.headers,
|
|
58
|
+
body: file,
|
|
59
|
+
// A presigned URL signs its host, so a redirect could never succeed; refusing
|
|
60
|
+
// it keeps the file from being sent anywhere the grant did not name.
|
|
61
|
+
redirect: "manual",
|
|
62
|
+
signal,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
// The signal's reason, not the runtime's error: some runtimes reject with a
|
|
67
|
+
// generic AbortError instead of the caller's own reason.
|
|
68
|
+
if (signal?.aborted)
|
|
69
|
+
throw signal.reason;
|
|
70
|
+
// Neither the runtime's message nor the error itself is kept: either can carry the
|
|
71
|
+
// request URL, and with it the grant's credential (Bun puts it on the error's `path`).
|
|
72
|
+
throw new UploadTransportError(`Upload of "${label}" could not reach storage at ${target.origin} ` +
|
|
73
|
+
`(${describeNetworkFailure(error)}). In a browser, a refused cross-origin request ` +
|
|
74
|
+
"looks the same: check that the page may connect to the storage origin (its CSP " +
|
|
75
|
+
"connect-src).");
|
|
76
|
+
}
|
|
77
|
+
if (response.status >= 200 && response.status < 300) {
|
|
78
|
+
await response.body?.cancel().catch(() => undefined);
|
|
79
|
+
return { uri: grant.uri };
|
|
80
|
+
}
|
|
81
|
+
// A browser reports a refused redirect as an opaque response with status 0.
|
|
82
|
+
if (response.type === "opaqueredirect" || (response.status >= 300 && response.status < 400)) {
|
|
83
|
+
await response.body?.cancel().catch(() => undefined);
|
|
84
|
+
throw new UploadTransportError(`Upload of "${label}" was redirected by storage, and the redirect was refused: a ` +
|
|
85
|
+
"presigned upload is valid only at the URL it was signed for.",
|
|
86
|
+
// A refused redirect in a browser is opaque, with status 0: no status reached us.
|
|
87
|
+
{ status: response.status || undefined });
|
|
88
|
+
}
|
|
89
|
+
// Only the error's code and message are kept, never the body: S3 echoes the
|
|
90
|
+
// canonical request on a signature mismatch, and with it the grant's credential.
|
|
91
|
+
const body = await response.text().catch(() => {
|
|
92
|
+
// A caller's abort errors the body stream too, and stays the caller's, unwrapped.
|
|
93
|
+
// Chrome and Firefox error it with a generic AbortError, so the reason is the signal's.
|
|
94
|
+
if (signal?.aborted)
|
|
95
|
+
throw signal.reason;
|
|
96
|
+
return "";
|
|
97
|
+
});
|
|
98
|
+
const refusal = parseStorageError(body);
|
|
99
|
+
const status = response.status;
|
|
100
|
+
if (status === 400 && refusal.code === "RequestTimeout") {
|
|
101
|
+
throw new UploadTransportError(`Upload of "${label}" timed out at storage (${describeStatus(response, refusal)}): ` +
|
|
102
|
+
"storage stopped waiting for the file's bytes and wrote nothing. Retry with the same " +
|
|
103
|
+
`grant before it expires at ${grant.expires_at}, or with a new one.`, { status });
|
|
104
|
+
}
|
|
105
|
+
if (status >= 400 && status < 500) {
|
|
106
|
+
const { code, advice } = classifyRefusal(status, refusal, grant);
|
|
107
|
+
throw new RejectedAssetError(`Storage refused the upload of "${label}" (${describeStatus(response, refusal)}): ${advice}`, label, status, { code });
|
|
108
|
+
}
|
|
109
|
+
throw new UploadTransportError(`Upload of "${label}" failed at storage (${describeStatus(response, refusal)})` +
|
|
110
|
+
(refusal.message ? `: ${refusal.message}` : "") +
|
|
111
|
+
". Retrying with the same grant either stores the file or reports the grant as used.", { status });
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The grant's URL, parsed before anything is sent. A runtime that cannot build a request
|
|
115
|
+
* from a URL names the whole URL in its error — Node and Chrome both do, for one that does
|
|
116
|
+
* not parse or that carries user info — and a browser resolves a relative one against the
|
|
117
|
+
* page, which would send the credential to the page's own origin. So only an absolute
|
|
118
|
+
* `http(s)` URL with no user info is sent, and the refusal names none of it.
|
|
119
|
+
*/
|
|
120
|
+
function storageTarget(grant, label) {
|
|
121
|
+
let target;
|
|
122
|
+
try {
|
|
123
|
+
target = new URL(grant.url);
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
target = undefined;
|
|
127
|
+
}
|
|
128
|
+
if (target === undefined ||
|
|
129
|
+
(target.protocol !== "https:" && target.protocol !== "http:") ||
|
|
130
|
+
target.username !== "" ||
|
|
131
|
+
target.password !== "") {
|
|
132
|
+
throw new UploadTransportError(`Upload of "${label}" was not sent: the grant's url is not an absolute http(s) URL ` +
|
|
133
|
+
"free of user info, so it is not the one requestUploadGrant returned. Pass the grant " +
|
|
134
|
+
"on unchanged.");
|
|
135
|
+
}
|
|
136
|
+
return target;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* A network failure described by the names and codes along its cause chain:
|
|
140
|
+
* "TypeError, caused by Error ENOTFOUND". Both are mutable, so each is kept only when it
|
|
141
|
+
* is a bare identifier, which cannot hold a URL.
|
|
142
|
+
*/
|
|
143
|
+
function describeNetworkFailure(error) {
|
|
144
|
+
const parts = [];
|
|
145
|
+
let current = error;
|
|
146
|
+
for (let depth = 0; depth < 5 && current instanceof Error; depth++) {
|
|
147
|
+
const name = isIdentifier(current.name) ? current.name : "Error";
|
|
148
|
+
const code = current.code;
|
|
149
|
+
parts.push(isIdentifier(code) ? `${name} ${code}` : name);
|
|
150
|
+
current = current.cause;
|
|
151
|
+
}
|
|
152
|
+
return parts.length > 0 ? parts.join(", caused by ") : "a non-Error rejection";
|
|
153
|
+
}
|
|
154
|
+
function isIdentifier(value) {
|
|
155
|
+
return typeof value === "string" && /^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(value);
|
|
156
|
+
}
|
|
157
|
+
/** Read `<Code>` and `<Message>` off an S3 error document. No XML parser: Node has none. */
|
|
158
|
+
function parseStorageError(body) {
|
|
159
|
+
return {
|
|
160
|
+
code: xmlElementText(body, "Code"),
|
|
161
|
+
message: xmlElementText(body, "Message"),
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function xmlElementText(body, element) {
|
|
165
|
+
const match = new RegExp(`<${element}>([^<]*)</${element}>`).exec(body);
|
|
166
|
+
if (!match?.[1])
|
|
167
|
+
return undefined;
|
|
168
|
+
return match[1]
|
|
169
|
+
.replace(/</g, "<")
|
|
170
|
+
.replace(/>/g, ">")
|
|
171
|
+
.replace(/"/g, '"')
|
|
172
|
+
.replace(/'/g, "'")
|
|
173
|
+
.replace(/&/g, "&");
|
|
174
|
+
}
|
|
175
|
+
function describeStatus(response, refusal) {
|
|
176
|
+
const reason = refusal.code ?? response.statusText;
|
|
177
|
+
return reason ? `${response.status} ${reason}` : String(response.status);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* What a `4xx` from storage means for the caller: the code it branches on, and words
|
|
181
|
+
* it can act on. An expired grant and an unsigned header both answer `403
|
|
182
|
+
* AccessDenied`, so only S3's message tells them apart.
|
|
183
|
+
*/
|
|
184
|
+
function classifyRefusal(status, refusal, grant) {
|
|
185
|
+
if (status === 412) {
|
|
186
|
+
return {
|
|
187
|
+
code: "grant_used",
|
|
188
|
+
advice: "this grant was already used. A grant writes one object, once. If an earlier attempt " +
|
|
189
|
+
"with it failed at storage, that attempt may have stored the file under the grant's " +
|
|
190
|
+
"URI; otherwise request a new grant.",
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
if (refusal.code === "SignatureDoesNotMatch") {
|
|
194
|
+
return {
|
|
195
|
+
code: "signature_mismatch",
|
|
196
|
+
advice: "the file's size, content type or metadata differ from what the grant signed. Send " +
|
|
197
|
+
"exactly the file the grant was requested for, with the grant's headers unchanged.",
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
if (refusal.message && /expired/i.test(refusal.message)) {
|
|
201
|
+
return {
|
|
202
|
+
code: "grant_expired",
|
|
203
|
+
advice: `the grant expired at ${grant.expires_at}. Request a new grant.`,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
if (refusal.message && /not signed/i.test(refusal.message)) {
|
|
207
|
+
return {
|
|
208
|
+
code: "unsigned_header",
|
|
209
|
+
advice: "the request carried a header the grant did not sign. Send the grant's headers and " +
|
|
210
|
+
"no other storage header.",
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
code: "store_refused",
|
|
215
|
+
advice: refusal.message ??
|
|
216
|
+
"request a new grant, or check the file against the one it was requested for.",
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/** The file's own name when it has one (`File`), else the object name the grant's URI ends in. */
|
|
220
|
+
function fileLabel(grant, file) {
|
|
221
|
+
const name = file.name;
|
|
222
|
+
if (typeof name === "string" && name.length > 0)
|
|
223
|
+
return name;
|
|
224
|
+
const tail = grant.uri.slice(grant.uri.lastIndexOf("/") + 1);
|
|
225
|
+
return tail.length > 0 ? tail : grant.uri;
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=upload-grant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-grant.js","sourceRoot":"","sources":["../src/upload-grant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAKvE,6FAA6F;AAC7F,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAkB9F;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAAkB,EAClB,IAAU,EACV,UAAkC,EAAE;IAEpC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACrC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,0FAA0F;IAC1F,IAAI,MAAM,EAAE,OAAO;QAAE,MAAM,MAAM,CAAC,MAAM,CAAC;IACzC,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC3C,IAAI,QAAkB,CAAC;IACvB,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,GAAG,E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GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;AAC5C,CAAC"}
|
package/dist/upload.d.ts
CHANGED
|
@@ -50,9 +50,10 @@ export declare function guessContentType(filename: string): string;
|
|
|
50
50
|
* being silently misread as text or a URL. `node:fs/promises` is imported
|
|
51
51
|
* dynamically and guarded by `isNodeRuntime()`, so it is only *loaded* in Node.
|
|
52
52
|
* Note: the dynamic import defers execution, not bundling — a browser-targeting
|
|
53
|
-
* bundler still statically resolves this literal specifier, so browser
|
|
54
|
-
* must
|
|
55
|
-
* browser
|
|
53
|
+
* bundler still statically resolves this literal specifier, so a browser consumer
|
|
54
|
+
* of the main entry must mark `node:*` external. A page that stores a file uses the
|
|
55
|
+
* browser-safe `@pipelex/sdk/upload` entry (`upload-grant.ts`) instead, which never
|
|
56
|
+
* reaches this module; making the main entry browser-safe as a whole stays open.
|
|
56
57
|
*/
|
|
57
58
|
export declare function readLocalPath(path: string): Promise<Uint8Array>;
|
|
58
59
|
/** Base64-encode bytes, cross-runtime (Buffer when present, else chunked btoa). */
|