5htp-airtable
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -12,3 +12,3 @@ { | ||
], | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"license": "MIT", | ||
@@ -27,3 +27,3 @@ "private": false, | ||
"devDependencies": { | ||
"5htp-core": "^0.3.4-3" | ||
"5htp-core": "^0.3.6-9" | ||
}, | ||
@@ -30,0 +30,0 @@ "dependencies": { |
@@ -17,6 +17,11 @@ # Airtable Sync for 5HTP | ||
## Changelog | ||
### 0.0.9 (22/12/2023) | ||
* Possibility to create RemoteProviders | ||
## To be done | ||
[] Import typings from 5htp-core (peerdeps) | ||
[] Make reference o | ||
[] Usage doc |
@@ -15,11 +15,12 @@ /*---------------------------------- | ||
// Specific | ||
export { default as Provider } from './provider'; | ||
import AirtableTable, { TMethod, TQueryDataObj } from './table'; | ||
import type { | ||
default as DataProvider, | ||
TSyncStats | ||
} from './provider'; | ||
import type { default as DataProvider, TSyncStats, TProviderAction } from './provider'; | ||
import WebhooksConnector from './webhooks'; | ||
import { TFieldType, TTypeHelper } from './typeHelpers'; | ||
// Export | ||
export { default as Provider } from './provider'; | ||
export { default as ProviderInterface } from './provider/interface'; | ||
export { default as RemoteProvider } from './provider/remote'; | ||
/*---------------------------------- | ||
@@ -166,2 +167,3 @@ - CONST | ||
public Router = this.use('Core/Router'); | ||
public Fetch = this.use('Core/Fetch'); // Send request to remote providers | ||
@@ -171,5 +173,7 @@ // Services | ||
// Initialized on start | ||
// Indexes | ||
public providers: {[providerId: string]: DataProvider} = {} | ||
public tableIdToProvider: {[tableId: string]: DataProvider} = {} | ||
private fieldsIdToWatch: string[] = [] | ||
public latestSyncTimes: TLatestSyncTimes = {} | ||
private tableMetasByName: TTablesMetadata = {} | ||
@@ -301,6 +305,2 @@ /*---------------------------------- | ||
public providers: {[providerId: string]: DataProvider} = {} | ||
public tableIdToProvider: {[tableId: string]: DataProvider} = {} | ||
private fieldsIdToWatch: string[] = [] | ||
/** | ||
@@ -380,2 +380,30 @@ * Register a Airtable provider instance to the Airtable Service | ||
public async handleRemoteRequest( | ||
providerId: string, | ||
action: TProviderAction, | ||
data: object | ||
) { | ||
// Get provider via ID | ||
const provider = this.providers[ providerId ]; | ||
if (provider === undefined) | ||
throw new Error(`No provider "${providerId}" has been found.`); | ||
// Check if provider.options.remote | ||
if (provider.options.remote !== true) | ||
throw new Error(`Remote access has not been enabled for provider "${providerId}".`); | ||
// Switch action | ||
switch (action) { | ||
case 'create': | ||
return await provider.create( data.record, data.airtableRecord ); | ||
case 'update': | ||
return await provider.update( data.records, data.simulate ); | ||
case 'delete': | ||
return await provider.delete( data.recordIds ); | ||
default: | ||
throw new Error('Unknown action: "' + action + '"') | ||
} | ||
} | ||
/*---------------------------------- | ||
@@ -382,0 +410,0 @@ - REPORTING |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
101850
11
2314
26