ワンクリックで
method
Add a new public API method to the Refold SDK with types, JSDoc, and endpoint mapping. Use when adding new SDK functionality.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Add a new public API method to the Refold SDK with types, JSDoc, and endpoint mapping. Use when adding new SDK functionality.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | method |
| description | Add a new public API method to the Refold SDK with types, JSDoc, and endpoint mapping. Use when adding new SDK functionality. |
| metadata | {"author":"iamtraction","version":"1.0.0","argument-hint":"<method-name>"} |
Add a new public API method to the Refold class with TypeScript types, JSDoc documentation, and backend endpoint mapping.
The user provides a method name (e.g., "getWorkflows", "createConfig") and describes the backend endpoint it maps to.
Refold classRefold class with JSDocnpm run build to generate .js and .d.ts// Add before the Refold class in refold.ts
/** The payload for creating a resource. */
export interface CreateResourcePayload {
/** The resource name. */
name: string;
/** Optional description. */
description?: string;
/** Configuration object. */
config?: Record<string, unknown>;
}
/** A resource object. */
export interface Resource {
/** The resource ID. */
_id: string;
/** The resource name. */
name: string;
/** The resource description. */
description?: string;
/** When the resource was created. */
createdAt: string;
/** When the resource was last updated. */
updatedAt: string;
}
/**
* Returns the resource details for the specified resource ID.
* @param {String} id The resource ID.
* @returns {Promise<Resource>} The resource details.
*/
public async getResource(id: string): Promise<Resource> {
const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/resource/${id}`, {
headers: {
authorization: `Bearer ${this.token}`,
},
});
if (res.status >= 400 && res.status < 600) {
const error = await res.json();
throw error;
}
return await res.json();
}
/**
* Returns the list of all resources.
* @returns {Promise<Resource[]>} The list of resources.
*/
public async getResources(): Promise<Resource[]>;
/**
* Returns the resource details for the specified slug.
* @param {String} slug The resource slug.
* @returns {Promise<Resource>} The resource details.
*/
public async getResources(slug: string): Promise<Resource>;
public async getResources(slug?: string): Promise<Resource | Resource[]> {
const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/resource${slug ? `/${slug}` : ""}`, {
headers: {
authorization: `Bearer ${this.token}`,
},
});
if (res.status >= 400 && res.status < 600) {
const error = await res.json();
throw error;
}
return await res.json();
}
/**
* Creates a new resource with the specified configuration.
* @param {CreateResourcePayload} payload The resource configuration.
* @returns {Promise<Resource>} The created resource.
*/
public async createResource(payload: CreateResourcePayload): Promise<Resource> {
const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/resource`, {
method: "POST",
headers: {
authorization: `Bearer ${this.token}`,
"content-type": "application/json",
},
body: JSON.stringify(payload),
});
if (res.status >= 400 && res.status < 600) {
const error = await res.json();
throw error;
}
return await res.json();
}
/**
* Updates an existing resource.
* @param {String} id The resource ID.
* @param {Partial<CreateResourcePayload>} payload The fields to update.
* @returns {Promise<Resource>} The updated resource.
*/
public async updateResource(id: string, payload: Partial<CreateResourcePayload>): Promise<Resource> {
const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/resource/${id}`, {
method: "PUT",
headers: {
authorization: `Bearer ${this.token}`,
"content-type": "application/json",
},
body: JSON.stringify(payload),
});
if (res.status >= 400 && res.status < 600) {
const error = await res.json();
throw error;
}
return await res.json();
}
/**
* Deletes the specified resource.
* @param {String} id The resource ID.
* @returns {Promise<unknown>} The deletion result.
*/
public async deleteResource(id: string): Promise<unknown> {
const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/resource/${id}`, {
method: "DELETE",
headers: {
authorization: `Bearer ${this.token}`,
},
});
if (res.status >= 400 && res.status < 600) {
const error = await res.json();
throw error;
}
return await res.json();
}
/**
* Returns a paginated list of resources.
* @param {Object} [params] Pagination parameters.
* @param {Number} [params.page] The page number.
* @param {Number} [params.limit] The number of items per page.
* @returns {Promise<PaginatedResponse<Resource>>} The paginated list.
*/
public async listResources(params?: { page?: number; limit?: number }): Promise<PaginatedResponse<Resource>> {
const query = new URLSearchParams();
if (params?.page) query.set("page", String(params.page));
if (params?.limit) query.set("limit", String(params.limit));
const res = await fetch(`${this.baseUrl}/api/v2/f-sdk/resources?${query}`, {
headers: {
authorization: `Bearer ${this.token}`,
},
});
if (res.status >= 400 && res.status < 600) {
const error = await res.json();
throw error;
}
return await res.json();
}
if (res.status >= 400 && res.status < 600) {
const error = await res.json();
throw error;
}
headers: {
authorization: `Bearer ${this.token}`,
}
headers: {
authorization: `Bearer ${this.token}`,
"content-type": "application/json",
slug, // Custom header for app context
}
interface PaginatedResponse<T> {
docs: T[];
totalDocs: number;
limit: number;
totalPages: number;
page: number;
}
npm run build # Compile to refold.js + refold.d.ts
npm run docs:llms # Generate TypeDoc (optional)
fetch, no external HTTP librariesres.status >= 400 && res.status < 600 and throw the parsed errorBearer auth — all methods include authorization: Bearer ${this.token}refold.ts, no separate files@deprecated JSDoc tagrefold.js (CommonJS) + refold.d.ts (type declarations)Review a pull request for code quality, patterns consistency, and potential issues. Use when asked to review a PR by number or URL.
Code style and formatting conventions for this codebase. Reference this when writing or reviewing code to ensure consistency.
Verify code quality, catch bugs, and validate implementation against codebase patterns. Use for testing, linting, type-checking, and manual review.