mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
updated rowy utils defs
This commit is contained in:
117
src/components/CodeEditor/rowy.d.ts
vendored
117
src/components/CodeEditor/rowy.d.ts
vendored
@@ -1,32 +1,95 @@
|
||||
/**
|
||||
* utility functions
|
||||
*/
|
||||
declare namespace rowy {
|
||||
type RowyFile = {
|
||||
downloadURL: string;
|
||||
name: string;
|
||||
type: string;
|
||||
lastModifiedTS: number;
|
||||
};
|
||||
type RowyUser = {
|
||||
email: any;
|
||||
emailVerified: boolean;
|
||||
displayName: string;
|
||||
photoURL: string;
|
||||
uid: string;
|
||||
timestamp: number;
|
||||
};
|
||||
type uploadOptions = {
|
||||
bucket?: string;
|
||||
folderPath?: string;
|
||||
fileName?: string;
|
||||
};
|
||||
interface Rowy {
|
||||
metadata: {
|
||||
/**
|
||||
* The project ID of the project running this function.
|
||||
*/
|
||||
projectId: () => Promise<string>;
|
||||
/**
|
||||
* The numeric project ID of the project running this function.
|
||||
*/
|
||||
projectNumber: () => Promise<string>;
|
||||
/**
|
||||
* The email address of service account running this function.
|
||||
* This is the service account that is used to call other APIs.
|
||||
* Ensure that the service account has the correct permissions.
|
||||
*/
|
||||
serviceAccountEmail: () => Promise<string>;
|
||||
/**
|
||||
* a user object of the service account running this function.
|
||||
* Compatible with Rowy audit fields
|
||||
* Can be used to add createdBy or updatedBy fields to a document.
|
||||
*/
|
||||
serviceAccountUser: () => Promise<RowyUser>;
|
||||
};
|
||||
/**
|
||||
* uploads a file to the cloud storage from a url
|
||||
* Gives access to the Secret Manager.
|
||||
* manage your secrets in the Google Cloud Console.
|
||||
*/
|
||||
function url2storage(
|
||||
url: string,
|
||||
storagePath: string,
|
||||
fileName?: string
|
||||
): Promise<{
|
||||
downloadURL: string;
|
||||
name: string;
|
||||
type: string;
|
||||
lastModifiedTS: Date;
|
||||
}>;
|
||||
|
||||
secrets: {
|
||||
/**
|
||||
* Get an existing secret from the secret manager.
|
||||
*/
|
||||
get: (name: string, version?: string) => Promise<string | undefined>;
|
||||
};
|
||||
/**
|
||||
* Gets the secret defined in Google Cloud Secret
|
||||
* Gives access to the Cloud Storage.
|
||||
*/
|
||||
async function getSecret(name: string, v?: string): Promise<string | null>;
|
||||
|
||||
async function getServiceAccountUser(): Promise<{
|
||||
email: string;
|
||||
emailVerified: boolean;
|
||||
displayName: string;
|
||||
photoURL: string;
|
||||
uid: string;
|
||||
timestamp: number;
|
||||
}>;
|
||||
storage: {
|
||||
upload: {
|
||||
/**
|
||||
* uploads a file to storage bucket from an external url.
|
||||
*/
|
||||
url: (
|
||||
url: string,
|
||||
options: uploadOptions
|
||||
) => Promise<RowyFile | undefined>;
|
||||
/**
|
||||
* uploads a file to storage bucket from a buffer or string
|
||||
*/
|
||||
data: (
|
||||
data: Buffer | string,
|
||||
options: uploadOptions
|
||||
) => Promise<RowyFile | undefined>;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* @deprecated will be removed in version 2.0.
|
||||
* use rowy.secrets.get instead.
|
||||
* Get an existing secret from the secret manager.
|
||||
*/
|
||||
getSecret: (name: string, version?: string) => Promise<string | undefined>;
|
||||
/**
|
||||
* @deprecated will be removed in version 2.0.
|
||||
* use rowy.metadata.serviceAccountUser instead.
|
||||
* Compatible with Rowy audit fields
|
||||
* Can be used to add createdBy or updatedBy fields to a document.
|
||||
*/
|
||||
getServiceAccountUser: () => Promise<RowyUser>;
|
||||
/**
|
||||
* @deprecated will be removed in version 2.0.
|
||||
* use rowy.storage.upload.url instead.
|
||||
* uploads a file to storage bucket from an external url.
|
||||
*/
|
||||
url2storage: (url: string) => Promise<RowyFile | undefined>;
|
||||
}
|
||||
|
||||
declare const rowy: Rowy;
|
||||
|
||||
Reference in New Issue
Block a user