Skip to content

Update template #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions base_folder/test/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ import {


import {
Context as SnapInContext,
ExecuteOperationResult,
ExecuteOperationResult_SerializationFormat,
ExecutionMetadata,
FunctionExecutionError,
FunctionInput,
OperationOutput,
} from '@devrev/typescript-sdk/dist/snap-ins';

Expand Down
6 changes: 5 additions & 1 deletion devrev-snapin-template.plain
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

- The Function implements part of The Snap-In functionality.

- The Airdrop SDK Library for TypeScript helps developers build snap-ins that integrate with DevRev’s Airdrop platform.
- The documentation for the The Airdrop SDK Library is provided in the resource [airdrop_sdk_library_documentation.md](docs/airdrop_sdk_library_documentation.md).
- Please note that EventContextIn and EventContextOut interfaces are deprecated.

- The External Domain Metadata is a JSON object that describes the logical domain model of an external system. It defines the types of external record types, the relationships between those record types, and the metadata associated with each field, including the field’s data type, human-readable name, and other descriptive attributes.

- The Initial Domain Mapping is a JSON object that defines how the logical domain model described by The External Domain Metadata maps to the target domain model in DevRev. It specifies the correspondence between each external record type and DevRev leaf type, as well as the mapping of individual fields, including transformation logic, value conversions, and any fixed or default values.
Expand All @@ -16,8 +20,8 @@
- The Snap-In will run on Node.js as the runtime environment.

- The Snap-In should use The Airdrop SDK Library version "1.5.1" for handling data extraction and loading, pushing data, event-driven actions, state management, and artifact handling.
- The documentation for the The Airdrop SDK Library is provided in the resource [airdrop_sdk_library_documentation.md](docs/airdrop_sdk_library_documentation.md).
- Please note that 'processTask' function **only** executes task if 'processTask' function is called from a worker thread. Therefore 'processTask' function should be called from a worker thread spawned using 'Spawn' class.
- If the worker is written in TypeScript, it must be referenced with a .ts extension, not .js.

- Use snake_case for JSON keys.

Expand Down
4 changes: 4 additions & 0 deletions docs/airdrop_sdk_library_documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ Defines the structure of events sent to external extractors from Airdrop platfor

Required. An object containing:

- _function_name_: A **string** representing the name of the the function that is being invoked.

- _event_type_: A **string** with the type of event that triggered the function invocation.

- _devrev_endpoint_: A **string** representing the DevRev endpoint URL

- _input_data_
Expand Down
56 changes: 56 additions & 0 deletions docs/mapping-reasons.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Airdrop uses transformation methods to map data from one data model to another.
These methods operate at the individual field level, transforming data field-by-field rather than entire records at once.
Each transformation method has specific requirements regarding the field types and data formats it can work with.
If the source data field does not meet these requirements for a particular transformation method, that mapping option is not available for selection during the mapping configuration process.

There are several reasons why some mappings might be unavailable:

1. A common reason is mismatch of types. For example, if a DevRev field is expected to be `rich_text`,
but the field is set as `text` mapping to some fields is unavailable.
2. Only references can be mapped to references. Ensure that source system fields are correctly
mapped to reference fields in DevRev.
3. Support for the `struct` type is limited. Marking a field as a struct in the metadata schema will
make it unavailable for mapping outside of using the custom jq transformation method.
4. Links are supported only on works and conversations.

## Transformation methods
The following tables outline the available transformation methods categorized by their applicable field types:

### Custom fields transformation methods

| Method | Description | Requirements |
|--------|-------------|-------------|
| `make_constrained_simple_value` | Propagates validation constraints from the external system and enforces those in DevRev | - |
| `make_enum` | Produces an enum field | External field must be of type enum |
| `make_uenum` | Produces an enum field | External field must be of type enum |
| `reference_custom_field` | Produces a reference field | External field must be of type reference |

### Metadata extraction transformation methods

| Method | Description | Requirements |
|--------|-------------|-------------|
| `make_custom_stages` | Makes custom stages | Requires stage diagram data in the domain metadata |
| `map_enum` | Produces an enum field | External field must be of type enum |
| `map_roles` | Maps permission roles from external to DevRev format | - |
| `use_as_array_value` | Produces an array field | External field must be a scalar (single-value) |
| `use_devrev_record` | Enables use of a fixed reference to something in DevRev | DON should be of the right type |
| `use_directly` | Identity operator that returns exactly the input | External field must be of the same type as the DevRev field; if external field is an array, internal field must also be an array |
| `use_fixed_value` | Produces a fixed value in DevRev | Only available for boolean or enum DevRev fields |

### Custom and stock fields transformation methods

| Method | Description | Requirements |
|--------|-------------|-------------|
| `use_rich_text` | Produces a rich text field | External field must be of type `rich_text` |

### Constructed custom fields transformation methods

| Method | Description | Requirements |
|--------|-------------|-------------|
| `construct_text_field` | Produces a text field | External field must be of type text |

### Universal transformation method

| Method | Description | Requirements |
|--------|-------------|-------------|
| `use_raw_jq` | Enables the use of `jq` to transform data | Can be used on all fields, but should be used sparingly, only if no other transformation method is available |