@danainnovations/directory 0.1.2 → 0.1.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 +4 -22
- package/dist/index.d.mts +1 -7
- package/dist/index.d.ts +1 -7
- package/dist/index.js +0 -19
- package/dist/index.mjs +0 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @danainnovations/directory
|
|
2
2
|
|
|
3
|
-
Sonance employee directory SDK.
|
|
3
|
+
Sonance employee directory SDK. Zero-config access to the company's active directory (synced live from Okta/AD via SCIM).
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -8,24 +8,7 @@ Sonance employee directory SDK. Access the company's active directory (synced li
|
|
|
8
8
|
npm install @danainnovations/directory
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
**Option A: Environment variable**
|
|
14
|
-
|
|
15
|
-
Add to your `.env`:
|
|
16
|
-
```
|
|
17
|
-
DIRECTORY_KEY=your-key-here
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
**Option B: Call `init()` at app startup**
|
|
21
|
-
|
|
22
|
-
```ts
|
|
23
|
-
import { init } from '@danainnovations/directory'
|
|
24
|
-
|
|
25
|
-
init('your-key-here')
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Get your key from the Sonance IT team or internal wiki.
|
|
11
|
+
No environment variables or API keys needed. Just install and use.
|
|
29
12
|
|
|
30
13
|
## React Hooks
|
|
31
14
|
|
|
@@ -107,17 +90,16 @@ interface UserSearchParams {
|
|
|
107
90
|
|
|
108
91
|
## How It Works
|
|
109
92
|
|
|
110
|
-
This package connects directly to a Supabase database that receives live SCIM provisioning from Okta. The data updates automatically whenever IT makes changes in Okta/Active Directory (new hires, terminations, department changes, etc.). Only active employees are returned — non-person accounts (service accounts, rooms, test users) are filtered out by row-level security.
|
|
93
|
+
This package connects directly to a Supabase database that receives live SCIM provisioning from Okta. The data updates automatically whenever IT makes changes in Okta/Active Directory (new hires, terminations, department changes, etc.). Only active employees are returned — non-person accounts (service accounts, rooms, test users) are filtered out by row-level security.
|
|
111
94
|
|
|
112
95
|
## AI Integration Notes
|
|
113
96
|
|
|
114
97
|
When integrating this package into a project:
|
|
115
|
-
- **IMPORTANT**: The project must have a `DIRECTORY_KEY` env var set, or call `init("key")` before any queries. Without it, all queries return empty results.
|
|
116
98
|
- Use the React hooks (`useUsers`, `useUser`, `useDepartments`, `useOrgChart`) for client components
|
|
117
99
|
- Use the async functions (`getUsers`, `getUser`, `getDepartments`, `getOrgChart`) for server components, API routes, or scripts
|
|
118
100
|
- All hooks return `{ loading, error }` alongside the data
|
|
119
101
|
- The `useUsers` hook re-fetches automatically when search params change
|
|
120
|
-
- No providers or
|
|
102
|
+
- No providers, context, or setup needed — just import and use
|
|
121
103
|
- For people pickers / autocomplete, use `useUsers({ search: inputValue })` with a debounced input
|
|
122
104
|
- For org charts, `useOrgChart()` returns a tree — each node has a `.reports[]` array of direct reports
|
|
123
105
|
- For department filters, `useDepartments()` returns departments sorted alphabetically with employee counts
|
package/dist/index.d.mts
CHANGED
|
@@ -38,12 +38,6 @@ interface OrgNode {
|
|
|
38
38
|
reports: OrgNode[];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
/**
|
|
42
|
-
* Initialize the directory SDK with your access key.
|
|
43
|
-
* Alternatively, set the DIRECTORY_KEY environment variable.
|
|
44
|
-
*/
|
|
45
|
-
declare function init(key: string): void;
|
|
46
|
-
|
|
47
41
|
declare function getUsers(params?: UserSearchParams): Promise<UserSearchResult>;
|
|
48
42
|
declare function getUser(emailOrId: string): Promise<DirectoryUser | null>;
|
|
49
43
|
declare function getDepartments(): Promise<Department[]>;
|
|
@@ -71,4 +65,4 @@ declare function useOrgChart(): {
|
|
|
71
65
|
error: Error | null;
|
|
72
66
|
};
|
|
73
67
|
|
|
74
|
-
export { type Department, type DirectoryUser, type OrgNode, type UserSearchParams, type UserSearchResult, getDepartments, getOrgChart, getUser, getUsers,
|
|
68
|
+
export { type Department, type DirectoryUser, type OrgNode, type UserSearchParams, type UserSearchResult, getDepartments, getOrgChart, getUser, getUsers, useDepartments, useOrgChart, useUser, useUsers };
|
package/dist/index.d.ts
CHANGED
|
@@ -38,12 +38,6 @@ interface OrgNode {
|
|
|
38
38
|
reports: OrgNode[];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
/**
|
|
42
|
-
* Initialize the directory SDK with your access key.
|
|
43
|
-
* Alternatively, set the DIRECTORY_KEY environment variable.
|
|
44
|
-
*/
|
|
45
|
-
declare function init(key: string): void;
|
|
46
|
-
|
|
47
41
|
declare function getUsers(params?: UserSearchParams): Promise<UserSearchResult>;
|
|
48
42
|
declare function getUser(emailOrId: string): Promise<DirectoryUser | null>;
|
|
49
43
|
declare function getDepartments(): Promise<Department[]>;
|
|
@@ -71,4 +65,4 @@ declare function useOrgChart(): {
|
|
|
71
65
|
error: Error | null;
|
|
72
66
|
};
|
|
73
67
|
|
|
74
|
-
export { type Department, type DirectoryUser, type OrgNode, type UserSearchParams, type UserSearchResult, getDepartments, getOrgChart, getUser, getUsers,
|
|
68
|
+
export { type Department, type DirectoryUser, type OrgNode, type UserSearchParams, type UserSearchResult, getDepartments, getOrgChart, getUser, getUsers, useDepartments, useOrgChart, useUser, useUsers };
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,6 @@ __export(index_exports, {
|
|
|
24
24
|
getOrgChart: () => getOrgChart,
|
|
25
25
|
getUser: () => getUser,
|
|
26
26
|
getUsers: () => getUsers,
|
|
27
|
-
init: () => init,
|
|
28
27
|
useDepartments: () => useDepartments,
|
|
29
28
|
useOrgChart: () => useOrgChart,
|
|
30
29
|
useUser: () => useUser,
|
|
@@ -37,29 +36,12 @@ var import_supabase_js = require("@supabase/supabase-js");
|
|
|
37
36
|
var SUPABASE_URL = "https://vfwtukipsinfkfjtivbw.supabase.co";
|
|
38
37
|
var SUPABASE_ANON_KEY = "sb_publishable_V0y4tzcVuftRGEAdvwHloA_iQf7tPUz";
|
|
39
38
|
var client = null;
|
|
40
|
-
var directoryKey = null;
|
|
41
|
-
function init(key) {
|
|
42
|
-
directoryKey = key;
|
|
43
|
-
client = null;
|
|
44
|
-
}
|
|
45
|
-
function getKey() {
|
|
46
|
-
const key = directoryKey || typeof process !== "undefined" && process.env?.DIRECTORY_KEY || "";
|
|
47
|
-
if (!key) {
|
|
48
|
-
console.warn('[@danainnovations/directory] No DIRECTORY_KEY set. Call init("your-key") or set the DIRECTORY_KEY env var.');
|
|
49
|
-
}
|
|
50
|
-
return key;
|
|
51
|
-
}
|
|
52
39
|
function getDirectoryClient() {
|
|
53
40
|
if (!client) {
|
|
54
41
|
client = (0, import_supabase_js.createClient)(SUPABASE_URL, SUPABASE_ANON_KEY, {
|
|
55
42
|
auth: {
|
|
56
43
|
autoRefreshToken: false,
|
|
57
44
|
persistSession: false
|
|
58
|
-
},
|
|
59
|
-
global: {
|
|
60
|
-
headers: {
|
|
61
|
-
"x-directory-key": getKey()
|
|
62
|
-
}
|
|
63
45
|
}
|
|
64
46
|
});
|
|
65
47
|
}
|
|
@@ -256,7 +238,6 @@ function useOrgChart() {
|
|
|
256
238
|
getOrgChart,
|
|
257
239
|
getUser,
|
|
258
240
|
getUsers,
|
|
259
|
-
init,
|
|
260
241
|
useDepartments,
|
|
261
242
|
useOrgChart,
|
|
262
243
|
useUser,
|
package/dist/index.mjs
CHANGED
|
@@ -3,29 +3,12 @@ import { createClient } from "@supabase/supabase-js";
|
|
|
3
3
|
var SUPABASE_URL = "https://vfwtukipsinfkfjtivbw.supabase.co";
|
|
4
4
|
var SUPABASE_ANON_KEY = "sb_publishable_V0y4tzcVuftRGEAdvwHloA_iQf7tPUz";
|
|
5
5
|
var client = null;
|
|
6
|
-
var directoryKey = null;
|
|
7
|
-
function init(key) {
|
|
8
|
-
directoryKey = key;
|
|
9
|
-
client = null;
|
|
10
|
-
}
|
|
11
|
-
function getKey() {
|
|
12
|
-
const key = directoryKey || typeof process !== "undefined" && process.env?.DIRECTORY_KEY || "";
|
|
13
|
-
if (!key) {
|
|
14
|
-
console.warn('[@danainnovations/directory] No DIRECTORY_KEY set. Call init("your-key") or set the DIRECTORY_KEY env var.');
|
|
15
|
-
}
|
|
16
|
-
return key;
|
|
17
|
-
}
|
|
18
6
|
function getDirectoryClient() {
|
|
19
7
|
if (!client) {
|
|
20
8
|
client = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
|
|
21
9
|
auth: {
|
|
22
10
|
autoRefreshToken: false,
|
|
23
11
|
persistSession: false
|
|
24
|
-
},
|
|
25
|
-
global: {
|
|
26
|
-
headers: {
|
|
27
|
-
"x-directory-key": getKey()
|
|
28
|
-
}
|
|
29
12
|
}
|
|
30
13
|
});
|
|
31
14
|
}
|
|
@@ -221,7 +204,6 @@ export {
|
|
|
221
204
|
getOrgChart,
|
|
222
205
|
getUser,
|
|
223
206
|
getUsers,
|
|
224
|
-
init,
|
|
225
207
|
useDepartments,
|
|
226
208
|
useOrgChart,
|
|
227
209
|
useUser,
|
package/package.json
CHANGED