@adventurelabs/scout-core 1.4.80 → 1.4.81
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.
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SupabaseClient } from "@supabase/supabase-js";
|
|
2
2
|
import { Database } from "../types/supabase";
|
|
3
|
-
import { IAbility, IHerdRole, IHerdRoleAbilityRow, IHerdRoleWithAbilities } from "../types/db";
|
|
3
|
+
import { IAbility, IHerdRole, IHerdRoleAbilityRow, IHerdRoleWithAbilities, IPlatformDefaultRoleAbilitiesGroup } from "../types/db";
|
|
4
4
|
import { IWebResponseCompatible } from "../types/requests";
|
|
5
5
|
export declare function server_list_abilities(supabaseClient?: SupabaseClient<Database>): Promise<IWebResponseCompatible<IAbility[]>>;
|
|
6
|
+
export declare function server_get_abilities_by_ids(ids: number[], supabaseClient?: SupabaseClient<Database>): Promise<IWebResponseCompatible<IAbility[]>>;
|
|
6
7
|
export declare function server_get_herd_roles(herd_id: number, supabaseClient?: SupabaseClient<Database>): Promise<IWebResponseCompatible<IHerdRole[]>>;
|
|
7
8
|
export declare function server_get_herd_roles_with_abilities(herd_id: number, supabaseClient?: SupabaseClient<Database>): Promise<IWebResponseCompatible<IHerdRoleWithAbilities[]>>;
|
|
8
9
|
export declare function server_get_herd_role_by_system_name(herd_id: number, system_name: string, supabaseClient?: SupabaseClient<Database>): Promise<IWebResponseCompatible<IHerdRole | null>>;
|
|
@@ -12,3 +13,6 @@ export declare function server_update_herd_role(herd_role_id: number, patch: {
|
|
|
12
13
|
}, supabaseClient?: SupabaseClient<Database>): Promise<IWebResponseCompatible<IHerdRole | null>>;
|
|
13
14
|
export declare function server_delete_herd_role(herd_role_id: number, supabaseClient?: SupabaseClient<Database>): Promise<IWebResponseCompatible<null>>;
|
|
14
15
|
export declare function server_set_herd_role_abilities(herd_role_id: number, ability_ids: number[], supabaseClient?: SupabaseClient<Database>): Promise<IWebResponseCompatible<IHerdRoleAbilityRow[]>>;
|
|
16
|
+
export declare function server_get_platform_default_role_abilities(supabaseClient?: SupabaseClient<Database>): Promise<IWebResponseCompatible<IPlatformDefaultRoleAbilitiesGroup[]>>;
|
|
17
|
+
export declare function server_set_platform_default_role_abilities(system_name: string, ability_keys: string[], supabaseClient?: SupabaseClient<Database>): Promise<IWebResponseCompatible<null>>;
|
|
18
|
+
export declare function server_reset_herd_default_role_abilities(herd_id: number, supabaseClient?: SupabaseClient<Database>): Promise<IWebResponseCompatible<null>>;
|
|
@@ -12,6 +12,21 @@ export async function server_list_abilities(supabaseClient) {
|
|
|
12
12
|
}
|
|
13
13
|
return IWebResponse.success(data ?? []).to_compatible();
|
|
14
14
|
}
|
|
15
|
+
export async function server_get_abilities_by_ids(ids, supabaseClient) {
|
|
16
|
+
if (ids.length === 0) {
|
|
17
|
+
return IWebResponse.success([]).to_compatible();
|
|
18
|
+
}
|
|
19
|
+
const supabase = supabaseClient ?? (await newServerClient());
|
|
20
|
+
const { data, error } = await supabase
|
|
21
|
+
.from("abilities")
|
|
22
|
+
.select("*")
|
|
23
|
+
.in("id", ids)
|
|
24
|
+
.order("key", { ascending: true });
|
|
25
|
+
if (error) {
|
|
26
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
27
|
+
}
|
|
28
|
+
return IWebResponse.success(data ?? []).to_compatible();
|
|
29
|
+
}
|
|
15
30
|
export async function server_get_herd_roles(herd_id, supabaseClient) {
|
|
16
31
|
const supabase = supabaseClient ?? (await newServerClient());
|
|
17
32
|
const { data, error } = await supabase
|
|
@@ -132,3 +147,35 @@ export async function server_set_herd_role_abilities(herd_role_id, ability_ids,
|
|
|
132
147
|
}
|
|
133
148
|
return IWebResponse.success(data ?? []).to_compatible();
|
|
134
149
|
}
|
|
150
|
+
export async function server_get_platform_default_role_abilities(supabaseClient) {
|
|
151
|
+
const supabase = supabaseClient ?? (await newServerClient());
|
|
152
|
+
const { data, error } = await supabase.rpc("get_platform_default_role_abilities");
|
|
153
|
+
if (error) {
|
|
154
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
155
|
+
}
|
|
156
|
+
const groups = Array.isArray(data)
|
|
157
|
+
? data
|
|
158
|
+
: [];
|
|
159
|
+
return IWebResponse.success(groups).to_compatible();
|
|
160
|
+
}
|
|
161
|
+
export async function server_set_platform_default_role_abilities(system_name, ability_keys, supabaseClient) {
|
|
162
|
+
const supabase = supabaseClient ?? (await newServerClient());
|
|
163
|
+
const { error } = await supabase.rpc("set_platform_default_role_abilities", {
|
|
164
|
+
p_system_name: system_name,
|
|
165
|
+
p_ability_keys: ability_keys,
|
|
166
|
+
});
|
|
167
|
+
if (error) {
|
|
168
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
169
|
+
}
|
|
170
|
+
return IWebResponse.success(null).to_compatible();
|
|
171
|
+
}
|
|
172
|
+
export async function server_reset_herd_default_role_abilities(herd_id, supabaseClient) {
|
|
173
|
+
const supabase = supabaseClient ?? (await newServerClient());
|
|
174
|
+
const { error } = await supabase.rpc("reset_herd_default_role_abilities", {
|
|
175
|
+
p_herd_id: herd_id,
|
|
176
|
+
});
|
|
177
|
+
if (error) {
|
|
178
|
+
return IWebResponse.error(error.message).to_compatible();
|
|
179
|
+
}
|
|
180
|
+
return IWebResponse.success(null).to_compatible();
|
|
181
|
+
}
|
package/dist/types/db.d.ts
CHANGED
|
@@ -33,6 +33,15 @@ export type IHerdRoleWithAbilities = IHerdRole & {
|
|
|
33
33
|
abilities: IAbility[];
|
|
34
34
|
ability_ids: number[];
|
|
35
35
|
};
|
|
36
|
+
export type IPlatformDefaultRoleAbilityRow = Database["public"]["Tables"]["platform_default_role_abilities"]["Row"];
|
|
37
|
+
/** One system role's default ability set from `get_platform_default_role_abilities`. */
|
|
38
|
+
export interface IPlatformDefaultRoleAbilitiesGroup {
|
|
39
|
+
system_name: string;
|
|
40
|
+
abilities: {
|
|
41
|
+
id: number;
|
|
42
|
+
key: string;
|
|
43
|
+
}[];
|
|
44
|
+
}
|
|
36
45
|
/** Stable machine id on `herd_roles` (e.g. admin, editor, viewer). Not `herds.slug`. */
|
|
37
46
|
export type HerdRoleSystemName = string;
|
|
38
47
|
export type IHerdInvitation = Database["public"]["Tables"]["herd_invitations"]["Row"];
|
package/dist/types/supabase.d.ts
CHANGED
|
@@ -1352,6 +1352,35 @@ export type Database = {
|
|
|
1352
1352
|
}
|
|
1353
1353
|
];
|
|
1354
1354
|
};
|
|
1355
|
+
platform_default_role_abilities: {
|
|
1356
|
+
Row: {
|
|
1357
|
+
ability_id: number;
|
|
1358
|
+
id: number;
|
|
1359
|
+
inserted_at: string;
|
|
1360
|
+
system_name: string;
|
|
1361
|
+
};
|
|
1362
|
+
Insert: {
|
|
1363
|
+
ability_id: number;
|
|
1364
|
+
id?: number;
|
|
1365
|
+
inserted_at?: string;
|
|
1366
|
+
system_name: string;
|
|
1367
|
+
};
|
|
1368
|
+
Update: {
|
|
1369
|
+
ability_id?: number;
|
|
1370
|
+
id?: number;
|
|
1371
|
+
inserted_at?: string;
|
|
1372
|
+
system_name?: string;
|
|
1373
|
+
};
|
|
1374
|
+
Relationships: [
|
|
1375
|
+
{
|
|
1376
|
+
foreignKeyName: "platform_default_role_abilities_ability_id_fkey";
|
|
1377
|
+
columns: ["ability_id"];
|
|
1378
|
+
isOneToOne: false;
|
|
1379
|
+
referencedRelation: "abilities";
|
|
1380
|
+
referencedColumns: ["id"];
|
|
1381
|
+
}
|
|
1382
|
+
];
|
|
1383
|
+
};
|
|
1355
1384
|
platform_superadmins: {
|
|
1356
1385
|
Row: {
|
|
1357
1386
|
inserted_at: string;
|
|
@@ -2991,6 +3020,10 @@ export type Database = {
|
|
|
2991
3020
|
isSetofReturn: true;
|
|
2992
3021
|
};
|
|
2993
3022
|
};
|
|
3023
|
+
get_platform_default_role_abilities: {
|
|
3024
|
+
Args: never;
|
|
3025
|
+
Returns: Json;
|
|
3026
|
+
};
|
|
2994
3027
|
get_pubsub_jwt_public_keys: {
|
|
2995
3028
|
Args: never;
|
|
2996
3029
|
Returns: Json;
|
|
@@ -3438,6 +3471,12 @@ export type Database = {
|
|
|
3438
3471
|
isSetofReturn: false;
|
|
3439
3472
|
};
|
|
3440
3473
|
};
|
|
3474
|
+
reset_herd_default_role_abilities: {
|
|
3475
|
+
Args: {
|
|
3476
|
+
p_herd_id: number;
|
|
3477
|
+
};
|
|
3478
|
+
Returns: undefined;
|
|
3479
|
+
};
|
|
3441
3480
|
revoke_client_abilities_jwt_public_key: {
|
|
3442
3481
|
Args: {
|
|
3443
3482
|
p_kid: string;
|
|
@@ -3501,6 +3540,13 @@ export type Database = {
|
|
|
3501
3540
|
};
|
|
3502
3541
|
Returns: undefined;
|
|
3503
3542
|
};
|
|
3543
|
+
set_platform_default_role_abilities: {
|
|
3544
|
+
Args: {
|
|
3545
|
+
p_ability_keys: string[];
|
|
3546
|
+
p_system_name: string;
|
|
3547
|
+
};
|
|
3548
|
+
Returns: undefined;
|
|
3549
|
+
};
|
|
3504
3550
|
sync_orphan_session_links: {
|
|
3505
3551
|
Args: {
|
|
3506
3552
|
preview?: boolean;
|