@gigadrive/sdk 0.7.27 → 0.8.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 +80 -21
- package/dist/index.d.mts +867 -836
- package/dist/index.d.ts +867 -836
- package/dist/index.js +317 -227
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +315 -227
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -567,996 +567,1000 @@ declare class ApiKeysResource extends BaseResource {
|
|
|
567
567
|
delete(apiKeyId: string): Promise<void>;
|
|
568
568
|
}
|
|
569
569
|
|
|
570
|
-
/**
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
/** The human-readable environment name, if scoped to a specific environment. */
|
|
585
|
-
environmentName: string | null;
|
|
586
|
-
/** ISO 8601 timestamp of when the variable was created. */
|
|
587
|
-
createdAt: string;
|
|
588
|
-
/** ISO 8601 timestamp of when the variable was last updated. */
|
|
589
|
-
updatedAt: string;
|
|
570
|
+
/**
|
|
571
|
+
* Resolves the various accepted upload inputs (in-memory bytes, a Node.js file
|
|
572
|
+
* path, or a Node.js readable stream) into the concrete values the upload flow
|
|
573
|
+
* needs: the object tus-js-client consumes, the byte size, an inferred content
|
|
574
|
+
* type, and the required checksums.
|
|
575
|
+
*
|
|
576
|
+
* @internal
|
|
577
|
+
*/
|
|
578
|
+
|
|
579
|
+
/** A minimal Node.js `Readable`-like shape (avoids depending on `node:stream` types). */
|
|
580
|
+
interface NodeReadableLike {
|
|
581
|
+
on(event: string, listener: (...args: unknown[]) => void): unknown;
|
|
582
|
+
pipe?: unknown;
|
|
583
|
+
read?: unknown;
|
|
590
584
|
}
|
|
591
|
-
/**
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
585
|
+
/** In-memory data accepted by the upload helpers. `Buffer` is a `Uint8Array`. */
|
|
586
|
+
type UploadData = Blob | ArrayBuffer | Uint8Array;
|
|
587
|
+
/** The tus-js-client file input union. */
|
|
588
|
+
type TusFile = File | Blob | Uint8Array | NodeReadableLike;
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Thin, injectable wrapper around `tus-js-client` that performs the resumable
|
|
592
|
+
* byte upload. Isolated here so the upload flow can be unit-tested with a fake
|
|
593
|
+
* transport (no real network I/O) and so abort/resume behaviour lives in one
|
|
594
|
+
* place.
|
|
595
|
+
*
|
|
596
|
+
* @internal
|
|
597
|
+
*/
|
|
598
|
+
|
|
599
|
+
/** A persistence backend for resumable upload fingerprints (matches tus-js-client's `UrlStorage`). */
|
|
600
|
+
interface UploadUrlStorage {
|
|
601
|
+
findAllUploads(): Promise<unknown[]>;
|
|
602
|
+
findUploadsByFingerprint(fingerprint: string): Promise<unknown[]>;
|
|
603
|
+
removeUpload(urlStorageKey: string): Promise<void>;
|
|
604
|
+
addUpload(fingerprint: string, upload: unknown): Promise<string>;
|
|
603
605
|
}
|
|
604
|
-
/**
|
|
605
|
-
interface
|
|
606
|
-
/**
|
|
607
|
-
|
|
608
|
-
/**
|
|
609
|
-
|
|
610
|
-
/**
|
|
611
|
-
|
|
606
|
+
/** Parameters for a single byte upload. */
|
|
607
|
+
interface TusUploadParams {
|
|
608
|
+
/** The file/data passed to tus-js-client. */
|
|
609
|
+
data: TusFile;
|
|
610
|
+
/** Signed upload URL (already includes the short-lived upload token). */
|
|
611
|
+
uploadUrl: string;
|
|
612
|
+
/** Total upload size in bytes. */
|
|
613
|
+
uploadSize: number;
|
|
614
|
+
/** Headers to send with each request (must include `Tus-Resumable`). */
|
|
615
|
+
headers: Record<string, string>;
|
|
616
|
+
/** Maximum chunk size in bytes. Required for streamed inputs. */
|
|
617
|
+
chunkSize?: number;
|
|
618
|
+
/** Retry backoff in milliseconds. `null`/`[]` disables retries. */
|
|
619
|
+
retryDelays?: number[] | null;
|
|
620
|
+
/** Progress callback. */
|
|
621
|
+
onProgress?: (bytesSent: number, bytesTotal: number) => void;
|
|
622
|
+
/** Abort signal to cancel the upload. */
|
|
623
|
+
signal?: AbortSignal;
|
|
624
|
+
/** Persist a resumable fingerprint so the upload can resume later. */
|
|
625
|
+
resume?: boolean;
|
|
626
|
+
/** Custom storage for resumable fingerprints (defaults to the tus-js-client default for the runtime). */
|
|
627
|
+
urlStorage?: UploadUrlStorage;
|
|
612
628
|
}
|
|
629
|
+
/** Performs a single resumable byte upload. Resolves on success, rejects on error/abort. */
|
|
630
|
+
type UploadTransport = (params: TusUploadParams) => Promise<void>;
|
|
631
|
+
/** Options shared by the high-level upload entry points. */
|
|
632
|
+
interface RunUploadOptions {
|
|
633
|
+
/** Maximum chunk size in bytes. */
|
|
634
|
+
chunkSize?: number;
|
|
635
|
+
/** Retry backoff in milliseconds. `null`/`[]` disables retries. */
|
|
636
|
+
retryDelays?: number[] | null;
|
|
637
|
+
/** Progress callback. */
|
|
638
|
+
onProgress?: (bytesSent: number, bytesTotal: number) => void;
|
|
639
|
+
/** Abort signal to cancel the upload. */
|
|
640
|
+
signal?: AbortSignal;
|
|
641
|
+
/** Persist a resumable fingerprint so the upload can resume later. */
|
|
642
|
+
resume?: boolean;
|
|
643
|
+
/** Custom storage for resumable fingerprints. */
|
|
644
|
+
urlStorage?: UploadUrlStorage;
|
|
645
|
+
}
|
|
646
|
+
|
|
613
647
|
/**
|
|
614
|
-
*
|
|
615
|
-
*
|
|
648
|
+
* Canonical environment-scoped bucket name or a deprecated bucket UUID.
|
|
649
|
+
*
|
|
650
|
+
* REST callers should use the immutable bucket `name`. UUID values remain
|
|
651
|
+
* accepted while existing integrations migrate. Global delivery/S3 slugs are
|
|
652
|
+
* not valid REST bucket references.
|
|
616
653
|
*/
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
/** The resolved variable value. */
|
|
621
|
-
value: string;
|
|
622
|
-
/** Where the resolved value came from after applying org → app → environment inheritance. */
|
|
623
|
-
source: 'organization' | 'application' | 'environment';
|
|
624
|
-
}
|
|
625
|
-
/** Query options for {@link ApplicationEnvVarsResource.pull}. */
|
|
626
|
-
interface PullEnvVarsQuery {
|
|
654
|
+
type StorageBucketReference = string;
|
|
655
|
+
/** Selects an application environment by slug or UUID for management calls. */
|
|
656
|
+
interface StorageEnvironmentOptions {
|
|
627
657
|
/**
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
* baseline (organization + application-wide variables only).
|
|
658
|
+
* Environment slug or UUID. Deployed workloads normally omit this because
|
|
659
|
+
* their credential determines the authoritative environment.
|
|
631
660
|
*/
|
|
632
661
|
environment?: string;
|
|
633
662
|
}
|
|
634
|
-
/** Result of pulling resolved environment variables for local development. */
|
|
635
|
-
interface PullEnvVarsResult {
|
|
636
|
-
/** Resolved, non-sensitive variables, ready to write to a local `.env` file. */
|
|
637
|
-
items: ResolvedEnvVar[];
|
|
638
|
-
/** Number of resolved variables returned. */
|
|
639
|
-
total: number;
|
|
640
|
-
/**
|
|
641
|
-
* Number of sensitive variables that were resolved but intentionally omitted.
|
|
642
|
-
* Secrets are never returned by the pull endpoint.
|
|
643
|
-
*/
|
|
644
|
-
omittedSensitive: number;
|
|
645
|
-
}
|
|
646
663
|
|
|
647
|
-
/**
|
|
648
|
-
|
|
649
|
-
* Accessed via `client.applications.envVars`.
|
|
650
|
-
*/
|
|
651
|
-
declare class ApplicationEnvVarsResource extends BaseResource {
|
|
664
|
+
/** A storage bucket belonging to one application environment. */
|
|
665
|
+
interface StorageBucket {
|
|
652
666
|
/**
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
* @param applicationId - The application ID (UUID).
|
|
656
|
-
* @returns A paginated list of environment variables.
|
|
657
|
-
*
|
|
658
|
-
* @example
|
|
659
|
-
* ```ts
|
|
660
|
-
* const { items } = await client.applications.envVars.list('app-id');
|
|
661
|
-
* for (const v of items) {
|
|
662
|
-
* console.log(`${v.key}=${v.sensitive ? '***' : v.value}`);
|
|
663
|
-
* }
|
|
664
|
-
* ```
|
|
667
|
+
* Internal bucket UUID. New REST calls should use {@link name} instead.
|
|
668
|
+
* @deprecated Use the environment-scoped bucket `name` for API addressing.
|
|
665
669
|
*/
|
|
666
|
-
|
|
670
|
+
id: string;
|
|
671
|
+
/** The application this bucket belongs to. */
|
|
672
|
+
applicationId: string;
|
|
673
|
+
/** Canonical immutable API/IaC identifier, unique within {@link environmentId}. */
|
|
674
|
+
name: string;
|
|
675
|
+
/** Global CDN/S3 identifier. This is not the bucket reference used by REST methods. */
|
|
676
|
+
slug: string;
|
|
677
|
+
/** `"public"` buckets use stable CDN URLs; `"private"` buckets require signed access URLs. */
|
|
678
|
+
visibility: 'public' | 'private';
|
|
679
|
+
/** Hostname used to serve public objects or signed private-object URLs. */
|
|
680
|
+
cdnHostname: string;
|
|
681
|
+
/** The application environment this bucket is scoped to. */
|
|
682
|
+
environmentId: string;
|
|
683
|
+
/** ISO 8601 creation timestamp. */
|
|
684
|
+
createdAt: string;
|
|
685
|
+
/** ISO 8601 last-updated timestamp. */
|
|
686
|
+
updatedAt: string;
|
|
687
|
+
}
|
|
688
|
+
interface CreateStorageBucketBase {
|
|
667
689
|
/**
|
|
668
|
-
*
|
|
669
|
-
*
|
|
670
|
-
* environment-specific overrides, returning only non-sensitive values — ready
|
|
671
|
-
* to write to a local `.env` file.
|
|
672
|
-
*
|
|
673
|
-
* @param applicationId - The application ID (UUID).
|
|
674
|
-
* @param query - Optional environment targeting.
|
|
675
|
-
* @returns The resolved non-sensitive variables plus the count of omitted secrets.
|
|
676
|
-
*
|
|
677
|
-
* @example
|
|
678
|
-
* ```ts
|
|
679
|
-
* const { items } = await client.applications.envVars.pull('app-id');
|
|
680
|
-
* const dotenv = items.map((v) => `${v.key}=${v.value}`).join('\n');
|
|
681
|
-
* ```
|
|
690
|
+
* Immutable lowercase URL-safe identifier. The API accepts 3–63 ASCII
|
|
691
|
+
* letters, numbers, and internal hyphens and does not normalize the value.
|
|
682
692
|
*/
|
|
683
|
-
|
|
693
|
+
name: string;
|
|
694
|
+
/** Bucket visibility. Defaults to `"private"`. */
|
|
695
|
+
visibility?: 'public' | 'private';
|
|
684
696
|
/**
|
|
685
|
-
*
|
|
686
|
-
*
|
|
687
|
-
* @param applicationId - The application ID (UUID).
|
|
688
|
-
* @param data - The variable key, value, and optional settings.
|
|
689
|
-
* @returns The newly created environment variable.
|
|
690
|
-
*
|
|
691
|
-
* @example
|
|
692
|
-
* ```ts
|
|
693
|
-
* const envVar = await client.applications.envVars.create('app-id', {
|
|
694
|
-
* key: 'DATABASE_URL',
|
|
695
|
-
* value: 'postgres://...',
|
|
696
|
-
* sensitive: true,
|
|
697
|
-
* });
|
|
698
|
-
* ```
|
|
697
|
+
* Explicit global delivery/S3 slug.
|
|
698
|
+
* @deprecated Omit this field and let the API generate the global slug.
|
|
699
699
|
*/
|
|
700
|
-
|
|
700
|
+
slug?: string;
|
|
701
|
+
}
|
|
702
|
+
/** Input for creating an environment-scoped storage bucket. */
|
|
703
|
+
type CreateStorageBucketInput = CreateStorageBucketBase & ({
|
|
704
|
+
/** Canonical environment slug or UUID. */
|
|
705
|
+
environment: string;
|
|
701
706
|
/**
|
|
702
|
-
*
|
|
703
|
-
*
|
|
704
|
-
*
|
|
705
|
-
* @param applicationId - The application ID (UUID).
|
|
706
|
-
* @param envVarId - The environment variable ID (UUID).
|
|
707
|
-
* @param data - The fields to update.
|
|
708
|
-
* @returns The updated environment variable.
|
|
709
|
-
*
|
|
710
|
-
* @example
|
|
711
|
-
* ```ts
|
|
712
|
-
* await client.applications.envVars.update('app-id', 'var-id', {
|
|
713
|
-
* value: 'postgres://new-host/db',
|
|
714
|
-
* });
|
|
715
|
-
* ```
|
|
707
|
+
* Deprecated compatibility selector. When both fields are supplied,
|
|
708
|
+
* they must resolve to the same environment.
|
|
709
|
+
* @deprecated Use {@link environment}.
|
|
716
710
|
*/
|
|
717
|
-
|
|
711
|
+
environmentId?: string;
|
|
712
|
+
} | {
|
|
713
|
+
environment?: undefined;
|
|
718
714
|
/**
|
|
719
|
-
*
|
|
720
|
-
*
|
|
721
|
-
* @param applicationId - The application ID (UUID).
|
|
722
|
-
* @param envVarId - The environment variable ID (UUID).
|
|
723
|
-
*
|
|
724
|
-
* @example
|
|
725
|
-
* ```ts
|
|
726
|
-
* await client.applications.envVars.delete('app-id', 'var-id');
|
|
727
|
-
* ```
|
|
715
|
+
* Application environment UUID.
|
|
716
|
+
* @deprecated Use `environment` with an environment slug or UUID.
|
|
728
717
|
*/
|
|
729
|
-
|
|
718
|
+
environmentId: string;
|
|
719
|
+
});
|
|
720
|
+
/** Query parameters for listing storage buckets. */
|
|
721
|
+
interface ListStorageBucketsQuery extends ListQuery, StorageEnvironmentOptions {
|
|
730
722
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
723
|
+
/**
|
|
724
|
+
* Manages storage buckets for an application.
|
|
725
|
+
*
|
|
726
|
+
* Methods accept an application ID as their first argument for compatibility.
|
|
727
|
+
* When the client has an application context, callers can omit it and address
|
|
728
|
+
* buckets directly by their environment-scoped names.
|
|
729
|
+
*/
|
|
730
|
+
declare class StorageBucketsResource extends BaseResource {
|
|
731
|
+
private readonly defaultApplicationId?;
|
|
732
|
+
constructor(httpClient: ConstructorParameters<typeof BaseResource>[0], defaultApplicationId?: string | undefined);
|
|
733
|
+
/** Lists buckets, optionally restricted to an environment slug or UUID. */
|
|
734
|
+
list(query?: ListStorageBucketsQuery): Promise<Paginated<StorageBucket>>;
|
|
735
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
736
|
+
list(applicationId: string, query?: ListStorageBucketsQuery): Promise<Paginated<StorageBucket>>;
|
|
737
|
+
/** Creates a bucket with an immutable environment-scoped name. */
|
|
738
|
+
create(data: CreateStorageBucketInput): Promise<StorageBucket>;
|
|
739
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
740
|
+
create(applicationId: string, data: CreateStorageBucketInput): Promise<StorageBucket>;
|
|
741
|
+
/** Gets a bucket by canonical environment-scoped name or deprecated UUID. */
|
|
742
|
+
get(bucketRef: StorageBucketReference, options?: StorageEnvironmentOptions): Promise<StorageBucket>;
|
|
743
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
744
|
+
get(applicationId: string, bucketRef: StorageBucketReference, options?: StorageEnvironmentOptions): Promise<StorageBucket>;
|
|
745
|
+
/** Permanently deletes a bucket and all of its live and trashed objects. */
|
|
746
|
+
delete(bucketRef: StorageBucketReference, options?: StorageEnvironmentOptions): Promise<void>;
|
|
747
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
748
|
+
delete(applicationId: string, bucketRef: StorageBucketReference, options?: StorageEnvironmentOptions): Promise<void>;
|
|
736
749
|
}
|
|
737
|
-
|
|
738
|
-
|
|
750
|
+
|
|
751
|
+
/** A file stored in a storage bucket. */
|
|
752
|
+
interface StorageObject {
|
|
753
|
+
/** Unique object identifier (UUID). */
|
|
739
754
|
id: string;
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
/**
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
755
|
+
/** Internal UUID of the bucket containing this object. */
|
|
756
|
+
bucketId: string;
|
|
757
|
+
/** The application this object belongs to. */
|
|
758
|
+
applicationId: string;
|
|
759
|
+
/** The upload session that created this object, or `null` for imported objects. */
|
|
760
|
+
uploadSessionId: string | null;
|
|
761
|
+
/** The object key within the bucket, such as `"images/photo.jpg"`. */
|
|
762
|
+
key: string;
|
|
763
|
+
/** MIME content type, or `null` when none was recorded. */
|
|
764
|
+
contentType: string | null;
|
|
765
|
+
/** File size in bytes. */
|
|
766
|
+
contentLength: number;
|
|
767
|
+
/** SHA-1 checksum, if available. */
|
|
768
|
+
checksumSha1: string | null;
|
|
769
|
+
/** SHA-256 checksum, if available. */
|
|
770
|
+
checksumSha256: string | null;
|
|
771
|
+
/** MD5 checksum, if available. */
|
|
772
|
+
checksumMd5: string | null;
|
|
773
|
+
/** ISO 8601 timestamp of upload finalization. */
|
|
774
|
+
uploadedAt: string;
|
|
775
|
+
/** ISO 8601 creation timestamp. */
|
|
776
|
+
createdAt: string;
|
|
777
|
+
/** ISO 8601 last-updated timestamp. */
|
|
778
|
+
updatedAt: string;
|
|
748
779
|
}
|
|
749
|
-
/**
|
|
750
|
-
interface
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
780
|
+
/** Access URL details for a public or private storage object. */
|
|
781
|
+
interface StorageObjectAccess {
|
|
782
|
+
/** `"public"` for stable CDN URLs or `"signed"` for expiring URLs. */
|
|
783
|
+
accessType: 'public' | 'signed';
|
|
784
|
+
/** URL used to read the object. */
|
|
785
|
+
url: string;
|
|
786
|
+
/** ISO 8601 expiry for signed URLs, or `null` for public URLs. */
|
|
787
|
+
expiresAt: string | null;
|
|
754
788
|
}
|
|
755
|
-
/**
|
|
756
|
-
interface
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
789
|
+
/** Query parameters for listing objects in a bucket. */
|
|
790
|
+
interface ListStorageObjectsQuery extends StorageEnvironmentOptions {
|
|
791
|
+
/** Only return objects whose key starts with this prefix. */
|
|
792
|
+
prefix?: string;
|
|
793
|
+
/** Group keys by this delimiter into virtual folders. Defaults to `"/"`. */
|
|
794
|
+
delimiter?: string;
|
|
795
|
+
/** Opaque cursor from a previous response. */
|
|
796
|
+
cursor?: string;
|
|
797
|
+
/** Maximum objects to return, from 1 through 1000. */
|
|
798
|
+
limit?: number;
|
|
760
799
|
}
|
|
761
|
-
/**
|
|
762
|
-
interface
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
contentType: string | null;
|
|
800
|
+
/** Options for creating an object access URL. */
|
|
801
|
+
interface StorageObjectAccessOptions extends StorageEnvironmentOptions {
|
|
802
|
+
/** Signed URL lifetime in seconds, from 60 through 86,400. */
|
|
803
|
+
expiresInSeconds?: number;
|
|
766
804
|
}
|
|
767
|
-
/**
|
|
768
|
-
interface
|
|
769
|
-
|
|
770
|
-
hostname: string;
|
|
771
|
-
path: string;
|
|
772
|
-
query: string | null;
|
|
773
|
-
protocol: string | null;
|
|
774
|
-
country: string | null;
|
|
775
|
-
userAgent: string | null;
|
|
776
|
-
referer: string | null;
|
|
805
|
+
/** A page of storage objects, including any common virtual-folder prefixes. */
|
|
806
|
+
interface StorageObjectList extends Paginated<StorageObject> {
|
|
807
|
+
commonPrefixes: string[];
|
|
777
808
|
}
|
|
778
|
-
/**
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
809
|
+
/**
|
|
810
|
+
* Reads and soft-deletes objects and creates access URLs.
|
|
811
|
+
*
|
|
812
|
+
* The context-bound overloads use the application configured on the client.
|
|
813
|
+
* Explicit application overloads remain available for management tools and
|
|
814
|
+
* compatibility. Bucket references should be canonical names; UUIDs remain a
|
|
815
|
+
* deprecated server-side fallback.
|
|
816
|
+
*/
|
|
817
|
+
declare class StorageObjectsResource extends BaseResource {
|
|
818
|
+
private readonly defaultApplicationId?;
|
|
819
|
+
constructor(httpClient: ConstructorParameters<typeof BaseResource>[0], defaultApplicationId?: string | undefined);
|
|
820
|
+
/** Lists objects in a bucket. */
|
|
821
|
+
list(bucketRef: StorageBucketReference, query?: ListStorageObjectsQuery): Promise<StorageObjectList>;
|
|
822
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
823
|
+
list(applicationId: string, bucketRef: StorageBucketReference, query?: ListStorageObjectsQuery): Promise<StorageObjectList>;
|
|
824
|
+
/** Gets object metadata by object UUID. */
|
|
825
|
+
get(bucketRef: StorageBucketReference, objectId: string, options?: StorageEnvironmentOptions): Promise<StorageObject>;
|
|
826
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
827
|
+
get(applicationId: string, bucketRef: StorageBucketReference, objectId: string, options?: StorageEnvironmentOptions): Promise<StorageObject>;
|
|
828
|
+
/**
|
|
829
|
+
* Resolves an object by exact key by paging a prefix listing.
|
|
830
|
+
*
|
|
831
|
+
* The API has no get-by-key endpoint. This helper preserves the same
|
|
832
|
+
* application, bucket, and environment across every page.
|
|
833
|
+
*/
|
|
834
|
+
getByKey(bucketRef: StorageBucketReference, key: string, options?: StorageEnvironmentOptions): Promise<StorageObject | null>;
|
|
835
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
836
|
+
getByKey(applicationId: string, bucketRef: StorageBucketReference, key: string, options?: StorageEnvironmentOptions): Promise<StorageObject | null>;
|
|
837
|
+
/** Moves a live object into the bucket trash. */
|
|
838
|
+
delete(bucketRef: StorageBucketReference, objectId: string, options?: StorageEnvironmentOptions): Promise<void>;
|
|
839
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
840
|
+
delete(applicationId: string, bucketRef: StorageBucketReference, objectId: string, options?: StorageEnvironmentOptions): Promise<void>;
|
|
841
|
+
/** Creates a stable public or time-limited signed object URL. */
|
|
842
|
+
getAccessUrl(bucketRef: StorageBucketReference, objectId: string, options?: StorageObjectAccessOptions): Promise<StorageObjectAccess>;
|
|
843
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
844
|
+
getAccessUrl(applicationId: string, bucketRef: StorageBucketReference, objectId: string, options?: StorageObjectAccessOptions): Promise<StorageObjectAccess>;
|
|
785
845
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
846
|
+
|
|
847
|
+
/** A soft-deleted storage object returned by a bucket trash listing. */
|
|
848
|
+
interface TrashedStorageObject extends StorageObject {
|
|
849
|
+
/** ISO 8601 timestamp when the object was moved to trash. */
|
|
850
|
+
deletedAt: string;
|
|
851
|
+
}
|
|
852
|
+
/** Query parameters for listing a bucket's trashed objects. */
|
|
853
|
+
interface ListStorageTrashQuery extends StorageEnvironmentOptions {
|
|
854
|
+
/** Only return trashed objects whose keys start with this prefix. */
|
|
855
|
+
prefix?: string;
|
|
856
|
+
/** Opaque cursor returned by a previous trash listing. */
|
|
857
|
+
cursor?: string;
|
|
858
|
+
/** Maximum objects to return, from 1 through 1000. */
|
|
859
|
+
limit?: number;
|
|
792
860
|
}
|
|
793
|
-
/** A
|
|
794
|
-
|
|
861
|
+
/** A page of soft-deleted objects. */
|
|
862
|
+
type StorageTrashList = Paginated<TrashedStorageObject>;
|
|
863
|
+
/** Result returned after permanently deleting every object in a bucket's trash. */
|
|
864
|
+
interface EmptyStorageTrashResult {
|
|
865
|
+
/** Number of trashed objects permanently deleted. */
|
|
866
|
+
purgedCount: number;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Manages the lifecycle of soft-deleted storage objects.
|
|
870
|
+
*
|
|
871
|
+
* Restoring can fail with HTTP 409 when a live object already uses the same
|
|
872
|
+
* key. Purge and empty operations are irreversible.
|
|
873
|
+
*/
|
|
874
|
+
declare class StorageTrashResource extends BaseResource {
|
|
875
|
+
private readonly defaultApplicationId?;
|
|
876
|
+
constructor(httpClient: ConstructorParameters<typeof BaseResource>[0], defaultApplicationId?: string | undefined);
|
|
877
|
+
/** Lists soft-deleted objects in a bucket. */
|
|
878
|
+
list(bucketRef: StorageBucketReference, query?: ListStorageTrashQuery): Promise<StorageTrashList>;
|
|
879
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
880
|
+
list(applicationId: string, bucketRef: StorageBucketReference, query?: ListStorageTrashQuery): Promise<StorageTrashList>;
|
|
881
|
+
/** Restores a soft-deleted object to its original key. */
|
|
882
|
+
restore(bucketRef: StorageBucketReference, objectId: string, options?: StorageEnvironmentOptions): Promise<StorageObject>;
|
|
883
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
884
|
+
restore(applicationId: string, bucketRef: StorageBucketReference, objectId: string, options?: StorageEnvironmentOptions): Promise<StorageObject>;
|
|
885
|
+
/** Permanently deletes one object from bucket trash. */
|
|
886
|
+
purge(bucketRef: StorageBucketReference, objectId: string, options?: StorageEnvironmentOptions): Promise<void>;
|
|
887
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
888
|
+
purge(applicationId: string, bucketRef: StorageBucketReference, objectId: string, options?: StorageEnvironmentOptions): Promise<void>;
|
|
889
|
+
/** Permanently deletes every object in a bucket's trash. */
|
|
890
|
+
empty(bucketRef: StorageBucketReference, options?: StorageEnvironmentOptions): Promise<EmptyStorageTrashResult>;
|
|
891
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
892
|
+
empty(applicationId: string, bucketRef: StorageBucketReference, options?: StorageEnvironmentOptions): Promise<EmptyStorageTrashResult>;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* Represents an upload session for a storage object. Upload sessions track the
|
|
897
|
+
* lifecycle of a file upload from creation through completion.
|
|
898
|
+
*/
|
|
899
|
+
interface StorageUploadSession {
|
|
900
|
+
/** Unique identifier (UUID). */
|
|
795
901
|
id: string;
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
902
|
+
/** The bucket this upload targets. */
|
|
903
|
+
bucketId: string;
|
|
904
|
+
/** The application this upload belongs to. */
|
|
905
|
+
applicationId: string;
|
|
906
|
+
/** The object key/path the file will be stored at (e.g. `"images/photo.jpg"`). */
|
|
907
|
+
key: string;
|
|
908
|
+
/** MIME content type declared at creation, or `null` if not specified. */
|
|
909
|
+
contentType: string | null;
|
|
910
|
+
/** Expected file size in bytes declared at creation, or `null`. */
|
|
911
|
+
contentLength: number | null;
|
|
912
|
+
/** SHA-1 checksum for server-side verification, if provided. */
|
|
913
|
+
checksumSha1: string | null;
|
|
914
|
+
/** SHA-256 checksum for server-side verification, if provided. */
|
|
915
|
+
checksumSha256: string | null;
|
|
916
|
+
/** MD5 checksum for server-side verification, if provided. */
|
|
917
|
+
checksumMd5: string | null;
|
|
918
|
+
/**
|
|
919
|
+
* Current session state:
|
|
920
|
+
* - `"pending"` — Session created, awaiting the first bytes.
|
|
921
|
+
* - `"ready"` — Receiving file data.
|
|
922
|
+
* - `"completed"` — Upload verified and storage object created.
|
|
923
|
+
* - `"failed"` — Upload failed or was rejected.
|
|
924
|
+
* - `"expired"` — Session exceeded its expiration time.
|
|
925
|
+
*/
|
|
926
|
+
state: 'pending' | 'ready' | 'completed' | 'failed' | 'expired';
|
|
927
|
+
/** ISO 8601 timestamp when this session (and its upload URL) expires. */
|
|
928
|
+
expiresAt: string;
|
|
929
|
+
/** ISO 8601 timestamp when the upload was finalized, or `null`. */
|
|
930
|
+
uploadedAt: string | null;
|
|
931
|
+
/** ISO 8601 creation timestamp. */
|
|
932
|
+
createdAt: string;
|
|
933
|
+
/** ISO 8601 last-updated timestamp. */
|
|
934
|
+
updatedAt: string;
|
|
807
935
|
}
|
|
808
|
-
/**
|
|
809
|
-
interface
|
|
810
|
-
/**
|
|
811
|
-
|
|
812
|
-
/**
|
|
813
|
-
|
|
936
|
+
/** Input for creating a new upload session. */
|
|
937
|
+
interface CreateUploadSessionInput {
|
|
938
|
+
/** The object key/path the file will be stored at (e.g. `"images/photo.jpg"`). 1–1024 characters. */
|
|
939
|
+
key: string;
|
|
940
|
+
/** File size in bytes. Required. */
|
|
941
|
+
contentLength: number;
|
|
942
|
+
/** Lowercase hex SHA-256 checksum (64 chars) of the content. Required for server-side verification. */
|
|
943
|
+
checksumSha256: string;
|
|
944
|
+
/** MIME content type of the file (e.g. `"image/jpeg"`). */
|
|
945
|
+
contentType?: string;
|
|
946
|
+
/** Optional lowercase hex SHA-1 checksum (40 chars). */
|
|
947
|
+
checksumSha1?: string;
|
|
948
|
+
/** Optional lowercase hex MD5 checksum (32 chars). */
|
|
949
|
+
checksumMd5?: string;
|
|
814
950
|
}
|
|
815
|
-
/** Query
|
|
816
|
-
interface
|
|
817
|
-
/** Filter to requests served by one deployment. */
|
|
818
|
-
deploymentId?: string;
|
|
819
|
-
/** Filter to requests served by one function route. */
|
|
820
|
-
deploymentFunctionId?: string;
|
|
821
|
-
/** Filter to requests served by one static asset route. */
|
|
822
|
-
deploymentAssetId?: string;
|
|
823
|
-
/** Filter to storage delivery requests for one bucket. */
|
|
824
|
-
storageBucketId?: string;
|
|
825
|
-
/** Filter to storage delivery requests for one object. */
|
|
826
|
-
storageObjectId?: string;
|
|
827
|
-
/** Only include requests that started at or after this ISO 8601 timestamp. */
|
|
828
|
-
from?: string;
|
|
829
|
-
/** Only include requests that started before or at this ISO 8601 timestamp. */
|
|
830
|
-
to?: string;
|
|
831
|
-
/** Maximum number of records to return. */
|
|
832
|
-
limit?: number;
|
|
833
|
-
/** Opaque cursor from a previous response's `nextCursor`. */
|
|
834
|
-
cursor?: string;
|
|
835
|
-
/** Filter by HTTP method (e.g. `"GET"`). */
|
|
836
|
-
method?: string;
|
|
837
|
-
/** Filter by exact HTTP status code. */
|
|
838
|
-
status?: number;
|
|
839
|
-
/** Filter by status family (`2`, `3`, `4`, or `5`). */
|
|
840
|
-
statusFamily?: number;
|
|
841
|
-
/** Filter by request hostname. */
|
|
842
|
-
hostname?: string;
|
|
843
|
-
/** Filter to requests whose path starts with this prefix. */
|
|
844
|
-
pathPrefix?: string;
|
|
845
|
-
/** Filter by ISO 3166-1 alpha-2 country code. */
|
|
846
|
-
country?: string;
|
|
847
|
-
/** Filter by origin region. */
|
|
848
|
-
region?: string;
|
|
849
|
-
/** Filter by edge location. */
|
|
850
|
-
edgeLocation?: string;
|
|
851
|
-
/** Filter by CDN cache state. */
|
|
852
|
-
cacheStatus?: string;
|
|
853
|
-
/** Filter by whether the response was served from cache. */
|
|
854
|
-
cacheHit?: boolean;
|
|
951
|
+
/** Query parameters for listing upload sessions in a bucket. */
|
|
952
|
+
interface ListStorageUploadSessionsQuery extends ListQuery, StorageEnvironmentOptions {
|
|
855
953
|
}
|
|
856
954
|
/**
|
|
857
|
-
*
|
|
858
|
-
*
|
|
955
|
+
* Response from creating an upload session. Contains both the session metadata
|
|
956
|
+
* and the resumable upload instructions (signed URL + headers).
|
|
957
|
+
*/
|
|
958
|
+
interface CreateUploadSessionResponse {
|
|
959
|
+
/** The created upload session. */
|
|
960
|
+
session: StorageUploadSession;
|
|
961
|
+
/** Resumable upload instructions — use these to send the file data. */
|
|
962
|
+
upload: {
|
|
963
|
+
/** The HTTP method for the byte upload (resumable upload protocol). */
|
|
964
|
+
method: 'PATCH';
|
|
965
|
+
/** Signed upload URL. Send your file data here. */
|
|
966
|
+
url: string;
|
|
967
|
+
/** Required headers to include with the upload request. */
|
|
968
|
+
headers: Record<string, string>;
|
|
969
|
+
/** The URL where the object will be accessible after upload (CDN URL for public buckets). */
|
|
970
|
+
publicObjectUrl: string;
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
/** A byte source for uploading directly to a known signed URL. */
|
|
974
|
+
interface UploadByteSource {
|
|
975
|
+
/** In-memory data (`File`/`Blob`/`Buffer`/`Uint8Array`/`ArrayBuffer`). */
|
|
976
|
+
data?: UploadData;
|
|
977
|
+
/** A filesystem path to stream from (Node.js only). */
|
|
978
|
+
path?: string;
|
|
979
|
+
/** A readable stream (Node.js only). Requires `contentLength`. */
|
|
980
|
+
stream?: NodeReadableLike;
|
|
981
|
+
/** Byte size — required for `stream` inputs, computed otherwise. */
|
|
982
|
+
contentLength?: number;
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Manage upload sessions and upload bytes to a signed upload URL using the
|
|
986
|
+
* resumable upload protocol. Accessed via `client.storage.uploadSessions`.
|
|
859
987
|
*
|
|
860
|
-
*
|
|
861
|
-
*
|
|
862
|
-
*
|
|
863
|
-
* const { items } = await client.applications.requests.list('app-id', {
|
|
864
|
-
* deploymentId: 'dep-id',
|
|
865
|
-
* statusFamily: 5,
|
|
866
|
-
* limit: 100,
|
|
867
|
-
* });
|
|
868
|
-
* ```
|
|
988
|
+
* For most use cases, prefer the high-level `client.storage.upload()`
|
|
989
|
+
* which creates the session, computes the required checksum, uploads the bytes,
|
|
990
|
+
* and returns the public URL.
|
|
869
991
|
*/
|
|
870
|
-
declare class
|
|
992
|
+
declare class StorageUploadSessionsResource extends BaseResource {
|
|
993
|
+
private readonly transport;
|
|
994
|
+
private readonly defaultApplicationId?;
|
|
995
|
+
constructor(httpClient: ConstructorParameters<typeof BaseResource>[0], transport?: UploadTransport, defaultApplicationId?: string | undefined);
|
|
871
996
|
/**
|
|
872
|
-
* List
|
|
997
|
+
* List upload sessions for a bucket.
|
|
873
998
|
*
|
|
874
|
-
* @param
|
|
875
|
-
* @param query - Optional
|
|
876
|
-
* @returns A
|
|
999
|
+
* @param bucketRef - Canonical bucket name or deprecated UUID fallback.
|
|
1000
|
+
* @param query - Optional pagination parameters.
|
|
1001
|
+
* @returns A paginated list of upload sessions.
|
|
877
1002
|
*/
|
|
878
|
-
list(
|
|
1003
|
+
list(bucketRef: StorageBucketReference, query?: ListStorageUploadSessionsQuery): Promise<Paginated<StorageUploadSession>>;
|
|
1004
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
1005
|
+
list(applicationId: string, bucketRef: StorageBucketReference, query?: ListStorageUploadSessionsQuery): Promise<Paginated<StorageUploadSession>>;
|
|
879
1006
|
/**
|
|
880
|
-
*
|
|
1007
|
+
* Create an upload session. Returns the session metadata and a signed upload
|
|
1008
|
+
* URL for sending file data. This is the low-level method — for most use
|
|
1009
|
+
* cases prefer `client.storage.upload()` which also computes the
|
|
1010
|
+
* required SHA-256 checksum for you.
|
|
881
1011
|
*
|
|
882
|
-
* @param
|
|
883
|
-
* @param
|
|
884
|
-
* @returns The
|
|
1012
|
+
* @param bucketRef - Canonical bucket name or deprecated UUID fallback.
|
|
1013
|
+
* @param data - Object key, content length, SHA-256 checksum, and optional content type / extra checksums.
|
|
1014
|
+
* @returns The session and resumable upload instructions (URL, method, headers).
|
|
885
1015
|
*/
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
/**
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
/**
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
1016
|
+
create(bucketRef: StorageBucketReference, data: CreateUploadSessionInput, options?: StorageEnvironmentOptions): Promise<CreateUploadSessionResponse>;
|
|
1017
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
1018
|
+
create(applicationId: string, bucketRef: StorageBucketReference, data: CreateUploadSessionInput, options?: StorageEnvironmentOptions): Promise<CreateUploadSessionResponse>;
|
|
1019
|
+
/**
|
|
1020
|
+
* Get an upload session by ID. Use this to track server-side processing after
|
|
1021
|
+
* an upload (poll until `state === 'completed'`).
|
|
1022
|
+
*
|
|
1023
|
+
* @param bucketRef - Canonical bucket name or deprecated UUID fallback.
|
|
1024
|
+
* @param sessionId - The upload session ID (UUID).
|
|
1025
|
+
* @returns The current session state.
|
|
1026
|
+
*/
|
|
1027
|
+
get(bucketRef: StorageBucketReference, sessionId: string, options?: StorageEnvironmentOptions): Promise<StorageUploadSession>;
|
|
1028
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
1029
|
+
get(applicationId: string, bucketRef: StorageBucketReference, sessionId: string, options?: StorageEnvironmentOptions): Promise<StorageUploadSession>;
|
|
1030
|
+
/**
|
|
1031
|
+
* Upload bytes directly to a pre-existing signed upload URL — for example, a
|
|
1032
|
+
* URL returned by {@link create} or handed to your client by a backend. Skips
|
|
1033
|
+
* session creation and checksum computation.
|
|
1034
|
+
*
|
|
1035
|
+
* @param url - A signed upload URL.
|
|
1036
|
+
* @param source - The bytes to upload.
|
|
1037
|
+
* @param options - Chunk size, retry config, progress, abort signal, resume,
|
|
1038
|
+
* and any required `headers` returned with the upload session.
|
|
1039
|
+
* @throws {@link UploadError} if the upload fails after all retries.
|
|
1040
|
+
*/
|
|
1041
|
+
uploadToUrl(url: string, source: UploadByteSource, options?: RunUploadOptions & {
|
|
1042
|
+
headers?: Record<string, string>;
|
|
1043
|
+
}): Promise<void>;
|
|
1044
|
+
/**
|
|
1045
|
+
* Resume an interrupted upload to a previously issued signed upload URL. The
|
|
1046
|
+
* resumable protocol negotiates the current offset and continues from there.
|
|
1047
|
+
*
|
|
1048
|
+
* @param url - The signed upload URL from the original {@link create} call.
|
|
1049
|
+
* @param source - The full bytes to upload (the same content as the original).
|
|
1050
|
+
* @param options - Chunk size, retry config, progress, abort signal.
|
|
1051
|
+
*/
|
|
1052
|
+
resumeFromUrl(url: string, source: UploadByteSource, options?: RunUploadOptions & {
|
|
1053
|
+
headers?: Record<string, string>;
|
|
1054
|
+
}): Promise<void>;
|
|
903
1055
|
}
|
|
904
|
-
/** In-memory data accepted by the upload helpers. `Buffer` is a `Uint8Array`. */
|
|
905
|
-
type UploadData = Blob | ArrayBuffer | Uint8Array;
|
|
906
|
-
/** The tus-js-client file input union. */
|
|
907
|
-
type TusFile = File | Blob | Uint8Array | NodeReadableLike;
|
|
908
|
-
|
|
909
|
-
/**
|
|
910
|
-
* Thin, injectable wrapper around `tus-js-client` that performs the resumable
|
|
911
|
-
* byte upload. Isolated here so the upload flow can be unit-tested with a fake
|
|
912
|
-
* transport (no real network I/O) and so abort/resume behaviour lives in one
|
|
913
|
-
* place.
|
|
914
|
-
*
|
|
915
|
-
* @internal
|
|
916
|
-
*/
|
|
917
1056
|
|
|
918
|
-
/**
|
|
919
|
-
interface
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
1057
|
+
/** Options controlling whether and how to wait for an upload to finalize server-side. */
|
|
1058
|
+
interface WaitForCompletionOptions extends StorageEnvironmentOptions {
|
|
1059
|
+
/** Maximum time to wait in milliseconds. Default: 60000. */
|
|
1060
|
+
timeoutMs?: number;
|
|
1061
|
+
/** How often to poll the session state, in milliseconds. Default: 1000. */
|
|
1062
|
+
pollIntervalMs?: number;
|
|
924
1063
|
}
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
1064
|
+
interface UploadFileOptions {
|
|
1065
|
+
/**
|
|
1066
|
+
* Explicit application UUID. Omit this when the client was configured with
|
|
1067
|
+
* `applicationId` or is running with `GIGADRIVE_APPLICATION_ID`.
|
|
1068
|
+
* @deprecated Configure `GigadriveClientConfig.applicationId` or use workload context.
|
|
1069
|
+
*/
|
|
1070
|
+
applicationId?: string;
|
|
1071
|
+
/**
|
|
1072
|
+
* Environment slug or UUID. Workloads normally omit this because the API
|
|
1073
|
+
* infers and enforces the deployment environment from their credential. If
|
|
1074
|
+
* completion options also specify an environment, this top-level value takes
|
|
1075
|
+
* precedence for the entire upload lifecycle.
|
|
1076
|
+
*/
|
|
1077
|
+
environment?: string;
|
|
1078
|
+
/** The object key/path in the bucket (e.g. `"images/logo.png"`). */
|
|
1079
|
+
key: string;
|
|
1080
|
+
/** In-memory data (browser `File`/`Blob`, Node `Buffer`, `Uint8Array`, `ArrayBuffer`). */
|
|
1081
|
+
data?: UploadData;
|
|
1082
|
+
/** A filesystem path to upload from (Node.js only). Size, checksum, and content type are derived automatically. */
|
|
1083
|
+
path?: string;
|
|
1084
|
+
/** A readable stream to upload from (Node.js only). Requires `contentLength` and `checksumSha256`. */
|
|
1085
|
+
stream?: NodeReadableLike;
|
|
1086
|
+
/** MIME content type. Inferred from `key` when omitted. */
|
|
1087
|
+
contentType?: string;
|
|
1088
|
+
/** Byte size. Required for `stream`; computed otherwise. */
|
|
1089
|
+
contentLength?: number;
|
|
1090
|
+
/** Pre-computed SHA-256 (skips hashing). Required for `stream`. */
|
|
1091
|
+
checksumSha256?: string;
|
|
1092
|
+
/** Also send a SHA-1 checksum. */
|
|
1093
|
+
checksumSha1?: string;
|
|
1094
|
+
/** Also send an MD5 checksum (Node.js only unless provided). */
|
|
1095
|
+
checksumMd5?: string;
|
|
1096
|
+
/** Maximum chunk size in bytes (for very large files / streams). */
|
|
936
1097
|
chunkSize?: number;
|
|
937
|
-
/** Retry backoff in milliseconds
|
|
1098
|
+
/** Retry backoff in milliseconds; `null`/`[]` disables retries. */
|
|
938
1099
|
retryDelays?: number[] | null;
|
|
939
|
-
/** Progress callback. */
|
|
1100
|
+
/** Progress callback invoked during the byte upload. */
|
|
940
1101
|
onProgress?: (bytesSent: number, bytesTotal: number) => void;
|
|
941
1102
|
/** Abort signal to cancel the upload. */
|
|
942
1103
|
signal?: AbortSignal;
|
|
943
|
-
/** Persist a resumable fingerprint so the upload can
|
|
1104
|
+
/** Persist a resumable fingerprint so the upload can be resumed later. */
|
|
944
1105
|
resume?: boolean;
|
|
945
|
-
/** Custom storage for resumable fingerprints
|
|
1106
|
+
/** Custom storage backend for resumable fingerprints. */
|
|
946
1107
|
urlStorage?: UploadUrlStorage;
|
|
1108
|
+
/** Wait until the object is finalized server-side before resolving. Pass options to tune polling. */
|
|
1109
|
+
waitForCompletion?: boolean | WaitForCompletionOptions;
|
|
947
1110
|
}
|
|
948
|
-
/**
|
|
949
|
-
type
|
|
950
|
-
/**
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1111
|
+
/** Input for the high-level {@link ApplicationStorageResource.upload | upload()} method. */
|
|
1112
|
+
type UploadFileInput = UploadFileOptions & ({
|
|
1113
|
+
/** Canonical environment-scoped bucket name, or a deprecated UUID fallback. */
|
|
1114
|
+
bucket: StorageBucketReference;
|
|
1115
|
+
bucketId?: never;
|
|
1116
|
+
} | {
|
|
1117
|
+
bucket?: never;
|
|
1118
|
+
/**
|
|
1119
|
+
* Internal bucket UUID.
|
|
1120
|
+
* @deprecated Use `bucket` with the canonical environment-scoped name.
|
|
1121
|
+
*/
|
|
1122
|
+
bucketId: string;
|
|
1123
|
+
});
|
|
1124
|
+
/** Result of a successful upload. */
|
|
1125
|
+
interface UploadFileResult {
|
|
1126
|
+
/** The upload session. When `waitForCompletion` was set, `state` is `"completed"`. */
|
|
1127
|
+
session: StorageUploadSession;
|
|
1128
|
+
/** The public/CDN URL of the uploaded object. */
|
|
1129
|
+
url: string;
|
|
1130
|
+
/** The finalized storage object — present only when `waitForCompletion` was set. */
|
|
1131
|
+
object?: StorageObject;
|
|
964
1132
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
applicationId: string;
|
|
972
|
-
/** Human-readable bucket name. */
|
|
973
|
-
name: string;
|
|
974
|
-
/** Globally unique, hostname-safe label used to build the bucket's serving hostname. */
|
|
975
|
-
slug: string;
|
|
976
|
-
/** `"public"` buckets serve objects through the CDN hostname; `"private"` buckets require signed access URLs. */
|
|
977
|
-
visibility: 'public' | 'private';
|
|
978
|
-
/** The hostname clients use to read public objects or signed private-object URLs. */
|
|
979
|
-
cdnHostname: string;
|
|
980
|
-
/** The application environment this bucket is scoped to. */
|
|
981
|
-
environmentId: string;
|
|
982
|
-
/** ISO 8601 creation timestamp. */
|
|
983
|
-
createdAt: string;
|
|
984
|
-
/** ISO 8601 last-updated timestamp. */
|
|
985
|
-
updatedAt: string;
|
|
1133
|
+
/** Options for {@link ApplicationStorageResource.uploadBatch | uploadBatch()}. */
|
|
1134
|
+
interface UploadBatchOptions {
|
|
1135
|
+
/** Maximum number of concurrent uploads. Default: 4. */
|
|
1136
|
+
concurrency?: number;
|
|
1137
|
+
/** Called after each file settles, with the number completed and the total. */
|
|
1138
|
+
onProgress?: (completed: number, total: number) => void;
|
|
986
1139
|
}
|
|
987
|
-
/**
|
|
988
|
-
interface
|
|
989
|
-
/**
|
|
990
|
-
|
|
991
|
-
/** The
|
|
992
|
-
|
|
993
|
-
/**
|
|
994
|
-
|
|
995
|
-
/** Bucket visibility. Defaults to `"private"`. */
|
|
996
|
-
visibility?: 'public' | 'private';
|
|
1140
|
+
/** The outcome of one file within a batch upload. Errors are isolated per file. */
|
|
1141
|
+
interface UploadBatchItemResult {
|
|
1142
|
+
/** The input that produced this result. */
|
|
1143
|
+
input: UploadFileInput;
|
|
1144
|
+
/** The successful result, if the upload succeeded. */
|
|
1145
|
+
result?: UploadFileResult;
|
|
1146
|
+
/** The error, if this upload failed. */
|
|
1147
|
+
error?: unknown;
|
|
997
1148
|
}
|
|
998
1149
|
/**
|
|
999
|
-
*
|
|
1000
|
-
*
|
|
1150
|
+
* Namespace for all storage operations on an application: bucket management,
|
|
1151
|
+
* object listing/access, low-level upload sessions, and the high-level
|
|
1152
|
+
* {@link upload} / {@link uploadBatch} helpers.
|
|
1153
|
+
*
|
|
1154
|
+
* Accessed canonically via `client.storage`. `client.applications.storage`
|
|
1155
|
+
* references the same resource for compatibility.
|
|
1001
1156
|
*
|
|
1002
1157
|
* @example
|
|
1003
1158
|
* ```ts
|
|
1004
|
-
* //
|
|
1005
|
-
* const
|
|
1006
|
-
*
|
|
1007
|
-
*
|
|
1008
|
-
*
|
|
1159
|
+
* // High-level upload (Node.js, from a path — checksum/size/content-type inferred)
|
|
1160
|
+
* const { url } = await client.storage.upload({
|
|
1161
|
+
* bucket: 'photos',
|
|
1162
|
+
* key: 'photos/cat.jpg',
|
|
1163
|
+
* path: './cat.jpg',
|
|
1009
1164
|
* });
|
|
1010
1165
|
*
|
|
1011
|
-
* //
|
|
1012
|
-
* const
|
|
1166
|
+
* // Browser upload from a file input, with progress and abort
|
|
1167
|
+
* const controller = new AbortController();
|
|
1168
|
+
* const { url } = await client.storage.upload({
|
|
1169
|
+
* bucket: 'uploads',
|
|
1170
|
+
* key: `uploads/${file.name}`,
|
|
1171
|
+
* data: file,
|
|
1172
|
+
* onProgress: (sent, total) => console.log(`${Math.round((sent / total) * 100)}%`),
|
|
1173
|
+
* signal: controller.signal,
|
|
1174
|
+
* });
|
|
1013
1175
|
* ```
|
|
1014
1176
|
*/
|
|
1015
|
-
declare class
|
|
1177
|
+
declare class ApplicationStorageResource {
|
|
1178
|
+
private readonly defaultApplicationId?;
|
|
1179
|
+
/** Create, list, get, and delete storage buckets. */
|
|
1180
|
+
readonly buckets: StorageBucketsResource;
|
|
1181
|
+
/** List, get, delete objects, and generate access URLs. */
|
|
1182
|
+
readonly objects: StorageObjectsResource;
|
|
1183
|
+
/** Low-level upload sessions and direct-to-URL byte uploads. */
|
|
1184
|
+
readonly uploadSessions: StorageUploadSessionsResource;
|
|
1185
|
+
/** Lists, restores, and permanently purges soft-deleted objects. */
|
|
1186
|
+
readonly trash: StorageTrashResource;
|
|
1187
|
+
private readonly transport;
|
|
1188
|
+
constructor(httpClient: HttpClient, transport?: UploadTransport, defaultApplicationId?: string | undefined);
|
|
1016
1189
|
/**
|
|
1017
|
-
*
|
|
1018
|
-
*
|
|
1019
|
-
*
|
|
1020
|
-
*
|
|
1021
|
-
* @returns A paginated list of storage buckets.
|
|
1190
|
+
* Upload a file to a storage bucket. Handles the full flow: computes the
|
|
1191
|
+
* required SHA-256 checksum, creates an upload session, uploads the bytes with
|
|
1192
|
+
* automatic retries (and optional progress/abort/resume), and returns the
|
|
1193
|
+
* public URL.
|
|
1022
1194
|
*
|
|
1023
|
-
*
|
|
1024
|
-
*
|
|
1025
|
-
*
|
|
1026
|
-
* console.log(`${total} buckets found`);
|
|
1027
|
-
* ```
|
|
1028
|
-
*/
|
|
1029
|
-
list(applicationId: string, query?: ListQuery): Promise<Paginated<StorageBucket>>;
|
|
1030
|
-
/**
|
|
1031
|
-
* Create a new storage bucket.
|
|
1195
|
+
* Accepts browser `File`/`Blob`, Node `Buffer`/`Uint8Array`/`ArrayBuffer`, a
|
|
1196
|
+
* Node filesystem `path`, or a Node readable `stream` (with `contentLength`
|
|
1197
|
+
* and `checksumSha256`). The content type is inferred from `key` when omitted.
|
|
1032
1198
|
*
|
|
1033
|
-
* @param
|
|
1034
|
-
* @
|
|
1035
|
-
* @
|
|
1199
|
+
* @param input - What and where to upload, plus optional transfer options.
|
|
1200
|
+
* @returns The upload session and public object URL (and the finalized object when `waitForCompletion` is set).
|
|
1201
|
+
* @throws {@link UploadError} if the byte upload fails.
|
|
1202
|
+
* @throws {@link UploadSessionExpiredError} if the session expires mid-upload.
|
|
1036
1203
|
*
|
|
1037
1204
|
* @example
|
|
1038
1205
|
* ```ts
|
|
1039
|
-
* const
|
|
1040
|
-
*
|
|
1041
|
-
*
|
|
1042
|
-
* visibility: 'public',
|
|
1206
|
+
* const { session, url, object } = await client.storage.upload({
|
|
1207
|
+
* bucket: 'reports', key: 'q1.pdf', path: './q1.pdf',
|
|
1208
|
+
* waitForCompletion: true,
|
|
1043
1209
|
* });
|
|
1044
|
-
* console.log(
|
|
1210
|
+
* console.log(object?.contentLength, 'bytes available at', url);
|
|
1045
1211
|
* ```
|
|
1046
1212
|
*/
|
|
1047
|
-
|
|
1213
|
+
upload(input: UploadFileInput): Promise<UploadFileResult>;
|
|
1048
1214
|
/**
|
|
1049
|
-
*
|
|
1215
|
+
* Upload many files concurrently. Each file is uploaded independently; a
|
|
1216
|
+
* failure for one file does not abort the others — inspect each item's
|
|
1217
|
+
* `error`/`result`.
|
|
1050
1218
|
*
|
|
1051
|
-
* @param
|
|
1052
|
-
* @param
|
|
1053
|
-
* @returns
|
|
1219
|
+
* @param inputs - The files to upload.
|
|
1220
|
+
* @param options - Concurrency limit and an aggregated progress callback.
|
|
1221
|
+
* @returns One result per input, in the same order.
|
|
1054
1222
|
*
|
|
1055
1223
|
* @example
|
|
1056
1224
|
* ```ts
|
|
1057
|
-
* const
|
|
1058
|
-
*
|
|
1225
|
+
* const results = await client.storage.uploadBatch(
|
|
1226
|
+
* files.map((f) => ({ bucket: 'uploads', key: f.name, data: f })),
|
|
1227
|
+
* { concurrency: 6, onProgress: (done, total) => console.log(`${done}/${total}`) },
|
|
1228
|
+
* );
|
|
1229
|
+
* const failed = results.filter((r) => r.error);
|
|
1059
1230
|
* ```
|
|
1060
1231
|
*/
|
|
1061
|
-
|
|
1232
|
+
uploadBatch(inputs: UploadFileInput[], options?: UploadBatchOptions): Promise<UploadBatchItemResult[]>;
|
|
1062
1233
|
/**
|
|
1063
|
-
*
|
|
1064
|
-
*
|
|
1065
|
-
* @param applicationId - The application ID (UUID).
|
|
1066
|
-
* @param bucketId - The bucket ID (UUID).
|
|
1234
|
+
* Poll an upload session until the object is finalized server-side.
|
|
1067
1235
|
*
|
|
1068
|
-
* @
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
1071
|
-
*
|
|
1236
|
+
* @param bucketRef - Canonical bucket name or deprecated UUID fallback.
|
|
1237
|
+
* @param sessionId - The upload session ID (UUID).
|
|
1238
|
+
* @param options - Timeout and polling interval.
|
|
1239
|
+
* @returns The completed session.
|
|
1240
|
+
* @throws {@link UploadError} if the session fails, expires, or the timeout elapses.
|
|
1072
1241
|
*/
|
|
1073
|
-
|
|
1242
|
+
waitForCompletion(bucketRef: StorageBucketReference, sessionId: string, options?: WaitForCompletionOptions): Promise<StorageUploadSession>;
|
|
1243
|
+
/** @deprecated Prefer the context-bound overload through `client.storage`. */
|
|
1244
|
+
waitForCompletion(applicationId: string, bucketRef: StorageBucketReference, sessionId: string, options?: WaitForCompletionOptions): Promise<StorageUploadSession>;
|
|
1074
1245
|
}
|
|
1075
1246
|
|
|
1076
|
-
/**
|
|
1077
|
-
interface
|
|
1078
|
-
/** Unique identifier
|
|
1247
|
+
/** An environment variable attached to an organization, application, or environment. */
|
|
1248
|
+
interface EnvVar {
|
|
1249
|
+
/** Unique identifier. */
|
|
1079
1250
|
id: string;
|
|
1080
|
-
/** The
|
|
1081
|
-
bucketId: string;
|
|
1082
|
-
/** The application this object belongs to. */
|
|
1083
|
-
applicationId: string;
|
|
1084
|
-
/** The upload session that created this object, or `null` for imported objects. */
|
|
1085
|
-
uploadSessionId: string | null;
|
|
1086
|
-
/** The object key (path) within the bucket (e.g. `"images/photo.jpg"`). */
|
|
1251
|
+
/** The variable name (e.g. `DATABASE_URL`). */
|
|
1087
1252
|
key: string;
|
|
1088
|
-
/**
|
|
1089
|
-
|
|
1090
|
-
/**
|
|
1091
|
-
|
|
1092
|
-
/**
|
|
1093
|
-
|
|
1094
|
-
/**
|
|
1095
|
-
|
|
1096
|
-
/**
|
|
1097
|
-
|
|
1098
|
-
/** ISO 8601 timestamp of when the
|
|
1099
|
-
uploadedAt: string;
|
|
1100
|
-
/** ISO 8601 creation timestamp. */
|
|
1253
|
+
/** The variable value. `null` when {@link sensitive} is `true` and the value is hidden from API responses. */
|
|
1254
|
+
value: string | null;
|
|
1255
|
+
/** When `true`, the value is redacted in API responses to protect secrets. */
|
|
1256
|
+
sensitive: boolean;
|
|
1257
|
+
/** The scope level at which this variable is defined. */
|
|
1258
|
+
scope: 'organization' | 'application' | 'environment';
|
|
1259
|
+
/** The environment ID, if this variable is scoped to a specific environment. */
|
|
1260
|
+
environmentId: string | null;
|
|
1261
|
+
/** The human-readable environment name, if scoped to a specific environment. */
|
|
1262
|
+
environmentName: string | null;
|
|
1263
|
+
/** ISO 8601 timestamp of when the variable was created. */
|
|
1101
1264
|
createdAt: string;
|
|
1102
|
-
/** ISO 8601 last
|
|
1265
|
+
/** ISO 8601 timestamp of when the variable was last updated. */
|
|
1103
1266
|
updatedAt: string;
|
|
1104
1267
|
}
|
|
1268
|
+
/** Input for creating a new environment variable. */
|
|
1269
|
+
interface CreateEnvVarInput {
|
|
1270
|
+
/** The variable name (e.g. `DATABASE_URL`). Must be unique within its scope. */
|
|
1271
|
+
key: string;
|
|
1272
|
+
/** The variable value. */
|
|
1273
|
+
value: string;
|
|
1274
|
+
/** Mark the variable as sensitive to hide its value in API responses. */
|
|
1275
|
+
sensitive?: boolean;
|
|
1276
|
+
/** The scope level. Defaults to the parent resource's scope. */
|
|
1277
|
+
scope?: 'organization' | 'application' | 'environment';
|
|
1278
|
+
/** The environment ID, when creating an environment-scoped variable. */
|
|
1279
|
+
environmentId?: string;
|
|
1280
|
+
}
|
|
1281
|
+
/** Input for updating an existing environment variable. All fields are optional — only provided fields are changed. */
|
|
1282
|
+
interface UpdateEnvVarInput {
|
|
1283
|
+
/** New variable name. */
|
|
1284
|
+
key?: string;
|
|
1285
|
+
/** New variable value. */
|
|
1286
|
+
value?: string;
|
|
1287
|
+
/** Change the sensitive flag. */
|
|
1288
|
+
sensitive?: boolean;
|
|
1289
|
+
}
|
|
1105
1290
|
/**
|
|
1106
|
-
*
|
|
1107
|
-
*
|
|
1291
|
+
* A resolved environment variable returned by the pull endpoint. Only
|
|
1292
|
+
* non-sensitive variables are returned, so {@link value} is always the real value.
|
|
1108
1293
|
*/
|
|
1109
|
-
interface
|
|
1110
|
-
/**
|
|
1111
|
-
|
|
1112
|
-
/** The
|
|
1113
|
-
|
|
1114
|
-
/**
|
|
1115
|
-
|
|
1294
|
+
interface ResolvedEnvVar {
|
|
1295
|
+
/** The variable name (e.g. `DATABASE_URL`). */
|
|
1296
|
+
key: string;
|
|
1297
|
+
/** The resolved variable value. */
|
|
1298
|
+
value: string;
|
|
1299
|
+
/** Where the resolved value came from after applying org → app → environment inheritance. */
|
|
1300
|
+
source: 'organization' | 'application' | 'environment';
|
|
1116
1301
|
}
|
|
1117
|
-
/** Query
|
|
1118
|
-
interface
|
|
1119
|
-
/**
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
/** Maximum number of objects to return (1–1000, default 200). */
|
|
1126
|
-
limit?: number;
|
|
1302
|
+
/** Query options for {@link ApplicationEnvVarsResource.pull}. */
|
|
1303
|
+
interface PullEnvVarsQuery {
|
|
1304
|
+
/**
|
|
1305
|
+
* Resolve environment-specific overrides for this environment slug on top of
|
|
1306
|
+
* the organization and application baseline. Omit for the local development
|
|
1307
|
+
* baseline (organization + application-wide variables only).
|
|
1308
|
+
*/
|
|
1309
|
+
environment?: string;
|
|
1127
1310
|
}
|
|
1128
|
-
/**
|
|
1129
|
-
interface
|
|
1130
|
-
/**
|
|
1131
|
-
|
|
1311
|
+
/** Result of pulling resolved environment variables for local development. */
|
|
1312
|
+
interface PullEnvVarsResult {
|
|
1313
|
+
/** Resolved, non-sensitive variables, ready to write to a local `.env` file. */
|
|
1314
|
+
items: ResolvedEnvVar[];
|
|
1315
|
+
/** Number of resolved variables returned. */
|
|
1316
|
+
total: number;
|
|
1317
|
+
/**
|
|
1318
|
+
* Number of sensitive variables that were resolved but intentionally omitted.
|
|
1319
|
+
* Secrets are never returned by the pull endpoint.
|
|
1320
|
+
*/
|
|
1321
|
+
omittedSensitive: number;
|
|
1132
1322
|
}
|
|
1323
|
+
|
|
1133
1324
|
/**
|
|
1134
|
-
*
|
|
1135
|
-
* Accessed via `client.applications.
|
|
1136
|
-
*
|
|
1137
|
-
* Objects are addressed by their object ID (UUID). If you only have the object
|
|
1138
|
-
* key, use {@link getByKey} to resolve it, or read the `id` from a listing.
|
|
1139
|
-
*
|
|
1140
|
-
* To upload objects, use `client.applications.storage.upload()`.
|
|
1141
|
-
*
|
|
1142
|
-
* @example
|
|
1143
|
-
* ```ts
|
|
1144
|
-
* // List all objects in a bucket
|
|
1145
|
-
* const { items } = await client.applications.storage.objects.list('app-id', 'bucket-id');
|
|
1146
|
-
* for (const obj of items) {
|
|
1147
|
-
* console.log(`${obj.key} (${obj.contentLength} bytes)`);
|
|
1148
|
-
* }
|
|
1149
|
-
*
|
|
1150
|
-
* // Get a signed download URL for a private object
|
|
1151
|
-
* const { url } = await client.applications.storage.objects.getAccessUrl('app-id', 'bucket-id', 'object-id');
|
|
1152
|
-
* ```
|
|
1325
|
+
* Manage environment variables scoped to an application.
|
|
1326
|
+
* Accessed via `client.applications.envVars`.
|
|
1153
1327
|
*/
|
|
1154
|
-
declare class
|
|
1328
|
+
declare class ApplicationEnvVarsResource extends BaseResource {
|
|
1155
1329
|
/**
|
|
1156
|
-
* List
|
|
1157
|
-
* grouped into virtual folders by a delimiter.
|
|
1330
|
+
* List all environment variables for an application.
|
|
1158
1331
|
*
|
|
1159
1332
|
* @param applicationId - The application ID (UUID).
|
|
1160
|
-
* @
|
|
1161
|
-
* @param query - Optional prefix/delimiter/cursor/limit parameters.
|
|
1162
|
-
* @returns A page of objects plus any common (folder) prefixes and a `nextCursor`.
|
|
1333
|
+
* @returns A paginated list of environment variables.
|
|
1163
1334
|
*
|
|
1164
1335
|
* @example
|
|
1165
1336
|
* ```ts
|
|
1166
|
-
*
|
|
1167
|
-
* const
|
|
1168
|
-
*
|
|
1169
|
-
*
|
|
1337
|
+
* const { items } = await client.applications.envVars.list('app-id');
|
|
1338
|
+
* for (const v of items) {
|
|
1339
|
+
* console.log(`${v.key}=${v.sensitive ? '***' : v.value}`);
|
|
1340
|
+
* }
|
|
1170
1341
|
* ```
|
|
1171
1342
|
*/
|
|
1172
|
-
list(applicationId: string,
|
|
1343
|
+
list(applicationId: string, query?: ListQuery): Promise<Paginated<EnvVar>>;
|
|
1173
1344
|
/**
|
|
1174
|
-
*
|
|
1345
|
+
* Pull the environment variables that apply to an application for local
|
|
1346
|
+
* development. Merges organization-wide, application-wide, and (optionally)
|
|
1347
|
+
* environment-specific overrides, returning only non-sensitive values — ready
|
|
1348
|
+
* to write to a local `.env` file.
|
|
1175
1349
|
*
|
|
1176
1350
|
* @param applicationId - The application ID (UUID).
|
|
1177
|
-
* @param
|
|
1178
|
-
* @
|
|
1179
|
-
* @returns The object metadata.
|
|
1351
|
+
* @param query - Optional environment targeting.
|
|
1352
|
+
* @returns The resolved non-sensitive variables plus the count of omitted secrets.
|
|
1180
1353
|
*
|
|
1181
1354
|
* @example
|
|
1182
1355
|
* ```ts
|
|
1183
|
-
* const
|
|
1184
|
-
*
|
|
1356
|
+
* const { items } = await client.applications.envVars.pull('app-id');
|
|
1357
|
+
* const dotenv = items.map((v) => `${v.key}=${v.value}`).join('\n');
|
|
1185
1358
|
* ```
|
|
1186
1359
|
*/
|
|
1187
|
-
|
|
1360
|
+
pull(applicationId: string, query?: PullEnvVarsQuery): Promise<PullEnvVarsResult>;
|
|
1188
1361
|
/**
|
|
1189
|
-
*
|
|
1190
|
-
* {@link list} — lists with the key as the prefix and returns the exact match,
|
|
1191
|
-
* paging through results until found, or `null` if no object with that key
|
|
1192
|
-
* exists. (The API has no get-by-key endpoint.)
|
|
1362
|
+
* Create a new environment variable for an application.
|
|
1193
1363
|
*
|
|
1194
1364
|
* @param applicationId - The application ID (UUID).
|
|
1195
|
-
* @param
|
|
1196
|
-
* @
|
|
1197
|
-
*
|
|
1365
|
+
* @param data - The variable key, value, and optional settings.
|
|
1366
|
+
* @returns The newly created environment variable.
|
|
1367
|
+
*
|
|
1368
|
+
* @example
|
|
1369
|
+
* ```ts
|
|
1370
|
+
* const envVar = await client.applications.envVars.create('app-id', {
|
|
1371
|
+
* key: 'DATABASE_URL',
|
|
1372
|
+
* value: 'postgres://...',
|
|
1373
|
+
* sensitive: true,
|
|
1374
|
+
* });
|
|
1375
|
+
* ```
|
|
1198
1376
|
*/
|
|
1199
|
-
|
|
1377
|
+
create(applicationId: string, data: CreateEnvVarInput): Promise<EnvVar>;
|
|
1200
1378
|
/**
|
|
1201
|
-
*
|
|
1379
|
+
* Update an existing environment variable. Only the fields you provide
|
|
1380
|
+
* will be changed; omitted fields are left unchanged.
|
|
1202
1381
|
*
|
|
1203
1382
|
* @param applicationId - The application ID (UUID).
|
|
1204
|
-
* @param
|
|
1205
|
-
* @param
|
|
1383
|
+
* @param envVarId - The environment variable ID (UUID).
|
|
1384
|
+
* @param data - The fields to update.
|
|
1385
|
+
* @returns The updated environment variable.
|
|
1206
1386
|
*
|
|
1207
1387
|
* @example
|
|
1208
1388
|
* ```ts
|
|
1209
|
-
* await client.applications.
|
|
1389
|
+
* await client.applications.envVars.update('app-id', 'var-id', {
|
|
1390
|
+
* value: 'postgres://new-host/db',
|
|
1391
|
+
* });
|
|
1210
1392
|
* ```
|
|
1211
1393
|
*/
|
|
1212
|
-
|
|
1394
|
+
update(applicationId: string, envVarId: string, data: UpdateEnvVarInput): Promise<EnvVar>;
|
|
1213
1395
|
/**
|
|
1214
|
-
*
|
|
1215
|
-
* returns a stable CDN URL. For private buckets, returns a time-limited
|
|
1216
|
-
* signed URL.
|
|
1396
|
+
* Permanently delete an environment variable.
|
|
1217
1397
|
*
|
|
1218
1398
|
* @param applicationId - The application ID (UUID).
|
|
1219
|
-
* @param
|
|
1220
|
-
* @param objectId - The object ID (UUID) — not the object key.
|
|
1221
|
-
* @param options - Optional `expiresInSeconds` for signed URLs (60–86400).
|
|
1222
|
-
* @returns The access URL and its type/expiry.
|
|
1399
|
+
* @param envVarId - The environment variable ID (UUID).
|
|
1223
1400
|
*
|
|
1224
1401
|
* @example
|
|
1225
1402
|
* ```ts
|
|
1226
|
-
*
|
|
1227
|
-
* expiresInSeconds: 3600,
|
|
1228
|
-
* });
|
|
1229
|
-
* if (access.accessType === 'signed') {
|
|
1230
|
-
* console.log(`Signed URL expires at ${access.expiresAt}`);
|
|
1231
|
-
* }
|
|
1232
|
-
* console.log(`Download: ${access.url}`);
|
|
1403
|
+
* await client.applications.envVars.delete('app-id', 'var-id');
|
|
1233
1404
|
* ```
|
|
1234
1405
|
*/
|
|
1235
|
-
|
|
1236
|
-
expiresInSeconds?: number;
|
|
1237
|
-
}): Promise<StorageObjectAccess>;
|
|
1406
|
+
delete(applicationId: string, envVarId: string): Promise<void>;
|
|
1238
1407
|
}
|
|
1239
1408
|
|
|
1240
|
-
/**
|
|
1241
|
-
|
|
1242
|
-
* lifecycle of a file upload from creation through completion.
|
|
1243
|
-
*/
|
|
1244
|
-
interface StorageUploadSession {
|
|
1245
|
-
/** Unique identifier (UUID). */
|
|
1409
|
+
/** A nested reference to the application that served a request. */
|
|
1410
|
+
interface NetworkRequestApplicationRef {
|
|
1246
1411
|
id: string;
|
|
1247
|
-
|
|
1248
|
-
bucketId: string;
|
|
1249
|
-
/** The application this upload belongs to. */
|
|
1250
|
-
applicationId: string;
|
|
1251
|
-
/** The object key/path the file will be stored at (e.g. `"images/photo.jpg"`). */
|
|
1252
|
-
key: string;
|
|
1253
|
-
/** MIME content type declared at creation, or `null` if not specified. */
|
|
1254
|
-
contentType: string | null;
|
|
1255
|
-
/** Expected file size in bytes declared at creation, or `null`. */
|
|
1256
|
-
contentLength: number | null;
|
|
1257
|
-
/** SHA-1 checksum for server-side verification, if provided. */
|
|
1258
|
-
checksumSha1: string | null;
|
|
1259
|
-
/** SHA-256 checksum for server-side verification, if provided. */
|
|
1260
|
-
checksumSha256: string | null;
|
|
1261
|
-
/** MD5 checksum for server-side verification, if provided. */
|
|
1262
|
-
checksumMd5: string | null;
|
|
1263
|
-
/**
|
|
1264
|
-
* Current session state:
|
|
1265
|
-
* - `"pending"` — Session created, awaiting the first bytes.
|
|
1266
|
-
* - `"ready"` — Receiving file data.
|
|
1267
|
-
* - `"completed"` — Upload verified and storage object created.
|
|
1268
|
-
* - `"failed"` — Upload failed or was rejected.
|
|
1269
|
-
* - `"expired"` — Session exceeded its expiration time.
|
|
1270
|
-
*/
|
|
1271
|
-
state: 'pending' | 'ready' | 'completed' | 'failed' | 'expired';
|
|
1272
|
-
/** ISO 8601 timestamp when this session (and its upload URL) expires. */
|
|
1273
|
-
expiresAt: string;
|
|
1274
|
-
/** ISO 8601 timestamp when the upload was finalized, or `null`. */
|
|
1275
|
-
uploadedAt: string | null;
|
|
1276
|
-
/** ISO 8601 creation timestamp. */
|
|
1277
|
-
createdAt: string;
|
|
1278
|
-
/** ISO 8601 last-updated timestamp. */
|
|
1279
|
-
updatedAt: string;
|
|
1280
|
-
}
|
|
1281
|
-
/** Input for creating a new upload session. */
|
|
1282
|
-
interface CreateUploadSessionInput {
|
|
1283
|
-
/** The object key/path the file will be stored at (e.g. `"images/photo.jpg"`). 1–1024 characters. */
|
|
1284
|
-
key: string;
|
|
1285
|
-
/** File size in bytes. Required. */
|
|
1286
|
-
contentLength: number;
|
|
1287
|
-
/** Lowercase hex SHA-256 checksum (64 chars) of the content. Required for server-side verification. */
|
|
1288
|
-
checksumSha256: string;
|
|
1289
|
-
/** MIME content type of the file (e.g. `"image/jpeg"`). */
|
|
1290
|
-
contentType?: string;
|
|
1291
|
-
/** Optional lowercase hex SHA-1 checksum (40 chars). */
|
|
1292
|
-
checksumSha1?: string;
|
|
1293
|
-
/** Optional lowercase hex MD5 checksum (32 chars). */
|
|
1294
|
-
checksumMd5?: string;
|
|
1412
|
+
name: string;
|
|
1295
1413
|
}
|
|
1296
|
-
/**
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
interface CreateUploadSessionResponse {
|
|
1301
|
-
/** The created upload session. */
|
|
1302
|
-
session: StorageUploadSession;
|
|
1303
|
-
/** Resumable upload instructions — use these to send the file data. */
|
|
1304
|
-
upload: {
|
|
1305
|
-
/** The HTTP method for the byte upload (resumable upload protocol). */
|
|
1306
|
-
method: 'PATCH';
|
|
1307
|
-
/** Signed upload URL. Send your file data here. */
|
|
1308
|
-
url: string;
|
|
1309
|
-
/** Required headers to include with the upload request. */
|
|
1310
|
-
headers: Record<string, string>;
|
|
1311
|
-
/** The URL where the object will be accessible after upload (CDN URL for public buckets). */
|
|
1312
|
-
publicObjectUrl: string;
|
|
1313
|
-
};
|
|
1414
|
+
/** A nested reference to the deployment that served a request. */
|
|
1415
|
+
interface NetworkRequestDeploymentRef {
|
|
1416
|
+
id: string;
|
|
1417
|
+
status: string;
|
|
1314
1418
|
}
|
|
1315
|
-
/** A
|
|
1316
|
-
interface
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
/** A readable stream (Node.js only). Requires `contentLength`. */
|
|
1322
|
-
stream?: NodeReadableLike;
|
|
1323
|
-
/** Byte size — required for `stream` inputs, computed otherwise. */
|
|
1324
|
-
contentLength?: number;
|
|
1419
|
+
/** A nested reference to the function route that handled a request. */
|
|
1420
|
+
interface NetworkRequestFunctionRef {
|
|
1421
|
+
id: string;
|
|
1422
|
+
name: string | null;
|
|
1423
|
+
path: string;
|
|
1424
|
+
region: string | null;
|
|
1325
1425
|
}
|
|
1326
|
-
/**
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
* For most use cases, prefer the high-level `client.applications.storage.upload()`
|
|
1332
|
-
* which creates the session, computes the required checksum, uploads the bytes,
|
|
1333
|
-
* and returns the public URL.
|
|
1334
|
-
*/
|
|
1335
|
-
declare class StorageUploadSessionsResource extends BaseResource {
|
|
1336
|
-
private readonly transport;
|
|
1337
|
-
constructor(httpClient: ConstructorParameters<typeof BaseResource>[0], transport?: UploadTransport);
|
|
1338
|
-
/**
|
|
1339
|
-
* List upload sessions for a bucket.
|
|
1340
|
-
*
|
|
1341
|
-
* @param applicationId - The application ID (UUID).
|
|
1342
|
-
* @param bucketId - The bucket ID (UUID).
|
|
1343
|
-
* @param query - Optional pagination parameters.
|
|
1344
|
-
* @returns A paginated list of upload sessions.
|
|
1345
|
-
*/
|
|
1346
|
-
list(applicationId: string, bucketId: string, query?: ListQuery): Promise<Paginated<StorageUploadSession>>;
|
|
1347
|
-
/**
|
|
1348
|
-
* Create an upload session. Returns the session metadata and a signed upload
|
|
1349
|
-
* URL for sending file data. This is the low-level method — for most use
|
|
1350
|
-
* cases prefer `client.applications.storage.upload()` which also computes the
|
|
1351
|
-
* required SHA-256 checksum for you.
|
|
1352
|
-
*
|
|
1353
|
-
* @param applicationId - The application ID (UUID).
|
|
1354
|
-
* @param bucketId - The bucket ID (UUID).
|
|
1355
|
-
* @param data - Object key, content length, SHA-256 checksum, and optional content type / extra checksums.
|
|
1356
|
-
* @returns The session and resumable upload instructions (URL, method, headers).
|
|
1357
|
-
*/
|
|
1358
|
-
create(applicationId: string, bucketId: string, data: CreateUploadSessionInput): Promise<CreateUploadSessionResponse>;
|
|
1359
|
-
/**
|
|
1360
|
-
* Get an upload session by ID. Use this to track server-side processing after
|
|
1361
|
-
* an upload (poll until `state === 'completed'`).
|
|
1362
|
-
*
|
|
1363
|
-
* @param applicationId - The application ID (UUID).
|
|
1364
|
-
* @param bucketId - The bucket ID (UUID).
|
|
1365
|
-
* @param sessionId - The upload session ID (UUID).
|
|
1366
|
-
* @returns The current session state.
|
|
1367
|
-
*/
|
|
1368
|
-
get(applicationId: string, bucketId: string, sessionId: string): Promise<StorageUploadSession>;
|
|
1369
|
-
/**
|
|
1370
|
-
* Upload bytes directly to a pre-existing signed upload URL — for example, a
|
|
1371
|
-
* URL returned by {@link create} or handed to your client by a backend. Skips
|
|
1372
|
-
* session creation and checksum computation.
|
|
1373
|
-
*
|
|
1374
|
-
* @param url - A signed upload URL.
|
|
1375
|
-
* @param source - The bytes to upload.
|
|
1376
|
-
* @param options - Chunk size, retry config, progress, abort signal, resume,
|
|
1377
|
-
* and any required `headers` returned with the upload session.
|
|
1378
|
-
* @throws {@link UploadError} if the upload fails after all retries.
|
|
1379
|
-
*/
|
|
1380
|
-
uploadToUrl(url: string, source: UploadByteSource, options?: RunUploadOptions & {
|
|
1381
|
-
headers?: Record<string, string>;
|
|
1382
|
-
}): Promise<void>;
|
|
1383
|
-
/**
|
|
1384
|
-
* Resume an interrupted upload to a previously issued signed upload URL. The
|
|
1385
|
-
* resumable protocol negotiates the current offset and continues from there.
|
|
1386
|
-
*
|
|
1387
|
-
* @param url - The signed upload URL from the original {@link create} call.
|
|
1388
|
-
* @param source - The full bytes to upload (the same content as the original).
|
|
1389
|
-
* @param options - Chunk size, retry config, progress, abort signal.
|
|
1390
|
-
*/
|
|
1391
|
-
resumeFromUrl(url: string, source: UploadByteSource, options?: RunUploadOptions & {
|
|
1392
|
-
headers?: Record<string, string>;
|
|
1393
|
-
}): Promise<void>;
|
|
1426
|
+
/** A nested reference to the static asset that served a request. */
|
|
1427
|
+
interface NetworkRequestAssetRef {
|
|
1428
|
+
id: string;
|
|
1429
|
+
path: string;
|
|
1430
|
+
objectKey: string;
|
|
1394
1431
|
}
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
/** How often to poll the session state, in milliseconds. Default: 1000. */
|
|
1401
|
-
pollIntervalMs?: number;
|
|
1432
|
+
/** A nested reference to the storage bucket involved in a request. */
|
|
1433
|
+
interface NetworkRequestBucketRef {
|
|
1434
|
+
id: string;
|
|
1435
|
+
name: string;
|
|
1436
|
+
slug: string;
|
|
1402
1437
|
}
|
|
1403
|
-
/**
|
|
1404
|
-
interface
|
|
1405
|
-
|
|
1406
|
-
applicationId: string;
|
|
1407
|
-
/** The target bucket ID (UUID). */
|
|
1408
|
-
bucketId: string;
|
|
1409
|
-
/** The object key/path in the bucket (e.g. `"images/logo.png"`). */
|
|
1438
|
+
/** A nested reference to the storage object involved in a request. */
|
|
1439
|
+
interface NetworkRequestObjectRef {
|
|
1440
|
+
id: string;
|
|
1410
1441
|
key: string;
|
|
1411
|
-
|
|
1412
|
-
data?: UploadData;
|
|
1413
|
-
/** A filesystem path to upload from (Node.js only). Size, checksum, and content type are derived automatically. */
|
|
1414
|
-
path?: string;
|
|
1415
|
-
/** A readable stream to upload from (Node.js only). Requires `contentLength` and `checksumSha256`. */
|
|
1416
|
-
stream?: NodeReadableLike;
|
|
1417
|
-
/** MIME content type. Inferred from `key` when omitted. */
|
|
1418
|
-
contentType?: string;
|
|
1419
|
-
/** Byte size. Required for `stream`; computed otherwise. */
|
|
1420
|
-
contentLength?: number;
|
|
1421
|
-
/** Pre-computed SHA-256 (skips hashing). Required for `stream`. */
|
|
1422
|
-
checksumSha256?: string;
|
|
1423
|
-
/** Also send a SHA-1 checksum. */
|
|
1424
|
-
checksumSha1?: string;
|
|
1425
|
-
/** Also send an MD5 checksum (Node.js only unless provided). */
|
|
1426
|
-
checksumMd5?: string;
|
|
1427
|
-
/** Maximum chunk size in bytes (for very large files / streams). */
|
|
1428
|
-
chunkSize?: number;
|
|
1429
|
-
/** Retry backoff in milliseconds; `null`/`[]` disables retries. */
|
|
1430
|
-
retryDelays?: number[] | null;
|
|
1431
|
-
/** Progress callback invoked during the byte upload. */
|
|
1432
|
-
onProgress?: (bytesSent: number, bytesTotal: number) => void;
|
|
1433
|
-
/** Abort signal to cancel the upload. */
|
|
1434
|
-
signal?: AbortSignal;
|
|
1435
|
-
/** Persist a resumable fingerprint so the upload can be resumed later. */
|
|
1436
|
-
resume?: boolean;
|
|
1437
|
-
/** Custom storage backend for resumable fingerprints. */
|
|
1438
|
-
urlStorage?: UploadUrlStorage;
|
|
1439
|
-
/** Wait until the object is finalized server-side before resolving. Pass options to tune polling. */
|
|
1440
|
-
waitForCompletion?: boolean | WaitForCompletionOptions;
|
|
1442
|
+
contentType: string | null;
|
|
1441
1443
|
}
|
|
1442
|
-
/**
|
|
1443
|
-
interface
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1444
|
+
/** The HTTP request details captured for a network request. */
|
|
1445
|
+
interface NetworkRequestDetails {
|
|
1446
|
+
method: string;
|
|
1447
|
+
hostname: string;
|
|
1448
|
+
path: string;
|
|
1449
|
+
query: string | null;
|
|
1450
|
+
protocol: string | null;
|
|
1451
|
+
country: string | null;
|
|
1452
|
+
userAgent: string | null;
|
|
1453
|
+
referer: string | null;
|
|
1450
1454
|
}
|
|
1451
|
-
/**
|
|
1452
|
-
interface
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1455
|
+
/** The HTTP response details captured for a network request. */
|
|
1456
|
+
interface NetworkResponseDetails {
|
|
1457
|
+
status: number | null;
|
|
1458
|
+
cacheStatus: 'hit' | 'miss' | 'bypass' | 'revalidated' | 'stale' | 'updating' | null;
|
|
1459
|
+
cacheHit: boolean | null;
|
|
1460
|
+
region: string | null;
|
|
1461
|
+
edgeLocation: string | null;
|
|
1457
1462
|
}
|
|
1458
|
-
/**
|
|
1459
|
-
interface
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1463
|
+
/** Byte and timing metrics for a network request. */
|
|
1464
|
+
interface NetworkRequestMetrics {
|
|
1465
|
+
requestBodyBytes: number | null;
|
|
1466
|
+
responseBodyBytes: number | null;
|
|
1467
|
+
bytesSent: number | null;
|
|
1468
|
+
durationMs: number | null;
|
|
1469
|
+
}
|
|
1470
|
+
/** A single observed request served through the Gigadrive Network edge (summary form). */
|
|
1471
|
+
interface NetworkRequestSummary {
|
|
1472
|
+
id: string;
|
|
1473
|
+
application: NetworkRequestApplicationRef;
|
|
1474
|
+
deployment: NetworkRequestDeploymentRef | null;
|
|
1475
|
+
deploymentFunction: NetworkRequestFunctionRef | null;
|
|
1476
|
+
deploymentAsset: NetworkRequestAssetRef | null;
|
|
1477
|
+
storageBucket: NetworkRequestBucketRef | null;
|
|
1478
|
+
storageObject: NetworkRequestObjectRef | null;
|
|
1479
|
+
request: NetworkRequestDetails;
|
|
1480
|
+
response: NetworkResponseDetails;
|
|
1481
|
+
metrics: NetworkRequestMetrics;
|
|
1482
|
+
startedAt: string;
|
|
1483
|
+
completedAt: string | null;
|
|
1484
|
+
}
|
|
1485
|
+
/** A full network request record, including sanitized request/response headers. */
|
|
1486
|
+
interface NetworkRequest extends NetworkRequestSummary {
|
|
1487
|
+
/** Sanitized request headers captured for debugging. */
|
|
1488
|
+
requestHeaders: Record<string, string>;
|
|
1489
|
+
/** Sanitized response headers captured for debugging. */
|
|
1490
|
+
responseHeaders: Record<string, string>;
|
|
1491
|
+
}
|
|
1492
|
+
/** Query filters for listing application requests. All fields are optional. */
|
|
1493
|
+
interface ListRequestsQuery {
|
|
1494
|
+
/** Filter to requests served by one deployment. */
|
|
1495
|
+
deploymentId?: string;
|
|
1496
|
+
/** Filter to requests served by one function route. */
|
|
1497
|
+
deploymentFunctionId?: string;
|
|
1498
|
+
/** Filter to requests served by one static asset route. */
|
|
1499
|
+
deploymentAssetId?: string;
|
|
1500
|
+
/** Filter to storage delivery requests for one bucket. */
|
|
1501
|
+
storageBucketId?: string;
|
|
1502
|
+
/** Filter to storage delivery requests for one object. */
|
|
1503
|
+
storageObjectId?: string;
|
|
1504
|
+
/** Only include requests that started at or after this ISO 8601 timestamp. */
|
|
1505
|
+
from?: string;
|
|
1506
|
+
/** Only include requests that started before or at this ISO 8601 timestamp. */
|
|
1507
|
+
to?: string;
|
|
1508
|
+
/** Maximum number of records to return. */
|
|
1509
|
+
limit?: number;
|
|
1510
|
+
/** Opaque cursor from a previous response's `nextCursor`. */
|
|
1511
|
+
cursor?: string;
|
|
1512
|
+
/** Filter by HTTP method (e.g. `"GET"`). */
|
|
1513
|
+
method?: string;
|
|
1514
|
+
/** Filter by exact HTTP status code. */
|
|
1515
|
+
status?: number;
|
|
1516
|
+
/** Filter by status family (`2`, `3`, `4`, or `5`). */
|
|
1517
|
+
statusFamily?: number;
|
|
1518
|
+
/** Filter by request hostname. */
|
|
1519
|
+
hostname?: string;
|
|
1520
|
+
/** Filter to requests whose path starts with this prefix. */
|
|
1521
|
+
pathPrefix?: string;
|
|
1522
|
+
/** Filter by ISO 3166-1 alpha-2 country code. */
|
|
1523
|
+
country?: string;
|
|
1524
|
+
/** Filter by origin region. */
|
|
1525
|
+
region?: string;
|
|
1526
|
+
/** Filter by edge location. */
|
|
1527
|
+
edgeLocation?: string;
|
|
1528
|
+
/** Filter by CDN cache state. */
|
|
1529
|
+
cacheStatus?: string;
|
|
1530
|
+
/** Filter by whether the response was served from cache. */
|
|
1531
|
+
cacheHit?: boolean;
|
|
1466
1532
|
}
|
|
1467
1533
|
/**
|
|
1468
|
-
*
|
|
1469
|
-
*
|
|
1470
|
-
* {@link upload} / {@link uploadBatch} helpers.
|
|
1471
|
-
*
|
|
1472
|
-
* Accessed via `client.applications.storage`.
|
|
1534
|
+
* Read observed traffic (request logs) for an application. Accessed via
|
|
1535
|
+
* `client.applications.requests`.
|
|
1473
1536
|
*
|
|
1474
1537
|
* @example
|
|
1475
1538
|
* ```ts
|
|
1476
|
-
* //
|
|
1477
|
-
* const {
|
|
1478
|
-
*
|
|
1479
|
-
*
|
|
1480
|
-
*
|
|
1481
|
-
* path: './cat.jpg',
|
|
1482
|
-
* });
|
|
1483
|
-
*
|
|
1484
|
-
* // Browser upload from a file input, with progress and abort
|
|
1485
|
-
* const controller = new AbortController();
|
|
1486
|
-
* const { url } = await client.applications.storage.upload({
|
|
1487
|
-
* applicationId: 'app-id',
|
|
1488
|
-
* bucketId: 'bucket-id',
|
|
1489
|
-
* key: `uploads/${file.name}`,
|
|
1490
|
-
* data: file,
|
|
1491
|
-
* onProgress: (sent, total) => console.log(`${Math.round((sent / total) * 100)}%`),
|
|
1492
|
-
* signal: controller.signal,
|
|
1539
|
+
* // Recent 5xx responses for a deployment
|
|
1540
|
+
* const { items } = await client.applications.requests.list('app-id', {
|
|
1541
|
+
* deploymentId: 'dep-id',
|
|
1542
|
+
* statusFamily: 5,
|
|
1543
|
+
* limit: 100,
|
|
1493
1544
|
* });
|
|
1494
1545
|
* ```
|
|
1495
1546
|
*/
|
|
1496
|
-
declare class
|
|
1497
|
-
/** Create, list, get, and delete storage buckets. */
|
|
1498
|
-
readonly buckets: StorageBucketsResource;
|
|
1499
|
-
/** List, get, delete objects, and generate access URLs. */
|
|
1500
|
-
readonly objects: StorageObjectsResource;
|
|
1501
|
-
/** Low-level upload sessions and direct-to-URL byte uploads. */
|
|
1502
|
-
readonly uploadSessions: StorageUploadSessionsResource;
|
|
1503
|
-
private readonly transport;
|
|
1504
|
-
constructor(httpClient: HttpClient, transport?: UploadTransport);
|
|
1505
|
-
/**
|
|
1506
|
-
* Upload a file to a storage bucket. Handles the full flow: computes the
|
|
1507
|
-
* required SHA-256 checksum, creates an upload session, uploads the bytes with
|
|
1508
|
-
* automatic retries (and optional progress/abort/resume), and returns the
|
|
1509
|
-
* public URL.
|
|
1510
|
-
*
|
|
1511
|
-
* Accepts browser `File`/`Blob`, Node `Buffer`/`Uint8Array`/`ArrayBuffer`, a
|
|
1512
|
-
* Node filesystem `path`, or a Node readable `stream` (with `contentLength`
|
|
1513
|
-
* and `checksumSha256`). The content type is inferred from `key` when omitted.
|
|
1514
|
-
*
|
|
1515
|
-
* @param input - What and where to upload, plus optional transfer options.
|
|
1516
|
-
* @returns The upload session and public object URL (and the finalized object when `waitForCompletion` is set).
|
|
1517
|
-
* @throws {@link UploadError} if the byte upload fails.
|
|
1518
|
-
* @throws {@link UploadSessionExpiredError} if the session expires mid-upload.
|
|
1519
|
-
*
|
|
1520
|
-
* @example
|
|
1521
|
-
* ```ts
|
|
1522
|
-
* const { session, url, object } = await client.applications.storage.upload({
|
|
1523
|
-
* applicationId, bucketId, key: 'reports/q1.pdf', path: './q1.pdf',
|
|
1524
|
-
* waitForCompletion: true,
|
|
1525
|
-
* });
|
|
1526
|
-
* console.log(object?.contentLength, 'bytes available at', url);
|
|
1527
|
-
* ```
|
|
1528
|
-
*/
|
|
1529
|
-
upload(input: UploadFileInput): Promise<UploadFileResult>;
|
|
1547
|
+
declare class ApplicationRequestsResource extends BaseResource {
|
|
1530
1548
|
/**
|
|
1531
|
-
*
|
|
1532
|
-
* failure for one file does not abort the others — inspect each item's
|
|
1533
|
-
* `error`/`result`.
|
|
1534
|
-
*
|
|
1535
|
-
* @param inputs - The files to upload.
|
|
1536
|
-
* @param options - Concurrency limit and an aggregated progress callback.
|
|
1537
|
-
* @returns One result per input, in the same order.
|
|
1549
|
+
* List requests for an application, with rich filtering and cursor pagination.
|
|
1538
1550
|
*
|
|
1539
|
-
* @
|
|
1540
|
-
*
|
|
1541
|
-
*
|
|
1542
|
-
* files.map((f) => ({ applicationId, bucketId, key: `uploads/${f.name}`, data: f })),
|
|
1543
|
-
* { concurrency: 6, onProgress: (done, total) => console.log(`${done}/${total}`) },
|
|
1544
|
-
* );
|
|
1545
|
-
* const failed = results.filter((r) => r.error);
|
|
1546
|
-
* ```
|
|
1551
|
+
* @param applicationId - The application ID (UUID).
|
|
1552
|
+
* @param query - Optional filters and pagination.
|
|
1553
|
+
* @returns A page of request summaries.
|
|
1547
1554
|
*/
|
|
1548
|
-
|
|
1555
|
+
list(applicationId: string, query?: ListRequestsQuery): Promise<Paginated<NetworkRequestSummary>>;
|
|
1549
1556
|
/**
|
|
1550
|
-
*
|
|
1557
|
+
* Get a single request by ID, including sanitized request/response headers.
|
|
1551
1558
|
*
|
|
1552
1559
|
* @param applicationId - The application ID (UUID).
|
|
1553
|
-
* @param
|
|
1554
|
-
* @
|
|
1555
|
-
* @param options - Timeout and polling interval.
|
|
1556
|
-
* @returns The completed session.
|
|
1557
|
-
* @throws {@link UploadError} if the session fails, expires, or the timeout elapses.
|
|
1560
|
+
* @param requestId - The request record ID (UUID).
|
|
1561
|
+
* @returns The full request record.
|
|
1558
1562
|
*/
|
|
1559
|
-
|
|
1563
|
+
get(applicationId: string, requestId: string): Promise<NetworkRequest>;
|
|
1560
1564
|
}
|
|
1561
1565
|
|
|
1562
1566
|
/** A `*.gigadrive.app` hostname assigned to an application or deployment. */
|
|
@@ -2276,15 +2280,14 @@ declare class ApplicationsResource extends BaseResource {
|
|
|
2276
2280
|
* @example
|
|
2277
2281
|
* ```ts
|
|
2278
2282
|
* // Upload a file
|
|
2279
|
-
* const { url } = await client.
|
|
2280
|
-
*
|
|
2281
|
-
* bucketId: 'bucket-id',
|
|
2283
|
+
* const { url } = await client.storage.upload({
|
|
2284
|
+
* bucket: 'assets',
|
|
2282
2285
|
* key: 'images/logo.png',
|
|
2283
2286
|
* data: fileData,
|
|
2284
2287
|
* });
|
|
2285
2288
|
*
|
|
2286
2289
|
* // List objects in a bucket
|
|
2287
|
-
* const { items } = await client.
|
|
2290
|
+
* const { items } = await client.storage.objects.list('assets');
|
|
2288
2291
|
* ```
|
|
2289
2292
|
*/
|
|
2290
2293
|
readonly storage: ApplicationStorageResource;
|
|
@@ -2297,7 +2300,7 @@ declare class ApplicationsResource extends BaseResource {
|
|
|
2297
2300
|
* ```
|
|
2298
2301
|
*/
|
|
2299
2302
|
readonly requests: ApplicationRequestsResource;
|
|
2300
|
-
constructor(
|
|
2303
|
+
constructor(httpClient: ConstructorParameters<typeof BaseResource>[0], defaultApplicationId?: string);
|
|
2301
2304
|
/**
|
|
2302
2305
|
* List applications the authenticated actor has access to.
|
|
2303
2306
|
*
|
|
@@ -2753,6 +2756,14 @@ declare class StickySessionsResource extends BaseResource {
|
|
|
2753
2756
|
* resolution chain.
|
|
2754
2757
|
*/
|
|
2755
2758
|
interface GigadriveClientConfig {
|
|
2759
|
+
/**
|
|
2760
|
+
* Default application UUID for context-bound storage calls.
|
|
2761
|
+
*
|
|
2762
|
+
* Falls back to `GIGADRIVE_APPLICATION_ID`, which the platform injects into
|
|
2763
|
+
* deployed workloads. Explicit application IDs supplied to compatibility
|
|
2764
|
+
* overloads take precedence over this value.
|
|
2765
|
+
*/
|
|
2766
|
+
applicationId?: string;
|
|
2756
2767
|
/**
|
|
2757
2768
|
* OAuth2 client ID (the API key ID from the Gigadrive dashboard).
|
|
2758
2769
|
* Used for both client-credentials and refresh-token flows.
|
|
@@ -2889,6 +2900,15 @@ declare class GigadriveClient {
|
|
|
2889
2900
|
readonly organizations: OrganizationsResource;
|
|
2890
2901
|
/** Application management (list, environment variables, storage). */
|
|
2891
2902
|
readonly applications: ApplicationsResource;
|
|
2903
|
+
/**
|
|
2904
|
+
* Context-bound file storage operations.
|
|
2905
|
+
*
|
|
2906
|
+
* Deployed workloads receive their application context through
|
|
2907
|
+
* `GIGADRIVE_APPLICATION_ID`; management clients can set
|
|
2908
|
+
* {@link GigadriveClientConfig.applicationId}. This is the same resource as
|
|
2909
|
+
* {@link applications}.storage.
|
|
2910
|
+
*/
|
|
2911
|
+
readonly storage: ApplicationStorageResource;
|
|
2892
2912
|
/** Deployment lifecycle (create, upload, status, logs). */
|
|
2893
2913
|
readonly deployments: DeploymentsResource;
|
|
2894
2914
|
/** AI Gateway — OpenAI-compatible chat completions and model listing. */
|
|
@@ -2944,6 +2964,17 @@ declare class GigadriveError extends Error {
|
|
|
2944
2964
|
declare class AuthenticationError extends GigadriveError {
|
|
2945
2965
|
constructor(message: string);
|
|
2946
2966
|
}
|
|
2967
|
+
/**
|
|
2968
|
+
* Thrown when an SDK operation requires local configuration that could not be
|
|
2969
|
+
* resolved before making an API request.
|
|
2970
|
+
*
|
|
2971
|
+
* Storage operations use this error when neither an explicit application ID,
|
|
2972
|
+
* `GigadriveClientConfig.applicationId`, nor the workload-provided
|
|
2973
|
+
* `GIGADRIVE_APPLICATION_ID` environment variable is available.
|
|
2974
|
+
*/
|
|
2975
|
+
declare class ConfigurationError extends GigadriveError {
|
|
2976
|
+
constructor(message: string);
|
|
2977
|
+
}
|
|
2947
2978
|
/**
|
|
2948
2979
|
* Thrown when the Gigadrive API returns a non-2xx HTTP response.
|
|
2949
2980
|
*
|
|
@@ -2977,7 +3008,7 @@ declare class ApiError extends GigadriveError {
|
|
|
2977
3008
|
* @example
|
|
2978
3009
|
* ```ts
|
|
2979
3010
|
* try {
|
|
2980
|
-
* await client.
|
|
3011
|
+
* await client.storage.upload({ bucket: 'assets', key, data });
|
|
2981
3012
|
* } catch (err) {
|
|
2982
3013
|
* if (err instanceof UploadError) {
|
|
2983
3014
|
* console.error('Upload failed:', err.message, err.cause);
|
|
@@ -3037,4 +3068,4 @@ declare function paginate<T>(fetchPage: (cursor: string | undefined) => Promise<
|
|
|
3037
3068
|
*/
|
|
3038
3069
|
declare function parseSSEStream<T = unknown>(response: Response): AsyncGenerator<T>;
|
|
3039
3070
|
|
|
3040
|
-
export { AiGatewayAudioResource, type AiGatewayBudget, type AiGatewayBudgetInput, AiGatewayBudgetsResource, AiGatewayPoliciesResource, type AiGatewayPolicy, type AiGatewayPolicyInput, type AiGatewayProviderAttempt, type AiGatewayRequestEvent, type AiGatewayRequestsQuery, AiGatewayResource, type AiGatewayUsageBreakdown, type AiGatewayUsageQuery, AiGatewayUsageResource, type AiGatewayUsageSummary, AiGatewayVideosResource, type AiModel, type AiModelCapabilities, type AiModelRoutingProvider, ApiError, type ApiKey, ApiKeysResource, type Application, ApplicationEnvVarsResource, type ApplicationHostnameList, ApplicationRequestsResource, ApplicationStorageResource, ApplicationsResource, AuthenticationError, type ChatCompletionChoice, type ChatCompletionChunk, type ChatCompletionContentPart, type ChatCompletionMessage, type ChatCompletionRequest, type ChatCompletionResponse, type ChatCompletionUsage, type CreateApiKeyInput, type CreateApiKeyResult, type CreateDeploymentInput, type CreateEnvVarInput, type CreateOrganizationInput, type CreateStickySessionUrlInput, type CreateStickySessionUrlResult, type CreateStorageBucketInput, type CreateUploadSessionInput, type CreateUploadSessionResponse, type Deployment, type DeploymentLog, type DeploymentLogPage, type DeploymentLogType, type DeploymentStatus, DeploymentsResource, type EnvVar, type GatewayRequestOptions, type GatewayResult, GigadriveClient, type GigadriveClientConfig, GigadriveError, type Hostname, type HostnameAvailability, type ImageCacheInspection, type ImageCachePurgeResult, ImageOptimizationResource, type ListApiKeysQuery, type ListApplicationsQuery, type ListDeploymentLogsQuery, type ListDeploymentsQuery, type ListQuery, type ListRequestsQuery, type ListStorageObjectsQuery, type ManagedImageUrlOptions, type NetworkRequest, type NetworkRequestApplicationRef, type NetworkRequestAssetRef, type NetworkRequestBucketRef, type NetworkRequestDeploymentRef, type NetworkRequestDetails, type NetworkRequestFunctionRef, type NetworkRequestMetrics, type NetworkRequestObjectRef, type NetworkRequestSummary, type NetworkResponseDetails, type NodeReadableLike, type Organization, OrganizationAiGatewayResource, OrganizationEnvVarsResource, type OrganizationMember, OrganizationMembersResource, type OrganizationMembershipRole, type OrganizationProductAccess, type OrganizationProductEntitlement, type OrganizationProductEntitlementCheck, type OrganizationProductSubscription, OrganizationProductsResource, OrganizationsResource, type Paginated, type PresignedUrlResult, type ProductAccessMode, type ProductAccessResolutionSource, type ProductDefaultAccessPolicy, type ProductDefinition, type ProductEntitlementStatus, type ProductPlan, type ProductSubscriptionStatus, type ProviderRouting, type PullEnvVarsQuery, type PullEnvVarsResult, type QueryValue, type ResolvedEnvVar, type ResponsesRequest, type ResponsesResponse, type RunUploadOptions, type SetProductionHostnameResult, type SpeechRequest, type StartUploadResult, StickySessionsResource, type StorageBucket, StorageBucketsResource, type StorageObject, type StorageObjectAccess, type StorageObjectList, StorageObjectsResource, type StorageUploadSession, StorageUploadSessionsResource, type TranscriptionRequest, type TranscriptionResponse, type UpdateEnvVarInput, type UploadBatchItemResult, type UploadBatchOptions, type UploadByteSource, type UploadData, UploadError, type UploadFileInput, type UploadFileResult, type UploadPart, UploadSessionExpiredError, type UploadUrlStorage, type VideoGenerationRequest, type VideoGenerationResponse, type VideoModelList, type WaitForCompletionOptions, createManagedImageUrl, paginate, parseSSEStream };
|
|
3071
|
+
export { AiGatewayAudioResource, type AiGatewayBudget, type AiGatewayBudgetInput, AiGatewayBudgetsResource, AiGatewayPoliciesResource, type AiGatewayPolicy, type AiGatewayPolicyInput, type AiGatewayProviderAttempt, type AiGatewayRequestEvent, type AiGatewayRequestsQuery, AiGatewayResource, type AiGatewayUsageBreakdown, type AiGatewayUsageQuery, AiGatewayUsageResource, type AiGatewayUsageSummary, AiGatewayVideosResource, type AiModel, type AiModelCapabilities, type AiModelRoutingProvider, ApiError, type ApiKey, ApiKeysResource, type Application, ApplicationEnvVarsResource, type ApplicationHostnameList, ApplicationRequestsResource, ApplicationStorageResource, ApplicationsResource, AuthenticationError, type ChatCompletionChoice, type ChatCompletionChunk, type ChatCompletionContentPart, type ChatCompletionMessage, type ChatCompletionRequest, type ChatCompletionResponse, type ChatCompletionUsage, ConfigurationError, type CreateApiKeyInput, type CreateApiKeyResult, type CreateDeploymentInput, type CreateEnvVarInput, type CreateOrganizationInput, type CreateStickySessionUrlInput, type CreateStickySessionUrlResult, type CreateStorageBucketInput, type CreateUploadSessionInput, type CreateUploadSessionResponse, type Deployment, type DeploymentLog, type DeploymentLogPage, type DeploymentLogType, type DeploymentStatus, DeploymentsResource, type EmptyStorageTrashResult, type EnvVar, type GatewayRequestOptions, type GatewayResult, GigadriveClient, type GigadriveClientConfig, GigadriveError, type Hostname, type HostnameAvailability, type ImageCacheInspection, type ImageCachePurgeResult, ImageOptimizationResource, type ListApiKeysQuery, type ListApplicationsQuery, type ListDeploymentLogsQuery, type ListDeploymentsQuery, type ListQuery, type ListRequestsQuery, type ListStorageBucketsQuery, type ListStorageObjectsQuery, type ListStorageTrashQuery, type ListStorageUploadSessionsQuery, type ManagedImageUrlOptions, type NetworkRequest, type NetworkRequestApplicationRef, type NetworkRequestAssetRef, type NetworkRequestBucketRef, type NetworkRequestDeploymentRef, type NetworkRequestDetails, type NetworkRequestFunctionRef, type NetworkRequestMetrics, type NetworkRequestObjectRef, type NetworkRequestSummary, type NetworkResponseDetails, type NodeReadableLike, type Organization, OrganizationAiGatewayResource, OrganizationEnvVarsResource, type OrganizationMember, OrganizationMembersResource, type OrganizationMembershipRole, type OrganizationProductAccess, type OrganizationProductEntitlement, type OrganizationProductEntitlementCheck, type OrganizationProductSubscription, OrganizationProductsResource, OrganizationsResource, type Paginated, type PresignedUrlResult, type ProductAccessMode, type ProductAccessResolutionSource, type ProductDefaultAccessPolicy, type ProductDefinition, type ProductEntitlementStatus, type ProductPlan, type ProductSubscriptionStatus, type ProviderRouting, type PullEnvVarsQuery, type PullEnvVarsResult, type QueryValue, type ResolvedEnvVar, type ResponsesRequest, type ResponsesResponse, type RunUploadOptions, type SetProductionHostnameResult, type SpeechRequest, type StartUploadResult, StickySessionsResource, type StorageBucket, type StorageBucketReference, StorageBucketsResource, type StorageEnvironmentOptions, type StorageObject, type StorageObjectAccess, type StorageObjectAccessOptions, type StorageObjectList, StorageObjectsResource, type StorageTrashList, StorageTrashResource, type StorageUploadSession, StorageUploadSessionsResource, type TranscriptionRequest, type TranscriptionResponse, type TrashedStorageObject, type UpdateEnvVarInput, type UploadBatchItemResult, type UploadBatchOptions, type UploadByteSource, type UploadData, UploadError, type UploadFileInput, type UploadFileResult, type UploadPart, UploadSessionExpiredError, type UploadUrlStorage, type VideoGenerationRequest, type VideoGenerationResponse, type VideoModelList, type WaitForCompletionOptions, createManagedImageUrl, paginate, parseSSEStream };
|