Skip to content

Commit

Permalink
Support for new recipe management and example of initial domain mappi…
Browse files Browse the repository at this point in the history
…ng (#7)

Added support for new recipe management which includes creation of
recipe blueprint and installing initial domain mapping file.
radovan-jorgic authored Sep 17, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent ce8016c commit 1bb8757
Showing 6 changed files with 140 additions and 9 deletions.
14 changes: 7 additions & 7 deletions code/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion code/package.json
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@
"yargs": "^17.6.2"
},
"dependencies": {
"@devrev/ts-adaas": "0.0.2",
"@devrev/ts-adaas": "0.0.3",
"axios": "^1.5.1",
"dotenv": "^16.0.3",
"js-jsonl": "^1.1.1",
4 changes: 3 additions & 1 deletion code/src/function-factory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import extraction from './functions/extraction/index';
import extraction from './functions/extraction';
import install_initial_domain_mapping from './functions/install_initial_domain_mapping';

export const functionFactory = {
extraction,
install_initial_domain_mapping,
} as const;

export type FunctionFactoryType = keyof typeof functionFactory;
107 changes: 107 additions & 0 deletions code/src/functions/extraction/initial_domain_mapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"starting_recipe_blueprint": {
"external_record_types": {
"contacts": {
"forward": true,
"reverse": false,
"shard": {
"constructed_custom_fields": {},
"devrev_leaf_type": {
"object_type": "revu"
},
"shard": "create_shard",
"stock_field_mappings": {
"display_name": {
"forward": true,
"primary_external_field": "name",
"reverse": false,
"transformation_method": {
"transformation_method": "use_directly"
}
},
"email": {
"forward": true,
"primary_external_field": "email",
"reverse": false,
"transformation_method": {
"transformation_method": "use_directly"
}
},
"full_name": {
"forward": true,
"primary_external_field": "name",
"reverse": false,
"transformation_method": {
"transformation_method": "use_directly"
}
},
"state": {
"forward": true,
"reverse": false,
"transformation_method": {
"enum": "UNASSIGNED",
"transformation_method": "use_fixed_value",
"value": "enum_value"
}
},
"user_type": {
"forward": true,
"reverse": false,
"transformation_method": {
"enum": "IDENTIFIED",
"transformation_method": "use_fixed_value",
"value": "enum_value"
}
}
}
}
},
"users": {
"forward": true,
"reverse": false,
"shard": {
"constructed_custom_fields": {},
"devrev_leaf_type": {
"object_type": "devu"
},
"shard": "create_shard",
"stock_field_mappings": {
"display_name": {
"forward": true,
"primary_external_field": "name",
"reverse": false,
"transformation_method": {
"transformation_method": "use_directly"
}
},
"email": {
"forward": true,
"primary_external_field": "email",
"reverse": false,
"transformation_method": {
"transformation_method": "use_directly"
}
},
"full_name": {
"forward": true,
"primary_external_field": "name",
"reverse": false,
"transformation_method": {
"transformation_method": "use_directly"
}
},
"state": {
"forward": true,
"reverse": false,
"transformation_method": {
"enum": "UNASSIGNED",
"transformation_method": "use_fixed_value",
"value": "enum_value"
}
}
}
}
}
}
}
}
16 changes: 16 additions & 0 deletions code/src/functions/install_initial_domain_mapping/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { AirdropEvent, installInitialDomainMapping } from '@devrev/ts-adaas';

import initialDomainMapping from '../extraction/initial_domain_mapping.json';

const run = async (events: AirdropEvent[]) => {
for (const event of events) {
try {
await installInitialDomainMapping(event, initialDomainMapping);
} catch (error) {
console.error('Failed to install initial domain mappings', error);
throw error;
}
}
};

export default run;
6 changes: 6 additions & 0 deletions manifest.yaml
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ service_account:
functions:
- name: extraction
description: Extraction function for the template snap-in
- name: install_initial_domain_mapping
description: Create blueprint and install initial domain mapping

keyring_types:
- id: example-connection
@@ -30,3 +32,7 @@ imports:
extractor_function: extraction
allowed_connection_types:
- example-connection

hooks:
- type: activate
function: install_initial_domain_mapping

0 comments on commit 1bb8757

Please sign in to comment.