@develit-services/rbac 0.0.1

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.
@@ -0,0 +1,20 @@
1
+ interface RbacServiceEnvironmentConfig {
2
+ d1: {
3
+ id: string;
4
+ };
5
+ vars: {
6
+ SERVICE_CONFIG_INCLUDE_CONFIRMATION: boolean;
7
+ };
8
+ }
9
+ interface RbacServiceWranglerConfig {
10
+ project: string;
11
+ name: string;
12
+ envs: {
13
+ local: RbacServiceEnvironmentConfig;
14
+ [key: string]: RbacServiceEnvironmentConfig;
15
+ };
16
+ }
17
+ interface RbacServiceEnv extends RbacEnv {
18
+ }
19
+
20
+ export type { RbacServiceWranglerConfig as R, RbacServiceEnvironmentConfig as a, RbacServiceEnv as b };
@@ -0,0 +1,20 @@
1
+ interface RbacServiceEnvironmentConfig {
2
+ d1: {
3
+ id: string;
4
+ };
5
+ vars: {
6
+ SERVICE_CONFIG_INCLUDE_CONFIRMATION: boolean;
7
+ };
8
+ }
9
+ interface RbacServiceWranglerConfig {
10
+ project: string;
11
+ name: string;
12
+ envs: {
13
+ local: RbacServiceEnvironmentConfig;
14
+ [key: string]: RbacServiceEnvironmentConfig;
15
+ };
16
+ }
17
+ interface RbacServiceEnv extends RbacEnv {
18
+ }
19
+
20
+ export type { RbacServiceWranglerConfig as R, RbacServiceEnvironmentConfig as a, RbacServiceEnv as b };
@@ -0,0 +1,20 @@
1
+ interface RbacServiceEnvironmentConfig {
2
+ d1: {
3
+ id: string;
4
+ };
5
+ vars: {
6
+ SERVICE_CONFIG_INCLUDE_CONFIRMATION: boolean;
7
+ };
8
+ }
9
+ interface RbacServiceWranglerConfig {
10
+ project: string;
11
+ name: string;
12
+ envs: {
13
+ local: RbacServiceEnvironmentConfig;
14
+ [key: string]: RbacServiceEnvironmentConfig;
15
+ };
16
+ }
17
+ interface RbacServiceEnv extends RbacEnv {
18
+ }
19
+
20
+ export type { RbacServiceWranglerConfig as R, RbacServiceEnvironmentConfig as a, RbacServiceEnv as b };
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ const backendSdk = require('@develit-io/backend-sdk');
4
+ const sqliteCore = require('drizzle-orm/sqlite-core');
5
+
6
+ const role = sqliteCore.sqliteTable("roles", {
7
+ ...backendSdk.base,
8
+ name: sqliteCore.text("name").notNull()
9
+ });
10
+
11
+ const roleScope = sqliteCore.sqliteTable("roles_scopes", {
12
+ ...backendSdk.base,
13
+ roleId: sqliteCore.text("role_id").notNull().references(() => role.id, { onDelete: "cascade" }),
14
+ scope: sqliteCore.text("scope").notNull(),
15
+ resourceId: sqliteCore.text("resource_id")
16
+ });
17
+
18
+ const userRole = sqliteCore.sqliteTable(
19
+ "user_roles",
20
+ {
21
+ ...backendSdk.base,
22
+ userId: sqliteCore.text("user_id").notNull(),
23
+ roleId: sqliteCore.text("role_id").notNull().references(() => role.id, { onDelete: "cascade" })
24
+ },
25
+ (t) => [sqliteCore.unique().on(t.userId, t.roleId)]
26
+ );
27
+
28
+ const userScope = sqliteCore.sqliteTable(
29
+ "user_scopes",
30
+ {
31
+ ...backendSdk.base,
32
+ userId: sqliteCore.text("user_id").notNull(),
33
+ scope: sqliteCore.text("scope").notNull(),
34
+ resourceId: sqliteCore.text("resource_id")
35
+ },
36
+ (t) => [sqliteCore.unique().on(t.userId, t.scope)]
37
+ );
38
+
39
+ const schema = {
40
+ __proto__: null,
41
+ role: role,
42
+ roleScope: roleScope,
43
+ userRole: userRole,
44
+ userScope: userScope
45
+ };
46
+
47
+ exports.role = role;
48
+ exports.roleScope = roleScope;
49
+ exports.schema = schema;
50
+ exports.userRole = userRole;
51
+ exports.userScope = userScope;