@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/docs/loyalty.md CHANGED
@@ -302,6 +302,23 @@ A loyalty failure never causes the interaction event to fail — errors are caug
302
302
 
303
303
  ---
304
304
 
305
+ ## External loyalty platforms
306
+
307
+ The schemes above are SmartLinks' own points. When a brand runs its programme on an external loyalty or
308
+ engagement platform, the platform stays the record of truth and SmartLinks connects to it through a
309
+ **connector app** and the integration engine — no member base is mirrored here:
310
+
311
+ | Flow | How |
312
+ |---|---|
313
+ | **Earn** — what happens on a pack or in a Hub awards points there | an outbound flow with `sourceEntity: 'interaction' \| 'event'`, an `eventMapping` onto the provider's registered events, signed delivery, retries — [integrations.md](integrations.md#event-sourced-flows-and-the-envelope) |
314
+ | **Profile** — member id, tier and points on the contact | the connector's webhook function calls `ctx.sl.members.apply(...)`; the contact gets `customFields.loyalty` and flat `loyaltyTier / loyaltyPoints / loyaltyMemberId`, usable in segments and comms targeting — [connectors.md](connectors.md#loyalty-and-crm-connectors) |
315
+ | **Gate / display** — "Gold members only", live balance | the entitlement check, answered on demand from a signed claim, the connector's cached `lookup`, or the contact's fields — [entitlements.md](entitlements.md) |
316
+
317
+ A collection runs one loyalty source: the native schemes here, or an external provider through a
318
+ connector.
319
+
320
+ ---
321
+
305
322
  ## TypeScript Types
306
323
 
307
324
  ```typescript
@@ -517,6 +517,9 @@ Prefer the platform primitives above over a dependency; when you do need one, pi
517
517
  | Check a tapped tag is real | `ctx.sl.tags.resolve(proofId)` → `{ id, claimSetId, code }` or `null` | `sl:tags:read` |
518
518
  | Put a visitor's details on a contact | `ctx.sl.contacts.upsert({ email, firstName, … })` → `{ contactId, created }` (fills empty fields only) | `sl:contacts:write` |
519
519
  | Record "they did X" | `ctx.sl.interactions.record({ interactionId, contactId, outcome, metadata })` | `sl:interactions:write` |
520
+ | Land a loyalty / CRM provider's view of a person (member id, tier, points, tags, external ids) | `ctx.sl.members.apply({ identity, contact?, loyalty?, tags?, externalIds? }, { provider })` → `{ contactId, op }` — matches by id, external id, email or phone; profile fields fill-empty only; see [connectors.md](connectors.md#loyalty-and-crm-connectors) | `sl:members:write` |
521
+ | Invoke a connector's action — redeem, enrol, issue a coupon, raise a ticket — with the connector's credentials | `ctx.sl.connectors.call('acme-loyalty', 'redeem', { rewardId })` → the action's result; `ctx.sl.connectors.actions(appId)` lists them; see [connectors.md](connectors.md#actions-provider-operations-on-demand) | `sl:connectors:write` |
522
+ | Ask "is this person gold or above?" without holding their member record | `ctx.sl.entitlements.check('tier>=gold')` → `{ allowed, basis, asOf, attributes }` for the signed-in caller (or `{ identity, token, fallback }`); see [entitlements.md](entitlements.md) | `sl:entitlements:read` |
520
523
  | Take a booking with your own checks (hours, queue token, payment) | `ctx.sl.bookings.create({ slotId \| resource + time, contactId, status, idempotencyKey })` — never oversold, never double-booked; also `confirm` / `cancel` / `move` / `mine` / `freebusy` / `message` (everyone booked, hydrated) / `slots.*` / `blocks.*` (see [bookings.md](bookings.md)) | `sl:bookings:write` (`sl:bookings:read` to read) |
521
524
 
522
525
  Notes:
package/openapi.yaml CHANGED
@@ -21235,6 +21235,32 @@ components:
21235
21235
  - id
21236
21236
  - title
21237
21237
  - component
21238
+ ConnectorAction:
21239
+ type: object
21240
+ properties:
21241
+ name:
21242
+ type: string
21243
+ title:
21244
+ type: string
21245
+ description:
21246
+ type: string
21247
+ function:
21248
+ type: string
21249
+ visibility:
21250
+ type: string
21251
+ enum:
21252
+ - admin
21253
+ - member
21254
+ - public
21255
+ input:
21256
+ type: object
21257
+ additionalProperties: true
21258
+ output:
21259
+ type: object
21260
+ additionalProperties: true
21261
+ required:
21262
+ - name
21263
+ - function
21238
21264
  AppConnectorDeclaration:
21239
21265
  type: object
21240
21266
  properties:
@@ -21280,10 +21306,18 @@ components:
21280
21306
  type: string
21281
21307
  fetch:
21282
21308
  type: string
21309
+ describeEvents:
21310
+ type: string
21311
+ lookup:
21312
+ type: string
21283
21313
  panels:
21284
21314
  type: array
21285
21315
  items:
21286
21316
  $ref: "#/components/schemas/ConnectorPanel"
21317
+ actions:
21318
+ type: array
21319
+ items:
21320
+ $ref: "#/components/schemas/ConnectorAction"
21287
21321
  aiGuide:
21288
21322
  type: string
21289
21323
  recordId:
@@ -29014,9 +29048,52 @@ components:
29014
29048
  additionalProperties: true
29015
29049
  required:
29016
29050
  - appId
29051
+ EventMappingRule:
29052
+ type: object
29053
+ properties:
29054
+ id:
29055
+ type: string
29056
+ match:
29057
+ type: object
29058
+ additionalProperties: true
29059
+ event:
29060
+ type: string
29061
+ attributes:
29062
+ type: object
29063
+ additionalProperties:
29064
+ type: object
29065
+ additionalProperties: true
29066
+ required:
29067
+ - event
29068
+ EventMapping:
29069
+ type: object
29070
+ properties:
29071
+ rules:
29072
+ type: array
29073
+ items:
29074
+ $ref: "#/components/schemas/EventMappingRule"
29075
+ unmatched:
29076
+ type: string
29077
+ enum:
29078
+ - skip
29079
+ - passthrough
29080
+ required:
29081
+ - rules
29017
29082
  IntegrationFlowConfig:
29018
29083
  type: object
29019
29084
  properties:
29085
+ signing:
29086
+ type: object
29087
+ additionalProperties: true
29088
+ identity:
29089
+ type: object
29090
+ additionalProperties: true
29091
+ eventMapping:
29092
+ $ref: "#/components/schemas/EventMapping"
29093
+ envelopeFormat:
29094
+ type: string
29095
+ enum:
29096
+ - cloudevents
29020
29097
  connection:
29021
29098
  $ref: "#/components/schemas/FlowConnection"
29022
29099
  fieldMappings:
@@ -29049,9 +29126,11 @@ components:
29049
29126
  schedule:
29050
29127
  type: string
29051
29128
  sourceEntity:
29052
- type: string
29129
+ type: object
29130
+ additionalProperties: true
29053
29131
  targetEntity:
29054
- type: string
29132
+ type: object
29133
+ additionalProperties: true
29055
29134
  config:
29056
29135
  $ref: "#/components/schemas/IntegrationFlowConfig"
29057
29136
  createdBy:
@@ -29424,6 +29503,144 @@ components:
29424
29503
  settings:
29425
29504
  type: object
29426
29505
  additionalProperties: true
29506
+ ConnectorEventsSchema:
29507
+ type: object
29508
+ properties:
29509
+ events:
29510
+ type: array
29511
+ items:
29512
+ type: object
29513
+ additionalProperties: true
29514
+ limits:
29515
+ type: object
29516
+ additionalProperties: true
29517
+ required:
29518
+ - events
29519
+ ConnectorLookupInput:
29520
+ type: object
29521
+ properties:
29522
+ installation:
29523
+ $ref: "#/components/schemas/ConnectorInstallation"
29524
+ identity:
29525
+ type: object
29526
+ additionalProperties: true
29527
+ want:
29528
+ type: array
29529
+ items:
29530
+ type: string
29531
+ required:
29532
+ - installation
29533
+ - identity
29534
+ ConnectorLookupResult:
29535
+ type: object
29536
+ properties:
29537
+ found:
29538
+ type: boolean
29539
+ memberId:
29540
+ type: string
29541
+ tier:
29542
+ type: string
29543
+ points:
29544
+ type: number
29545
+ status:
29546
+ type: string
29547
+ attributes:
29548
+ type: object
29549
+ additionalProperties: true
29550
+ asOf:
29551
+ type: string
29552
+ required:
29553
+ - found
29554
+ EventEnvelope:
29555
+ type: object
29556
+ properties:
29557
+ specVersion:
29558
+ type: number
29559
+ id:
29560
+ type: string
29561
+ type:
29562
+ type: string
29563
+ entityType:
29564
+ type: string
29565
+ entityId:
29566
+ type: string
29567
+ occurredAt:
29568
+ type: string
29569
+ collectionId:
29570
+ type: string
29571
+ orgId:
29572
+ type: string
29573
+ appId:
29574
+ type: string
29575
+ identity:
29576
+ type: object
29577
+ additionalProperties: true
29578
+ contactId:
29579
+ type: string
29580
+ userId:
29581
+ type: string
29582
+ externalIds:
29583
+ type: object
29584
+ additionalProperties:
29585
+ type: string
29586
+ anonymousId:
29587
+ type: string
29588
+ sessionId:
29589
+ type: string
29590
+ emailHash:
29591
+ type: string
29592
+ phoneHash:
29593
+ type: string
29594
+ hashAlgorithm:
29595
+ type: string
29596
+ enum:
29597
+ - hmac-sha256
29598
+ email:
29599
+ type: string
29600
+ phone:
29601
+ type: string
29602
+ identityPolicy:
29603
+ $ref: "#/components/schemas/IdentityPolicy"
29604
+ product:
29605
+ type: object
29606
+ additionalProperties: true
29607
+ proof:
29608
+ type: object
29609
+ additionalProperties: true
29610
+ consent:
29611
+ type: object
29612
+ additionalProperties: true
29613
+ subject:
29614
+ type: object
29615
+ additionalProperties: true
29616
+ event:
29617
+ type: object
29618
+ additionalProperties: true
29619
+ attributes:
29620
+ type: object
29621
+ additionalProperties: true
29622
+ required:
29623
+ - specVersion
29624
+ - id
29625
+ - type
29626
+ - entityType
29627
+ - entityId
29628
+ - occurredAt
29629
+ - collectionId
29630
+ - orgId
29631
+ - appId
29632
+ - identity
29633
+ - contactId
29634
+ - userId
29635
+ - externalIds
29636
+ - anonymousId
29637
+ - sessionId
29638
+ - identityPolicy
29639
+ - product
29640
+ - proof
29641
+ - consent
29642
+ - subject
29643
+ - attributes
29427
29644
  CapturedRequest:
29428
29645
  type: object
29429
29646
  properties:
@@ -29763,6 +29980,24 @@ components:
29763
29980
  - webhook
29764
29981
  - oauth2
29765
29982
  - none
29983
+ IdentityPolicy:
29984
+ type: string
29985
+ enum:
29986
+ - externalIds
29987
+ - hashed
29988
+ - raw
29989
+ FlowSourceEntity:
29990
+ type: string
29991
+ enum:
29992
+ - product
29993
+ - interaction
29994
+ - contact
29995
+ - event
29996
+ FlowTargetEntity:
29997
+ type: string
29998
+ enum:
29999
+ - product
30000
+ - contact
29766
30001
  UpdateFlowInput:
29767
30002
  $ref: "#/components/schemas/CreateFlowInput"
29768
30003
  ConnectorConsoleStep:
@@ -29773,6 +30008,8 @@ components:
29773
30008
  - sample
29774
30009
  - shape
29775
30010
  - serialize
30011
+ - describeEvents
30012
+ - lookup
29776
30013
  RunTrigger:
29777
30014
  type: string
29778
30015
  enum:
package/package.json CHANGED
@@ -1,87 +1,87 @@
1
- {
2
- "name": "@proveanything/smartlinks",
3
- "version": "2.1.13",
4
- "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
- "type": "module",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js",
12
- "default": "./dist/index.js"
13
- },
14
- "./testing": {
15
- "types": "./dist/testing/index.d.ts",
16
- "import": "./dist/testing/index.js",
17
- "default": "./dist/testing/index.js"
18
- },
19
- "./*": {
20
- "types": "./dist/*.d.ts",
21
- "import": "./dist/*.js",
22
- "default": "./dist/*.js"
23
- },
24
- "./baseline.css": "./dist/baseline.css",
25
- "./baseline.classes.json": "./dist/baseline.classes.json",
26
- "./theme.css": "./dist/theme.css",
27
- "./theme-boot.js": "./dist/theme-boot.js",
28
- "./package.json": "./package.json"
29
- },
30
- "bin": {
31
- "smartlinks-register-release": "scripts/register-release.mjs",
32
- "smartlinks-publish": "scripts/publish.mjs",
33
- "smartlinks-doctor": "scripts/doctor.mjs",
34
- "smartlinks-headless": "scripts/headless-check.mjs"
35
- },
36
- "files": [
37
- "dist/",
38
- "docs/",
39
- "scripts/register-release.mjs",
40
- "scripts/publish.mjs",
41
- "scripts/doctor.mjs",
42
- "scripts/headless-check.mjs",
43
- "scripts/lib/",
44
- "openapi.yaml",
45
- "README.md"
46
- ],
47
- "scripts": {
48
- "test": "node test/run.cjs",
49
- "build": "tsc && node scripts/fix-esm-extensions.mjs && node generate-api-summary.cjs && node generate-openapi.cjs && node scripts/copy-docs-to-dist.cjs && node scripts/build-baseline.mjs",
50
- "docs": "typedoc",
51
- "docs:summary": "node generate-api-summary.cjs",
52
- "docs:openapi": "node generate-openapi.cjs",
53
- "docs:openapi:lint": "npx --yes @redocly/cli@latest lint openapi.yaml",
54
- "docs:openapi:check": "node generate-openapi.cjs && npx --yes @redocly/cli@latest lint openapi.yaml",
55
- "build:docs": "tsc build-docs.ts --outDir dist && node dist/build-docs.js",
56
- "prepublishOnly": "npm run build"
57
- },
58
- "keywords": [
59
- "smartlinks",
60
- "api",
61
- "authentication",
62
- "traceability",
63
- "blockchain",
64
- "typescript",
65
- "sdk"
66
- ],
67
- "author": "Glenn Shoosmith",
68
- "license": "MIT",
69
- "publishConfig": {
70
- "access": "public"
71
- },
72
- "dependencies": {
73
- "cross-fetch": "^3.1.5",
74
- "es-module-lexer": "^1.7.0"
75
- },
76
- "devDependencies": {
77
- "ts-node": "^10.9.1",
78
- "typedoc": "^0.25.13",
79
- "typedoc-plugin-markdown": "^3.17.1",
80
- "typescript": "^4.9.0"
81
- },
82
- "repository": {
83
- "type": "git",
84
- "url": "https://github.com/Prove-Anything/smartlinks.git"
85
- },
86
- "homepage": "https://smartlinks.app"
87
- }
1
+ {
2
+ "name": "@proveanything/smartlinks",
3
+ "version": "2.1.15",
4
+ "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./testing": {
15
+ "types": "./dist/testing/index.d.ts",
16
+ "import": "./dist/testing/index.js",
17
+ "default": "./dist/testing/index.js"
18
+ },
19
+ "./*": {
20
+ "types": "./dist/*.d.ts",
21
+ "import": "./dist/*.js",
22
+ "default": "./dist/*.js"
23
+ },
24
+ "./baseline.css": "./dist/baseline.css",
25
+ "./baseline.classes.json": "./dist/baseline.classes.json",
26
+ "./theme.css": "./dist/theme.css",
27
+ "./theme-boot.js": "./dist/theme-boot.js",
28
+ "./package.json": "./package.json"
29
+ },
30
+ "bin": {
31
+ "smartlinks-register-release": "scripts/register-release.mjs",
32
+ "smartlinks-publish": "scripts/publish.mjs",
33
+ "smartlinks-doctor": "scripts/doctor.mjs",
34
+ "smartlinks-headless": "scripts/headless-check.mjs"
35
+ },
36
+ "files": [
37
+ "dist/",
38
+ "docs/",
39
+ "scripts/register-release.mjs",
40
+ "scripts/publish.mjs",
41
+ "scripts/doctor.mjs",
42
+ "scripts/headless-check.mjs",
43
+ "scripts/lib/",
44
+ "openapi.yaml",
45
+ "README.md"
46
+ ],
47
+ "scripts": {
48
+ "test": "node test/run.cjs",
49
+ "build": "tsc && node scripts/fix-esm-extensions.mjs && node generate-api-summary.cjs && node generate-openapi.cjs && node scripts/copy-docs-to-dist.cjs && node scripts/build-baseline.mjs",
50
+ "docs": "typedoc",
51
+ "docs:summary": "node generate-api-summary.cjs",
52
+ "docs:openapi": "node generate-openapi.cjs",
53
+ "docs:openapi:lint": "npx --yes @redocly/cli@latest lint openapi.yaml",
54
+ "docs:openapi:check": "node generate-openapi.cjs && npx --yes @redocly/cli@latest lint openapi.yaml",
55
+ "build:docs": "tsc build-docs.ts --outDir dist && node dist/build-docs.js",
56
+ "prepublishOnly": "npm run build"
57
+ },
58
+ "keywords": [
59
+ "smartlinks",
60
+ "api",
61
+ "authentication",
62
+ "traceability",
63
+ "blockchain",
64
+ "typescript",
65
+ "sdk"
66
+ ],
67
+ "author": "Glenn Shoosmith",
68
+ "license": "MIT",
69
+ "publishConfig": {
70
+ "access": "public"
71
+ },
72
+ "dependencies": {
73
+ "cross-fetch": "^3.1.5",
74
+ "es-module-lexer": "^1.7.0"
75
+ },
76
+ "devDependencies": {
77
+ "ts-node": "^10.9.1",
78
+ "typedoc": "^0.25.13",
79
+ "typedoc-plugin-markdown": "^3.17.1",
80
+ "typescript": "^4.9.0"
81
+ },
82
+ "repository": {
83
+ "type": "git",
84
+ "url": "https://github.com/Prove-Anything/smartlinks.git"
85
+ },
86
+ "homepage": "https://smartlinks.app"
87
+ }