Package Exports
- onecrew-api-client
- onecrew-api-client/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (onecrew-api-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
OneCrew API Client
A TypeScript/JavaScript client library for the OneCrew Backend API, designed for Expo and React Native applications.
Installation
npm install onecrew-api-clientQuick Start
import { OneCrewApi } from 'onecrew-api-client';
// Initialize the API client
const api = new OneCrewApi('https://your-api-url.com');
// Initialize authentication
await api.initialize();
// Example: Login and manage user details
await api.auth.login({
email: 'user@example.com',
password: 'password'
});
// Create user details
const userDetails = await api.createUserDetails({
gender: 'female',
age: 25,
nationality: 'American',
height_cm: 165,
weight_kg: 58,
skin_tone: 'medium',
hair_color: 'brown',
willing_to_travel: true
});
// Get user details
const details = await api.getUserDetails();
console.log('User details:', details.data);
// Example: Managing talent profile with dropdowns
const [hairColors, skinTones, profile] = await Promise.all([
api.getAvailableHairColors(),
api.getAvailableSkinTones(),
api.getTalentProfile()
]);
// Create dropdown options with current selection
const hairColorOptions = hairColors.data.map(option => ({
id: option.id,
name: option.name,
selected: option.id === profile.data.hair_color_id
}));
const skinToneOptions = skinTones.data.map(option => ({
id: option.id,
name: option.name,
selected: option.id === profile.data.skin_tone_id
}));
// Update talent profile
await api.updateTalentProfile({
hair_color_id: 'selected-hair-color-id',
skin_tone_id: 'selected-skin-tone-id',
eye_color: 'brown',
height_cm: 175,
weight_kg: 70
});Features
- 🔐 Authentication: JWT token management with secure storage
- 👥 User Management: Get, update, and manage user profiles
- 📋 User Details: Complete user profile details management
- 🎭 Talent Profile: Comprehensive talent profile management
- 🛠️ Skills Management: Add, remove, and manage user skills
- 🎯 Abilities: Manage abilities with proficiency levels
- 🌍 Languages: Multi-language support with proficiency levels
- 🖼️ Portfolio: Media portfolio management (images/videos)
- 🎬 Project Management: Create, join, and manage film projects
- 👥 Team Management: Create and manage teams
- 💬 Communication: Real-time messaging and conversations
- 🔍 Search: Advanced search across users, projects, and teams
- 📁 File Upload: Upload files and media
- 📱 React Native Ready: Optimized for Expo and React Native
API Methods
User Management
getUsers(params?)- Get all users with filtersgetUserById(userId)- Get user by IDgetUserByIdDirect(userId)- Direct user endpointupdateUserProfile(updates)- Update current user profiledeleteUser()- Delete current user
User Details Management
getUserDetails(userId?)- Get user details (current user or by ID)createUserDetails(details)- Create user detailsupdateUserDetails(updates)- Update current user's detailsupdateUserDetailsById(userId, updates)- Update specific user's detailspatchUserDetails(updates)- Partial update of current user's detailsdeleteUserDetails(userId?)- Delete user details
Talent Profile Management
getTalentProfile()- Get current user's talent profileupdateTalentProfile(updates)- Update talent profilepatchTalentProfile(updates)- Partial update of talent profilegetAvailableHairColors()- Get all available hair colors for dropdownsgetAvailableSkinTones()- Get all available skin tones for dropdowns
Skills Management
getAvailableSkills()- Get all available skillsgetUserSkills()- Get user's current skillsaddUserSkill(skillId)- Add skill to user profileremoveUserSkill(skillId)- Remove skill from user profile
Abilities Management
getAvailableAbilities()- Get all available abilitiesgetUserAbilities()- Get user's current abilitiesaddUserAbility(abilityId, proficiency)- Add ability with proficiency (1-5)updateUserAbility(abilityId, proficiency)- Update ability proficiencyremoveUserAbility(abilityId)- Remove ability from user profile
Languages Management
getAvailableLanguages()- Get all available languagesgetUserLanguages()- Get user's current languagesaddUserLanguage(languageId, level)- Add language with proficiency levelremoveUserLanguage(languageId)- Remove language from user profile
Portfolio Management
getUserPortfolio()- Get user's portfolio itemsaddPortfolioItem(item)- Add image/video to portfolioupdatePortfolioItem(itemId, updates)- Update portfolio itemremovePortfolioItem(itemId)- Remove portfolio item
Project Management
getProjects(params?)- Get all projectsgetProjectById(projectId)- Get project by IDcreateProject(projectData)- Create new projectupdateProject(projectId, updates)- Update projectjoinProject(projectId, role?)- Join a projectleaveProject(projectId)- Leave a project
Team Management
getTeams(params?)- Get all teamsgetTeamById(teamId)- Get team by IDcreateTeam(teamData)- Create new teamjoinTeam(teamData)- Join a teamleaveTeam(teamId)- Leave a team
Communication
getConversations(params?)- Get user conversationscreateConversation(participantIds, name?)- Create conversationgetMessages(conversationId, params?)- Get conversation messagessendMessage(conversationId, messageData)- Send message
Search
searchUsers(params)- Search userssearchProjects(params)- Search projectssearchTeams(params)- Search teamsglobalSearch(query, params?)- Global searchgetSearchSuggestions(query)- Get search suggestions
File Upload
uploadFile(file)- Upload file
Examples
Talent Profile Management
// Get talent profile
const talentProfile = await api.getTalentProfile();
console.log('Talent profile:', talentProfile.data);
// Update talent profile
const updatedProfile = await api.updateTalentProfile({
height_cm: 175,
weight_kg: 70,
eye_color: 'brown',
travel_ready: true,
union_member: false
});Skills Management
// Get available skills
const availableSkills = await api.getAvailableSkills();
console.log('Available skills:', availableSkills.data);
// Get user's current skills
const userSkills = await api.getUserSkills();
console.log('User skills:', userSkills.data);
// Add a skill to user profile
const skillToAdd = availableSkills.data[0];
const addedSkill = await api.addUserSkill(skillToAdd.id);
console.log('Added skill:', addedSkill.data);
// Remove a skill from user profile
await api.removeUserSkill(skillToAdd.id);Abilities Management
// Get available abilities
const availableAbilities = await api.getAvailableAbilities();
console.log('Available abilities:', availableAbilities.data);
// Add ability with proficiency level (1-5)
const abilityToAdd = availableAbilities.data[0];
const addedAbility = await api.addUserAbility(abilityToAdd.id, 4);
console.log('Added ability:', addedAbility.data);
// Update ability proficiency
await api.updateUserAbility(abilityToAdd.id, 5);Languages Management
// Get available languages
const availableLanguages = await api.getAvailableLanguages();
console.log('Available languages:', availableLanguages.data);
// Add language with proficiency level
const languageToAdd = availableLanguages.data[0];
const addedLanguage = await api.addUserLanguage(languageToAdd.id, 'native');
console.log('Added language:', addedLanguage.data);Portfolio Management
// Get user's portfolio
const portfolio = await api.getUserPortfolio();
console.log('Portfolio items:', portfolio.data);
// Add portfolio item
const newItem = await api.addPortfolioItem({
kind: 'image',
url: 'https://example.com/image.jpg',
caption: 'My headshot',
sort_order: 1
});
console.log('Added portfolio item:', newItem.data);
// Update portfolio item
await api.updatePortfolioItem(newItem.data.id, {
caption: 'Updated headshot caption',
sort_order: 2
});Configuration
const api = new OneCrewApi(
'https://your-api-url.com', // Base URL
30000, // Timeout in milliseconds (optional)
3 // Number of retries (optional)
);Authentication
The client automatically handles JWT token storage and refresh:
// Login
const authResponse = await api.auth.login({
email: 'user@example.com',
password: 'password'
});
// Check if user is authenticated
const isAuthenticated = await api.auth.isAuthenticated();
// Logout
await api.auth.logout();Error Handling
All methods return a consistent response format:
interface ApiResponse<T> {
success: boolean;
data?: T;
error?: string;
message?: string;
}
// Example usage
const response = await api.getUserById('user-id');
if (response.success) {
console.log('User data:', response.data);
} else {
console.error('Error:', response.error);
}TypeScript Support
Full TypeScript support with comprehensive type definitions for all API responses and request parameters.
License
MIT
Support
For support and questions, please contact the OneCrew team.