@itm-studio/partner-sdk 0.2.2 → 0.2.3

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/README.md CHANGED
@@ -369,6 +369,7 @@ Use OTP subscribe when you want the user to confirm the phone number before the
369
369
  - `listNames`: optional brand list names. Missing lists are created automatically and the subscribed user is attached to them.
370
370
  - `compliance`: optional metadata about how consent was collected. This is the right place for fields like `pageUrl`, `submissionMethod`, `submittedAt`, `timezone`, and geo/browser/device details.
371
371
  - `compliance.ipAddress` and `compliance.userAgent`: optional. If you omit them and forward `x-forwarded-for` and `user-agent`, the backend backfills those values for you.
372
+ - `postSubscriptionMessage`: optional welcome message delivered automatically after the subscription becomes active. See [Post-Subscription Welcome Message](#post-subscription-welcome-message).
372
373
 
373
374
  ### OTP Flow Step By Step
374
375
 
@@ -381,6 +382,63 @@ Use OTP subscribe when you want the user to confirm the phone number before the
381
382
 
382
383
  If the verification token is invalid or expired, verification fails and the subscription is not created.
383
384
 
385
+ ### Post-Subscription Welcome Message
386
+
387
+ `postSubscriptionMessage` lets you fan out a welcome touch across SMS, email, and push the moment a subscription becomes active. The backend dispatches each channel asynchronously after the subscription is created (direct mode) or verified (OTP mode), so the mutation still returns synchronously — delivery happens in the background.
388
+
389
+ **Channels are independent.** Provide any combination of `sms`, `email`, and `push`. Channels you omit are skipped.
390
+
391
+ ```typescript
392
+ await itm.mutation({
393
+ createPartnerBrandSubscription: {
394
+ __args: {
395
+ input: {
396
+ phoneNumber: '+14155550111',
397
+ fullName: 'Jane Doe',
398
+ email: 'jane@example.com',
399
+ postSubscriptionMessage: {
400
+ sms: {
401
+ body: 'Welcome to Acme — your first drop ships Friday. Reply STOP to opt out.',
402
+ mediaUrls: ['https://cdn.example.com/welcome-banner.png'],
403
+ },
404
+ email: {
405
+ subject: 'Welcome to Acme',
406
+ body: 'Hi Jane,\n\nThanks for subscribing — here is what to expect next...',
407
+ },
408
+ push: {
409
+ title: 'Welcome to Acme',
410
+ body: 'Tap to see what is dropping this week.',
411
+ },
412
+ },
413
+ },
414
+ },
415
+ verificationRequired: true,
416
+ subscription: { uid: true },
417
+ },
418
+ });
419
+ ```
420
+
421
+ **Channel inputs:**
422
+
423
+ | Channel | Required | Optional | Notes |
424
+ |---|---|---|---|
425
+ | `sms` | `body` | `mediaUrls` (string array of image URLs for MMS) | Delivered to `phoneNumber`. |
426
+ | `email` | `subject`, `body` | — | `body` is plain text or markdown, rendered via React Email. Skipped if the user has no primary email or the brand has no configured email alias. |
427
+ | `push` | `title`, `body` | — | Skipped if the user has no push tokens or has opted out of brand messages. |
428
+
429
+ **Delivery semantics:**
430
+
431
+ - The message is sent **at most once per active subscription period**. The backend uses an atomic per-channel claim plus an idempotency key on each underlying task, so retrying the mutation (for example after a transient network failure) will not duplicate sends.
432
+ - The message is delivered when the subscription is **newly created or reactivated** — re-subscribing an already-active user is a no-op.
433
+ - In OTP mode, the message fires **after** `verifyPartnerBrandSubscription` succeeds, not when the OTP is requested.
434
+ - Channel failures are isolated: if email cannot be sent because the user has no primary email, SMS and push are still attempted.
435
+
436
+ **Recommended usage:**
437
+
438
+ - Pass `postSubscriptionMessage` on the **first** `createPartnerBrandSubscription` call. In OTP mode, the message is buffered with the pending session and delivered after `verifyPartnerBrandSubscription`. You do **not** repeat it on the verify call.
439
+ - For a marketing-style first SMS, prefer including a clear opt-out instruction (e.g. `Reply STOP to opt out`) alongside any branded copy.
440
+ - For the email channel, your brand must have an email alias configured on the backend. Confirm this in backstage before relying on the email channel in production.
441
+
384
442
  ### `createPartnerBrandSubscription`
385
443
 
386
444
  Subscribe a phone number to the authenticated partner brand.
package/dist/index.d.mts CHANGED
@@ -795,6 +795,34 @@ interface SubscriptionComplianceInput {
795
795
  timezone?: (Scalars['String'] | null);
796
796
  userAgent?: (Scalars['String'] | null);
797
797
  }
798
+ interface PostSubscriptionSmsInput {
799
+ /** SMS message body delivered to the subscriber. */
800
+ body: Scalars['String'];
801
+ /** Optional MMS media URLs (image links) attached to the SMS. */
802
+ mediaUrls?: (Scalars['String'][] | null);
803
+ }
804
+ interface PostSubscriptionEmailInput {
805
+ /** Email subject line. */
806
+ subject: Scalars['String'];
807
+ /** Plain-text or markdown body. Rendered via React Email. */
808
+ body: Scalars['String'];
809
+ }
810
+ interface PostSubscriptionPushInput {
811
+ /** Push notification title. */
812
+ title: Scalars['String'];
813
+ /** Push notification body. */
814
+ body: Scalars['String'];
815
+ }
816
+ /**
817
+ * Welcome message delivered after a successful subscription. Each channel is independent —
818
+ * provide any combination of sms, email, and push. Channels with no input are skipped.
819
+ * The message is sent at most once per active subscription period (atomic per-channel claim).
820
+ */
821
+ interface PostSubscriptionMessageInput {
822
+ sms?: (PostSubscriptionSmsInput | null);
823
+ email?: (PostSubscriptionEmailInput | null);
824
+ push?: (PostSubscriptionPushInput | null);
825
+ }
798
826
  interface CreatePartnerBrandSubscriptionInput {
799
827
  compliance?: (SubscriptionComplianceInput | null);
800
828
  email?: (Scalars['String'] | null);
@@ -805,6 +833,13 @@ interface CreatePartnerBrandSubscriptionInput {
805
833
  /** E.164 phone number (for example +14155551234) */
806
834
  phoneNumber: Scalars['String'];
807
835
  requireOtpVerification?: (Scalars['Boolean'] | null);
836
+ /**
837
+ * Optional welcome message to deliver via the chosen channels. Sent at most once per active
838
+ * subscription period — safe to retry. Email requires the user to have a primary email and
839
+ * the brand to have a configured email alias. Push requires the user to have at least one
840
+ * push token and to not have opted out of brand messages.
841
+ */
842
+ postSubscriptionMessage?: (PostSubscriptionMessageInput | null);
808
843
  }
809
844
  interface VerifyPartnerBrandSubscriptionInput {
810
845
  code: Scalars['String'];
@@ -1009,4 +1044,4 @@ type ITMPartnerClient = Client;
1009
1044
  */
1010
1045
  declare function createITMPartnerClient(config: ITMPartnerClientConfig): ITMPartnerClient;
1011
1046
 
1012
- export { type BrandSubscription, type CreatePartnerBrandSubscriptionInput, type CreatePartnerBrandSubscriptionResponse, type CreatePartnerMomentInput, type CreatePartnerTicketTierInput, type Currency, DEFAULT_API_URL, type Dimensions, type DimensionsInput, type Echo, type EchoMediaAsset, type EchoType, type GetBrandEchoesForUserResponse, type GetPartnerCustomersResponse, type GetPublicMomentsResponse, type GetTicketsResponse, type ITMPartnerClient, type ITMPartnerClientConfig, type ITMPartnerHeaders, type ITMPartnerHeadersObject, type MediaAsset, type MediaAssetUploadUrl, type MerchPurchase, type Moment, type MomentCategory, type MomentCollection, type MomentCollectionLink, type MomentDiscountCodeUsage, type MomentSortOrder, type MomentStatus, type MomentSubcategory, type MomentType, type Mutation, type PartnerCustomer, type PartnerMomentStats, type Payment, type PaymentStatus, type Query, type SubscriptionComplianceInput, type ThirdPartyEchoType, type Ticket, type TicketExtension, type TicketExtensionStatus, type TicketTier, type User, type Venue, type VenueInput, type VerifyPartnerBrandSubscriptionInput, createITMPartnerClient, everything, generateMutationOp, generateQueryOp };
1047
+ export { type BrandSubscription, type CreatePartnerBrandSubscriptionInput, type CreatePartnerBrandSubscriptionResponse, type CreatePartnerMomentInput, type CreatePartnerTicketTierInput, type Currency, DEFAULT_API_URL, type Dimensions, type DimensionsInput, type Echo, type EchoMediaAsset, type EchoType, type GetBrandEchoesForUserResponse, type GetPartnerCustomersResponse, type GetPublicMomentsResponse, type GetTicketsResponse, type ITMPartnerClient, type ITMPartnerClientConfig, type ITMPartnerHeaders, type ITMPartnerHeadersObject, type MediaAsset, type MediaAssetUploadUrl, type MerchPurchase, type Moment, type MomentCategory, type MomentCollection, type MomentCollectionLink, type MomentDiscountCodeUsage, type MomentSortOrder, type MomentStatus, type MomentSubcategory, type MomentType, type Mutation, type PartnerCustomer, type PartnerMomentStats, type Payment, type PaymentStatus, type PostSubscriptionEmailInput, type PostSubscriptionMessageInput, type PostSubscriptionPushInput, type PostSubscriptionSmsInput, type Query, type SubscriptionComplianceInput, type ThirdPartyEchoType, type Ticket, type TicketExtension, type TicketExtensionStatus, type TicketTier, type User, type Venue, type VenueInput, type VerifyPartnerBrandSubscriptionInput, createITMPartnerClient, everything, generateMutationOp, generateQueryOp };
package/dist/index.d.ts CHANGED
@@ -795,6 +795,34 @@ interface SubscriptionComplianceInput {
795
795
  timezone?: (Scalars['String'] | null);
796
796
  userAgent?: (Scalars['String'] | null);
797
797
  }
798
+ interface PostSubscriptionSmsInput {
799
+ /** SMS message body delivered to the subscriber. */
800
+ body: Scalars['String'];
801
+ /** Optional MMS media URLs (image links) attached to the SMS. */
802
+ mediaUrls?: (Scalars['String'][] | null);
803
+ }
804
+ interface PostSubscriptionEmailInput {
805
+ /** Email subject line. */
806
+ subject: Scalars['String'];
807
+ /** Plain-text or markdown body. Rendered via React Email. */
808
+ body: Scalars['String'];
809
+ }
810
+ interface PostSubscriptionPushInput {
811
+ /** Push notification title. */
812
+ title: Scalars['String'];
813
+ /** Push notification body. */
814
+ body: Scalars['String'];
815
+ }
816
+ /**
817
+ * Welcome message delivered after a successful subscription. Each channel is independent —
818
+ * provide any combination of sms, email, and push. Channels with no input are skipped.
819
+ * The message is sent at most once per active subscription period (atomic per-channel claim).
820
+ */
821
+ interface PostSubscriptionMessageInput {
822
+ sms?: (PostSubscriptionSmsInput | null);
823
+ email?: (PostSubscriptionEmailInput | null);
824
+ push?: (PostSubscriptionPushInput | null);
825
+ }
798
826
  interface CreatePartnerBrandSubscriptionInput {
799
827
  compliance?: (SubscriptionComplianceInput | null);
800
828
  email?: (Scalars['String'] | null);
@@ -805,6 +833,13 @@ interface CreatePartnerBrandSubscriptionInput {
805
833
  /** E.164 phone number (for example +14155551234) */
806
834
  phoneNumber: Scalars['String'];
807
835
  requireOtpVerification?: (Scalars['Boolean'] | null);
836
+ /**
837
+ * Optional welcome message to deliver via the chosen channels. Sent at most once per active
838
+ * subscription period — safe to retry. Email requires the user to have a primary email and
839
+ * the brand to have a configured email alias. Push requires the user to have at least one
840
+ * push token and to not have opted out of brand messages.
841
+ */
842
+ postSubscriptionMessage?: (PostSubscriptionMessageInput | null);
808
843
  }
809
844
  interface VerifyPartnerBrandSubscriptionInput {
810
845
  code: Scalars['String'];
@@ -1009,4 +1044,4 @@ type ITMPartnerClient = Client;
1009
1044
  */
1010
1045
  declare function createITMPartnerClient(config: ITMPartnerClientConfig): ITMPartnerClient;
1011
1046
 
1012
- export { type BrandSubscription, type CreatePartnerBrandSubscriptionInput, type CreatePartnerBrandSubscriptionResponse, type CreatePartnerMomentInput, type CreatePartnerTicketTierInput, type Currency, DEFAULT_API_URL, type Dimensions, type DimensionsInput, type Echo, type EchoMediaAsset, type EchoType, type GetBrandEchoesForUserResponse, type GetPartnerCustomersResponse, type GetPublicMomentsResponse, type GetTicketsResponse, type ITMPartnerClient, type ITMPartnerClientConfig, type ITMPartnerHeaders, type ITMPartnerHeadersObject, type MediaAsset, type MediaAssetUploadUrl, type MerchPurchase, type Moment, type MomentCategory, type MomentCollection, type MomentCollectionLink, type MomentDiscountCodeUsage, type MomentSortOrder, type MomentStatus, type MomentSubcategory, type MomentType, type Mutation, type PartnerCustomer, type PartnerMomentStats, type Payment, type PaymentStatus, type Query, type SubscriptionComplianceInput, type ThirdPartyEchoType, type Ticket, type TicketExtension, type TicketExtensionStatus, type TicketTier, type User, type Venue, type VenueInput, type VerifyPartnerBrandSubscriptionInput, createITMPartnerClient, everything, generateMutationOp, generateQueryOp };
1047
+ export { type BrandSubscription, type CreatePartnerBrandSubscriptionInput, type CreatePartnerBrandSubscriptionResponse, type CreatePartnerMomentInput, type CreatePartnerTicketTierInput, type Currency, DEFAULT_API_URL, type Dimensions, type DimensionsInput, type Echo, type EchoMediaAsset, type EchoType, type GetBrandEchoesForUserResponse, type GetPartnerCustomersResponse, type GetPublicMomentsResponse, type GetTicketsResponse, type ITMPartnerClient, type ITMPartnerClientConfig, type ITMPartnerHeaders, type ITMPartnerHeadersObject, type MediaAsset, type MediaAssetUploadUrl, type MerchPurchase, type Moment, type MomentCategory, type MomentCollection, type MomentCollectionLink, type MomentDiscountCodeUsage, type MomentSortOrder, type MomentStatus, type MomentSubcategory, type MomentType, type Mutation, type PartnerCustomer, type PartnerMomentStats, type Payment, type PaymentStatus, type PostSubscriptionEmailInput, type PostSubscriptionMessageInput, type PostSubscriptionPushInput, type PostSubscriptionSmsInput, type Query, type SubscriptionComplianceInput, type ThirdPartyEchoType, type Ticket, type TicketExtension, type TicketExtensionStatus, type TicketTier, type User, type Venue, type VenueInput, type VerifyPartnerBrandSubscriptionInput, createITMPartnerClient, everything, generateMutationOp, generateQueryOp };
package/dist/index.js CHANGED
@@ -1490,6 +1490,53 @@ var types_default = {
1490
1490
  13
1491
1491
  ]
1492
1492
  },
1493
+ "PostSubscriptionSmsInput": {
1494
+ "body": [
1495
+ 13
1496
+ ],
1497
+ "mediaUrls": [
1498
+ 13
1499
+ ],
1500
+ "__typename": [
1501
+ 13
1502
+ ]
1503
+ },
1504
+ "PostSubscriptionEmailInput": {
1505
+ "subject": [
1506
+ 13
1507
+ ],
1508
+ "body": [
1509
+ 13
1510
+ ],
1511
+ "__typename": [
1512
+ 13
1513
+ ]
1514
+ },
1515
+ "PostSubscriptionPushInput": {
1516
+ "title": [
1517
+ 13
1518
+ ],
1519
+ "body": [
1520
+ 13
1521
+ ],
1522
+ "__typename": [
1523
+ 13
1524
+ ]
1525
+ },
1526
+ "PostSubscriptionMessageInput": {
1527
+ "sms": [
1528
+ 45
1529
+ ],
1530
+ "email": [
1531
+ 46
1532
+ ],
1533
+ "push": [
1534
+ 47
1535
+ ],
1536
+ "__typename": [
1537
+ 13
1538
+ ]
1539
+ },
1493
1540
  "CreatePartnerBrandSubscriptionInput": {
1494
1541
  "compliance": [
1495
1542
  44
@@ -1509,6 +1556,9 @@ var types_default = {
1509
1556
  "requireOtpVerification": [
1510
1557
  17
1511
1558
  ],
1559
+ "postSubscriptionMessage": [
1560
+ 48
1561
+ ],
1512
1562
  "__typename": [
1513
1563
  13
1514
1564
  ]
@@ -1586,7 +1636,7 @@ var types_default = {
1586
1636
  },
1587
1637
  "Mutation": {
1588
1638
  "getPartnerUploadUrl": [
1589
- 47,
1639
+ 51,
1590
1640
  {
1591
1641
  "filename": [
1592
1642
  13,
@@ -1599,7 +1649,7 @@ var types_default = {
1599
1649
  }
1600
1650
  ],
1601
1651
  "createPartnerMediaAsset": [
1602
- 48,
1652
+ 52,
1603
1653
  {
1604
1654
  "mimetype": [
1605
1655
  13,
@@ -1616,10 +1666,10 @@ var types_default = {
1616
1666
  }
1617
1667
  ],
1618
1668
  "createPartnerBrandSubscription": [
1619
- 49,
1669
+ 53,
1620
1670
  {
1621
1671
  "input": [
1622
- 45,
1672
+ 49,
1623
1673
  "CreatePartnerBrandSubscriptionInput!"
1624
1674
  ]
1625
1675
  }
@@ -1637,7 +1687,7 @@ var types_default = {
1637
1687
  38,
1638
1688
  {
1639
1689
  "input": [
1640
- 46,
1690
+ 50,
1641
1691
  "VerifyPartnerBrandSubscriptionInput!"
1642
1692
  ]
1643
1693
  }