@gravity-rail/sdk 0.8.0 → 0.10.1

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.
Files changed (43) hide show
  1. package/README.md +38 -0
  2. package/dist/{chunk-ML55PVP7.js → chunk-2BJG4GYM.js} +641 -541
  3. package/dist/chunk-2BJG4GYM.js.map +1 -0
  4. package/dist/chunk-FSSXKQR5.js +471 -0
  5. package/dist/chunk-FSSXKQR5.js.map +1 -0
  6. package/dist/{chunk-QS6ZRQUZ.js → chunk-TJT7A4CO.js} +8 -1
  7. package/dist/{chunk-QS6ZRQUZ.js.map → chunk-TJT7A4CO.js.map} +1 -1
  8. package/dist/{client-C2aWAalu.d.cts → client-BffM3KcA.d.cts} +1190 -313
  9. package/dist/{client-CLGovEox.d.ts → client-DfjAYbt8.d.ts} +1190 -313
  10. package/dist/helpers.cjs +178 -2
  11. package/dist/helpers.cjs.map +1 -1
  12. package/dist/helpers.d.cts +82 -3
  13. package/dist/helpers.d.ts +82 -3
  14. package/dist/helpers.js +156 -1
  15. package/dist/helpers.js.map +1 -1
  16. package/dist/index.cjs +851 -166
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +14 -8
  19. package/dist/index.d.ts +14 -8
  20. package/dist/index.js +144 -20
  21. package/dist/index.js.map +1 -1
  22. package/dist/{inquiries-CmECZnkl.d.cts → inquiries-UcWNYo-Q.d.cts} +564 -79
  23. package/dist/{inquiries-CmECZnkl.d.ts → inquiries-UcWNYo-Q.d.ts} +564 -79
  24. package/dist/internal.cjs +784 -153
  25. package/dist/internal.cjs.map +1 -1
  26. package/dist/internal.d.cts +241 -5
  27. package/dist/internal.d.ts +241 -5
  28. package/dist/internal.js +71 -7
  29. package/dist/internal.js.map +1 -1
  30. package/dist/realtime.cjs +1 -0
  31. package/dist/realtime.cjs.map +1 -1
  32. package/dist/realtime.js +1 -0
  33. package/dist/realtime.js.map +1 -1
  34. package/dist/schemas.cjs +29 -7
  35. package/dist/schemas.cjs.map +1 -1
  36. package/dist/schemas.d.cts +106 -51
  37. package/dist/schemas.d.ts +106 -51
  38. package/dist/schemas.js +29 -8
  39. package/dist/schemas.js.map +1 -1
  40. package/dist/{scopes-D6a_Mvqr.d.ts → scopes-CjSvITpL.d.cts} +53 -8
  41. package/dist/{scopes-CDaJBQVT.d.cts → scopes-CmNKWrzb.d.ts} +53 -8
  42. package/package.json +5 -5
  43. package/dist/chunk-ML55PVP7.js.map +0 -1
package/README.md CHANGED
@@ -366,6 +366,44 @@ const clientWs = await client.createClientWorkspace(workspaceId, {
366
366
  await client.provisionClientWorkspace(workspaceId, clientWs.id);
367
367
  ```
368
368
 
369
+ ## Helpers (`@gravity-rail/sdk/helpers`)
370
+
371
+ Small compound operations built on the client methods, for the common
372
+ "register → populate a form → enroll → verify webhooks" integration flow:
373
+
374
+ ```typescript
375
+ import {
376
+ // member resolution + enrollment
377
+ resolveMemberId, // { memberId | phone | externalId } → member id
378
+ findOrCreateMemberLabels, // idempotent label lookup/create → ids
379
+ upsertDataRecordForMember,// idempotent member-scoped record write
380
+ enrollMemberInJourney, // resolve member → tag → enroll (409 = already enrolled)
381
+ // outbound calling
382
+ findMemberByPhone,
383
+ resolveOutboundPhoneNumberId,
384
+ resolveOutboundWorkflowId,
385
+ // webhook signatures (isomorphic HMAC-SHA256; verify the RAW body)
386
+ verifyWebhookSignature,
387
+ signWebhookPayload,
388
+ WEBHOOK_SIGNATURE_HEADER,
389
+ } from '@gravity-rail/sdk/helpers';
390
+
391
+ // Enroll into a journey by any identifier, applying cohort labels:
392
+ await enrollMemberInJourney(client, workspaceUuid, {
393
+ externalId: 'patient-123',
394
+ journeyId,
395
+ labels: ['pilot-cohort'],
396
+ });
397
+
398
+ // Verify an inbound webhook in your POST handler:
399
+ const result = await verifyWebhookSignature(
400
+ rawBody,
401
+ request.headers.get(WEBHOOK_SIGNATURE_HEADER),
402
+ signingSecret,
403
+ );
404
+ if (!result.ok) return new Response(result.reason, { status: 401 });
405
+ ```
406
+
369
407
  ## Type System
370
408
 
371
409
  Full TypeScript types for every API entity: