@pikku/addon-admin 0.12.6 → 0.12.8
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/dist/.pikku/addon/agent/index.d.ts +1 -1
- package/dist/.pikku/addon/agent/index.js +1 -1
- package/dist/.pikku/addon/agent/pikku-agent-map.gen.d.ts +1 -1
- package/dist/.pikku/addon/agent/pikku-agent-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/agent/pikku-model-aliases.gen.js +1 -1
- package/dist/.pikku/addon/agent/pikku-scorer-names.gen.d.ts +1 -1
- package/dist/.pikku/addon/analytics/index.d.ts +1 -1
- package/dist/.pikku/addon/analytics/index.js +1 -1
- package/dist/.pikku/addon/analytics/pikku-analytics-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/analytics/pikku-analytics-types.gen.js +1 -1
- package/dist/.pikku/addon/auth/index.d.ts +1 -1
- package/dist/.pikku/addon/auth/index.js +1 -1
- package/dist/.pikku/addon/auth/pikku-auth-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/auth/pikku-auth-types.gen.js +1 -1
- package/dist/.pikku/addon/channel/index.d.ts +1 -1
- package/dist/.pikku/addon/channel/index.js +1 -1
- package/dist/.pikku/addon/channel/pikku-channel-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/channel/pikku-channel-types.gen.js +1 -1
- package/dist/.pikku/addon/cli/index.d.ts +8 -0
- package/dist/.pikku/addon/cli/index.d.ts.map +1 -0
- package/dist/.pikku/addon/cli/index.js +8 -0
- package/dist/.pikku/addon/cli/index.js.map +1 -0
- package/dist/.pikku/addon/cli/pikku-cli-types.gen.d.ts +62 -0
- package/dist/.pikku/addon/cli/pikku-cli-types.gen.d.ts.map +1 -0
- package/dist/.pikku/addon/cli/pikku-cli-types.gen.js +49 -0
- package/dist/.pikku/addon/cli/pikku-cli-types.gen.js.map +1 -0
- package/dist/.pikku/addon/error/index.d.ts +1 -1
- package/dist/.pikku/addon/error/index.js +1 -1
- package/dist/.pikku/addon/error/pikku-error-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/error/pikku-error-types.gen.js +1 -1
- package/dist/.pikku/addon/function/index.d.ts +1 -1
- package/dist/.pikku/addon/function/index.js +1 -1
- package/dist/.pikku/addon/function/pikku-function-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/function/pikku-function-types.gen.js +1 -1
- package/dist/.pikku/addon/function/pikku-functions-meta-verbose.gen.json +224 -41
- package/dist/.pikku/addon/function/pikku-functions-meta.gen.js +1 -1
- package/dist/.pikku/addon/function/pikku-functions-meta.gen.json +154 -5
- package/dist/.pikku/addon/function/pikku-functions.gen.js +9 -1
- package/dist/.pikku/addon/function/pikku-functions.gen.js.map +1 -1
- package/dist/.pikku/addon/http/index.d.ts +1 -1
- package/dist/.pikku/addon/http/index.js +1 -1
- package/dist/.pikku/addon/http/pikku-http-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/http/pikku-http-types.gen.js +1 -1
- package/dist/.pikku/addon/mcp/index.d.ts +1 -1
- package/dist/.pikku/addon/mcp/index.js +1 -1
- package/dist/.pikku/addon/mcp/pikku-mcp-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/mcp/pikku-mcp-types.gen.js +1 -1
- package/dist/.pikku/addon/middleware/index.d.ts +1 -1
- package/dist/.pikku/addon/middleware/index.js +1 -1
- package/dist/.pikku/addon/middleware/pikku-middleware-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/middleware/pikku-middleware-types.gen.js +1 -1
- package/dist/.pikku/addon/pikku-bootstrap-scenarios.gen.d.ts +1 -1
- package/dist/.pikku/addon/pikku-bootstrap-scenarios.gen.js +1 -1
- package/dist/.pikku/addon/pikku-bootstrap.gen.d.ts +1 -1
- package/dist/.pikku/addon/pikku-bootstrap.gen.js +1 -1
- package/dist/.pikku/addon/pikku-package.gen.js +2 -2
- package/dist/.pikku/addon/pikku-package.gen.js.map +1 -1
- package/dist/.pikku/addon/pikku-services.gen.d.ts +5 -3
- package/dist/.pikku/addon/pikku-services.gen.d.ts.map +1 -1
- package/dist/.pikku/addon/pikku-services.gen.js +3 -1
- package/dist/.pikku/addon/pikku-services.gen.js.map +1 -1
- package/dist/.pikku/addon/rpc/pikku-rpc-wirings-map.gen.d.ts +22 -1
- package/dist/.pikku/addon/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +22 -1
- package/dist/.pikku/addon/rpc/pikku-rpc-wirings-map.remote.gen.d.ts +18 -1
- package/dist/.pikku/addon/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
- package/dist/.pikku/addon/rpc/pikku-rpc-wirings-meta.internal.gen.json +5 -1
- package/dist/.pikku/addon/scenarios/index.d.ts +1 -1
- package/dist/.pikku/addon/scenarios/index.js +1 -1
- package/dist/.pikku/addon/scenarios/pikku-personas.gen.js +1 -1
- package/dist/.pikku/addon/scenarios/pikku-scenario-functions-meta.gen.js +1 -1
- package/dist/.pikku/addon/scenarios/pikku-scenario-functions.gen.d.ts +1 -1
- package/dist/.pikku/addon/scenarios/pikku-scenario-types.gen.d.ts +7 -1
- package/dist/.pikku/addon/scenarios/pikku-scenario-types.gen.d.ts.map +1 -1
- package/dist/.pikku/addon/scenarios/pikku-scenario-types.gen.js.map +1 -1
- package/dist/.pikku/addon/scenarios/pikku-scenario-wirings-meta.gen.js +1 -1
- package/dist/.pikku/addon/scenarios/pikku-scenario-wirings.gen.d.ts +1 -1
- package/dist/.pikku/addon/scenarios/schemas/register.gen.d.ts +1 -1
- package/dist/.pikku/addon/scenarios/schemas/register.gen.js +1 -1
- package/dist/.pikku/addon/schemas/register.gen.js +15 -1
- package/dist/.pikku/addon/schemas/register.gen.js.map +1 -1
- package/dist/.pikku/addon/schemas/schemas/ListUsersInput.schema.json +1 -1
- package/dist/.pikku/addon/schemas/schemas/ListUsersOutput.schema.json +1 -1
- package/dist/.pikku/addon/schemas/schemas/TriggerSourceForgetInput.schema.json +1 -0
- package/dist/.pikku/addon/schemas/schemas/TriggerSourceForgetOutput.schema.json +1 -0
- package/dist/.pikku/addon/schemas/schemas/TriggerSourceListOutput.schema.json +1 -0
- package/dist/.pikku/addon/schemas/schemas/TriggerSourceReconcileInput.schema.json +1 -0
- package/dist/.pikku/addon/schemas/schemas/TriggerSourceReconcileOutput.schema.json +1 -0
- package/dist/.pikku/addon/schemas/schemas/TriggerSourceTeardownInput.schema.json +1 -0
- package/dist/.pikku/addon/schemas/schemas/TriggerSourceTeardownOutput.schema.json +1 -0
- package/dist/.pikku/addon/scopes/index.d.ts +1 -1
- package/dist/.pikku/addon/scopes/index.js +1 -1
- package/dist/.pikku/addon/scopes/pikku-flags.gen.d.ts +1 -1
- package/dist/.pikku/addon/scopes/pikku-personas.gen.js +1 -1
- package/dist/.pikku/addon/scopes/pikku-roles.gen.d.ts +1 -1
- package/dist/.pikku/addon/scopes/pikku-scope-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/scopes/pikku-scope-types.gen.js +1 -1
- package/dist/.pikku/addon/scopes/pikku-scopes-meta.gen.json +11 -0
- package/dist/.pikku/addon/scopes/pikku-scopes.gen.d.ts +2 -2
- package/dist/.pikku/addon/scopes/pikku-scopes.gen.d.ts.map +1 -1
- package/dist/.pikku/addon/scopes/pikku-scopes.gen.js.map +1 -1
- package/dist/.pikku/addon/secrets/index.d.ts +1 -1
- package/dist/.pikku/addon/secrets/index.js +1 -1
- package/dist/.pikku/addon/secrets/pikku-secret-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/secrets/pikku-secret-types.gen.js +1 -1
- package/dist/.pikku/addon/secrets/pikku-secrets.gen.d.ts +1 -1
- package/dist/.pikku/addon/secrets/pikku-secrets.gen.js +1 -1
- package/dist/.pikku/addon/services/pikku-meta-service.gen.d.ts +1 -1
- package/dist/.pikku/addon/services/pikku-meta-service.gen.js +1 -1
- package/dist/.pikku/addon/setup/index.d.ts +1 -1
- package/dist/.pikku/addon/setup/index.js +1 -1
- package/dist/.pikku/addon/setup/pikku-addon-setup-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/setup/pikku-addon-setup-types.gen.js +1 -1
- package/dist/.pikku/addon/setup/pikku-setup-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/setup/pikku-setup-types.gen.js +1 -1
- package/dist/.pikku/addon/trigger/index.d.ts +1 -1
- package/dist/.pikku/addon/trigger/index.js +1 -1
- package/dist/.pikku/addon/trigger/pikku-trigger-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/trigger/pikku-trigger-types.gen.js +1 -1
- package/dist/.pikku/addon/variables/index.d.ts +1 -1
- package/dist/.pikku/addon/variables/index.js +1 -1
- package/dist/.pikku/addon/variables/pikku-variable-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/variables/pikku-variable-types.gen.js +1 -1
- package/dist/.pikku/addon/variables/pikku-variables.gen.d.ts +1 -1
- package/dist/.pikku/addon/variables/pikku-variables.gen.js +1 -1
- package/dist/.pikku/addon/webhooks/pikku-outgoing-webhooks-meta.gen.json +1 -0
- package/dist/.pikku/addon/webhooks/pikku-outgoing-webhooks.gen.d.ts +12 -0
- package/dist/.pikku/addon/webhooks/pikku-outgoing-webhooks.gen.d.ts.map +1 -0
- package/dist/.pikku/addon/webhooks/pikku-outgoing-webhooks.gen.js +3 -0
- package/dist/.pikku/addon/webhooks/pikku-outgoing-webhooks.gen.js.map +1 -0
- package/dist/.pikku/addon/workflow/index.d.ts +1 -1
- package/dist/.pikku/addon/workflow/index.js +1 -1
- package/dist/.pikku/addon/workflow/pikku-scenario-step-map.gen.d.ts +1 -1
- package/dist/.pikku/addon/workflow/pikku-workflow-map.gen.d.ts +1 -1
- package/dist/.pikku/addon/workflow/pikku-workflow-types.gen.d.ts +1 -1
- package/dist/.pikku/addon/workflow/pikku-workflow-types.gen.js +1 -1
- package/dist/.pikku/addon/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
- package/dist/.pikku/addon/workflow/pikku-workflow-wirings.gen.d.ts +1 -1
- package/dist/.pikku/addon/workflow/pikku-workflow-wirings.gen.js +1 -1
- package/dist/src/functions/list-users.function.d.ts +15 -0
- package/dist/src/functions/list-users.function.d.ts.map +1 -1
- package/dist/src/functions/list-users.function.js +102 -25
- package/dist/src/functions/list-users.function.js.map +1 -1
- package/dist/src/functions/list-users.function.test.d.ts +2 -0
- package/dist/src/functions/list-users.function.test.d.ts.map +1 -0
- package/dist/src/functions/list-users.function.test.js +175 -0
- package/dist/src/functions/list-users.function.test.js.map +1 -0
- package/dist/src/functions/trigger-source-forget.function.d.ts +14 -0
- package/dist/src/functions/trigger-source-forget.function.d.ts.map +1 -0
- package/dist/src/functions/trigger-source-forget.function.js +13 -0
- package/dist/src/functions/trigger-source-forget.function.js.map +1 -0
- package/dist/src/functions/trigger-source-list.function.d.ts +9 -0
- package/dist/src/functions/trigger-source-list.function.d.ts.map +1 -0
- package/dist/src/functions/trigger-source-list.function.js +12 -0
- package/dist/src/functions/trigger-source-list.function.js.map +1 -0
- package/dist/src/functions/trigger-source-reconcile.function.d.ts +18 -0
- package/dist/src/functions/trigger-source-reconcile.function.d.ts.map +1 -0
- package/dist/src/functions/trigger-source-reconcile.function.js +12 -0
- package/dist/src/functions/trigger-source-reconcile.function.js.map +1 -0
- package/dist/src/functions/trigger-source-teardown.function.d.ts +21 -0
- package/dist/src/functions/trigger-source-teardown.function.d.ts.map +1 -0
- package/dist/src/functions/trigger-source-teardown.function.js +12 -0
- package/dist/src/functions/trigger-source-teardown.function.js.map +1 -0
- package/dist/src/lib/is-person.d.ts +16 -0
- package/dist/src/lib/is-person.d.ts.map +1 -1
- package/dist/src/lib/is-person.js +17 -1
- package/dist/src/lib/is-person.js.map +1 -1
- package/dist/src/lib/require-trigger-source-store.d.ts +3 -0
- package/dist/src/lib/require-trigger-source-store.d.ts.map +1 -0
- package/dist/src/lib/require-trigger-source-store.js +7 -0
- package/dist/src/lib/require-trigger-source-store.js.map +1 -0
- package/dist/src/lib/user.schemas.d.ts +7 -0
- package/dist/src/lib/user.schemas.d.ts.map +1 -1
- package/dist/src/lib/user.schemas.js +26 -0
- package/dist/src/lib/user.schemas.js.map +1 -1
- package/dist/src/scopes.js +11 -0
- package/dist/src/scopes.js.map +1 -1
- package/dist/src/services.d.ts.map +1 -1
- package/dist/src/services.js +2 -1
- package/dist/src/services.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was generated by @pikku/cli@0.12.171
|
|
3
|
+
*/
|
|
4
|
+
import type { TypedWebhookService as CoreTypedWebhookService } from '@pikku/core/webhook';
|
|
5
|
+
import type { WebhookService } from '@pikku/core/services';
|
|
6
|
+
import './pikku-outgoing-webhooks-meta.gen.json';
|
|
7
|
+
export interface OutgoingWebhooksMap {
|
|
8
|
+
}
|
|
9
|
+
export type OutgoingWebhookEvent = keyof OutgoingWebhooksMap;
|
|
10
|
+
export type TypedWebhookService = CoreTypedWebhookService<OutgoingWebhooksMap>;
|
|
11
|
+
export declare const typedWebhookService: (service: WebhookService) => TypedWebhookService;
|
|
12
|
+
//# sourceMappingURL=pikku-outgoing-webhooks.gen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pikku-outgoing-webhooks.gen.d.ts","sourceRoot":"","sources":["../../../../.pikku/addon/webhooks/pikku-outgoing-webhooks.gen.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,mBAAmB,IAAI,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AACzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,yCAAyC,CAAsB;AAEtE,MAAM,WAAW,mBAAmB;CAAG;AAEvC,MAAM,MAAM,oBAAoB,GAAG,MAAM,mBAAmB,CAAA;AAE5D,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,CAAC,mBAAmB,CAAC,CAAA;AAE9E,eAAO,MAAM,mBAAmB,YAAa,cAAc,KAAG,mBACnB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pikku-outgoing-webhooks.gen.js","sourceRoot":"","sources":["../../../../.pikku/addon/webhooks/pikku-outgoing-webhooks.gen.ts"],"names":[],"mappings":"AAKA,OAAO,yCAAyC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAQtE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAuB,EAAuB,EAAE,CAClF,OAAyC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was generated by @pikku/cli@0.12.
|
|
2
|
+
* This file was generated by @pikku/cli@0.12.171
|
|
3
3
|
*/
|
|
4
4
|
import { WorkflowCancelledException } from '@pikku/core/workflow';
|
|
5
5
|
import type { PikkuWorkflowGraphConfig, PikkuWorkflowGraphResult } from '@pikku/core/workflow';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare const listUsers: import("#pikku/addon/function").PikkuFunctionConfig<{
|
|
2
2
|
search?: string | undefined;
|
|
3
3
|
limit?: number | undefined;
|
|
4
|
+
offset?: number | undefined;
|
|
5
|
+
includeRoles?: boolean | undefined;
|
|
4
6
|
}, {
|
|
5
7
|
users: {
|
|
6
8
|
id: string;
|
|
@@ -11,10 +13,15 @@ export declare const listUsers: import("#pikku/addon/function").PikkuFunctionCon
|
|
|
11
13
|
banned?: boolean | undefined;
|
|
12
14
|
banReason?: string | undefined;
|
|
13
15
|
banExpires?: string | undefined;
|
|
16
|
+
roles?: string[] | undefined;
|
|
17
|
+
fields?: Record<string, unknown> | undefined;
|
|
14
18
|
}[];
|
|
19
|
+
total: number;
|
|
15
20
|
}, "rpc" | "session", import("#pikku/addon/function").PikkuFunction<{
|
|
16
21
|
search?: string | undefined;
|
|
17
22
|
limit?: number | undefined;
|
|
23
|
+
offset?: number | undefined;
|
|
24
|
+
includeRoles?: boolean | undefined;
|
|
18
25
|
}, {
|
|
19
26
|
users: {
|
|
20
27
|
id: string;
|
|
@@ -25,10 +32,15 @@ export declare const listUsers: import("#pikku/addon/function").PikkuFunctionCon
|
|
|
25
32
|
banned?: boolean | undefined;
|
|
26
33
|
banReason?: string | undefined;
|
|
27
34
|
banExpires?: string | undefined;
|
|
35
|
+
roles?: string[] | undefined;
|
|
36
|
+
fields?: Record<string, unknown> | undefined;
|
|
28
37
|
}[];
|
|
38
|
+
total: number;
|
|
29
39
|
}, "rpc" | "session", import("#pikku/addon/function").WiredServices> | import("#pikku/addon/function").PikkuFunctionSessionless<{
|
|
30
40
|
search?: string | undefined;
|
|
31
41
|
limit?: number | undefined;
|
|
42
|
+
offset?: number | undefined;
|
|
43
|
+
includeRoles?: boolean | undefined;
|
|
32
44
|
}, {
|
|
33
45
|
users: {
|
|
34
46
|
id: string;
|
|
@@ -39,6 +51,9 @@ export declare const listUsers: import("#pikku/addon/function").PikkuFunctionCon
|
|
|
39
51
|
banned?: boolean | undefined;
|
|
40
52
|
banReason?: string | undefined;
|
|
41
53
|
banExpires?: string | undefined;
|
|
54
|
+
roles?: string[] | undefined;
|
|
55
|
+
fields?: Record<string, unknown> | undefined;
|
|
42
56
|
}[];
|
|
57
|
+
total: number;
|
|
43
58
|
}, "rpc" | "session", import("#pikku/addon/function").WiredServices, unknown>, undefined, undefined>;
|
|
44
59
|
//# sourceMappingURL=list-users.function.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-users.function.d.ts","sourceRoot":"","sources":["../../../src/functions/list-users.function.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list-users.function.d.ts","sourceRoot":"","sources":["../../../src/functions/list-users.function.ts"],"names":[],"mappings":"AA+CA,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oGA8FpB,CAAA"}
|
|
@@ -1,40 +1,117 @@
|
|
|
1
1
|
import { pikkuFunc } from '#pikku/addon/function';
|
|
2
|
-
import {
|
|
2
|
+
import { verifyScopes } from '@pikku/core/scope';
|
|
3
|
+
import { isPerson, PLATFORM_USER_ID, SYNTHETIC_MARKERS, } from '../lib/is-person.js';
|
|
3
4
|
import { ListUsersInput, ListUsersOutput } from '../lib/user.schemas.js';
|
|
5
|
+
/** Rows read per marker when gathering synthetic ids. */
|
|
6
|
+
const SYNTHETIC_CEILING = 1000;
|
|
7
|
+
/**
|
|
8
|
+
* The ids that are not people, so the query itself can exclude them.
|
|
9
|
+
*
|
|
10
|
+
* They are gathered by id rather than excluded with `actor != true`, because
|
|
11
|
+
* both marker columns are declared `required: false`: a host whose migration
|
|
12
|
+
* left them nullable stores NULL for every ordinary user, and `column != true`
|
|
13
|
+
* is NULL for a NULL column — not true, so SQL drops the row and the directory
|
|
14
|
+
* comes back empty. A primary key is never NULL, so `id NOT IN (...)` is safe
|
|
15
|
+
* on any schema.
|
|
16
|
+
*/
|
|
17
|
+
const syntheticIds = async (ctx) => {
|
|
18
|
+
// The platform principal exists as soon as a singleton credential is linked
|
|
19
|
+
// and never goes away afterwards, so it is cheaper to always exclude it than
|
|
20
|
+
// to ask whether it is there.
|
|
21
|
+
const ids = new Set([PLATFORM_USER_ID]);
|
|
22
|
+
const declared = ctx.tables?.user?.fields ?? {};
|
|
23
|
+
for (const marker of SYNTHETIC_MARKERS) {
|
|
24
|
+
if (!(marker in declared)) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const rows = (await ctx.adapter.findMany({
|
|
28
|
+
model: 'user',
|
|
29
|
+
where: [{ field: marker, operator: 'eq', value: true }],
|
|
30
|
+
select: ['id'],
|
|
31
|
+
limit: SYNTHETIC_CEILING,
|
|
32
|
+
}));
|
|
33
|
+
for (const row of rows) {
|
|
34
|
+
ids.add(row.id);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return [...ids];
|
|
38
|
+
};
|
|
4
39
|
export const listUsers = pikkuFunc({
|
|
5
40
|
title: 'List Users',
|
|
6
|
-
description: 'Lists and searches the user directory, read through the auth adapter so it works on any database better-auth supports.',
|
|
41
|
+
description: 'Lists and searches the user directory, read through the auth adapter so it works on any database better-auth supports. Newest first, paged with `limit` and `offset`.',
|
|
7
42
|
expose: true,
|
|
8
43
|
scopes: ['admin:users:list'],
|
|
9
44
|
input: ListUsersInput,
|
|
10
45
|
output: ListUsersOutput,
|
|
11
|
-
func: async ({ auth }, { search, limit }) => {
|
|
46
|
+
func: async ({ auth, scopeService }, { search, limit, offset, includeRoles }, { session }) => {
|
|
12
47
|
if (!auth) {
|
|
13
|
-
return { users: [] };
|
|
48
|
+
return { users: [], total: 0 };
|
|
49
|
+
}
|
|
50
|
+
// Checked here rather than declared on the function, so that asking for the
|
|
51
|
+
// directory alone does not require a scope only the roles need.
|
|
52
|
+
if (includeRoles) {
|
|
53
|
+
verifyScopes(['admin:scopes:read'], session);
|
|
14
54
|
}
|
|
15
55
|
const ctx = await (await auth()).$context;
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
56
|
+
const where = search
|
|
57
|
+
? [{ field: 'email', operator: 'contains', value: search }]
|
|
58
|
+
: [];
|
|
59
|
+
where.push({
|
|
60
|
+
field: 'id',
|
|
61
|
+
operator: 'not_in',
|
|
62
|
+
value: await syntheticIds(ctx),
|
|
63
|
+
});
|
|
64
|
+
const [rows, total] = await Promise.all([
|
|
65
|
+
ctx.adapter.findMany({
|
|
66
|
+
model: 'user',
|
|
67
|
+
where,
|
|
68
|
+
limit: limit ?? 200,
|
|
69
|
+
offset: offset ?? 0,
|
|
70
|
+
// Paging over an unordered result means nothing: without a stable sort
|
|
71
|
+
// the second page is drawn from a different arrangement than the first.
|
|
72
|
+
sortBy: { field: 'createdAt', direction: 'desc' },
|
|
73
|
+
}),
|
|
74
|
+
ctx.adapter.count({ model: 'user', where }),
|
|
75
|
+
]);
|
|
76
|
+
// A floor under the query: a host with more than SYNTHETIC_CEILING marked
|
|
77
|
+
// rows loses a page slot to one the gather missed, rather than showing a
|
|
78
|
+
// service principal in a people-picker.
|
|
79
|
+
const users = rows.filter(isPerson);
|
|
80
|
+
const roles = includeRoles && scopeService
|
|
81
|
+
? await scopeService.listRolesForUsers(users.map((row) => row.id))
|
|
82
|
+
: undefined;
|
|
83
|
+
// `returned: false` marks a column that must not leave the server, and
|
|
84
|
+
// reading the adapter directly bypasses where better-auth normally applies
|
|
85
|
+
// it.
|
|
86
|
+
const additionalFields = Object.entries((ctx.options?.user?.additionalFields ?? {}))
|
|
87
|
+
.filter(([, attribute]) => attribute?.returned !== false)
|
|
88
|
+
.map(([name]) => name);
|
|
23
89
|
return {
|
|
24
|
-
users:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
:
|
|
37
|
-
|
|
90
|
+
users: users.map((row) => {
|
|
91
|
+
const fields = {};
|
|
92
|
+
for (const name of additionalFields) {
|
|
93
|
+
if (row[name] !== undefined && row[name] !== null) {
|
|
94
|
+
fields[name] = row[name];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
id: row.id,
|
|
99
|
+
email: row.email,
|
|
100
|
+
name: row.name ?? undefined,
|
|
101
|
+
image: row.image ?? undefined,
|
|
102
|
+
createdAt: row.createdAt
|
|
103
|
+
? new Date(row.createdAt).toISOString()
|
|
104
|
+
: undefined,
|
|
105
|
+
banned: typeof row.banned === 'boolean' ? row.banned : undefined,
|
|
106
|
+
banReason: row.banReason ?? undefined,
|
|
107
|
+
banExpires: row.banExpires
|
|
108
|
+
? new Date(row.banExpires).toISOString()
|
|
109
|
+
: undefined,
|
|
110
|
+
roles: roles ? (roles[row.id] ?? []) : undefined,
|
|
111
|
+
fields: Object.keys(fields).length > 0 ? fields : undefined,
|
|
112
|
+
};
|
|
113
|
+
}),
|
|
114
|
+
total,
|
|
38
115
|
};
|
|
39
116
|
},
|
|
40
117
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-users.function.js","sourceRoot":"","sources":["../../../src/functions/list-users.function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"list-users.function.js","sourceRoot":"","sources":["../../../src/functions/list-users.function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExE,yDAAyD;AACzD,MAAM,iBAAiB,GAAG,IAAI,CAAA;AAE9B;;;;;;;;;GASG;AACH,MAAM,YAAY,GAAG,KAAK,EAAE,GAAQ,EAAqB,EAAE;IACzD,4EAA4E;IAC5E,6EAA6E;IAC7E,8BAA8B;IAC9B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAS,CAAC,gBAAgB,CAAC,CAAC,CAAA;IAC/C,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,IAAI,EAAE,CAAA;IAE/C,KAAK,MAAM,MAAM,IAAI,iBAAiB,EAAE,CAAC;QACvC,IAAI,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,EAAE,CAAC;YAC1B,SAAQ;QACV,CAAC;QACD,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;YACvC,KAAK,EAAE,MAAM;YACb,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;YACvD,MAAM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;SACN,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-users.function.test.d.ts","sourceRoot":"","sources":["../../../src/functions/list-users.function.test.ts"],"names":[],"mappings":""}
|