@proveanything/smartlinks 2.1.13 → 2.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/integrations.d.ts +28 -0
- package/dist/api/integrations.js +28 -0
- package/dist/docs/API_SUMMARY.md +132 -7
- package/dist/docs/connectors.md +98 -4
- package/dist/docs/entitlements.md +90 -0
- package/dist/docs/integrations.md +167 -9
- package/dist/docs/interactions.md +545 -540
- package/dist/docs/loyalty.md +17 -0
- package/dist/docs/server-functions.md +3 -0
- package/dist/openapi.yaml +239 -2
- package/dist/types/appManifest.d.ts +42 -1
- package/dist/types/integrations.d.ts +168 -3
- package/docs/API_SUMMARY.md +132 -7
- package/docs/connectors.md +98 -4
- package/docs/entitlements.md +90 -0
- package/docs/integrations.md +167 -9
- package/docs/interactions.md +545 -540
- package/docs/loyalty.md +17 -0
- package/docs/server-functions.md +3 -0
- package/openapi.yaml +239 -2
- package/package.json +87 -87
package/docs/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.15 | Generated: 2026-11-09T15:17:42.472Z
|
|
4
4
|
|
|
5
5
|
This is a concise summary of all available API functions and types.
|
|
6
6
|
|
|
@@ -64,8 +64,9 @@ For detailed guides on specific features:
|
|
|
64
64
|
- **[Analytics](analytics.md)** - Web analytics, link-click tracking, QR/tag scan telemetry, and event reporting
|
|
65
65
|
- **[Analytics Metadata Conventions](analytics-metadata-conventions.md)** - Standard recommended keys and conventions for analytics metadata fields
|
|
66
66
|
- **[Loyalty: Points, Members & Earning Rules](loyalty.md)** - Loyalty schemes, automatic point earning via interaction rules, member balances, transaction history, and manual adjustments
|
|
67
|
-
- **[Integrations](integrations.md)** - Inbound/outbound integration flows + the sealed-secret store; triggers (manual/event/schedule),
|
|
68
|
-
- **[Connectors](connectors.md)** - Connector apps (adapters for one external provider): a manifest `connector` block + server functions (testConnection/describeTarget/sample/fetch/shape/serialize/send); core does the mapping
|
|
67
|
+
- **[Integrations](integrations.md)** - Inbound/outbound integration flows + the sealed-secret store; triggers (manual/event/schedule), event patterns, the event envelope (interaction/contact/event sources), identity policy, event mapping, signed deliveries, contact as a target, field mappings
|
|
68
|
+
- **[Connectors](connectors.md)** - Connector apps (adapters for one external provider): a manifest `connector` block + server functions (testConnection/describeTarget/sample/fetch/shape/serialize/send/describeEvents/lookup); loyalty and CRM connectors; actions (provider operations on demand); core does the mapping
|
|
69
|
+
- **[Entitlements](entitlements.md)** - "Is this person gold or above?" answered on demand from signed claims, a connector lookup (cached), or the contact — never a mirrored member base; gates on interaction types and in server functions
|
|
69
70
|
- **[AI Tools & Skills](ai-tools-and-skills.md)** - The AI capability catalog: skills apps invoke by name (e.g. research.brand), the tools the AI reaches for (web fetch/screenshot/brand assets/image gen), the agent loop, and how apps discover them
|
|
70
71
|
- **[Deep Link Discovery](deep-link-discovery.md)** - Registering and discovering navigable app states for portal menus and AI orchestration
|
|
71
72
|
- **[AI Guide Template](ai-guide-template.md)** - A sample for an app on how to build an AI setup guide
|
|
@@ -3111,6 +3112,19 @@ interface ConnectorPanel {
|
|
|
3111
3112
|
}
|
|
3112
3113
|
```
|
|
3113
3114
|
|
|
3115
|
+
**ConnectorAction** (interface)
|
|
3116
|
+
```typescript
|
|
3117
|
+
interface ConnectorAction {
|
|
3118
|
+
name: string
|
|
3119
|
+
title?: string
|
|
3120
|
+
description?: string
|
|
3121
|
+
function: string
|
|
3122
|
+
visibility?: 'admin' | 'member' | 'public'
|
|
3123
|
+
input?: Record<string, unknown>
|
|
3124
|
+
output?: Record<string, unknown>
|
|
3125
|
+
}
|
|
3126
|
+
```
|
|
3127
|
+
|
|
3114
3128
|
**AppConnectorDeclaration** (interface)
|
|
3115
3129
|
```typescript
|
|
3116
3130
|
interface AppConnectorDeclaration {
|
|
@@ -3129,11 +3143,14 @@ interface AppConnectorDeclaration {
|
|
|
3129
3143
|
serialize?: string
|
|
3130
3144
|
send?: string
|
|
3131
3145
|
fetch?: string
|
|
3146
|
+
describeEvents?: string
|
|
3147
|
+
lookup?: string
|
|
3132
3148
|
}
|
|
3133
3149
|
panels?: ConnectorPanel[]
|
|
3150
|
+
actions?: ConnectorAction[]
|
|
3134
3151
|
aiGuide?: string
|
|
3135
3152
|
recordId?: string
|
|
3136
|
-
limits?: { requestsPerSecond?: number }
|
|
3153
|
+
limits?: { requestsPerSecond?: number; maxEvents?: number; maxAttributes?: number }
|
|
3137
3154
|
}
|
|
3138
3155
|
```
|
|
3139
3156
|
|
|
@@ -7953,9 +7970,31 @@ interface FlowConnectorRef {
|
|
|
7953
7970
|
}
|
|
7954
7971
|
```
|
|
7955
7972
|
|
|
7973
|
+
**EventMappingRule** (interface)
|
|
7974
|
+
```typescript
|
|
7975
|
+
interface EventMappingRule {
|
|
7976
|
+
id?: string
|
|
7977
|
+
match?: { types?: string[]; interactionIds?: string[]; outcomes?: string[]; appIds?: string[] }
|
|
7978
|
+
event: string
|
|
7979
|
+
attributes?: Record<string, string | number | boolean | { path: string; default?: unknown } | { value: unknown }>
|
|
7980
|
+
}
|
|
7981
|
+
```
|
|
7982
|
+
|
|
7983
|
+
**EventMapping** (interface)
|
|
7984
|
+
```typescript
|
|
7985
|
+
interface EventMapping {
|
|
7986
|
+
rules: EventMappingRule[]
|
|
7987
|
+
unmatched?: 'skip' | 'passthrough'
|
|
7988
|
+
}
|
|
7989
|
+
```
|
|
7990
|
+
|
|
7956
7991
|
**IntegrationFlowConfig** (interface)
|
|
7957
7992
|
```typescript
|
|
7958
7993
|
interface IntegrationFlowConfig {
|
|
7994
|
+
signing?: { credentialRef: string; previousCredentialRef?: string }
|
|
7995
|
+
identity?: { policy?: IdentityPolicy; hashKeyCredentialRef?: string }
|
|
7996
|
+
eventMapping?: EventMapping
|
|
7997
|
+
envelopeFormat?: 'cloudevents'
|
|
7959
7998
|
connection?: FlowConnection
|
|
7960
7999
|
fieldMappings?: FieldMapping[]
|
|
7961
8000
|
connector?: FlowConnectorRef
|
|
@@ -7975,8 +8014,8 @@ interface IntegrationFlow {
|
|
|
7975
8014
|
status: FlowStatus
|
|
7976
8015
|
eventTypes: string[]
|
|
7977
8016
|
schedule: string | null
|
|
7978
|
-
sourceEntity: string | null
|
|
7979
|
-
targetEntity: string | null
|
|
8017
|
+
sourceEntity: FlowSourceEntity | string | null
|
|
8018
|
+
targetEntity: FlowTargetEntity | string | null
|
|
7980
8019
|
config: IntegrationFlowConfig
|
|
7981
8020
|
createdBy: string | null
|
|
7982
8021
|
createdAt: string
|
|
@@ -8165,6 +8204,70 @@ interface SaveConnectorInstallationInput {
|
|
|
8165
8204
|
}
|
|
8166
8205
|
```
|
|
8167
8206
|
|
|
8207
|
+
**ConnectorEventsSchema** (interface)
|
|
8208
|
+
```typescript
|
|
8209
|
+
interface ConnectorEventsSchema {
|
|
8210
|
+
events: Array<{ name: string; title?: string; attributes?: Array<{ name: string; type?: string; required?: boolean }> }>
|
|
8211
|
+
limits?: { maxEvents?: number; maxAttributes?: number }
|
|
8212
|
+
}
|
|
8213
|
+
```
|
|
8214
|
+
|
|
8215
|
+
**ConnectorLookupInput** (interface)
|
|
8216
|
+
```typescript
|
|
8217
|
+
interface ConnectorLookupInput {
|
|
8218
|
+
installation: ConnectorInstallation
|
|
8219
|
+
identity: { externalId?: string | null; email?: string | null; phone?: string | null; emailHash?: string | null; phoneHash?: string | null; contactId?: string | null }
|
|
8220
|
+
want?: string[]
|
|
8221
|
+
}
|
|
8222
|
+
```
|
|
8223
|
+
|
|
8224
|
+
**ConnectorLookupResult** (interface)
|
|
8225
|
+
```typescript
|
|
8226
|
+
interface ConnectorLookupResult {
|
|
8227
|
+
found: boolean
|
|
8228
|
+
memberId?: string | null
|
|
8229
|
+
tier?: string | null
|
|
8230
|
+
points?: number | null
|
|
8231
|
+
status?: string | null
|
|
8232
|
+
attributes?: Record<string, unknown>
|
|
8233
|
+
asOf?: string | null
|
|
8234
|
+
}
|
|
8235
|
+
```
|
|
8236
|
+
|
|
8237
|
+
**EventEnvelope** (interface)
|
|
8238
|
+
```typescript
|
|
8239
|
+
interface EventEnvelope {
|
|
8240
|
+
specVersion: number
|
|
8241
|
+
id: string
|
|
8242
|
+
type: string
|
|
8243
|
+
entityType: string | null
|
|
8244
|
+
entityId: string | null
|
|
8245
|
+
occurredAt: string
|
|
8246
|
+
collectionId: string
|
|
8247
|
+
orgId: string
|
|
8248
|
+
appId: string | null
|
|
8249
|
+
identity: {
|
|
8250
|
+
contactId: string | null
|
|
8251
|
+
userId: string | null
|
|
8252
|
+
externalIds: Record<string, string>
|
|
8253
|
+
anonymousId: string | null
|
|
8254
|
+
sessionId: string | null
|
|
8255
|
+
emailHash?: string | null
|
|
8256
|
+
phoneHash?: string | null
|
|
8257
|
+
hashAlgorithm?: 'hmac-sha256' | null
|
|
8258
|
+
email?: string | null
|
|
8259
|
+
phone?: string | null
|
|
8260
|
+
}
|
|
8261
|
+
identityPolicy: IdentityPolicy
|
|
8262
|
+
product: { id: string; name?: string | null; sku?: string | null; gtin?: string | null; variantId?: string | null; batchId?: string | null } | null
|
|
8263
|
+
proof: { id: string } | null
|
|
8264
|
+
consent: { channels: Record<'email' | 'sms' | 'push' | 'whatsapp', 'opted_in' | 'opted_out' | 'suppressed' | 'unknown'>; topics: Record<string, boolean>; updatedAt: string | null } | null
|
|
8265
|
+
subject: Record<string, unknown>
|
|
8266
|
+
event?: { name: string; attributes: Record<string, unknown>; rule: string | null }
|
|
8267
|
+
attributes: Record<string, unknown>
|
|
8268
|
+
}
|
|
8269
|
+
```
|
|
8270
|
+
|
|
8168
8271
|
**CapturedRequest** (interface)
|
|
8169
8272
|
```typescript
|
|
8170
8273
|
interface CapturedRequest {
|
|
@@ -8367,9 +8470,15 @@ interface RecordTypesResponse {
|
|
|
8367
8470
|
|
|
8368
8471
|
**FlowAuthMethod** = `'api_key' | 'bearer' | 'basic' | 'webhook' | 'oauth2' | 'none'`
|
|
8369
8472
|
|
|
8473
|
+
**IdentityPolicy** = `'externalIds' | 'hashed' | 'raw'`
|
|
8474
|
+
|
|
8475
|
+
**FlowSourceEntity** = `'product' | 'interaction' | 'contact' | 'event'`
|
|
8476
|
+
|
|
8477
|
+
**FlowTargetEntity** = `'product' | 'contact'`
|
|
8478
|
+
|
|
8370
8479
|
**UpdateFlowInput** = `Partial<Omit<CreateFlowInput, 'direction'>> & {`
|
|
8371
8480
|
|
|
8372
|
-
**ConnectorConsoleStep** = `'testConnection' | 'describeTarget' | 'sample' | 'shape' | 'serialize'`
|
|
8481
|
+
**ConnectorConsoleStep** = `'testConnection' | 'describeTarget' | 'sample' | 'shape' | 'serialize' | 'describeEvents' | 'lookup'`
|
|
8373
8482
|
|
|
8374
8483
|
**RunTrigger** = `'manual' | 'event' | 'schedule' | 'test'`
|
|
8375
8484
|
|
|
@@ -12894,6 +13003,22 @@ Save a connector's non-secret Connect-form values and/or settings. PUT /integrat
|
|
|
12894
13003
|
input: Record<string, unknown> & { flowId?: string } = {}) → `Promise<T>`
|
|
12895
13004
|
Run a connector step from the console: `testConnection` → ConnectorTestResult, `describeTarget` → ConnectorTargetSchema, `sample` → ConnectorRecords, and dry runs of `shape` ({ records }) → ConnectorShapeResult and `serialize` ({ documents }) → ConnectorSerializeResult. The server adds the installation; pass `flowId` to layer that flow's settings. POST /integrations/connectors/:appId/steps/:step
|
|
12896
13005
|
|
|
13006
|
+
**runConnectorAction**(collectionId: string,
|
|
13007
|
+
appId: string,
|
|
13008
|
+
action: string,
|
|
13009
|
+
input: Record<string, unknown> = {}) → `Promise<T>`
|
|
13010
|
+
Invoke a connector ACTION from the console (any visibility): redeem, enrol, adjust points, issue a coupon… The connector's function runs with its own credentials and is told who asked. POST /integrations/connectors/:appId/actions/:action { input }
|
|
13011
|
+
|
|
13012
|
+
**listConnectorActions**(collectionId: string,
|
|
13013
|
+
appId: string) → `Promise<`
|
|
13014
|
+
PUBLIC (the Hub, a site): the connector actions the caller may invoke — those declared `public`, plus `member` ones when signed in. GET /public/collection/:collectionId/connectors/:appId/actions
|
|
13015
|
+
|
|
13016
|
+
**callConnectorAction**(collectionId: string,
|
|
13017
|
+
appId: string,
|
|
13018
|
+
action: string,
|
|
13019
|
+
input: Record<string, unknown> = {}) → `Promise<T>`
|
|
13020
|
+
PUBLIC (the Hub, a site): invoke a connector action — e.g. redeem a reward for the signed-in member. 401 SIGN_IN_REQUIRED for a `member` action without a session; 403 for an admin-only one; 400 with `missing[]` when a required input is absent. POST /public/collection/:collectionId/connectors/:appId/actions/:action { input }
|
|
13021
|
+
|
|
12897
13022
|
### interactions
|
|
12898
13023
|
|
|
12899
13024
|
**query**(collectionId: string,
|
package/docs/connectors.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Integration connectors
|
|
2
2
|
|
|
3
3
|
A **connector** is an app that knows one external provider (a PIM, a content network, a shop
|
|
4
|
-
platform…). It is installed on a collection like any app, versioned and released like any app, and
|
|
4
|
+
platform, a loyalty or CRM system…). It is installed on a collection like any app, versioned and released like any app, and
|
|
5
5
|
it adds a manifest `connector` block plus a handful of [server functions](server-functions.md) the
|
|
6
6
|
integration engine and the integrations console call by convention.
|
|
7
7
|
|
|
@@ -83,7 +83,7 @@ Types: `AppConnectorDeclaration` and friends in `@proveanything/smartlinks` (`sr
|
|
|
83
83
|
| `provider` | Stable provider key (`syndigo`, `oneworldsync`). |
|
|
84
84
|
| `title` | Provider display name; defaults to the app name. |
|
|
85
85
|
| `directions` | `inbound` (provider → SmartLinks), `outbound` (SmartLinks → provider), or both. |
|
|
86
|
-
| `entities` | SmartLinks entities it maps
|
|
86
|
+
| `entities` | SmartLinks entities it maps: `product`, and for people-shaped providers `interaction`, `contact`, `event` (see [Loyalty and CRM connectors](#loyalty-and-crm-connectors)). |
|
|
87
87
|
| `connection.fields[]` | The console's **Connect** form. A field with `secret` is stored as this app's secret of that name on the collection (write-only; never returned to the browser). Other fields are saved in the installation's connection settings. |
|
|
88
88
|
| `settings` | JSON Schema for installation settings; the console renders it as a form. |
|
|
89
89
|
| `presets[]` | Ready-made flows ("Products → provider"). A preset's `flow.config.fieldMappings` is a **suggested** mapping: the connector's knowledge of the provider, which the customer accepts or edits in core. |
|
|
@@ -91,7 +91,8 @@ Types: `AppConnectorDeclaration` and friends in `@proveanything/smartlinks` (`sr
|
|
|
91
91
|
| `panels[]` | Provider-specific screens the console mounts (an API explorer, a status page). |
|
|
92
92
|
| `aiGuide` | A guide the mapping assistant reads: the provider's quirks, required fields, good defaults. |
|
|
93
93
|
| `recordId` | Path of the provider's own id in a fetched record (e.g. `gtin`). Inbound records are landed and matched by it, so a re-import updates the same product instead of creating another. Default `id`; a flow can override it (`config.upsert.externalIdPath`). |
|
|
94
|
-
| `limits` | `{ requestsPerSecond }` toward the provider, enforced across every SmartLinks worker. |
|
|
94
|
+
| `limits` | `{ requestsPerSecond }` toward the provider, enforced across every SmartLinks worker; `{ maxEvents, maxAttributes }` when the provider caps registered events — a flow's `eventMapping` is checked against them when saved. |
|
|
95
|
+
| `actions[]` | Provider operations invoked on demand (redeem, enrol, issue…): name, title, function, `visibility`, input schema. See [Actions](#actions-provider-operations-on-demand). |
|
|
95
96
|
|
|
96
97
|
---
|
|
97
98
|
|
|
@@ -111,7 +112,9 @@ declare the provider's hosts (`network:<host>`) and the secrets it reads (`secre
|
|
|
111
112
|
| `fetch` | Every inbound run | `ConnectorFetchInput` `{ installation, cursor, limit }` | `ConnectorRecords` `{ records, nextCursor }`: one page per call |
|
|
112
113
|
| `shape` | Every inbound run (and sample dry runs) | `ConnectorShapeInput` `{ installation, records }` | `ConnectorShapeResult` `{ documents, skipped }`: one provider-neutral document per record, same order; `null` skips one |
|
|
113
114
|
| `serialize` | Every outbound run | `ConnectorSerializeInput` `{ installation, documents, entities, targetOptions, eventType? }`: documents core mapped to `describeTarget` paths; `entities` = the SmartLinks record each came from (id, name); `targetOptions` = per-field options the mapping carries (e.g. locale, unit); a deletion arrives as `{ id, _deleted: true }` | `ConnectorSerializeResult` `{ payloads, skipped }`: one provider payload per document, same order; `null` skips one |
|
|
114
|
-
| `send` | Every outbound run | `ConnectorSendInput` `{ installation, payloads }` | `ConnectorSendResult` `{ results: [{ index, ok, status, error, externalId }] }` |
|
|
115
|
+
| `send` | Every outbound run | `ConnectorSendInput` `{ installation, payloads, eventType? }` | `ConnectorSendResult` `{ results: [{ index, ok, status, error, externalId, retryable?, retryAfterSeconds? }] }` — `retryable: false` for a provider validation error (dead at once), `true` / a 5xx or 429 status for anything worth retrying |
|
|
116
|
+
| `describeEvents` | Mapper opens; a flow with an `eventMapping` is saved | `{ installation }` | `ConnectorEventsSchema` `{ events: [{ name, title, attributes: [{ name, type, required }] }], limits: { maxEvents, maxAttributes } }`: the event names the provider has registered for this customer |
|
|
117
|
+
| `lookup` | An entitlement check (`docs/entitlements.md`) | `ConnectorLookupInput` `{ installation, identity: { externalId, email, phone } \| { externalId, emailHash, phoneHash }, want }` | `ConnectorLookupResult` `{ found, memberId, tier, points, status, attributes, asOf }`. Throw for an outage — never `found: false` |
|
|
115
118
|
|
|
116
119
|
**How a run flows:**
|
|
117
120
|
- **Inbound:** `fetch` (paged; every record is landed as received) → `shape` → core maps the documents
|
|
@@ -182,6 +185,96 @@ export async function shape(_ctx: any, event: any): Promise<ConnectorShapeResult
|
|
|
182
185
|
|
|
183
186
|
---
|
|
184
187
|
|
|
188
|
+
## Loyalty and CRM connectors
|
|
189
|
+
|
|
190
|
+
A provider that is about **people** rather than products uses the same contract with three more
|
|
191
|
+
pieces; nothing provider-specific lives in core. Full contract: `loyalty-connector-authoring.md` in the
|
|
192
|
+
platform's design docs; the shapes are in [integrations.md](integrations.md#event-sourced-flows-and-the-envelope).
|
|
193
|
+
|
|
194
|
+
| Flow | What core does | What the connector does |
|
|
195
|
+
|---|---|---|
|
|
196
|
+
| **Earn** (us → them) | an outbound flow with `sourceEntity: 'interaction' \| 'contact' \| 'event'` sends one **envelope** per event, through the flow's identity policy and `eventMapping`, signed, with retries and a run log | `describeEvents` (what the provider has registered), `serialize` (envelope → the provider's event payload), `send` if the generic HTTP destination can't make the call |
|
|
197
|
+
| **Profile** (them → us) | `ctx.sl.members.apply(document)` matches the contact and writes member id, tier, points, tags, external ids; or an inbound flow with `targetEntity: 'contact'` | an **HTTP-trigger function** receiving the provider's member webhook (verify their signature, then apply); or `fetch` + `shape` for a poll |
|
|
198
|
+
| **Gate / display** (on demand) | `entitlements.check` — claims → cached `lookup` → the contact's own loyalty fields → fallback; Valkey cache keyed on an identity hash, brand-set TTL | `lookup`: one identity → tier / points / status |
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
// A member webhook: the provider tells us about a person; we land it on the contact.
|
|
202
|
+
export default async function memberWebhook(event: any, ctx: any) {
|
|
203
|
+
verifyProviderSignature(event, await ctx.secrets.get('webhookSecret'))
|
|
204
|
+
const m = event.body
|
|
205
|
+
return ctx.sl.members.apply({
|
|
206
|
+
identity: { externalId: m.memberId, email: m.email },
|
|
207
|
+
contact: { firstName: m.firstName, lastName: m.lastName }, // fills empty fields only
|
|
208
|
+
loyalty: { memberId: m.memberId, tier: m.tier, points: m.points, status: m.status, asOf: m.updatedAt },
|
|
209
|
+
tags: { add: [`tier:${m.tier}`] },
|
|
210
|
+
}, { provider: 'acme-loyalty' }) // → { contactId, op: 'created' | 'updated' | 'unchanged' }
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Declare it `{ "trigger": { "type": "http" }, "capabilities": ["sl:members:write", "secrets:webhookSecret"] }`;
|
|
215
|
+
`sl:members:write` is approved by the admin on install. The envelope's `identity.externalIds[<provider>]`
|
|
216
|
+
is the member id this wrote back, so **Earn** can address the member by the provider's own id.
|
|
217
|
+
|
|
218
|
+
A connector should ship an `eventMapping` **preset** with the provider's standard event names and an
|
|
219
|
+
`aiGuide` paragraph, so the console's assistant proposes a customer's mapping in the provider's terms.
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Actions: provider operations on demand
|
|
224
|
+
|
|
225
|
+
Steps are called by the engine. **Actions** are called when someone asks: redeem a reward, enrol a
|
|
226
|
+
member, issue a coupon, raise a ticket, send a receipt, check a balance. A connector declares them in
|
|
227
|
+
the manifest and implements each as a server function; the platform decides who may call them and
|
|
228
|
+
runs them with the connector's credentials, telling the function who asked.
|
|
229
|
+
|
|
230
|
+
```jsonc
|
|
231
|
+
"connector": {
|
|
232
|
+
"actions": [
|
|
233
|
+
{ "name": "redeem", "title": "Redeem a reward", "function": "redeemReward", "visibility": "member",
|
|
234
|
+
"input": { "type": "object", "required": ["rewardId"], "properties": { "rewardId": { "type": "string" } } } },
|
|
235
|
+
{ "name": "enrol", "title": "Join the programme", "function": "enrolMember", "visibility": "member" },
|
|
236
|
+
{ "name": "coupon-status", "title": "Coupon status", "function": "couponStatus", "visibility": "public" },
|
|
237
|
+
{ "name": "adjust-points", "title": "Adjust points", "function": "adjustPoints" } // admin only (the default)
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
| `visibility` | Who may invoke it |
|
|
243
|
+
|---|---|
|
|
244
|
+
| `admin` (default) | the console and admin API; any app function |
|
|
245
|
+
| `member` | also a signed-in person through the Hub / a site |
|
|
246
|
+
| `public` | also anyone |
|
|
247
|
+
|
|
248
|
+
The function receives `event.body = { input, installation, caller: { userId, contactId, role, surface } }`
|
|
249
|
+
and returns JSON (or a `Response`). `input.required` fields from the declared schema are checked before
|
|
250
|
+
the function runs (400 with `missing[]`); fuller validation is the connector's job.
|
|
251
|
+
|
|
252
|
+
```ts
|
|
253
|
+
export async function redeemReward(ctx: any, event: any) {
|
|
254
|
+
const { input, caller } = event.body
|
|
255
|
+
if (!caller.contactId) return new Response(JSON.stringify({ error: 'no_contact' }), { status: 400 })
|
|
256
|
+
const memberId = (await ctx.sl.contacts.forCaller())?.customFields?.loyaltyMemberId // written by Profile
|
|
257
|
+
const res = await ctx.fetch(`${api}/members/${memberId}/redemptions`, { method: 'POST', headers: auth(await ctx.secrets.get('apiKey')), body: JSON.stringify({ reward: input.rewardId }) })
|
|
258
|
+
return res.json()
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Calling an action:
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
// From the Hub or a site (visibility public / member):
|
|
266
|
+
const { actions } = await integrations.listConnectorActions(collectionId, 'acme-loyalty')
|
|
267
|
+
const out = await integrations.callConnectorAction(collectionId, 'acme-loyalty', 'redeem', { rewardId: 'R-5' })
|
|
268
|
+
|
|
269
|
+
// From another app's server function (any visibility; needs sl:connectors:write):
|
|
270
|
+
const out = await ctx.sl.connectors.call('acme-loyalty', 'redeem', { rewardId: 'R-5' })
|
|
271
|
+
|
|
272
|
+
// From the console (any visibility):
|
|
273
|
+
await integrations.runConnectorAction(collectionId, 'acme-loyalty', 'adjust-points', { memberId, delta: 100 })
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
185
278
|
## Where configuration lives
|
|
186
279
|
|
|
187
280
|
| What | Where |
|
|
@@ -220,6 +313,7 @@ await secrets.put(collectionId, 'provider-key', value, { appId }) /
|
|
|
220
313
|
await integrations.saveConnectorInstallation(collectionId, appId, { connection: { environment: 'production' } })
|
|
221
314
|
const test = await integrations.runConnectorStep(collectionId, appId, 'testConnection')
|
|
222
315
|
const target = await integrations.runConnectorStep(collectionId, appId, 'describeTarget')
|
|
316
|
+
const events = await integrations.runConnectorStep(collectionId, appId, 'describeEvents') // loyalty / engagement providers
|
|
223
317
|
const { records } = await integrations.runConnectorStep(collectionId, appId, 'sample', { limit: 5 })
|
|
224
318
|
const shaped = await integrations.runConnectorStep(collectionId, appId, 'shape', { records }) // dry run
|
|
225
319
|
const wire = await integrations.runConnectorStep(collectionId, appId, 'serialize', { documents }) // dry run
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Entitlements: "can this person do this?" without a mirror of their member base
|
|
2
|
+
|
|
3
|
+
A brand with twenty million members wants a game only Gold members can play. SmartLinks never copies
|
|
4
|
+
the member base to find out. A **gate** says what it needs — a predicate such as `tier>=gold` — and the
|
|
5
|
+
platform asks the collection's configured **sources**, in order, stopping at the first that answers.
|
|
6
|
+
The brand's system stays the record of truth; every answer says where it came from (`basis`) and how
|
|
7
|
+
old it is (`asOf`).
|
|
8
|
+
|
|
9
|
+
| Source | Data kept here | When it fits |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| **claims** | none | the brand's SSO or app issues a short-lived signed token carrying the tier; the caller presents it |
|
|
12
|
+
| **lookup** | a hashed key → a small answer, for minutes | the loyalty connector's `lookup` step answers for one person; cached in Valkey under an HMAC of the identity for the TTL the brand sets (default 15 min; "not a member" 5 min); one in-flight lookup per key; the connector's own rate limit applies |
|
|
13
|
+
| **contact** | what the contact already holds | `customFields.loyalty` / `loyaltyTier` written by the connector's member webhook (`ctx.sl.members.apply`) |
|
|
14
|
+
| **fallback** | — | when nothing answered: `deny` (default), `allow`, or `degrade` (allow, flagged `degraded: true`) |
|
|
15
|
+
|
|
16
|
+
Every decision is one structured log line — gate, predicate, allowed, basis, age, an identity **hash**
|
|
17
|
+
— and never an identifier. A caller sees `attributes` (tier, points, status, member) and never a member
|
|
18
|
+
id.
|
|
19
|
+
|
|
20
|
+
## Predicates
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
'tier>=gold' 'tier=silver' 'tier in gold,platinum' 'points>=500' 'member'
|
|
24
|
+
{ tier: { gte: 'gold' } } { tier: { in: ['gold', 'platinum'] } } { member: true }
|
|
25
|
+
{ attribute: { path: 'status', eq: 'active' } }
|
|
26
|
+
{ all: [p1, p2] } { any: [p1, p2] } { not: p }
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Tier comparisons use the collection's ordered `tiers` list (lowest first); a tier the list doesn't know
|
|
30
|
+
never satisfies an ordered comparison. A malformed predicate is a configuration error (`BAD_PREDICATE`),
|
|
31
|
+
never a silent denial.
|
|
32
|
+
|
|
33
|
+
## Where gates live
|
|
34
|
+
|
|
35
|
+
**An interaction type** — the public submit route checks it; the caller may present a claim:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
await SL.interactions.updateInteraction(collectionId, appId, typeId, {
|
|
39
|
+
permissions: { allowPublicSubmit: true, requires: { entitlement: 'tier>=gold', fallback: 'deny' } },
|
|
40
|
+
})
|
|
41
|
+
// A refused submit: 403 { error: 'FORBIDDEN', reason: 'entitlement_denied' }
|
|
42
|
+
// With a claim: body.entitlementToken = '<jwt>' or header X-SmartLinks-Entitlement: <jwt>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**A server function** — for the signed-in caller by default:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
const d = await ctx.sl.entitlements.check('tier>=gold') // needs sl:entitlements:read
|
|
49
|
+
// → { allowed: true, basis: 'lookup-cache', asOf: '2026-11-08T09:00:00.000Z', attributes: { tier: 'gold', points: 1500, member: true } }
|
|
50
|
+
if (!d.allowed) return new Response(JSON.stringify({ error: 'gold_only' }), { status: 403 })
|
|
51
|
+
// Someone else, or a presented claim:
|
|
52
|
+
await ctx.sl.entitlements.check({ points: { gte: 500 } }, { identity: { email }, token, fallback: 'degrade' })
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Configuring a collection
|
|
56
|
+
|
|
57
|
+
The `entitlements` setting group (`settings.set(collectionId, 'entitlements', {...})`):
|
|
58
|
+
|
|
59
|
+
```jsonc
|
|
60
|
+
{
|
|
61
|
+
"sources": ["claims", "lookup", "contact"], // tried in this order
|
|
62
|
+
"fallback": "deny",
|
|
63
|
+
"tiers": ["bronze", "silver", "gold", "platinum"], // lowest first
|
|
64
|
+
"claims": {
|
|
65
|
+
"secretRef": "sec_brand_sso", // HS256 shared secret in the secret store …
|
|
66
|
+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----…", // … or an RS256 / ES256 public key
|
|
67
|
+
"issuer": "https://login.brand.example", "audience": "smartlinks",
|
|
68
|
+
"tierClaim": "tier", "memberIdClaim": "sub", "attributesClaim": "entitlements", "maxAgeSec": 900
|
|
69
|
+
},
|
|
70
|
+
"lookup": {
|
|
71
|
+
"connectorAppId": "acme-loyalty", "provider": "acme-loyalty",
|
|
72
|
+
"ttlSec": 900, "negativeTtlSec": 300,
|
|
73
|
+
"identity": "raw", // what the connector's lookup receives: 'raw' (email/phone) or 'hashed'
|
|
74
|
+
"want": ["tier", "points", "status"]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The connector side (`lookup`) is one step: one identity in, `{ found, memberId, tier, points, status,
|
|
80
|
+
asOf }` out; throw on an outage so the next source is tried — see
|
|
81
|
+
[connectors.md](connectors.md#loyalty-and-crm-connectors).
|
|
82
|
+
|
|
83
|
+
## What a brand can be told
|
|
84
|
+
|
|
85
|
+
- We never need a copy of your member base: claims and lookups hold nothing, or a minutes-old answer per
|
|
86
|
+
active person.
|
|
87
|
+
- Where you want a local copy, it holds no identifiers (the HMAC mirror — on request).
|
|
88
|
+
- Your system remains the record of truth: every answer carries `asOf` and `basis`; TTLs are yours to set.
|
|
89
|
+
- You see every call: the connector's calls are rate-limited, logged, and leave from a fixed egress IP.
|
|
90
|
+
- Nothing leaves without a policy: the envelope's identity policy per flow.
|
package/docs/integrations.md
CHANGED
|
@@ -3,16 +3,18 @@
|
|
|
3
3
|
An **integration flow** is one input/output pipeline between SmartLinks and an external
|
|
4
4
|
system. There are two directions:
|
|
5
5
|
|
|
6
|
-
- **outbound** — read a SmartLinks
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
- **outbound** — read a SmartLinks **product** that changed, or **one event** (an interaction, a
|
|
7
|
+
contact change, a tag scan — any spine event) as the [envelope](#event-sourced-flows-and-the-envelope),
|
|
8
|
+
transform it with field mappings, and send it to an external endpoint (signed, if you want).
|
|
9
|
+
- **inbound** — fetch from an external system and write a SmartLinks **product** or **contact**
|
|
10
|
+
(a provider's view of a person: member id, tier, points — see [Contact as a target](#contact-as-a-target)).
|
|
10
11
|
|
|
11
12
|
Flows are triggered three ways, all converging on the same executor:
|
|
12
13
|
|
|
13
14
|
- **manual** — `integrations.runFlow(...)`, inline (returns a run summary) or enqueued.
|
|
14
|
-
- **event** — an outbound flow subscribed to an event type (e.g. `product.updated
|
|
15
|
-
automatically when
|
|
15
|
+
- **event** — an outbound flow subscribed to an event type (e.g. `product.updated`,
|
|
16
|
+
`interaction.submitted`, `contact.*`, `tag.scanned`, `*`) fires automatically when it happens. See
|
|
17
|
+
[Event names and patterns](#event-names-and-patterns).
|
|
16
18
|
- **schedule** — a flow carrying a cron/interval `schedule` is run by the scan job. *(next)*
|
|
17
19
|
|
|
18
20
|
Provider-specific logic (a provider's payload format, its API, its connect form) lives in a
|
|
@@ -52,17 +54,21 @@ interface IntegrationFlow {
|
|
|
52
54
|
direction: 'inbound' | 'outbound'
|
|
53
55
|
name: string
|
|
54
56
|
status: 'draft' | 'active' | 'paused' | 'error' // only 'active' flows fire on events/schedule
|
|
55
|
-
eventTypes: string[] // e.g. ['product.updated']
|
|
57
|
+
eventTypes: string[] // e.g. ['product.updated'], ['interaction.*'], ['*']
|
|
56
58
|
schedule: string | null // cron/interval for scheduled flows
|
|
57
|
-
sourceEntity:
|
|
58
|
-
targetEntity:
|
|
59
|
+
sourceEntity: 'product' | 'interaction' | 'contact' | 'event' | null // outbound: what it reads
|
|
60
|
+
targetEntity: 'product' | 'contact' | null // inbound: what it writes
|
|
59
61
|
config: {
|
|
60
62
|
connection?: {
|
|
61
63
|
baseUrl?: string
|
|
62
64
|
sendEndpoint?: string // outbound: appended to baseUrl
|
|
63
65
|
defaultHeaders?: Record<string, string>
|
|
64
66
|
auth?: { method: 'api_key' | 'bearer' | 'basic' | ..., headerName?: string, credentialRef?: string }
|
|
67
|
+
timeoutMs?: number
|
|
65
68
|
}
|
|
69
|
+
signing?: { credentialRef: string, previousCredentialRef?: string } // X-SmartLinks-Signature (below)
|
|
70
|
+
identity?: { policy?: 'externalIds' | 'hashed' | 'raw', hashKeyCredentialRef?: string } // event-sourced flows
|
|
71
|
+
eventMapping?: EventMapping // event-sourced flows: many events → the provider's few
|
|
66
72
|
fieldMappings?: FieldMapping[]
|
|
67
73
|
}
|
|
68
74
|
// ...run watermark/telemetry: lastRunAt, lastRunStatus, lastRunCount, totalSynced
|
|
@@ -85,6 +91,158 @@ aborts the whole record.
|
|
|
85
91
|
|
|
86
92
|
---
|
|
87
93
|
|
|
94
|
+
## Event names and patterns
|
|
95
|
+
|
|
96
|
+
A flow's `eventTypes` (and a server function's `trigger.eventTypes`) name events exactly or by prefix:
|
|
97
|
+
|
|
98
|
+
| Subscription | Matches |
|
|
99
|
+
|---|---|
|
|
100
|
+
| `product.updated` | exactly that |
|
|
101
|
+
| `interaction.submitted:<typeId>` | one interaction type's submissions |
|
|
102
|
+
| `interaction.*` | every interaction event |
|
|
103
|
+
| `record.updated:*` | record updates of any type |
|
|
104
|
+
| `*` | everything in the collection — a raw event stream |
|
|
105
|
+
|
|
106
|
+
Events on the spine today: `product.created / updated / deleted`, `record.<verb>[:<recordType>]`,
|
|
107
|
+
`interaction.submitted[:<typeId>]`, `contact.created / updated / deleted / erased`,
|
|
108
|
+
`tag.scanned[:<eventType>]` (a scan resolves in the redirect, before any page could run a tag),
|
|
109
|
+
`proof.created / transferred`, `attestation.created[:type]`, `booking.*`, `slot.*`.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Event-sourced flows and the envelope
|
|
114
|
+
|
|
115
|
+
A flow with `sourceEntity: 'interaction' | 'contact' | 'event'` sends **one event per run** — not a
|
|
116
|
+
product. Every such event is wrapped in the same **envelope**, whatever the destination, and only then
|
|
117
|
+
mapped with the flow's field mappings (or handed to a connector's `serialize`):
|
|
118
|
+
|
|
119
|
+
```jsonc
|
|
120
|
+
{
|
|
121
|
+
"specVersion": 1, // bumped only when a consumer could break
|
|
122
|
+
"id": "0b2b…", // the event's id — stable across retries; use it as the destination's idempotency / transaction id
|
|
123
|
+
"type": "interaction.submitted:quiz-1",
|
|
124
|
+
"entityType": "interaction", "entityId": "0b2b…",
|
|
125
|
+
"occurredAt": "2026-11-08T10:00:00.000Z",
|
|
126
|
+
"collectionId": "…", "orgId": "…", "appId": "quiz",
|
|
127
|
+
"identity": {
|
|
128
|
+
"contactId": "…", "userId": "…",
|
|
129
|
+
"externalIds": { "acme-loyalty": "M-9", "crm": "C-1" }, // ids other systems know this person by
|
|
130
|
+
"anonymousId": "v-77", "sessionId": "s-1", // the visitor / device and session, before anyone signed in (every policy)
|
|
131
|
+
"emailHash": "…", "phoneHash": "…", "hashAlgorithm": "hmac-sha256" // policy 'hashed' (default)
|
|
132
|
+
// "email", "phone": only under policy 'raw'
|
|
133
|
+
},
|
|
134
|
+
"identityPolicy": "hashed",
|
|
135
|
+
"product": { "id": "P1", "name": "Widget", "sku": "W-1", "gtin": "0500…", "variantId": null, "batchId": null },
|
|
136
|
+
"proof": { "id": "…" },
|
|
137
|
+
"consent": { "channels": { "email": "opted_in", "sms": "suppressed", "push": "unknown", "whatsapp": "unknown" }, "topics": { "offers": true }, "updatedAt": "…" }, // null when about nobody we hold
|
|
138
|
+
"subject": { "interactionId": "quiz-1", "outcome": "completed", "metadata": { "score": 9 }, "source": "hub" },
|
|
139
|
+
"event": { "name": "engagement_completed", "attributes": { "kind": "quiz", "score": 9 }, "rule": "quiz" }, // from eventMapping
|
|
140
|
+
"attributes": {}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Field mappings read envelope paths (`identity.externalIds.acme-loyalty`, `subject.outcome`,
|
|
145
|
+
`event.name`, `product.sku`). With no mappings the envelope itself is sent. A failed event delivery
|
|
146
|
+
keeps its envelope and is retried from it; a product is re-read instead.
|
|
147
|
+
|
|
148
|
+
**CloudEvents.** `config.envelopeFormat: 'cloudevents'` wraps each delivered body (mapped or not) as a
|
|
149
|
+
CloudEvents 1.0 structured event — `{ specversion: '1.0', id, type, source: 'urn:smartlinks:collection:<id>',
|
|
150
|
+
subject, time, datacontenttype, dataschema: 'urn:smartlinks:envelope:v1', data }` — the shape every event
|
|
151
|
+
bus, lake and serverless tool already consumes.
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
const flow = await integrations.createFlow(collectionId, {
|
|
155
|
+
appId: 'core-integrations', direction: 'outbound', name: 'Engagement → loyalty', status: 'active',
|
|
156
|
+
eventTypes: ['interaction.*', 'tag.scanned:*'],
|
|
157
|
+
sourceEntity: 'event',
|
|
158
|
+
config: {
|
|
159
|
+
connection: { baseUrl: 'https://api.acme.example', sendEndpoint: '/events', auth: { method: 'bearer', credentialRef: ref } },
|
|
160
|
+
signing: { credentialRef: signingRef },
|
|
161
|
+
identity: { policy: 'hashed' },
|
|
162
|
+
eventMapping: {
|
|
163
|
+
rules: [
|
|
164
|
+
{ id: 'quiz', match: { interactionIds: ['quiz-1'], outcomes: ['completed'] }, event: 'engagement_completed',
|
|
165
|
+
attributes: { kind: 'quiz', score: '{{ subject.metadata.score }}', sku: { path: 'product.sku' } } },
|
|
166
|
+
{ id: 'scan', match: { types: ['tag.scanned:*'] }, event: 'pack_scanned', attributes: { sku: { path: 'product.sku' } } },
|
|
167
|
+
],
|
|
168
|
+
unmatched: 'skip',
|
|
169
|
+
},
|
|
170
|
+
fieldMappings: [
|
|
171
|
+
{ targetPath: 'event_name', sourcePath: 'event.name', transformType: 'direct' },
|
|
172
|
+
{ targetPath: 'external_id', sourcePath: 'identity.externalIds.acme-loyalty', transformType: 'direct' },
|
|
173
|
+
{ targetPath: 'transaction_id', sourcePath: 'id', transformType: 'direct' },
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
})
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Identity policy
|
|
180
|
+
|
|
181
|
+
`config.identity.policy` decides what about the person leaves the platform:
|
|
182
|
+
|
|
183
|
+
| Policy | The envelope's `identity` carries |
|
|
184
|
+
|---|---|
|
|
185
|
+
| `externalIds` | `contactId`, `userId`, `externalIds` — nothing else |
|
|
186
|
+
| `hashed` (default) | the above plus `emailHash` / `phoneHash`: HMAC-SHA256 with a **per-collection** key, or the brand's own key when `identity.hashKeyCredentialRef` names one (so hashes match a mirror the brand built) |
|
|
187
|
+
| `raw` | the above plus `email` and `phone` |
|
|
188
|
+
|
|
189
|
+
No hash key configured on the server → no hashes, never an unkeyed hash.
|
|
190
|
+
|
|
191
|
+
### Event mapping
|
|
192
|
+
|
|
193
|
+
Loyalty and engagement platforms accept a small, pre-registered set of event names. `config.eventMapping`
|
|
194
|
+
folds our many interaction types into those names: rules in order, first match wins; `match` may name
|
|
195
|
+
`types` (exact or patterns), `interactionIds`, `outcomes`, `appIds`; attributes are literals, Liquid
|
|
196
|
+
templates over the envelope, or `{ path, default }`. Unmatched events are skipped (and shown as skipped
|
|
197
|
+
in the run) unless `unmatched: 'passthrough'`. When the flow has a connector with a `describeEvents`
|
|
198
|
+
step, the mapping is **validated when saved** against the provider's registered events and its
|
|
199
|
+
`limits` (`maxEvents`, `maxAttributes`): `createFlow` / `updateFlow` answer `400 EVENT_MAPPING_INVALID`
|
|
200
|
+
with `problems[]`.
|
|
201
|
+
|
|
202
|
+
### Signed deliveries
|
|
203
|
+
|
|
204
|
+
With `config.signing.credentialRef`, every HTTP delivery carries:
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
X-SmartLinks-Signature: t=1730900000,v1=<hex HMAC-SHA256(secret, `${t}.${rawBody}`)>
|
|
208
|
+
X-SmartLinks-Delivery: <uuid, new per attempt>
|
|
209
|
+
X-SmartLinks-Event: interaction.submitted:quiz-1
|
|
210
|
+
X-SmartLinks-Run: <run id>
|
|
211
|
+
Idempotency-Key: <flowId>:<eventId>:<hash of the body>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
The signature covers the exact bytes of the body. A receiver recomputes it, compares in constant time,
|
|
215
|
+
and rejects `t` older than about five minutes. During a rotation `previousCredentialRef` adds a second
|
|
216
|
+
`v1=` so a receiver that knows either secret verifies.
|
|
217
|
+
|
|
218
|
+
Destinations must be **public hosts**: loopback, private ranges and cloud metadata addresses are
|
|
219
|
+
refused as a permanent failure. (Local development: `INTEGRATION_ALLOW_PRIVATE_DESTINATIONS=1` on the
|
|
220
|
+
server.)
|
|
221
|
+
|
|
222
|
+
### Contact as a target
|
|
223
|
+
|
|
224
|
+
An inbound flow with `targetEntity: 'contact'` writes a provider's view of a person. After the
|
|
225
|
+
connector's `shape` (or your field mappings) each record is a **member document**:
|
|
226
|
+
|
|
227
|
+
```jsonc
|
|
228
|
+
{
|
|
229
|
+
"identity": { "externalId": "M-9", "email": "ada@example.com" }, // contactId | externalId | email | phone — at least one
|
|
230
|
+
"contact": { "firstName": "Ada", "lastName": "Lovelace" }, // fills EMPTY profile fields only
|
|
231
|
+
"externalIds": { "acme-crm": "C-1" }, // merged
|
|
232
|
+
"customFields": { "region": "UK" }, // merged (never `comms`)
|
|
233
|
+
"tags": { "add": ["gold"], "remove": ["silver"] },
|
|
234
|
+
"loyalty": { "memberId": "M-9", "tier": "gold", "points": 1500, "status": "active", "asOf": "…", "attributes": { "since": 2024 } }
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
Matching: `contactId` → `externalIds[<provider>]` → email → phone; a new contact is created once however
|
|
239
|
+
many workers see the same member. Loyalty lands as `customFields.loyalty` plus flat
|
|
240
|
+
`customFields.loyaltyTier / loyaltyPoints / loyaltyMemberId / loyaltyProvider` for segments and comms
|
|
241
|
+
targeting. The same document is what a server function applies with `ctx.sl.members.apply(...)` (a
|
|
242
|
+
provider's webhook, see [connectors.md](connectors.md#loyalty-and-crm-connectors)).
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
88
246
|
## Secrets (write-only)
|
|
89
247
|
|
|
90
248
|
The secret store is **write-only from the client**: you can set, rotate, list (refs +
|