@knocklabs/react-core 0.3.0-rc-2.0 → 0.3.0-rc-4.0

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Changelog
2
2
 
3
- ## 0.3.0-rc-2.0
3
+ ## 0.3.0-rc-4.0
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -8,9 +8,11 @@
8
8
 
9
9
  ### Patch Changes
10
10
 
11
+ - 2b1e000: fix: types for userId should handle undefined and null
11
12
  - Updated dependencies [1b3ad4b]
13
+ - Updated dependencies [2b1e000]
12
14
  - Updated dependencies [f442962]
13
- - @knocklabs/client@0.11.0-rc-2.0
15
+ - @knocklabs/client@0.11.0-rc-4.0
14
16
 
15
17
  ## 0.2.26
16
18
 
@@ -1 +1 @@
1
- {"version":3,"file":"KnockProvider.js","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"sourcesContent":["import Knock, { AuthenticateOptions, LogLevel } from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\n\nimport { I18nContent, KnockI18nProvider } from \"../../i18n\";\nimport { useAuthenticatedKnockClient } from \"../hooks\";\n\nexport interface KnockProviderState {\n knock: Knock;\n}\n\nconst KnockContext = React.createContext<KnockProviderState | null>(null);\n\nexport interface KnockProviderProps {\n // Knock client props\n apiKey: string;\n host?: string;\n // Authentication props\n userId: string;\n userToken?: string;\n onUserTokenExpiring?: AuthenticateOptions[\"onUserTokenExpiring\"];\n timeBeforeExpirationInMs?: AuthenticateOptions[\"timeBeforeExpirationInMs\"];\n\n // i18n translations\n i18n?: I18nContent;\n\n logLevel?: LogLevel;\n}\n\nexport const KnockProvider: React.FC<PropsWithChildren<KnockProviderProps>> = ({\n apiKey,\n host,\n logLevel,\n userId,\n userToken,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n children,\n i18n,\n}) => {\n // We memoize the options here so that we don't create a new object on every re-render\n const authenticateOptions = React.useMemo(\n () => ({\n host,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n logLevel,\n }),\n [host, onUserTokenExpiring, timeBeforeExpirationInMs, logLevel],\n );\n\n const knock = useAuthenticatedKnockClient(\n apiKey,\n userId,\n userToken,\n authenticateOptions,\n );\n\n return (\n <KnockContext.Provider\n value={{\n knock,\n }}\n >\n <KnockI18nProvider i18n={i18n}>{children}</KnockI18nProvider>\n </KnockContext.Provider>\n );\n};\n\nexport const useKnockClient = (): Knock => {\n const context = React.useContext(KnockContext);\n if (!context) {\n throw new Error(\"useKnockClient must be used within a KnockProvider\");\n }\n return context.knock;\n};\n"],"names":["KnockContext","React","createContext","KnockProvider","apiKey","host","logLevel","userId","userToken","onUserTokenExpiring","timeBeforeExpirationInMs","children","i18n","authenticateOptions","useMemo","knock","useAuthenticatedKnockClient","KnockI18nProvider","useKnockClient","context","useContext","Error"],"mappings":"yjBAWMA,EAAeC,EAAMC,cAAyC,IAAI,EAkB3DC,EAAiEA,CAAC,CAC7EC,OAAAA,EACAC,KAAAA,EACAC,SAAAA,EACAC,OAAAA,EACAC,UAAAA,EACAC,oBAAAA,EACAC,yBAAAA,EACAC,SAAAA,EACAC,KAAAA,CACF,IAAM,CAEEC,MAAAA,EAAsBZ,EAAMa,QAChC,KAAO,CACLT,KAAAA,EACAI,oBAAAA,EACAC,yBAAAA,EACAJ,SAAAA,CAAAA,GAEF,CAACD,EAAMI,EAAqBC,EAA0BJ,CAAQ,CAChE,EAEMS,EAAQC,EACZZ,EACAG,EACAC,EACAK,CACF,EAEA,OACGZ,EAAA,cAAAD,EAAa,SAAb,CACC,MAAO,CACLe,MAAAA,CAAAA,CAGF,EAAAd,EAAA,cAACgB,EAAAA,kBAAkB,CAAA,KAAAL,CAAA,EAAaD,CAAS,CAC3C,CAEJ,EAEaO,EAAiBA,IAAa,CACnCC,MAAAA,EAAUlB,EAAMmB,WAAWpB,CAAY,EAC7C,GAAI,CAACmB,EACG,MAAA,IAAIE,MAAM,oDAAoD,EAEtE,OAAOF,EAAQJ,KACjB"}
1
+ {"version":3,"file":"KnockProvider.js","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"sourcesContent":["import Knock, { AuthenticateOptions, LogLevel } from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\n\nimport { I18nContent, KnockI18nProvider } from \"../../i18n\";\nimport { useAuthenticatedKnockClient } from \"../hooks\";\n\nexport interface KnockProviderState {\n knock: Knock;\n}\n\nconst KnockContext = React.createContext<KnockProviderState | null>(null);\n\nexport interface KnockProviderProps {\n // Knock client props\n apiKey: string;\n host?: string;\n // Authentication props\n userId: Knock[\"userId\"];\n userToken?: Knock[\"userToken\"];\n onUserTokenExpiring?: AuthenticateOptions[\"onUserTokenExpiring\"];\n timeBeforeExpirationInMs?: AuthenticateOptions[\"timeBeforeExpirationInMs\"];\n // i18n translations\n i18n?: I18nContent;\n logLevel?: LogLevel;\n}\n\nexport const KnockProvider: React.FC<PropsWithChildren<KnockProviderProps>> = ({\n apiKey,\n host,\n logLevel,\n userId,\n userToken,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n children,\n i18n,\n}) => {\n // We memoize the options here so that we don't create a new object on every re-render\n const authenticateOptions = React.useMemo(\n () => ({\n host,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n logLevel,\n }),\n [host, onUserTokenExpiring, timeBeforeExpirationInMs, logLevel],\n );\n\n const knock = useAuthenticatedKnockClient(\n apiKey,\n userId,\n userToken,\n authenticateOptions,\n );\n\n return (\n <KnockContext.Provider\n value={{\n knock,\n }}\n >\n <KnockI18nProvider i18n={i18n}>{children}</KnockI18nProvider>\n </KnockContext.Provider>\n );\n};\n\nexport const useKnockClient = (): Knock => {\n const context = React.useContext(KnockContext);\n if (!context) {\n throw new Error(\"useKnockClient must be used within a KnockProvider\");\n }\n return context.knock;\n};\n"],"names":["KnockContext","React","createContext","KnockProvider","apiKey","host","logLevel","userId","userToken","onUserTokenExpiring","timeBeforeExpirationInMs","children","i18n","authenticateOptions","useMemo","knock","useAuthenticatedKnockClient","KnockI18nProvider","useKnockClient","context","useContext","Error"],"mappings":"yjBAWMA,EAAeC,EAAMC,cAAyC,IAAI,EAgB3DC,EAAiEA,CAAC,CAC7EC,OAAAA,EACAC,KAAAA,EACAC,SAAAA,EACAC,OAAAA,EACAC,UAAAA,EACAC,oBAAAA,EACAC,yBAAAA,EACAC,SAAAA,EACAC,KAAAA,CACF,IAAM,CAEEC,MAAAA,EAAsBZ,EAAMa,QAChC,KAAO,CACLT,KAAAA,EACAI,oBAAAA,EACAC,yBAAAA,EACAJ,SAAAA,CAAAA,GAEF,CAACD,EAAMI,EAAqBC,EAA0BJ,CAAQ,CAChE,EAEMS,EAAQC,EACZZ,EACAG,EACAC,EACAK,CACF,EAEA,OACGZ,EAAA,cAAAD,EAAa,SAAb,CACC,MAAO,CACLe,MAAAA,CAAAA,CAGF,EAAAd,EAAA,cAACgB,EAAAA,kBAAkB,CAAA,KAAAL,CAAA,EAAaD,CAAS,CAC3C,CAEJ,EAEaO,EAAiBA,IAAa,CACnCC,MAAAA,EAAUlB,EAAMmB,WAAWpB,CAAY,EAC7C,GAAI,CAACmB,EACG,MAAA,IAAIE,MAAM,oDAAoD,EAEtE,OAAOF,EAAQJ,KACjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthenticatedKnockClient.js","sources":["../../../../../src/modules/core/hooks/useAuthenticatedKnockClient.ts"],"sourcesContent":["import Knock, { AuthenticateOptions, KnockOptions } from \"@knocklabs/client\";\nimport React from \"react\";\n\nimport { useStableOptions } from \"../../core\";\n\nfunction authenticateWithOptions(\n knock: Knock,\n userId: string,\n userToken?: string,\n options: AuthenticateOptions = {},\n) {\n knock.authenticate(userId, userToken, {\n onUserTokenExpiring: options?.onUserTokenExpiring,\n timeBeforeExpirationInMs: options?.timeBeforeExpirationInMs,\n });\n}\n\nexport type AuthenticatedKnockClientOptions = KnockOptions &\n AuthenticateOptions;\n\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userId: string,\n userToken?: string,\n options: AuthenticatedKnockClientOptions = {},\n) {\n const knockRef = React.useRef<Knock | undefined>();\n const stableOptions = useStableOptions(options);\n\n return React.useMemo(() => {\n const currentKnock = knockRef.current;\n\n // If the userId and the userToken changes then just reauth\n if (\n currentKnock &&\n currentKnock.isAuthenticated() &&\n (currentKnock.userId !== userId || currentKnock.userToken !== userToken)\n ) {\n authenticateWithOptions(currentKnock, userId, userToken, stableOptions);\n return currentKnock;\n }\n\n if (currentKnock) {\n currentKnock.teardown();\n }\n\n // Otherwise instantiate a new Knock client\n const knock = new Knock(apiKey, {\n host: stableOptions.host,\n logLevel: stableOptions.logLevel,\n });\n\n authenticateWithOptions(knock, userId, userToken, stableOptions);\n knockRef.current = knock;\n\n return knock;\n }, [apiKey, userId, userToken, stableOptions]);\n}\n\nexport default useAuthenticatedKnockClient;\n"],"names":["authenticateWithOptions","knock","userId","userToken","options","authenticate","onUserTokenExpiring","timeBeforeExpirationInMs","useAuthenticatedKnockClient","apiKey","knockRef","React","useRef","stableOptions","useStableOptions","useMemo","currentKnock","current","isAuthenticated","teardown","Knock","host","logLevel"],"mappings":"qPAKA,SAASA,EACPC,EACAC,EACAC,EACAC,EAA+B,CAAA,EAC/B,CACMC,EAAAA,aAAaH,EAAQC,EAAW,CACpCG,oBAAqBF,GAAAA,YAAAA,EAASE,oBAC9BC,yBAA0BH,GAAAA,YAAAA,EAASG,wBAAAA,CACpC,CACH,CAKA,SAASC,EACPC,EACAP,EACAC,EACAC,EAA2C,CAAA,EAC3C,CACMM,MAAAA,EAAWC,UAAMC,SACjBC,EAAgBC,EAAiBV,CAAO,EAEvCO,OAAAA,EAAAA,QAAMI,QAAQ,IAAM,CACzB,MAAMC,EAAeN,EAASO,QAI5BD,GAAAA,GACAA,EAAaE,gBAAgB,IAC5BF,EAAad,SAAWA,GAAUc,EAAab,YAAcA,GAEtCa,OAAAA,EAAAA,EAAcd,EAAQC,EAAWU,CAAa,EAC/DG,EAGLA,GACFA,EAAaG,SAAS,EAIlBlB,MAAAA,EAAQ,IAAImB,EAAAA,QAAMX,EAAQ,CAC9BY,KAAMR,EAAcQ,KACpBC,SAAUT,EAAcS,QAAAA,CACzB,EAEuBrB,OAAAA,EAAAA,EAAOC,EAAQC,EAAWU,CAAa,EAC/DH,EAASO,QAAUhB,EAEZA,GACN,CAACQ,EAAQP,EAAQC,EAAWU,CAAa,CAAC,CAC/C"}
1
+ {"version":3,"file":"useAuthenticatedKnockClient.js","sources":["../../../../../src/modules/core/hooks/useAuthenticatedKnockClient.ts"],"sourcesContent":["import Knock, { AuthenticateOptions, KnockOptions } from \"@knocklabs/client\";\nimport React from \"react\";\n\nimport { useStableOptions } from \"../../core\";\n\nfunction authenticateWithOptions(\n knock: Knock,\n userId: Knock[\"userId\"],\n userToken?: Knock[\"userToken\"],\n options: AuthenticateOptions = {},\n) {\n knock.authenticate(userId, userToken, {\n onUserTokenExpiring: options?.onUserTokenExpiring,\n timeBeforeExpirationInMs: options?.timeBeforeExpirationInMs,\n });\n}\n\nexport type AuthenticatedKnockClientOptions = KnockOptions &\n AuthenticateOptions;\n\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userId: Knock[\"userId\"],\n userToken?: Knock[\"userToken\"],\n options: AuthenticatedKnockClientOptions = {},\n) {\n const knockRef = React.useRef<Knock | undefined>();\n const stableOptions = useStableOptions(options);\n\n return React.useMemo(() => {\n const currentKnock = knockRef.current;\n\n // If the userId and the userToken changes then just reauth\n if (\n currentKnock &&\n currentKnock.isAuthenticated() &&\n (currentKnock.userId !== userId || currentKnock.userToken !== userToken)\n ) {\n authenticateWithOptions(currentKnock, userId, userToken, stableOptions);\n return currentKnock;\n }\n\n if (currentKnock) {\n currentKnock.teardown();\n }\n\n // Otherwise instantiate a new Knock client\n const knock = new Knock(apiKey, {\n host: stableOptions.host,\n logLevel: stableOptions.logLevel,\n });\n\n authenticateWithOptions(knock, userId, userToken, stableOptions);\n knockRef.current = knock;\n\n return knock;\n }, [apiKey, userId, userToken, stableOptions]);\n}\n\nexport default useAuthenticatedKnockClient;\n"],"names":["authenticateWithOptions","knock","userId","userToken","options","authenticate","onUserTokenExpiring","timeBeforeExpirationInMs","useAuthenticatedKnockClient","apiKey","knockRef","React","useRef","stableOptions","useStableOptions","useMemo","currentKnock","current","isAuthenticated","teardown","Knock","host","logLevel"],"mappings":"qPAKA,SAASA,EACPC,EACAC,EACAC,EACAC,EAA+B,CAAA,EAC/B,CACMC,EAAAA,aAAaH,EAAQC,EAAW,CACpCG,oBAAqBF,GAAAA,YAAAA,EAASE,oBAC9BC,yBAA0BH,GAAAA,YAAAA,EAASG,wBAAAA,CACpC,CACH,CAKA,SAASC,EACPC,EACAP,EACAC,EACAC,EAA2C,CAAA,EAC3C,CACMM,MAAAA,EAAWC,UAAMC,SACjBC,EAAgBC,EAAiBV,CAAO,EAEvCO,OAAAA,EAAAA,QAAMI,QAAQ,IAAM,CACzB,MAAMC,EAAeN,EAASO,QAI5BD,GAAAA,GACAA,EAAaE,gBAAgB,IAC5BF,EAAad,SAAWA,GAAUc,EAAab,YAAcA,GAEtCa,OAAAA,EAAAA,EAAcd,EAAQC,EAAWU,CAAa,EAC/DG,EAGLA,GACFA,EAAaG,SAAS,EAIlBlB,MAAAA,EAAQ,IAAImB,EAAAA,QAAMX,EAAQ,CAC9BY,KAAMR,EAAcQ,KACpBC,SAAUT,EAAcS,QAAAA,CACzB,EAEuBrB,OAAAA,EAAAA,EAAOC,EAAQC,EAAWU,CAAa,EAC/DH,EAASO,QAAUhB,EAEZA,GACN,CAACQ,EAAQP,EAAQC,EAAWU,CAAa,CAAC,CAC/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["../../../../src/modules/core/utils.ts"],"sourcesContent":["import { FeedClientOptions } from \"@knocklabs/client\";\nimport { intlFormatDistance, parseISO } from \"date-fns\";\nimport { ReactNode } from \"react\";\n\nexport function formatBadgeCount(count: number): string | number {\n return count > 9 ? \"9+\" : count;\n}\n\ntype FormatTimestampOptions = {\n locale?: string | string[];\n};\n\nexport function formatTimestamp(\n ts: string,\n options: FormatTimestampOptions = {},\n) {\n try {\n const parsedTs = parseISO(ts);\n const formatted = intlFormatDistance(parsedTs, new Date(), {\n locale: options.locale,\n });\n\n return formatted;\n } catch (e) {\n return ts;\n }\n}\n\nexport function toSentenceCase(string: string): string {\n return string.charAt(0).toUpperCase() + string.slice(1);\n}\n\nexport function renderNodeOrFallback(node: ReactNode, fallback: ReactNode) {\n return node !== undefined ? node : fallback;\n}\n\n/*\n Used to build a consistent key for the KnockFeedProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function feedProviderKey(\n userId: string | undefined,\n feedId: string,\n options: FeedClientOptions = {},\n) {\n return [\n userId,\n feedId,\n options.source,\n options.tenant,\n options.has_tenant,\n options.archived,\n ]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n\n/*\n Used to build a consistent key for the KnockSlackProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function slackProviderKey({\n knockSlackChannelId,\n tenant,\n connectionStatus,\n errorLabel,\n}: {\n knockSlackChannelId: string;\n tenant: string;\n connectionStatus: string;\n errorLabel: string | null;\n}) {\n return [knockSlackChannelId, tenant, connectionStatus, errorLabel]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n"],"names":["formatBadgeCount","count","formatTimestamp","ts","options","parsedTs","parseISO","formatted","intlFormatDistance","Date","locale","toSentenceCase","string","charAt","toUpperCase","slice","renderNodeOrFallback","node","fallback","undefined","feedProviderKey","userId","feedId","source","tenant","has_tenant","archived","filter","f","join","slackProviderKey","knockSlackChannelId","connectionStatus","errorLabel"],"mappings":"4GAIO,SAASA,EAAiBC,EAAgC,CACxDA,OAAAA,EAAQ,EAAI,KAAOA,CAC5B,CAMO,SAASC,EACdC,EACAC,EAAkC,GAClC,CACI,GAAA,CACIC,MAAAA,EAAWC,WAASH,CAAE,EAKrBI,OAJWC,EAAAA,mBAAmBH,EAAU,IAAII,KAAQ,CACzDC,OAAQN,EAAQM,MAAAA,CACjB,OAGS,CACHP,OAAAA,CACT,CACF,CAEO,SAASQ,EAAeC,EAAwB,CAC9CA,OAAAA,EAAOC,OAAO,CAAC,EAAEC,cAAgBF,EAAOG,MAAM,CAAC,CACxD,CAEgBC,SAAAA,EAAqBC,EAAiBC,EAAqB,CAClED,OAAAA,IAASE,OAAYF,EAAOC,CACrC,CAMO,SAASE,EACdC,EACAC,EACAlB,EAA6B,CAAA,EAC7B,CACO,MAAA,CACLiB,EACAC,EACAlB,EAAQmB,OACRnB,EAAQoB,OACRpB,EAAQqB,WACRrB,EAAQsB,QAAQ,EAEfC,UAAcC,GAAM,IAAuB,EAC3CC,KAAK,GAAG,CACb,CAMO,SAASC,EAAiB,CAC/BC,oBAAAA,EACAP,OAAAA,EACAQ,iBAAAA,EACAC,WAAAA,CAMF,EAAG,CACD,MAAO,CAACF,EAAqBP,EAAQQ,EAAkBC,CAAU,EAC9DN,OAAcC,GAAAA,GAAM,IAAuB,EAC3CC,KAAK,GAAG,CACb"}
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/modules/core/utils.ts"],"sourcesContent":["import Knock, { FeedClientOptions } from \"@knocklabs/client\";\nimport { intlFormatDistance, parseISO } from \"date-fns\";\nimport { ReactNode } from \"react\";\n\nexport function formatBadgeCount(count: number): string | number {\n return count > 9 ? \"9+\" : count;\n}\n\ntype FormatTimestampOptions = {\n locale?: string | string[];\n};\n\nexport function formatTimestamp(\n ts: string,\n options: FormatTimestampOptions = {},\n) {\n try {\n const parsedTs = parseISO(ts);\n const formatted = intlFormatDistance(parsedTs, new Date(), {\n locale: options.locale,\n });\n\n return formatted;\n } catch (e) {\n return ts;\n }\n}\n\nexport function toSentenceCase(string: string): string {\n return string.charAt(0).toUpperCase() + string.slice(1);\n}\n\nexport function renderNodeOrFallback(node: ReactNode, fallback: ReactNode) {\n return node !== undefined ? node : fallback;\n}\n\n/*\n Used to build a consistent key for the KnockFeedProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function feedProviderKey(\n userId: Knock[\"userId\"],\n feedId: string,\n options: FeedClientOptions = {},\n) {\n return [\n userId,\n feedId,\n options.source,\n options.tenant,\n options.has_tenant,\n options.archived,\n ]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n\n/*\n Used to build a consistent key for the KnockSlackProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function slackProviderKey({\n knockSlackChannelId,\n tenant,\n connectionStatus,\n errorLabel,\n}: {\n knockSlackChannelId: string;\n tenant: string;\n connectionStatus: string;\n errorLabel: string | null;\n}) {\n return [knockSlackChannelId, tenant, connectionStatus, errorLabel]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n"],"names":["formatBadgeCount","count","formatTimestamp","ts","options","parsedTs","parseISO","formatted","intlFormatDistance","Date","locale","toSentenceCase","string","charAt","toUpperCase","slice","renderNodeOrFallback","node","fallback","undefined","feedProviderKey","userId","feedId","source","tenant","has_tenant","archived","filter","f","join","slackProviderKey","knockSlackChannelId","connectionStatus","errorLabel"],"mappings":"4GAIO,SAASA,EAAiBC,EAAgC,CACxDA,OAAAA,EAAQ,EAAI,KAAOA,CAC5B,CAMO,SAASC,EACdC,EACAC,EAAkC,GAClC,CACI,GAAA,CACIC,MAAAA,EAAWC,WAASH,CAAE,EAKrBI,OAJWC,EAAAA,mBAAmBH,EAAU,IAAII,KAAQ,CACzDC,OAAQN,EAAQM,MAAAA,CACjB,OAGS,CACHP,OAAAA,CACT,CACF,CAEO,SAASQ,EAAeC,EAAwB,CAC9CA,OAAAA,EAAOC,OAAO,CAAC,EAAEC,cAAgBF,EAAOG,MAAM,CAAC,CACxD,CAEgBC,SAAAA,EAAqBC,EAAiBC,EAAqB,CAClED,OAAAA,IAASE,OAAYF,EAAOC,CACrC,CAMO,SAASE,EACdC,EACAC,EACAlB,EAA6B,CAAA,EAC7B,CACO,MAAA,CACLiB,EACAC,EACAlB,EAAQmB,OACRnB,EAAQoB,OACRpB,EAAQqB,WACRrB,EAAQsB,QAAQ,EAEfC,UAAcC,GAAM,IAAuB,EAC3CC,KAAK,GAAG,CACb,CAMO,SAASC,EAAiB,CAC/BC,oBAAAA,EACAP,OAAAA,EACAQ,iBAAAA,EACAC,WAAAA,CAMF,EAAG,CACD,MAAO,CAACF,EAAqBP,EAAQQ,EAAkBC,CAAU,EAC9DN,OAAcC,GAAAA,GAAM,IAAuB,EAC3CC,KAAK,GAAG,CACb"}
@@ -1 +1 @@
1
- {"version":3,"file":"KnockProvider.mjs","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"sourcesContent":["import Knock, { AuthenticateOptions, LogLevel } from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\n\nimport { I18nContent, KnockI18nProvider } from \"../../i18n\";\nimport { useAuthenticatedKnockClient } from \"../hooks\";\n\nexport interface KnockProviderState {\n knock: Knock;\n}\n\nconst KnockContext = React.createContext<KnockProviderState | null>(null);\n\nexport interface KnockProviderProps {\n // Knock client props\n apiKey: string;\n host?: string;\n // Authentication props\n userId: string;\n userToken?: string;\n onUserTokenExpiring?: AuthenticateOptions[\"onUserTokenExpiring\"];\n timeBeforeExpirationInMs?: AuthenticateOptions[\"timeBeforeExpirationInMs\"];\n\n // i18n translations\n i18n?: I18nContent;\n\n logLevel?: LogLevel;\n}\n\nexport const KnockProvider: React.FC<PropsWithChildren<KnockProviderProps>> = ({\n apiKey,\n host,\n logLevel,\n userId,\n userToken,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n children,\n i18n,\n}) => {\n // We memoize the options here so that we don't create a new object on every re-render\n const authenticateOptions = React.useMemo(\n () => ({\n host,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n logLevel,\n }),\n [host, onUserTokenExpiring, timeBeforeExpirationInMs, logLevel],\n );\n\n const knock = useAuthenticatedKnockClient(\n apiKey,\n userId,\n userToken,\n authenticateOptions,\n );\n\n return (\n <KnockContext.Provider\n value={{\n knock,\n }}\n >\n <KnockI18nProvider i18n={i18n}>{children}</KnockI18nProvider>\n </KnockContext.Provider>\n );\n};\n\nexport const useKnockClient = (): Knock => {\n const context = React.useContext(KnockContext);\n if (!context) {\n throw new Error(\"useKnockClient must be used within a KnockProvider\");\n }\n return context.knock;\n};\n"],"names":["KnockContext","React","createContext","KnockProvider","apiKey","host","logLevel","userId","userToken","onUserTokenExpiring","timeBeforeExpirationInMs","children","i18n","authenticateOptions","useMemo","knock","useAuthenticatedKnockClient","KnockI18nProvider","useKnockClient","context","useContext","Error"],"mappings":";;;;AAWA,MAAMA,IAAeC,EAAMC,cAAyC,IAAI,GAkB3DC,IAAiEA,CAAC;AAAA,EAC7EC,QAAAA;AAAAA,EACAC,MAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,QAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,qBAAAA;AAAAA,EACAC,0BAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,MAAAA;AACF,MAAM;AAEEC,QAAAA,IAAsBZ,EAAMa,QAChC,OAAO;AAAA,IACLT,MAAAA;AAAAA,IACAI,qBAAAA;AAAAA,IACAC,0BAAAA;AAAAA,IACAJ,UAAAA;AAAAA,EAAAA,IAEF,CAACD,GAAMI,GAAqBC,GAA0BJ,CAAQ,CAChE,GAEMS,IAAQC,EACZZ,GACAG,GACAC,GACAK,CACF;AAEA,SACG,gBAAAZ,EAAA,cAAAD,EAAa,UAAb,EACC,OAAO;AAAA,IACLe,OAAAA;AAAAA,EAAAA,EAGF,GAAA,gBAAAd,EAAA,cAACgB,GAAkB,EAAA,MAAAL,EAAA,GAAaD,CAAS,CAC3C;AAEJ,GAEaO,IAAiBA,MAAa;AACnCC,QAAAA,IAAUlB,EAAMmB,WAAWpB,CAAY;AAC7C,MAAI,CAACmB;AACG,UAAA,IAAIE,MAAM,oDAAoD;AAEtE,SAAOF,EAAQJ;AACjB;"}
1
+ {"version":3,"file":"KnockProvider.mjs","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"sourcesContent":["import Knock, { AuthenticateOptions, LogLevel } from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\n\nimport { I18nContent, KnockI18nProvider } from \"../../i18n\";\nimport { useAuthenticatedKnockClient } from \"../hooks\";\n\nexport interface KnockProviderState {\n knock: Knock;\n}\n\nconst KnockContext = React.createContext<KnockProviderState | null>(null);\n\nexport interface KnockProviderProps {\n // Knock client props\n apiKey: string;\n host?: string;\n // Authentication props\n userId: Knock[\"userId\"];\n userToken?: Knock[\"userToken\"];\n onUserTokenExpiring?: AuthenticateOptions[\"onUserTokenExpiring\"];\n timeBeforeExpirationInMs?: AuthenticateOptions[\"timeBeforeExpirationInMs\"];\n // i18n translations\n i18n?: I18nContent;\n logLevel?: LogLevel;\n}\n\nexport const KnockProvider: React.FC<PropsWithChildren<KnockProviderProps>> = ({\n apiKey,\n host,\n logLevel,\n userId,\n userToken,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n children,\n i18n,\n}) => {\n // We memoize the options here so that we don't create a new object on every re-render\n const authenticateOptions = React.useMemo(\n () => ({\n host,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n logLevel,\n }),\n [host, onUserTokenExpiring, timeBeforeExpirationInMs, logLevel],\n );\n\n const knock = useAuthenticatedKnockClient(\n apiKey,\n userId,\n userToken,\n authenticateOptions,\n );\n\n return (\n <KnockContext.Provider\n value={{\n knock,\n }}\n >\n <KnockI18nProvider i18n={i18n}>{children}</KnockI18nProvider>\n </KnockContext.Provider>\n );\n};\n\nexport const useKnockClient = (): Knock => {\n const context = React.useContext(KnockContext);\n if (!context) {\n throw new Error(\"useKnockClient must be used within a KnockProvider\");\n }\n return context.knock;\n};\n"],"names":["KnockContext","React","createContext","KnockProvider","apiKey","host","logLevel","userId","userToken","onUserTokenExpiring","timeBeforeExpirationInMs","children","i18n","authenticateOptions","useMemo","knock","useAuthenticatedKnockClient","KnockI18nProvider","useKnockClient","context","useContext","Error"],"mappings":";;;;AAWA,MAAMA,IAAeC,EAAMC,cAAyC,IAAI,GAgB3DC,IAAiEA,CAAC;AAAA,EAC7EC,QAAAA;AAAAA,EACAC,MAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,QAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,qBAAAA;AAAAA,EACAC,0BAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,MAAAA;AACF,MAAM;AAEEC,QAAAA,IAAsBZ,EAAMa,QAChC,OAAO;AAAA,IACLT,MAAAA;AAAAA,IACAI,qBAAAA;AAAAA,IACAC,0BAAAA;AAAAA,IACAJ,UAAAA;AAAAA,EAAAA,IAEF,CAACD,GAAMI,GAAqBC,GAA0BJ,CAAQ,CAChE,GAEMS,IAAQC,EACZZ,GACAG,GACAC,GACAK,CACF;AAEA,SACG,gBAAAZ,EAAA,cAAAD,EAAa,UAAb,EACC,OAAO;AAAA,IACLe,OAAAA;AAAAA,EAAAA,EAGF,GAAA,gBAAAd,EAAA,cAACgB,GAAkB,EAAA,MAAAL,EAAA,GAAaD,CAAS,CAC3C;AAEJ,GAEaO,IAAiBA,MAAa;AACnCC,QAAAA,IAAUlB,EAAMmB,WAAWpB,CAAY;AAC7C,MAAI,CAACmB;AACG,UAAA,IAAIE,MAAM,oDAAoD;AAEtE,SAAOF,EAAQJ;AACjB;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthenticatedKnockClient.mjs","sources":["../../../../../src/modules/core/hooks/useAuthenticatedKnockClient.ts"],"sourcesContent":["import Knock, { AuthenticateOptions, KnockOptions } from \"@knocklabs/client\";\nimport React from \"react\";\n\nimport { useStableOptions } from \"../../core\";\n\nfunction authenticateWithOptions(\n knock: Knock,\n userId: string,\n userToken?: string,\n options: AuthenticateOptions = {},\n) {\n knock.authenticate(userId, userToken, {\n onUserTokenExpiring: options?.onUserTokenExpiring,\n timeBeforeExpirationInMs: options?.timeBeforeExpirationInMs,\n });\n}\n\nexport type AuthenticatedKnockClientOptions = KnockOptions &\n AuthenticateOptions;\n\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userId: string,\n userToken?: string,\n options: AuthenticatedKnockClientOptions = {},\n) {\n const knockRef = React.useRef<Knock | undefined>();\n const stableOptions = useStableOptions(options);\n\n return React.useMemo(() => {\n const currentKnock = knockRef.current;\n\n // If the userId and the userToken changes then just reauth\n if (\n currentKnock &&\n currentKnock.isAuthenticated() &&\n (currentKnock.userId !== userId || currentKnock.userToken !== userToken)\n ) {\n authenticateWithOptions(currentKnock, userId, userToken, stableOptions);\n return currentKnock;\n }\n\n if (currentKnock) {\n currentKnock.teardown();\n }\n\n // Otherwise instantiate a new Knock client\n const knock = new Knock(apiKey, {\n host: stableOptions.host,\n logLevel: stableOptions.logLevel,\n });\n\n authenticateWithOptions(knock, userId, userToken, stableOptions);\n knockRef.current = knock;\n\n return knock;\n }, [apiKey, userId, userToken, stableOptions]);\n}\n\nexport default useAuthenticatedKnockClient;\n"],"names":["authenticateWithOptions","knock","userId","userToken","options","authenticate","onUserTokenExpiring","timeBeforeExpirationInMs","useAuthenticatedKnockClient","apiKey","knockRef","React","useRef","stableOptions","useStableOptions","useMemo","currentKnock","current","isAuthenticated","teardown","Knock","host","logLevel"],"mappings":";;;;;AAKA,SAASA,EACPC,GACAC,GACAC,GACAC,IAA+B,CAAA,GAC/B;AACMC,EAAAA,EAAAA,aAAaH,GAAQC,GAAW;AAAA,IACpCG,qBAAqBF,KAAAA,gBAAAA,EAASE;AAAAA,IAC9BC,0BAA0BH,KAAAA,gBAAAA,EAASG;AAAAA,EAAAA,CACpC;AACH;AAKA,SAASC,EACPC,GACAP,GACAC,GACAC,IAA2C,CAAA,GAC3C;AACMM,QAAAA,IAAWC,EAAMC,UACjBC,IAAgBC,EAAiBV,CAAO;AAEvCO,SAAAA,EAAMI,QAAQ,MAAM;AACzB,UAAMC,IAAeN,EAASO;AAI5BD,QAAAA,KACAA,EAAaE,gBAAgB,MAC5BF,EAAad,WAAWA,KAAUc,EAAab,cAAcA;AAEtCa,aAAAA,EAAAA,GAAcd,GAAQC,GAAWU,CAAa,GAC/DG;AAGT,IAAIA,KACFA,EAAaG,SAAS;AAIlBlB,UAAAA,IAAQ,IAAImB,EAAMX,GAAQ;AAAA,MAC9BY,MAAMR,EAAcQ;AAAAA,MACpBC,UAAUT,EAAcS;AAAAA,IAAAA,CACzB;AAEuBrB,WAAAA,EAAAA,GAAOC,GAAQC,GAAWU,CAAa,GAC/DH,EAASO,UAAUhB,GAEZA;AAAAA,KACN,CAACQ,GAAQP,GAAQC,GAAWU,CAAa,CAAC;AAC/C;"}
1
+ {"version":3,"file":"useAuthenticatedKnockClient.mjs","sources":["../../../../../src/modules/core/hooks/useAuthenticatedKnockClient.ts"],"sourcesContent":["import Knock, { AuthenticateOptions, KnockOptions } from \"@knocklabs/client\";\nimport React from \"react\";\n\nimport { useStableOptions } from \"../../core\";\n\nfunction authenticateWithOptions(\n knock: Knock,\n userId: Knock[\"userId\"],\n userToken?: Knock[\"userToken\"],\n options: AuthenticateOptions = {},\n) {\n knock.authenticate(userId, userToken, {\n onUserTokenExpiring: options?.onUserTokenExpiring,\n timeBeforeExpirationInMs: options?.timeBeforeExpirationInMs,\n });\n}\n\nexport type AuthenticatedKnockClientOptions = KnockOptions &\n AuthenticateOptions;\n\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userId: Knock[\"userId\"],\n userToken?: Knock[\"userToken\"],\n options: AuthenticatedKnockClientOptions = {},\n) {\n const knockRef = React.useRef<Knock | undefined>();\n const stableOptions = useStableOptions(options);\n\n return React.useMemo(() => {\n const currentKnock = knockRef.current;\n\n // If the userId and the userToken changes then just reauth\n if (\n currentKnock &&\n currentKnock.isAuthenticated() &&\n (currentKnock.userId !== userId || currentKnock.userToken !== userToken)\n ) {\n authenticateWithOptions(currentKnock, userId, userToken, stableOptions);\n return currentKnock;\n }\n\n if (currentKnock) {\n currentKnock.teardown();\n }\n\n // Otherwise instantiate a new Knock client\n const knock = new Knock(apiKey, {\n host: stableOptions.host,\n logLevel: stableOptions.logLevel,\n });\n\n authenticateWithOptions(knock, userId, userToken, stableOptions);\n knockRef.current = knock;\n\n return knock;\n }, [apiKey, userId, userToken, stableOptions]);\n}\n\nexport default useAuthenticatedKnockClient;\n"],"names":["authenticateWithOptions","knock","userId","userToken","options","authenticate","onUserTokenExpiring","timeBeforeExpirationInMs","useAuthenticatedKnockClient","apiKey","knockRef","React","useRef","stableOptions","useStableOptions","useMemo","currentKnock","current","isAuthenticated","teardown","Knock","host","logLevel"],"mappings":";;;;;AAKA,SAASA,EACPC,GACAC,GACAC,GACAC,IAA+B,CAAA,GAC/B;AACMC,EAAAA,EAAAA,aAAaH,GAAQC,GAAW;AAAA,IACpCG,qBAAqBF,KAAAA,gBAAAA,EAASE;AAAAA,IAC9BC,0BAA0BH,KAAAA,gBAAAA,EAASG;AAAAA,EAAAA,CACpC;AACH;AAKA,SAASC,EACPC,GACAP,GACAC,GACAC,IAA2C,CAAA,GAC3C;AACMM,QAAAA,IAAWC,EAAMC,UACjBC,IAAgBC,EAAiBV,CAAO;AAEvCO,SAAAA,EAAMI,QAAQ,MAAM;AACzB,UAAMC,IAAeN,EAASO;AAI5BD,QAAAA,KACAA,EAAaE,gBAAgB,MAC5BF,EAAad,WAAWA,KAAUc,EAAab,cAAcA;AAEtCa,aAAAA,EAAAA,GAAcd,GAAQC,GAAWU,CAAa,GAC/DG;AAGT,IAAIA,KACFA,EAAaG,SAAS;AAIlBlB,UAAAA,IAAQ,IAAImB,EAAMX,GAAQ;AAAA,MAC9BY,MAAMR,EAAcQ;AAAAA,MACpBC,UAAUT,EAAcS;AAAAA,IAAAA,CACzB;AAEuBrB,WAAAA,EAAAA,GAAOC,GAAQC,GAAWU,CAAa,GAC/DH,EAASO,UAAUhB,GAEZA;AAAAA,KACN,CAACQ,GAAQP,GAAQC,GAAWU,CAAa,CAAC;AAC/C;"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","sources":["../../../../src/modules/core/utils.ts"],"sourcesContent":["import { FeedClientOptions } from \"@knocklabs/client\";\nimport { intlFormatDistance, parseISO } from \"date-fns\";\nimport { ReactNode } from \"react\";\n\nexport function formatBadgeCount(count: number): string | number {\n return count > 9 ? \"9+\" : count;\n}\n\ntype FormatTimestampOptions = {\n locale?: string | string[];\n};\n\nexport function formatTimestamp(\n ts: string,\n options: FormatTimestampOptions = {},\n) {\n try {\n const parsedTs = parseISO(ts);\n const formatted = intlFormatDistance(parsedTs, new Date(), {\n locale: options.locale,\n });\n\n return formatted;\n } catch (e) {\n return ts;\n }\n}\n\nexport function toSentenceCase(string: string): string {\n return string.charAt(0).toUpperCase() + string.slice(1);\n}\n\nexport function renderNodeOrFallback(node: ReactNode, fallback: ReactNode) {\n return node !== undefined ? node : fallback;\n}\n\n/*\n Used to build a consistent key for the KnockFeedProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function feedProviderKey(\n userId: string | undefined,\n feedId: string,\n options: FeedClientOptions = {},\n) {\n return [\n userId,\n feedId,\n options.source,\n options.tenant,\n options.has_tenant,\n options.archived,\n ]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n\n/*\n Used to build a consistent key for the KnockSlackProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function slackProviderKey({\n knockSlackChannelId,\n tenant,\n connectionStatus,\n errorLabel,\n}: {\n knockSlackChannelId: string;\n tenant: string;\n connectionStatus: string;\n errorLabel: string | null;\n}) {\n return [knockSlackChannelId, tenant, connectionStatus, errorLabel]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n"],"names":["formatBadgeCount","count","formatTimestamp","ts","options","parsedTs","parseISO","formatted","intlFormatDistance","Date","locale","toSentenceCase","string","charAt","toUpperCase","slice","renderNodeOrFallback","node","fallback","undefined","feedProviderKey","userId","feedId","source","tenant","has_tenant","archived","filter","f","join","slackProviderKey","knockSlackChannelId","connectionStatus","errorLabel"],"mappings":";AAIO,SAASA,EAAiBC,GAAgC;AACxDA,SAAAA,IAAQ,IAAI,OAAOA;AAC5B;AAMO,SAASC,EACdC,GACAC,IAAkC,IAClC;AACI,MAAA;AACIC,UAAAA,IAAWC,EAASH,CAAE;AAKrBI,WAJWC,EAAmBH,GAAU,oBAAII,QAAQ;AAAA,MACzDC,QAAQN,EAAQM;AAAAA,IAAAA,CACjB;AAAA,UAGS;AACHP,WAAAA;AAAAA,EACT;AACF;AAEO,SAASQ,EAAeC,GAAwB;AAC9CA,SAAAA,EAAOC,OAAO,CAAC,EAAEC,gBAAgBF,EAAOG,MAAM,CAAC;AACxD;AAEgBC,SAAAA,EAAqBC,GAAiBC,GAAqB;AAClED,SAAAA,MAASE,SAAYF,IAAOC;AACrC;AAMO,SAASE,EACdC,GACAC,GACAlB,IAA6B,CAAA,GAC7B;AACO,SAAA,CACLiB,GACAC,GACAlB,EAAQmB,QACRnB,EAAQoB,QACRpB,EAAQqB,YACRrB,EAAQsB,QAAQ,EAEfC,OAAQC,OAAMA,KAAM,IAAuB,EAC3CC,KAAK,GAAG;AACb;AAMO,SAASC,EAAiB;AAAA,EAC/BC,qBAAAA;AAAAA,EACAP,QAAAA;AAAAA,EACAQ,kBAAAA;AAAAA,EACAC,YAAAA;AAMF,GAAG;AACD,SAAO,CAACF,GAAqBP,GAAQQ,GAAkBC,CAAU,EAC9DN,OAAQC,CAAMA,MAAAA,KAAM,IAAuB,EAC3CC,KAAK,GAAG;AACb;"}
1
+ {"version":3,"file":"utils.mjs","sources":["../../../../src/modules/core/utils.ts"],"sourcesContent":["import Knock, { FeedClientOptions } from \"@knocklabs/client\";\nimport { intlFormatDistance, parseISO } from \"date-fns\";\nimport { ReactNode } from \"react\";\n\nexport function formatBadgeCount(count: number): string | number {\n return count > 9 ? \"9+\" : count;\n}\n\ntype FormatTimestampOptions = {\n locale?: string | string[];\n};\n\nexport function formatTimestamp(\n ts: string,\n options: FormatTimestampOptions = {},\n) {\n try {\n const parsedTs = parseISO(ts);\n const formatted = intlFormatDistance(parsedTs, new Date(), {\n locale: options.locale,\n });\n\n return formatted;\n } catch (e) {\n return ts;\n }\n}\n\nexport function toSentenceCase(string: string): string {\n return string.charAt(0).toUpperCase() + string.slice(1);\n}\n\nexport function renderNodeOrFallback(node: ReactNode, fallback: ReactNode) {\n return node !== undefined ? node : fallback;\n}\n\n/*\n Used to build a consistent key for the KnockFeedProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function feedProviderKey(\n userId: Knock[\"userId\"],\n feedId: string,\n options: FeedClientOptions = {},\n) {\n return [\n userId,\n feedId,\n options.source,\n options.tenant,\n options.has_tenant,\n options.archived,\n ]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n\n/*\n Used to build a consistent key for the KnockSlackProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function slackProviderKey({\n knockSlackChannelId,\n tenant,\n connectionStatus,\n errorLabel,\n}: {\n knockSlackChannelId: string;\n tenant: string;\n connectionStatus: string;\n errorLabel: string | null;\n}) {\n return [knockSlackChannelId, tenant, connectionStatus, errorLabel]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n"],"names":["formatBadgeCount","count","formatTimestamp","ts","options","parsedTs","parseISO","formatted","intlFormatDistance","Date","locale","toSentenceCase","string","charAt","toUpperCase","slice","renderNodeOrFallback","node","fallback","undefined","feedProviderKey","userId","feedId","source","tenant","has_tenant","archived","filter","f","join","slackProviderKey","knockSlackChannelId","connectionStatus","errorLabel"],"mappings":";AAIO,SAASA,EAAiBC,GAAgC;AACxDA,SAAAA,IAAQ,IAAI,OAAOA;AAC5B;AAMO,SAASC,EACdC,GACAC,IAAkC,IAClC;AACI,MAAA;AACIC,UAAAA,IAAWC,EAASH,CAAE;AAKrBI,WAJWC,EAAmBH,GAAU,oBAAII,QAAQ;AAAA,MACzDC,QAAQN,EAAQM;AAAAA,IAAAA,CACjB;AAAA,UAGS;AACHP,WAAAA;AAAAA,EACT;AACF;AAEO,SAASQ,EAAeC,GAAwB;AAC9CA,SAAAA,EAAOC,OAAO,CAAC,EAAEC,gBAAgBF,EAAOG,MAAM,CAAC;AACxD;AAEgBC,SAAAA,EAAqBC,GAAiBC,GAAqB;AAClED,SAAAA,MAASE,SAAYF,IAAOC;AACrC;AAMO,SAASE,EACdC,GACAC,GACAlB,IAA6B,CAAA,GAC7B;AACO,SAAA,CACLiB,GACAC,GACAlB,EAAQmB,QACRnB,EAAQoB,QACRpB,EAAQqB,YACRrB,EAAQsB,QAAQ,EAEfC,OAAQC,OAAMA,KAAM,IAAuB,EAC3CC,KAAK,GAAG;AACb;AAMO,SAASC,EAAiB;AAAA,EAC/BC,qBAAAA;AAAAA,EACAP,QAAAA;AAAAA,EACAQ,kBAAAA;AAAAA,EACAC,YAAAA;AAMF,GAAG;AACD,SAAO,CAACF,GAAqBP,GAAQQ,GAAkBC,CAAU,EAC9DN,OAAQC,CAAMA,MAAAA,KAAM,IAAuB,EAC3CC,KAAK,GAAG;AACb;"}
@@ -9,8 +9,8 @@ export interface KnockProviderState {
9
9
  export interface KnockProviderProps {
10
10
  apiKey: string;
11
11
  host?: string;
12
- userId: string;
13
- userToken?: string;
12
+ userId: Knock["userId"];
13
+ userToken?: Knock["userToken"];
14
14
  onUserTokenExpiring?: AuthenticateOptions["onUserTokenExpiring"];
15
15
  timeBeforeExpirationInMs?: AuthenticateOptions["timeBeforeExpirationInMs"];
16
16
  i18n?: I18nContent;
@@ -1 +1 @@
1
- {"version":3,"file":"KnockProvider.d.ts","sourceRoot":"","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAqB,MAAM,YAAY,CAAC;AAG5D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,KAAK,CAAC;CACd;AAID,MAAM,WAAW,kBAAkB;IAEjC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;IACjE,wBAAwB,CAAC,EAAE,mBAAmB,CAAC,0BAA0B,CAAC,CAAC;IAG3E,IAAI,CAAC,EAAE,WAAW,CAAC;IAEnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAsCzE,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,KAMjC,CAAC"}
1
+ {"version":3,"file":"KnockProvider.d.ts","sourceRoot":"","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAqB,MAAM,YAAY,CAAC;AAG5D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,KAAK,CAAC;CACd;AAID,MAAM,WAAW,kBAAkB;IAEjC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxB,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC/B,mBAAmB,CAAC,EAAE,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;IACjE,wBAAwB,CAAC,EAAE,mBAAmB,CAAC,0BAA0B,CAAC,CAAC;IAE3E,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAsCzE,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,KAMjC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { default as Knock, AuthenticateOptions, KnockOptions } from '@knocklabs/client';
2
2
 
3
3
  export type AuthenticatedKnockClientOptions = KnockOptions & AuthenticateOptions;
4
- declare function useAuthenticatedKnockClient(apiKey: string, userId: string, userToken?: string, options?: AuthenticatedKnockClientOptions): Knock;
4
+ declare function useAuthenticatedKnockClient(apiKey: string, userId: Knock["userId"], userToken?: Knock["userToken"], options?: AuthenticatedKnockClientOptions): Knock;
5
5
  export default useAuthenticatedKnockClient;
6
6
  //# sourceMappingURL=useAuthenticatedKnockClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthenticatedKnockClient.d.ts","sourceRoot":"","sources":["../../../../../src/modules/core/hooks/useAuthenticatedKnockClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAiB7E,MAAM,MAAM,+BAA+B,GAAG,YAAY,GACxD,mBAAmB,CAAC;AAEtB,iBAAS,2BAA2B,CAClC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,GAAE,+BAAoC,SAiC9C;AAED,eAAe,2BAA2B,CAAC"}
1
+ {"version":3,"file":"useAuthenticatedKnockClient.d.ts","sourceRoot":"","sources":["../../../../../src/modules/core/hooks/useAuthenticatedKnockClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAiB7E,MAAM,MAAM,+BAA+B,GAAG,YAAY,GACxD,mBAAmB,CAAC;AAEtB,iBAAS,2BAA2B,CAClC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,EACvB,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,EAC9B,OAAO,GAAE,+BAAoC,SAiC9C;AAED,eAAe,2BAA2B,CAAC"}
@@ -1,4 +1,4 @@
1
- import { FeedClientOptions } from '@knocklabs/client';
1
+ import { default as Knock, FeedClientOptions } from '@knocklabs/client';
2
2
  import { ReactNode } from 'react';
3
3
 
4
4
  export declare function formatBadgeCount(count: number): string | number;
@@ -8,7 +8,7 @@ type FormatTimestampOptions = {
8
8
  export declare function formatTimestamp(ts: string, options?: FormatTimestampOptions): string;
9
9
  export declare function toSentenceCase(string: string): string;
10
10
  export declare function renderNodeOrFallback(node: ReactNode, fallback: ReactNode): ReactNode;
11
- export declare function feedProviderKey(userId: string | undefined, feedId: string, options?: FeedClientOptions): string;
11
+ export declare function feedProviderKey(userId: Knock["userId"], feedId: string, options?: FeedClientOptions): string;
12
12
  export declare function slackProviderKey({ knockSlackChannelId, tenant, connectionStatus, errorLabel, }: {
13
13
  knockSlackChannelId: string;
14
14
  tenant: string;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/modules/core/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAE/D;AAED,KAAK,sBAAsB,GAAG;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF,wBAAgB,eAAe,CAC7B,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,sBAA2B,UAYrC;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,aAExE;AAMD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,iBAAsB,UAYhC;AAMD,wBAAgB,gBAAgB,CAAC,EAC/B,mBAAmB,EACnB,MAAM,EACN,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,UAIA"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/modules/core/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAE/D;AAED,KAAK,sBAAsB,GAAG;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF,wBAAgB,eAAe,CAC7B,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,sBAA2B,UAYrC;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,aAExE;AAMD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,EACvB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,iBAAsB,UAYhC;AAMD,wBAAgB,gBAAgB,CAAC,EAC/B,mBAAmB,EACnB,MAAM,EACN,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,UAIA"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@knocklabs/react-core",
3
3
  "description": "A set of React components to build notification experiences powered by Knock",
4
4
  "author": "@knocklabs",
5
- "version": "0.3.0-rc-2.0",
5
+ "version": "0.3.0-rc-4.0",
6
6
  "license": "MIT",
7
7
  "main": "dist/cjs/index.js",
8
8
  "module": "dist/esm/index.mjs",
@@ -49,7 +49,7 @@
49
49
  "react": "^16.11.0 || ^17.0.0 || ^18.0.0"
50
50
  },
51
51
  "dependencies": {
52
- "@knocklabs/client": "^0.11.0-rc-2.0",
52
+ "@knocklabs/client": "^0.11.0-rc-4.0",
53
53
  "@tanstack/react-store": "^0.5.5",
54
54
  "date-fns": "^4.0.0",
55
55
  "fast-deep-equal": "^3.1.3",
@@ -16,14 +16,12 @@ export interface KnockProviderProps {
16
16
  apiKey: string;
17
17
  host?: string;
18
18
  // Authentication props
19
- userId: string;
20
- userToken?: string;
19
+ userId: Knock["userId"];
20
+ userToken?: Knock["userToken"];
21
21
  onUserTokenExpiring?: AuthenticateOptions["onUserTokenExpiring"];
22
22
  timeBeforeExpirationInMs?: AuthenticateOptions["timeBeforeExpirationInMs"];
23
-
24
23
  // i18n translations
25
24
  i18n?: I18nContent;
26
-
27
25
  logLevel?: LogLevel;
28
26
  }
29
27
 
@@ -5,8 +5,8 @@ import { useStableOptions } from "../../core";
5
5
 
6
6
  function authenticateWithOptions(
7
7
  knock: Knock,
8
- userId: string,
9
- userToken?: string,
8
+ userId: Knock["userId"],
9
+ userToken?: Knock["userToken"],
10
10
  options: AuthenticateOptions = {},
11
11
  ) {
12
12
  knock.authenticate(userId, userToken, {
@@ -20,8 +20,8 @@ export type AuthenticatedKnockClientOptions = KnockOptions &
20
20
 
21
21
  function useAuthenticatedKnockClient(
22
22
  apiKey: string,
23
- userId: string,
24
- userToken?: string,
23
+ userId: Knock["userId"],
24
+ userToken?: Knock["userToken"],
25
25
  options: AuthenticatedKnockClientOptions = {},
26
26
  ) {
27
27
  const knockRef = React.useRef<Knock | undefined>();
@@ -1,4 +1,4 @@
1
- import { FeedClientOptions } from "@knocklabs/client";
1
+ import Knock, { FeedClientOptions } from "@knocklabs/client";
2
2
  import { intlFormatDistance, parseISO } from "date-fns";
3
3
  import { ReactNode } from "react";
4
4
 
@@ -39,7 +39,7 @@ export function renderNodeOrFallback(node: ReactNode, fallback: ReactNode) {
39
39
  to trigger a re-render of the context when a key property changes.
40
40
  */
41
41
  export function feedProviderKey(
42
- userId: string | undefined,
42
+ userId: Knock["userId"],
43
43
  feedId: string,
44
44
  options: FeedClientOptions = {},
45
45
  ) {