Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into salesforce-custom-obj…
Browse files Browse the repository at this point in the history
…ect-external-id
  • Loading branch information
seg-leonelsanches committed Feb 11, 2025
2 parents 487f516 + 078cbaa commit 2ec8f2f
Show file tree
Hide file tree
Showing 532 changed files with 28,432 additions and 5,167 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
test:
name: Unit tests
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
matrix:
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:

lint:
name: Lint
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
timeout-minutes: 20
strategy:
matrix:
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:

validate:
name: Validate
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
timeout-minutes: 20
strategy:
matrix:
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
# env: # Disable saucelabs - we blew through our quota.
# SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}}
# SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}}
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
timeout-minutes: 20
strategy:
matrix:
Expand Down Expand Up @@ -171,7 +171,7 @@ jobs:

browser-tests-core:
name: 'Browser tests: actions-core'
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

timeout-minutes: 10

Expand All @@ -192,7 +192,7 @@ jobs:
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
Expand All @@ -214,7 +214,7 @@ jobs:

snyk:
name: Snyk
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

timeout-minutes: 5

Expand All @@ -237,7 +237,7 @@ jobs:
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ext.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
env:
HUSKY: 0
NX_DISABLE_DB: true
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

timeout-minutes: 20

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/label-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
pr-labeler:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
permissions:
contents: read
pull-requests: write
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
HUSKY: 0
NX_DISABLE_DB: true
if: startsWith(github.event.head_commit.message, 'Publish') == true
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

timeout-minutes: 15

Expand Down
36 changes: 15 additions & 21 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ on:
push:
branches:
- main
- release
- hotfix/**

jobs:
build-and-publish:
env:
HUSKY: 0
NX_DISABLE_DB: true
if: startsWith(github.event.head_commit.message, 'Publish') == true
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

timeout-minutes: 15

Expand All @@ -25,6 +25,9 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
Expand All @@ -33,6 +36,11 @@ jobs:
registry-url: 'https://registry.npmjs.org'
cache: yarn

- name: Setup git credentials
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Install Dependencies
run: yarn install --frozen-lockfile

Expand All @@ -50,25 +58,9 @@ jobs:
- name: Publish
run: |
yarn lerna publish from-package --yes --allowBranch=main --loglevel=verbose --dist-tag latest
release:
needs: build-and-publish # comment when testing locally with https://github.com/nektos/act

runs-on: ubuntu-20.04
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled to ensure the commit history for the repository is available to the action
fetch-tags: true

- name: Setup git credentials
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
yarn lerna publish from-package --yes --loglevel=verbose --dist-tag latest
- name: Generate Release Tag
- name: Generate Tags
id: get-release-tag
run: ./scripts/generate-release-tags.sh

Expand All @@ -79,5 +71,7 @@ jobs:
RELEASE_TAG: ${{ steps.get-release-tag.outputs.release-tag }}
with:
script: |
const cloudManifest = require('./packages/destination-actions/dist/destinations/index.js').manifest
const browserManifest = require('./packages/destinations-manifest/dist/index.js').manifest
const script = require('./scripts/github-action/create-github-release.js')
await script({github, context, core, exec})
await script({github, context, core, exec, cloudManifest, browserManifest})
6 changes: 3 additions & 3 deletions .github/workflows/required-field-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

jobs:
required-field-check:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

timeout-minutes: 5

Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
}
}
} else {
// If key is not present in requiredFieldsOnMain, then all fields are added recently
const getActionKeys = Object.keys(requiredFieldsOnBranch[key])
for(const actionKey of getActionKeys) {
Expand All @@ -109,7 +109,7 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo
})
const diffComment = comments.data.find(comment => comment.body.includes('<!--REQUIRED_FIELD_DIFF-->'))
const diffComment = comments.data.find(comment => comment.body.includes('<!--REQUIRED_FIELD_DIFF-->'))
const comment = fs.readFileSync("./.github/REQUIRED_FIELD_WARNING_TEMPLATE.md", "utf8")
const commentBody = comment.replace('{{FIELDS_ADDED}}', fieldsAdded.join('\n'))
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/version-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ on:
description: 'Base branch to create PR to'
required: true
default: 'main'
type: choice
options:
- main
- release
run_id:
description: 'Unique identifier for the run'
required: false
Expand Down Expand Up @@ -67,7 +63,13 @@ jobs:
run: NODE_ENV=production yarn build

- name: Version Packages
run: yarn lerna version minor --yes --allow-branch ${{ github.event.inputs.branch }} --no-git-tag-version --no-commit-hooks --no-private
run: |
# minor version bump for main branch and patch for hotfixes
if [ "${{ github.event.inputs.base_branch }}" == "main" ]; then
yarn lerna version minor --yes --allow-branch ${{ github.event.inputs.branch }} --no-git-tag-version --no-commit-hooks --no-private
else
yarn lerna version patch --yes --allow-branch ${{ github.event.inputs.branch }} --no-git-tag-version --no-commit-hooks --no-private
fi
- name: Commit and push
id: commit_and_push
Expand Down
122 changes: 121 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ interface InputField {
dynamic?: boolean

/** Whether or not the field is required */
required?: boolean
required?: boolean | DependsOnConditions

/**
* Optional definition for the properties of `type: 'object'` fields
Expand Down Expand Up @@ -358,6 +358,126 @@ const destination = {

In addition to default values for input fields, you can also specify the defaultSubscription for a given action – this is the FQL query that will be automatically populated when a customer configures a new subscription triggering a given action.

## Required Fields

You may configure a field to either be always required, not required, or conditionally required. Validation for required fields is performed both when a user is configuring a mapping in the UI and when an event payload is delivered through a `perform` block.

**An example of each possible value for `required`**

```js
const destination = {
actions: {
readmeAction: {
fields: {
operation: {
label: 'An operation for the readme action',
required: true // This field is always required and any payloads omitting it will fail
},
creationName: {
label: "The name of the resource to create, required when operation = 'create'",
required: {
// This field is required only when the 'operation' field has the value 'create'
match: 'all',
conditions: [
{
fieldKey: 'operation',
operator: 'is',
value: 'create'
}
]
}
},
email: {
label: 'The customer email',
required: false // This field is not required. This is the same as not including the 'required' property at all
},
userIdentifiers: {
phone: {
label: 'The customer phone number',
required: {
// If email is not provided then a phone number is required
conditions: [{ fieldKey: 'email', operator: 'is', value: undefined }]
}
},
countryCode: {
label: 'The country code for the customer phone number',
required: {
// If a userIdentifiers.phone is provided then the country code is also required
conditions: [
{
fieldKey: 'userIdentifiers.phone', // Dot notation may be used to address object fields.
operator: 'is_not',
value: undefined
}
]
}
}
}
}
}
}
}
```

**Examples of valid and invalid payloads for the fields above**

```json
// This payload is valid since the only required field, 'operation', is defined.
{
"operation": "update",
"email": "[email protected]"
}
```

```json
// This payload is invalid since 'creationName' is required because 'operation' is 'create'
{
"operation": "create",
"email": "[email protected]"
}
// This error will be thrown:
"message": "The root value is missing the required field 'creationName'. The root value must match \"then\" schema."
```

```json
// This payload is valid since the two required fields, 'operation' and 'creationName' are defined.
{
"operation": "create",
"creationName": "readme",
"email": "[email protected]"
}
```

```json
// This payload is invalid since 'phone' is required when 'email' is missing.
{
"operation": "update",
}
// This error will be thrown:
"message": "The root value is missing the required field 'phone'. The root value must match \"then\" schema."
```

```json
// This payload is invalid since 'countryCode' is required when 'phone' is defined
{
"operation": "update",
"userIdentifiers": { "phone": "619-555-5555" }
}
// This error will be thrown:
"message": "The root value is missing the required field 'countryCode'. The root value must match \"then\" schema."
```

```json
// This payload is valid since all conditionally required fields are included
{
"operation": "update",
"userIdentifiers": {
"phone": "619-555-5555",
"countryCode": "+1"
}
}
```

## Dynamic Fields

You can setup a field which dynamically fetches inputs from your destination. These dynamic fields can be used to populate a dropdown menu of options for your users to select.
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"npmClientArgs": ["--ignore-engines", "--ignore-optional"]
},
"version": {
"allowBranch": ["main", "release"]
"allowBranch": ["main", "hotfix/*"]
}
}
}
4 changes: 2 additions & 2 deletions packages/actions-shared/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@segment/actions-shared",
"description": "Shared destination action methods and definitions.",
"version": "1.119.0",
"version": "1.126.0",
"repository": {
"type": "git",
"url": "https://github.com/segmentio/action-destinations",
Expand Down Expand Up @@ -37,7 +37,7 @@
},
"dependencies": {
"@amplitude/ua-parser-js": "^0.7.25",
"@segment/actions-core": "^3.138.0",
"@segment/actions-core": "^3.145.0",
"cheerio": "^1.0.0-rc.10",
"dayjs": "^1.10.7",
"escape-goat": "^3",
Expand Down
Loading

0 comments on commit 2ec8f2f

Please sign in to comment.