750 lines
19 KiB
TypeScript
750 lines
19 KiB
TypeScript
// Generated by AshTypescript - RPC Actions
|
|
// Do not edit this file manually
|
|
|
|
|
|
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
|
|
|
|
/**
|
|
* Configuration options for action RPC requests
|
|
*/
|
|
export interface ActionConfig {
|
|
// Request data
|
|
input?: Record<string, any>;
|
|
identity?: any;
|
|
fields?: Array<string | Record<string, any>>; // Field selection
|
|
filter?: Record<string, any>; // Filter options (for reads)
|
|
sort?: string | string[]; // Sort options
|
|
page?:
|
|
| {
|
|
// Offset-based pagination
|
|
limit?: number;
|
|
offset?: number;
|
|
count?: boolean;
|
|
}
|
|
| {
|
|
// Keyset pagination
|
|
limit?: number;
|
|
after?: string;
|
|
before?: string;
|
|
};
|
|
|
|
// Metadata
|
|
metadataFields?: ReadonlyArray<string>;
|
|
|
|
// HTTP customization
|
|
headers?: Record<string, string>; // Custom headers
|
|
fetchOptions?: RequestInit; // Fetch options (signal, cache, etc.)
|
|
customFetch?: (
|
|
input: RequestInfo | URL,
|
|
init?: RequestInit,
|
|
) => Promise<Response>;
|
|
|
|
// Multitenancy
|
|
tenant?: string; // Tenant parameter
|
|
|
|
// Hook context
|
|
hookCtx?: Record<string, any>;
|
|
}
|
|
|
|
/**
|
|
* Configuration options for validation RPC requests
|
|
*/
|
|
export interface ValidationConfig {
|
|
// Request data
|
|
input?: Record<string, any>;
|
|
|
|
// HTTP customization
|
|
headers?: Record<string, string>;
|
|
fetchOptions?: RequestInit;
|
|
customFetch?: (
|
|
input: RequestInfo | URL,
|
|
init?: RequestInit,
|
|
) => Promise<Response>;
|
|
|
|
// Hook context
|
|
hookCtx?: Record<string, any>;
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
* Gets the CSRF token from the page's meta tag
|
|
* Returns null if no CSRF token is found
|
|
*/
|
|
export function getPhoenixCSRFToken(): string | null {
|
|
return document
|
|
?.querySelector("meta[name='csrf-token']")
|
|
?.getAttribute("content") || null;
|
|
}
|
|
|
|
/**
|
|
* Builds headers object with CSRF token for Phoenix applications
|
|
* Returns headers object with X-CSRF-Token (if available)
|
|
*/
|
|
export function buildCSRFHeaders(headers: Record<string, string> = {}): Record<string, string> {
|
|
const csrfToken = getPhoenixCSRFToken();
|
|
if (csrfToken) {
|
|
headers["X-CSRF-Token"] = csrfToken;
|
|
}
|
|
|
|
return headers;
|
|
}
|
|
|
|
/**
|
|
* Internal helper function for making action RPC requests
|
|
* Handles hooks, request configuration, fetch execution, and error handling
|
|
* @param config Configuration matching ActionConfig
|
|
*/
|
|
export async function executeActionRpcRequest<T>(
|
|
payload: Record<string, any>,
|
|
config: ActionConfig
|
|
): Promise<T> {
|
|
const processedConfig = config;
|
|
|
|
const headers: Record<string, string> = {
|
|
"Content-Type": "application/json",
|
|
...processedConfig.headers,
|
|
...config.headers,
|
|
};
|
|
|
|
const fetchFunction = config.customFetch || processedConfig.customFetch || fetch;
|
|
const fetchOptions: RequestInit = {
|
|
...processedConfig.fetchOptions,
|
|
...config.fetchOptions,
|
|
method: "POST",
|
|
headers,
|
|
body: JSON.stringify(payload),
|
|
};
|
|
|
|
const response = await fetchFunction("/rpc/run", fetchOptions);
|
|
const result = response.ok ? await response.json() : null;
|
|
|
|
|
|
if (!response.ok) {
|
|
return {
|
|
success: false,
|
|
errors: [
|
|
{
|
|
type: "network_error",
|
|
message: `Network request failed: ${response.statusText}`,
|
|
shortMessage: "Network error",
|
|
vars: { statusCode: response.status, statusText: response.statusText },
|
|
fields: [],
|
|
path: [],
|
|
details: { statusCode: response.status }
|
|
}
|
|
],
|
|
} as T;
|
|
}
|
|
|
|
return result as T;
|
|
}
|
|
|
|
|
|
/**
|
|
* Internal helper function for making validation RPC requests
|
|
* Handles hooks, request configuration, fetch execution, and error handling
|
|
* @param config Configuration matching ValidationConfig
|
|
*/
|
|
export async function executeValidationRpcRequest<T>(
|
|
payload: Record<string, any>,
|
|
config: ValidationConfig
|
|
): Promise<T> {
|
|
const processedConfig = config;
|
|
|
|
const headers: Record<string, string> = {
|
|
"Content-Type": "application/json",
|
|
...processedConfig.headers,
|
|
...config.headers,
|
|
};
|
|
|
|
const fetchFunction = config.customFetch || processedConfig.customFetch || fetch;
|
|
const fetchOptions: RequestInit = {
|
|
...processedConfig.fetchOptions,
|
|
...config.fetchOptions,
|
|
method: "POST",
|
|
headers,
|
|
body: JSON.stringify(payload),
|
|
};
|
|
|
|
const response = await fetchFunction("/rpc/validate", fetchOptions);
|
|
const result = response.ok ? await response.json() : null;
|
|
|
|
|
|
if (!response.ok) {
|
|
return {
|
|
success: false,
|
|
errors: [
|
|
{
|
|
type: "network_error",
|
|
message: `Network request failed: ${response.statusText}`,
|
|
shortMessage: "Network error",
|
|
vars: { statusCode: response.status, statusText: response.statusText },
|
|
fields: [],
|
|
path: [],
|
|
details: { statusCode: response.status }
|
|
}
|
|
],
|
|
} as T;
|
|
}
|
|
|
|
return result as 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>[];
|
|
|
|
export type InferCreateTweetResult<
|
|
Fields extends CreateTweetFields | undefined,
|
|
> = InferResult<tweetsResourceSchema, Fields>;
|
|
|
|
export type CreateTweetResult<Fields extends CreateTweetFields | undefined = undefined> = | { success: true; data: InferCreateTweetResult<Fields>; }
|
|
| { success: false; errors: AshRpcError[]; }
|
|
|
|
;
|
|
|
|
/**
|
|
* Create a new Tweet
|
|
*
|
|
* @ashActionType :create
|
|
*/
|
|
export async function createTweet<Fields extends CreateTweetFields | undefined = undefined>(
|
|
config: {
|
|
tenant?: string;
|
|
input: CreateTweetInput;
|
|
fields?: Fields;
|
|
headers?: Record<string, string>;
|
|
fetchOptions?: RequestInit;
|
|
customFetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
}
|
|
): Promise<CreateTweetResult<Fields extends undefined ? [] : Fields>> {
|
|
const payload = {
|
|
action: "create_tweet",
|
|
...(config.tenant !== undefined && { tenant: config.tenant }),
|
|
input: config.input,
|
|
...(config.fields !== undefined && { fields: config.fields })
|
|
};
|
|
|
|
return executeActionRpcRequest<CreateTweetResult<Fields extends undefined ? [] : Fields>>(
|
|
payload,
|
|
config
|
|
);
|
|
}
|
|
|
|
|
|
/**
|
|
* Validate: Create a new Tweet
|
|
*
|
|
* @ashActionType :create
|
|
* @validation true
|
|
*/
|
|
export async function validateCreateTweet(
|
|
config: {
|
|
tenant?: string;
|
|
input: CreateTweetInput;
|
|
headers?: Record<string, string>;
|
|
fetchOptions?: RequestInit;
|
|
customFetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
}
|
|
): Promise<ValidationResult> {
|
|
const payload = {
|
|
action: "create_tweet",
|
|
...(config.tenant !== undefined && { tenant: config.tenant }),
|
|
input: config.input
|
|
};
|
|
|
|
return executeValidationRpcRequest<ValidationResult>(
|
|
payload,
|
|
config
|
|
);
|
|
}
|
|
|
|
|
|
export type DestroyTweetResult = | { success: true; data: {}; }
|
|
| { success: false; errors: AshRpcError[]; }
|
|
|
|
;
|
|
|
|
/**
|
|
* Delete a Tweet
|
|
*
|
|
* @ashActionType :destroy
|
|
*/
|
|
export async function destroyTweet(
|
|
config: {
|
|
tenant?: string;
|
|
identity: UUID;
|
|
headers?: Record<string, string>;
|
|
fetchOptions?: RequestInit;
|
|
customFetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
}
|
|
): Promise<DestroyTweetResult> {
|
|
const payload = {
|
|
action: "destroy_tweet",
|
|
...(config.tenant !== undefined && { tenant: config.tenant }),
|
|
identity: config.identity
|
|
};
|
|
|
|
return executeActionRpcRequest<DestroyTweetResult>(
|
|
payload,
|
|
config
|
|
);
|
|
}
|
|
|
|
|
|
/**
|
|
* Validate: Delete a Tweet
|
|
*
|
|
* @ashActionType :destroy
|
|
* @validation true
|
|
*/
|
|
export async function validateDestroyTweet(
|
|
config: {
|
|
tenant?: string;
|
|
identity: UUID | string;
|
|
headers?: Record<string, string>;
|
|
fetchOptions?: RequestInit;
|
|
customFetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
}
|
|
): Promise<ValidationResult> {
|
|
const payload = {
|
|
action: "destroy_tweet",
|
|
...(config.tenant !== undefined && { tenant: config.tenant }),
|
|
identity: config.identity
|
|
};
|
|
|
|
return executeValidationRpcRequest<ValidationResult>(
|
|
payload,
|
|
config
|
|
);
|
|
}
|
|
|
|
|
|
export type LikeTweetFields = UnifiedFieldSelection<tweetsResourceSchema>[];
|
|
|
|
export type InferLikeTweetResult<
|
|
Fields extends LikeTweetFields | undefined,
|
|
> = InferResult<tweetsResourceSchema, Fields>;
|
|
|
|
export type LikeTweetResult<Fields extends LikeTweetFields | undefined = undefined> = | { success: true; data: InferLikeTweetResult<Fields>; }
|
|
| { success: false; errors: AshRpcError[]; }
|
|
|
|
;
|
|
|
|
/**
|
|
* Update an existing Tweet
|
|
*
|
|
* @ashActionType :update
|
|
*/
|
|
export async function likeTweet<Fields extends LikeTweetFields | undefined = undefined>(
|
|
config: {
|
|
tenant?: string;
|
|
identity: UUID;
|
|
fields?: Fields;
|
|
headers?: Record<string, string>;
|
|
fetchOptions?: RequestInit;
|
|
customFetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
}
|
|
): Promise<LikeTweetResult<Fields extends undefined ? [] : Fields>> {
|
|
const payload = {
|
|
action: "like_tweet",
|
|
...(config.tenant !== undefined && { tenant: config.tenant }),
|
|
identity: config.identity,
|
|
...(config.fields !== undefined && { fields: config.fields })
|
|
};
|
|
|
|
return executeActionRpcRequest<LikeTweetResult<Fields extends undefined ? [] : Fields>>(
|
|
payload,
|
|
config
|
|
);
|
|
}
|
|
|
|
|
|
/**
|
|
* Validate: Update an existing Tweet
|
|
*
|
|
* @ashActionType :update
|
|
* @validation true
|
|
*/
|
|
export async function validateLikeTweet(
|
|
config: {
|
|
tenant?: string;
|
|
identity: UUID | string;
|
|
headers?: Record<string, string>;
|
|
fetchOptions?: RequestInit;
|
|
customFetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
}
|
|
): Promise<ValidationResult> {
|
|
const payload = {
|
|
action: "like_tweet",
|
|
...(config.tenant !== undefined && { tenant: config.tenant }),
|
|
identity: config.identity
|
|
};
|
|
|
|
return executeValidationRpcRequest<ValidationResult>(
|
|
payload,
|
|
config
|
|
);
|
|
}
|
|
|
|
|
|
export type ReadTweetFields = UnifiedFieldSelection<tweetsResourceSchema>[];
|
|
|
|
|
|
export type InferReadTweetResult<
|
|
Fields extends ReadTweetFields | undefined,
|
|
Page extends ReadTweetConfig["page"] = undefined
|
|
> = ConditionalPaginatedResultMixed<Page, Array<InferResult<tweetsResourceSchema, Fields>>, {
|
|
results: Array<InferResult<tweetsResourceSchema, Fields>>;
|
|
hasMore: boolean;
|
|
limit: number;
|
|
offset: number;
|
|
count?: number | null;
|
|
type: "offset";
|
|
}, {
|
|
results: Array<InferResult<tweetsResourceSchema, Fields>>;
|
|
hasMore: boolean;
|
|
limit: number;
|
|
after: string | null;
|
|
before: string | null;
|
|
previousPage: string;
|
|
nextPage: string;
|
|
count?: number | null;
|
|
type: "keyset";
|
|
}>;
|
|
|
|
export type ReadTweetConfig = {
|
|
tenant?: string;
|
|
fields: ReadTweetFields;
|
|
filter?: tweetsFilterInput;
|
|
sort?: SortString<tweetsSortField> | SortString<tweetsSortField>[];
|
|
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 ReadTweetResult<Fields extends ReadTweetFields, Page extends ReadTweetConfig["page"] = undefined> = | { success: true; data: InferReadTweetResult<Fields, Page>; }
|
|
| { success: false; errors: AshRpcError[]; }
|
|
|
|
;
|
|
|
|
/**
|
|
* Read Tweet records
|
|
*
|
|
* @ashActionType :read
|
|
*/
|
|
export async function readTweet<Fields extends ReadTweetFields, Config extends ReadTweetConfig = ReadTweetConfig>(
|
|
config: Config & { fields: Fields }
|
|
): Promise<ReadTweetResult<Fields, Config["page"]>> {
|
|
const payload = {
|
|
action: "read_tweet",
|
|
...(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<ReadTweetResult<Fields, Config["page"]>>(
|
|
payload,
|
|
config
|
|
);
|
|
}
|
|
|
|
|
|
/**
|
|
* Validate: Read Tweet records
|
|
*
|
|
* @ashActionType :read
|
|
* @validation true
|
|
*/
|
|
export async function validateReadTweet(
|
|
config: {
|
|
tenant?: string;
|
|
headers?: Record<string, string>;
|
|
fetchOptions?: RequestInit;
|
|
customFetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
}
|
|
): Promise<ValidationResult> {
|
|
const payload = {
|
|
action: "read_tweet",
|
|
...(config.tenant !== undefined && { tenant: config.tenant })
|
|
};
|
|
|
|
return executeValidationRpcRequest<ValidationResult>(
|
|
payload,
|
|
config
|
|
);
|
|
}
|
|
|
|
|
|
export type UnlikeTweetFields = UnifiedFieldSelection<tweetsResourceSchema>[];
|
|
|
|
export type InferUnlikeTweetResult<
|
|
Fields extends UnlikeTweetFields | undefined,
|
|
> = InferResult<tweetsResourceSchema, Fields>;
|
|
|
|
export type UnlikeTweetResult<Fields extends UnlikeTweetFields | undefined = undefined> = | { success: true; data: InferUnlikeTweetResult<Fields>; }
|
|
| { success: false; errors: AshRpcError[]; }
|
|
|
|
;
|
|
|
|
/**
|
|
* Update an existing Tweet
|
|
*
|
|
* @ashActionType :update
|
|
*/
|
|
export async function unlikeTweet<Fields extends UnlikeTweetFields | undefined = undefined>(
|
|
config: {
|
|
tenant?: string;
|
|
identity: UUID;
|
|
fields?: Fields;
|
|
headers?: Record<string, string>;
|
|
fetchOptions?: RequestInit;
|
|
customFetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
}
|
|
): Promise<UnlikeTweetResult<Fields extends undefined ? [] : Fields>> {
|
|
const payload = {
|
|
action: "unlike_tweet",
|
|
...(config.tenant !== undefined && { tenant: config.tenant }),
|
|
identity: config.identity,
|
|
...(config.fields !== undefined && { fields: config.fields })
|
|
};
|
|
|
|
return executeActionRpcRequest<UnlikeTweetResult<Fields extends undefined ? [] : Fields>>(
|
|
payload,
|
|
config
|
|
);
|
|
}
|
|
|
|
|
|
/**
|
|
* Validate: Update an existing Tweet
|
|
*
|
|
* @ashActionType :update
|
|
* @validation true
|
|
*/
|
|
export async function validateUnlikeTweet(
|
|
config: {
|
|
tenant?: string;
|
|
identity: UUID | string;
|
|
headers?: Record<string, string>;
|
|
fetchOptions?: RequestInit;
|
|
customFetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
}
|
|
): Promise<ValidationResult> {
|
|
const payload = {
|
|
action: "unlike_tweet",
|
|
...(config.tenant !== undefined && { tenant: config.tenant }),
|
|
identity: config.identity
|
|
};
|
|
|
|
return executeValidationRpcRequest<ValidationResult>(
|
|
payload,
|
|
config
|
|
);
|
|
}
|
|
|
|
|
|
export type UpdateTweetInput = {
|
|
content?: string;
|
|
};
|
|
|
|
export type UpdateTweetFields = UnifiedFieldSelection<tweetsResourceSchema>[];
|
|
|
|
export type InferUpdateTweetResult<
|
|
Fields extends UpdateTweetFields | undefined,
|
|
> = InferResult<tweetsResourceSchema, Fields>;
|
|
|
|
export type UpdateTweetResult<Fields extends UpdateTweetFields | undefined = undefined> = | { success: true; data: InferUpdateTweetResult<Fields>; }
|
|
| { success: false; errors: AshRpcError[]; }
|
|
|
|
;
|
|
|
|
/**
|
|
* Update an existing Tweet
|
|
*
|
|
* @ashActionType :update
|
|
*/
|
|
export async function updateTweet<Fields extends UpdateTweetFields | undefined = undefined>(
|
|
config: {
|
|
tenant?: string;
|
|
identity: UUID;
|
|
input: UpdateTweetInput;
|
|
fields?: Fields;
|
|
headers?: Record<string, string>;
|
|
fetchOptions?: RequestInit;
|
|
customFetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
}
|
|
): Promise<UpdateTweetResult<Fields extends undefined ? [] : Fields>> {
|
|
const payload = {
|
|
action: "update_tweet",
|
|
...(config.tenant !== undefined && { tenant: config.tenant }),
|
|
identity: config.identity,
|
|
input: config.input,
|
|
...(config.fields !== undefined && { fields: config.fields })
|
|
};
|
|
|
|
return executeActionRpcRequest<UpdateTweetResult<Fields extends undefined ? [] : Fields>>(
|
|
payload,
|
|
config
|
|
);
|
|
}
|
|
|
|
|
|
/**
|
|
* Validate: Update an existing Tweet
|
|
*
|
|
* @ashActionType :update
|
|
* @validation true
|
|
*/
|
|
export async function validateUpdateTweet(
|
|
config: {
|
|
tenant?: string;
|
|
identity: UUID | string;
|
|
input: UpdateTweetInput;
|
|
headers?: Record<string, string>;
|
|
fetchOptions?: RequestInit;
|
|
customFetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
}
|
|
): Promise<ValidationResult> {
|
|
const payload = {
|
|
action: "update_tweet",
|
|
...(config.tenant !== undefined && { tenant: config.tenant }),
|
|
identity: config.identity,
|
|
input: config.input
|
|
};
|
|
|
|
return executeValidationRpcRequest<ValidationResult>(
|
|
payload,
|
|
config
|
|
);
|
|
}
|
|
|