Current collected state Current
Observed since 20 Oct, 20:35 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
5htp-airtable
Integrate Airtable to any 5HTP App
5HTP Service to integrate Airtable API and synchronise it with MySQL tables
npm install --save 5htp-airtable
To be done
/*----------------------------------
- DEPENDANCES
----------------------------------*/
// App
import { Airtable, Hub } from '@app';
import DataProvider, { TAirtableMapper } from '5htp-airtable/provider';
/*----------------------------------
- TYPES
----------------------------------*/
type UserFromAirtable = {
// Identity
'First Name': string,
'Last Name': string,
'Country': string[],
'Languages': string[],
'Password'?: string,
// Contact Info
'Email': string,
'Phone Number': string,
'LinkedIn URL': string,
// Synced Table
'Created': Date,
'Updated': Date
}
type UserRelations = {
languages: string[],
}
/*----------------------------------
- PROVIDER
----------------------------------*/
export default class UserProvider extends DataProvider<UserFromAirtable, User, UserRelations> {
public constructor( public users: UserService, public app = users.app ) {
super(app, 'users');
// Register to Airtable service + load airtable & db table metadatas
Airtable.registerProvider(this);
}
// Input
public airtable = Airtable.table('myAirtableBase', 'myAirtableTable');
// All the required fields in User database table should be mapped here
// So we ensure that after the mapping, we upsert the minimum required values
public mapper: TAirtableMapper<UserFromAirtable, User, UserRelations> = {
// Identoty
'firstName': {
airtable: 'First Name',
},
'lastName': {
airtable: 'Last Name',
},
'country': {
airtable: 'Country',
toOne: () => Hub.geolocations
},
'languages': {
airtable: 'Languages',
toMany: () => ({
table: 'UserLanguage',
pk: {
key: 'headhunter',
},
fk: {
key: 'language',
provider: Hub.languages,
}
})
},
'password': {
airtable: 'Password',
},
}
// Database table name
public tableName = 'User';
}
import UserProvider from './provider';
export default class UsersService extends Service {
// 1. Instanciate Provider
public provider = new UserProvider(this);
public async start() {
// 2. Ensure the database is sync with Airtable
await this.provider.sync();
}
public async signup( newUser: User, request: Request ) {
// 3. Insert new data on both Airtable and Database
const inserted = await this.provider.create({
...newUser,
password: sha1(newUser.password),
});
}
public async resetPassword(
type: string,
token: string,
rawPassword: string,
) {
// 4. Update data on both Airtable and Database
await this.provider.update([{
airtableId: user.airtableId,
email: email,
password: sha1(rawPassword)
}]);
}
}
To be done
[] Fix typings [] Import typings from 5htp-core (peerdeps) [] Tests [] Usage doc
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
dayjsEnvironment{
"local_name": "dayjs",
"alias": false,
"peer_metadata": null
} | ^1.11.9 | runtime |
ngrokEnvironment{
"local_name": "ngrok",
"alias": false,
"peer_metadata": null
} | ^5.0.0-beta.2 | runtime |
short-unique-idEnvironment{
"local_name": "short-unique-id",
"alias": false,
"peer_metadata": null
} | ^4.4.4 | runtime |
5htp-coreEnvironment{
"local_name": "5htp-core",
"alias": false,
"peer_metadata": null
} | ^0.3.7 | development |
Source distribution
{
"shasum": "e1bc95cabcda320e9a4266d2de1203999cb2d4b0",
"tarball": "https://registry.npmjs.org/5htp-airtable/-/5htp-airtable-0.1.0.tgz",
"fileCount": 13,
"integrity": "sha512-6kWhPiYXjz3vRr1Wwf64hz0oGhHJPMiKvpaFwT2gO/pKPJLX2vVOzGlJ3FIrf4ix87N/L93ejR+63jiNXg8PIQ==",
"signatures": [
{
"sig": "MEUCIQCh+Xmaz84fTlApejNpPlqg/BTgoL2Zb6eT2aYfUvJRTQIgaX12KI4VwtdUzGtwzjVQoOh95CAQ4zSaVimNvHWBahk=",
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"
}
],
"unpackedSize": 113262
}Observed since 20 Oct, 20:35 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:850f46a0bd67f0b5063c4258117656ca3fcfcda8fe125963879e768b903af365