Working s3 compatible file uplaods!
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// Do not edit this file manually
|
||||
|
||||
|
||||
import type { AshRpcError, ConditionalPaginatedResultMixed, InferResult, SortString, UUID, UnifiedFieldSelection, ValidationResult, tweetsFilterInput, tweetsResourceSchema, tweetsSortField } from "./ash_types";
|
||||
import type { AshRpcError, ConditionalPaginatedResultMixed, InferResult, SortString, UUID, UnifiedFieldSelection, ValidationResult, mediaFilterInput, mediaResourceSchema, mediaSortField, tweetsFilterInput, tweetsResourceSchema, tweetsSortField } from "./ash_types";
|
||||
export type * from "./ash_types";
|
||||
|
||||
// Helper Functions
|
||||
@@ -201,8 +201,110 @@ export async function executeValidationRpcRequest<T>(
|
||||
|
||||
|
||||
|
||||
export type ReadMediaFields = UnifiedFieldSelection<mediaResourceSchema>[];
|
||||
|
||||
|
||||
export type InferReadMediaResult<
|
||||
Fields extends ReadMediaFields | undefined,
|
||||
Page extends ReadMediaConfig["page"] = undefined
|
||||
> = ConditionalPaginatedResultMixed<Page, Array<InferResult<mediaResourceSchema, Fields>>, {
|
||||
results: Array<InferResult<mediaResourceSchema, Fields>>;
|
||||
hasMore: boolean;
|
||||
limit: number;
|
||||
offset: number;
|
||||
count?: number | null;
|
||||
type: "offset";
|
||||
}, {
|
||||
results: Array<InferResult<mediaResourceSchema, Fields>>;
|
||||
hasMore: boolean;
|
||||
limit: number;
|
||||
after: string | null;
|
||||
before: string | null;
|
||||
previousPage: string;
|
||||
nextPage: string;
|
||||
count?: number | null;
|
||||
type: "keyset";
|
||||
}>;
|
||||
|
||||
export type ReadMediaConfig = {
|
||||
tenant?: string;
|
||||
fields: ReadMediaFields;
|
||||
filter?: mediaFilterInput;
|
||||
sort?: SortString<mediaSortField> | SortString<mediaSortField>[];
|
||||
page?: (
|
||||
{
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
count?: boolean;
|
||||
} | {
|
||||
limit?: number;
|
||||
after?: string;
|
||||
before?: string;
|
||||
}
|
||||
);
|
||||
headers?: Record<string, string>;
|
||||
fetchOptions?: RequestInit;
|
||||
customFetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
||||
};
|
||||
|
||||
export type ReadMediaResult<Fields extends ReadMediaFields, Page extends ReadMediaConfig["page"] = undefined> = | { success: true; data: InferReadMediaResult<Fields, Page>; }
|
||||
| { success: false; errors: AshRpcError[]; }
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* Read Media records
|
||||
*
|
||||
* @ashActionType :read
|
||||
*/
|
||||
export async function readMedia<Fields extends ReadMediaFields, Config extends ReadMediaConfig = ReadMediaConfig>(
|
||||
config: Config & { fields: Fields }
|
||||
): Promise<ReadMediaResult<Fields, Config["page"]>> {
|
||||
const payload = {
|
||||
action: "read_media",
|
||||
...(config.tenant !== undefined && { tenant: config.tenant }),
|
||||
...(config.fields !== undefined && { fields: config.fields }),
|
||||
...(config.filter && { filter: config.filter }),
|
||||
...(config.sort && { sort: Array.isArray(config.sort) ? config.sort.join(",") : config.sort }),
|
||||
...(config.page && { page: config.page })
|
||||
};
|
||||
|
||||
return executeActionRpcRequest<ReadMediaResult<Fields, Config["page"]>>(
|
||||
payload,
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate: Read Media records
|
||||
*
|
||||
* @ashActionType :read
|
||||
* @validation true
|
||||
*/
|
||||
export async function validateReadMedia(
|
||||
config: {
|
||||
tenant?: string;
|
||||
headers?: Record<string, string>;
|
||||
fetchOptions?: RequestInit;
|
||||
customFetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
||||
}
|
||||
): Promise<ValidationResult> {
|
||||
const payload = {
|
||||
action: "read_media",
|
||||
...(config.tenant !== undefined && { tenant: config.tenant })
|
||||
};
|
||||
|
||||
return executeValidationRpcRequest<ValidationResult>(
|
||||
payload,
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
export type CreateTweetInput = {
|
||||
content: string;
|
||||
mediaId?: UUID;
|
||||
};
|
||||
|
||||
export type CreateTweetFields = UnifiedFieldSelection<tweetsResourceSchema>[];
|
||||
|
||||
Reference in New Issue
Block a user