Skip to content

Commit a44341e

Browse files
authored
Update template (#8)
Update to the snap-in template and some additional documentation. Here are the details of this update: 1. The reference to docs/airdrop_sdk_library_documentation.md was moved to Definitions sections so that it's available also to the conformance tests. 2. In devrev-snapin-template.plain we've added a small implementation hint that AI consistently got wrong. 3. In docs/airdrop_sdk_library_documentation.md 'function_name' and 'event_type' attributes were missing in AirdropEvent object. This was really confusing AI so I added it. 4. We are also adding docs/mapping-reasons.mdx that is needed for initial domain mapping and will be referenced in specific snap-ins (e.g. Trello). The file was copied from https://github.com/devrev/fern-api-docs/blob/main/fern/docs/pages/airdrop/data-model/mapping-reasons.mdx 5. From runner.ts I've deleted some unused imports. Work item: https://app.devrev.ai/devrev/works/ISS-188589
1 parent cba43ff commit a44341e

File tree

4 files changed

+65
-4
lines changed

4 files changed

+65
-4
lines changed

base_folder/test/runner.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@ import {
1919

2020

2121
import {
22-
Context as SnapInContext,
2322
ExecuteOperationResult,
2423
ExecuteOperationResult_SerializationFormat,
25-
ExecutionMetadata,
2624
FunctionExecutionError,
27-
FunctionInput,
2825
OperationOutput,
2926
} from '@devrev/typescript-sdk/dist/snap-ins';
3027

devrev-snapin-template.plain

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

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

7+
- The Airdrop SDK Library for TypeScript helps developers build snap-ins that integrate with DevRev’s Airdrop platform.
8+
- The documentation for the The Airdrop SDK Library is provided in the resource [airdrop_sdk_library_documentation.md](docs/airdrop_sdk_library_documentation.md).
9+
- Please note that EventContextIn and EventContextOut interfaces are deprecated.
10+
711
- 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.
812

913
- 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.
@@ -16,8 +20,8 @@
1620
- The Snap-In will run on Node.js as the runtime environment.
1721

1822
- 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.
19-
- The documentation for the The Airdrop SDK Library is provided in the resource [airdrop_sdk_library_documentation.md](docs/airdrop_sdk_library_documentation.md).
2023
- 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.
24+
- If the worker is written in TypeScript, it must be referenced with a .ts extension, not .js.
2125

2226
- Use snake_case for JSON keys.
2327

docs/airdrop_sdk_library_documentation.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,10 @@ Defines the structure of events sent to external extractors from Airdrop platfor
390390

391391
Required. An object containing:
392392

393+
- _function_name_: A **string** representing the name of the the function that is being invoked.
394+
395+
- _event_type_: A **string** with the type of event that triggered the function invocation.
396+
393397
- _devrev_endpoint_: A **string** representing the DevRev endpoint URL
394398

395399
- _input_data_

docs/mapping-reasons.mdx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
Airdrop uses transformation methods to map data from one data model to another.
2+
These methods operate at the individual field level, transforming data field-by-field rather than entire records at once.
3+
Each transformation method has specific requirements regarding the field types and data formats it can work with.
4+
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.
5+
6+
There are several reasons why some mappings might be unavailable:
7+
8+
1. A common reason is mismatch of types. For example, if a DevRev field is expected to be `rich_text`,
9+
but the field is set as `text` mapping to some fields is unavailable.
10+
2. Only references can be mapped to references. Ensure that source system fields are correctly
11+
mapped to reference fields in DevRev.
12+
3. Support for the `struct` type is limited. Marking a field as a struct in the metadata schema will
13+
make it unavailable for mapping outside of using the custom jq transformation method.
14+
4. Links are supported only on works and conversations.
15+
16+
## Transformation methods
17+
The following tables outline the available transformation methods categorized by their applicable field types:
18+
19+
### Custom fields transformation methods
20+
21+
| Method | Description | Requirements |
22+
|--------|-------------|-------------|
23+
| `make_constrained_simple_value` | Propagates validation constraints from the external system and enforces those in DevRev | - |
24+
| `make_enum` | Produces an enum field | External field must be of type enum |
25+
| `make_uenum` | Produces an enum field | External field must be of type enum |
26+
| `reference_custom_field` | Produces a reference field | External field must be of type reference |
27+
28+
### Metadata extraction transformation methods
29+
30+
| Method | Description | Requirements |
31+
|--------|-------------|-------------|
32+
| `make_custom_stages` | Makes custom stages | Requires stage diagram data in the domain metadata |
33+
| `map_enum` | Produces an enum field | External field must be of type enum |
34+
| `map_roles` | Maps permission roles from external to DevRev format | - |
35+
| `use_as_array_value` | Produces an array field | External field must be a scalar (single-value) |
36+
| `use_devrev_record` | Enables use of a fixed reference to something in DevRev | DON should be of the right type |
37+
| `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 |
38+
| `use_fixed_value` | Produces a fixed value in DevRev | Only available for boolean or enum DevRev fields |
39+
40+
### Custom and stock fields transformation methods
41+
42+
| Method | Description | Requirements |
43+
|--------|-------------|-------------|
44+
| `use_rich_text` | Produces a rich text field | External field must be of type `rich_text` |
45+
46+
### Constructed custom fields transformation methods
47+
48+
| Method | Description | Requirements |
49+
|--------|-------------|-------------|
50+
| `construct_text_field` | Produces a text field | External field must be of type text |
51+
52+
### Universal transformation method
53+
54+
| Method | Description | Requirements |
55+
|--------|-------------|-------------|
56+
| `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 |

0 commit comments

Comments
 (0)