From 124aa59ee8328c237a7635eebc22641fe6a4544a Mon Sep 17 00:00:00 2001 From: Dan Yishai Date: Sun, 23 Jun 2024 13:51:27 +0300 Subject: [PATCH] dan/per-10080-node-sdk-local-facts-uploader (#371) * Added Node SDK docs for local facts feature * Added docs for waitForSync * add newlines to fix doc --------- Co-authored-by: Asaf Cohen --- .../manage-data/local-facts-uploader.mdx | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/docs/how-to/manage-data/local-facts-uploader.mdx b/docs/how-to/manage-data/local-facts-uploader.mdx index 8bb836e6..9736584a 100644 --- a/docs/how-to/manage-data/local-facts-uploader.mdx +++ b/docs/how-to/manage-data/local-facts-uploader.mdx @@ -54,6 +54,25 @@ permit = Permit( ) ``` + + + + +```typescript +import { Permit } from "permit"; + +const permit = new Permit({ + // your secret API KEY + token: "", + // In production, you might need to change this URL to fit your deployment + // This is the address where you can find the PDP container. + pdp: "http://localhost:7766", + // configure the SDK to upload facts via the PDP + proxyFactsViaPdp: true, + // Add here any more configurations that you usually use +}); +``` + @@ -112,7 +131,40 @@ async with permit.wait_for_sync(timeout=15) as p: ``` + + +```typescript +import { Permit } from "permit"; + +const permit = new Permit({ + // your secret API KEY + token: "", + // In production, you might need to change this URL to fit your deployment + // This is the address where you can find the PDP container. + pdp: "http://localhost:7766", + // configure the SDK to upload facts via the PDP + proxyFactsViaPdp: true, + // configure the default time to wait for the facts to be synced + factsSyncTimeout: 10, + // Add here any more configurations that you usually use +}); + +await permit.api.users.sync({ + key: "auth0|elon", + email: "elonmusk@tesla.com", + first_name: "Elon", + last_name: "Musk", + attributes: { + age: 50, + favorite_color: "red", + }, +}); + +// or you can use the waitForSync function to customize the timeout for a specific call +await permit.api.users.waitForSync(10).create({ key: "auth0|elon" }); +``` + :::note Supported APIs