@gravity-rail/sdk 0.7.4 → 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.
- package/README.md +38 -0
- package/dist/{chunk-ANY7WLOD.js → chunk-2BJG4GYM.js} +778 -545
- package/dist/chunk-2BJG4GYM.js.map +1 -0
- package/dist/chunk-FSSXKQR5.js +471 -0
- package/dist/chunk-FSSXKQR5.js.map +1 -0
- package/dist/{chunk-QS6ZRQUZ.js → chunk-TJT7A4CO.js} +8 -1
- package/dist/{chunk-QS6ZRQUZ.js.map → chunk-TJT7A4CO.js.map} +1 -1
- package/dist/{client-B_cweJhP.d.cts → client-BffM3KcA.d.cts} +1367 -344
- package/dist/{client-C-on7whi.d.ts → client-DfjAYbt8.d.ts} +1367 -344
- package/dist/helpers.cjs +178 -2
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +82 -3
- package/dist/helpers.d.ts +82 -3
- package/dist/helpers.js +156 -1
- package/dist/helpers.js.map +1 -1
- package/dist/index.cjs +992 -174
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -8
- package/dist/index.d.ts +14 -8
- package/dist/index.js +144 -20
- package/dist/index.js.map +1 -1
- package/dist/{inquiries-BX3PuU-7.d.cts → inquiries-UcWNYo-Q.d.cts} +567 -79
- package/dist/{inquiries-BX3PuU-7.d.ts → inquiries-UcWNYo-Q.d.ts} +567 -79
- package/dist/internal.cjs +925 -161
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +241 -5
- package/dist/internal.d.ts +241 -5
- package/dist/internal.js +71 -7
- package/dist/internal.js.map +1 -1
- package/dist/realtime.cjs +1 -0
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.js +1 -0
- package/dist/realtime.js.map +1 -1
- package/dist/schemas.cjs +40 -7
- package/dist/schemas.cjs.map +1 -1
- package/dist/schemas.d.cts +134 -51
- package/dist/schemas.d.ts +134 -51
- package/dist/schemas.js +40 -8
- package/dist/schemas.js.map +1 -1
- package/dist/{scopes-ColqadkM.d.ts → scopes-CjSvITpL.d.cts} +53 -8
- package/dist/{scopes-CNbQi30F.d.cts → scopes-CmNKWrzb.d.ts} +53 -8
- package/package.json +6 -6
- package/dist/chunk-ANY7WLOD.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:
|