@laboratory-one/api-components 0.0.23 → 0.0.25
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/src/ability/ability.factory.d.ts +5 -0
- package/dist/src/ability/ability.factory.d.ts.map +1 -0
- package/dist/src/ability/ability.factory.js +22 -0
- package/dist/src/ability/ability.factory.js.map +1 -0
- package/dist/src/ability/ability.module.d.ts +3 -0
- package/dist/src/ability/ability.module.d.ts.map +1 -0
- package/dist/src/ability/ability.module.js +16 -0
- package/dist/src/ability/ability.module.js.map +1 -0
- package/dist/src/ability/ability.util.d.ts +7 -0
- package/dist/src/ability/ability.util.d.ts.map +1 -0
- package/dist/src/ability/ability.util.js +30 -0
- package/dist/src/ability/ability.util.js.map +1 -0
- package/dist/src/ability/action.enum.d.ts +9 -0
- package/dist/src/ability/action.enum.d.ts.map +1 -0
- package/dist/src/ability/action.enum.js +11 -0
- package/dist/src/ability/action.enum.js.map +1 -0
- package/dist/src/ability/app-ability.type.d.ts +7 -0
- package/dist/src/ability/app-ability.type.d.ts.map +1 -0
- package/dist/src/ability/app-ability.type.js +3 -0
- package/dist/src/ability/app-ability.type.js.map +1 -0
- package/dist/src/ability/index.d.ts +7 -0
- package/dist/src/ability/index.d.ts.map +1 -0
- package/dist/src/ability/index.js +10 -0
- package/dist/src/ability/index.js.map +1 -0
- package/dist/src/ability/services.enum.d.ts +7 -0
- package/dist/src/ability/services.enum.d.ts.map +1 -0
- package/dist/src/ability/services.enum.js +9 -0
- package/dist/src/ability/services.enum.js.map +1 -0
- package/dist/src/cron/cron.module.d.ts.map +1 -0
- package/dist/src/cron/cron.module.js.map +1 -0
- package/dist/src/cron/cron.service.d.ts.map +1 -0
- package/dist/src/cron/cron.service.js.map +1 -0
- package/dist/src/cron/cron.util.d.ts.map +1 -0
- package/dist/src/cron/cron.util.js.map +1 -0
- package/dist/src/cron/index.d.ts.map +1 -0
- package/dist/src/cron/index.js.map +1 -0
- package/dist/src/decorator/index.d.ts +3 -0
- package/dist/src/decorator/index.d.ts.map +1 -0
- package/dist/src/decorator/index.js +6 -0
- package/dist/src/decorator/index.js.map +1 -0
- package/dist/src/decorator/policies.decorator.d.ts +4 -0
- package/dist/src/decorator/policies.decorator.d.ts.map +1 -0
- package/dist/src/decorator/policies.decorator.js +8 -0
- package/dist/src/decorator/policies.decorator.js.map +1 -0
- package/dist/src/decorator/policies.handler.d.ts +9 -0
- package/dist/src/decorator/policies.handler.d.ts.map +1 -0
- package/dist/src/decorator/policies.handler.js +14 -0
- package/dist/src/decorator/policies.handler.js.map +1 -0
- package/dist/src/enums/humanDay.enum.d.ts.map +1 -0
- package/dist/src/enums/humanDay.enum.js.map +1 -0
- package/dist/src/enums/index.d.ts.map +1 -0
- package/dist/src/enums/index.js.map +1 -0
- package/dist/src/enums/serverDay.enum.d.ts.map +1 -0
- package/dist/src/enums/serverDay.enum.js.map +1 -0
- package/dist/src/guard/auth.guard.d.ts.map +1 -0
- package/dist/src/guard/auth.guard.js.map +1 -0
- package/dist/src/guard/index.d.ts +3 -0
- package/dist/src/guard/index.d.ts.map +1 -0
- package/{src → dist/src}/guard/index.js +1 -0
- package/dist/src/guard/index.js.map +1 -0
- package/dist/src/guard/policies.guard.d.ts +11 -0
- package/dist/src/guard/policies.guard.d.ts.map +1 -0
- package/dist/src/guard/policies.guard.js +44 -0
- package/dist/src/guard/policies.guard.js.map +1 -0
- package/dist/src/health/dtos/health.response.dto.d.ts.map +1 -0
- package/dist/src/health/dtos/health.response.dto.js.map +1 -0
- package/dist/src/health/dtos/index.d.ts.map +1 -0
- package/dist/src/health/dtos/index.js.map +1 -0
- package/dist/src/health/health.controller.d.ts.map +1 -0
- package/dist/src/health/health.controller.js.map +1 -0
- package/dist/src/health/health.module.d.ts.map +1 -0
- package/dist/src/health/health.module.js.map +1 -0
- package/dist/src/health/health.service.d.ts.map +1 -0
- package/dist/src/health/health.service.js.map +1 -0
- package/dist/src/health/index.d.ts.map +1 -0
- package/dist/src/health/index.js.map +1 -0
- package/dist/src/middleware/index.d.ts.map +1 -0
- package/dist/src/middleware/index.js.map +1 -0
- package/dist/src/middleware/logger.middleware.d.ts.map +1 -0
- package/dist/src/middleware/logger.middleware.js.map +1 -0
- package/dist/src/prisma/index.d.ts.map +1 -0
- package/dist/src/prisma/index.js.map +1 -0
- package/dist/src/prisma/prisma.module.d.ts.map +1 -0
- package/dist/src/prisma/prisma.module.js.map +1 -0
- package/dist/src/prisma/prisma.service.d.ts.map +1 -0
- package/dist/src/prisma/prisma.service.js.map +1 -0
- package/dist/src/push/index.d.ts.map +1 -0
- package/dist/src/push/index.js.map +1 -0
- package/dist/src/push/push.module.d.ts.map +1 -0
- package/dist/src/push/push.module.js.map +1 -0
- package/dist/src/push/push.service.d.ts.map +1 -0
- package/dist/src/push/push.service.js.map +1 -0
- package/dist/src/search/index.d.ts.map +1 -0
- package/dist/src/search/index.js.map +1 -0
- package/dist/src/search/search.module.d.ts.map +1 -0
- package/dist/src/search/search.module.js.map +1 -0
- package/dist/src/search/search.service.d.ts.map +1 -0
- package/dist/src/search/search.service.js.map +1 -0
- package/dist/src/services/index.d.ts.map +1 -0
- package/dist/src/services/index.js.map +1 -0
- package/dist/src/services/instrument-sentry.d.ts.map +1 -0
- package/dist/src/services/instrument-sentry.js.map +1 -0
- package/dist/src/types/index.d.ts +5 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/{src → dist/src}/types/index.js +2 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/policy.type.d.ts +8 -0
- package/dist/src/types/policy.type.d.ts.map +1 -0
- package/dist/src/types/policy.type.js +3 -0
- package/dist/src/types/policy.type.js.map +1 -0
- package/dist/src/types/req.type.d.ts.map +1 -0
- package/dist/src/types/req.type.js.map +1 -0
- package/dist/src/types/reqWithUser.type.d.ts +4 -0
- package/dist/src/types/reqWithUser.type.d.ts.map +1 -0
- package/dist/src/types/reqWithUser.type.js +3 -0
- package/dist/src/types/reqWithUser.type.js.map +1 -0
- package/dist/src/types/success.response.dto.d.ts.map +1 -0
- package/dist/src/types/success.response.dto.js.map +1 -0
- package/dist/src/utils/datetime.util.d.ts.map +1 -0
- package/dist/src/utils/datetime.util.js.map +1 -0
- package/dist/src/utils/error.util.d.ts.map +1 -0
- package/dist/src/utils/error.util.js.map +1 -0
- package/{src → dist/src}/utils/index.d.ts +0 -1
- package/dist/src/utils/index.d.ts.map +1 -0
- package/{src → dist/src}/utils/index.js +0 -1
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/input.util.d.ts.map +1 -0
- package/dist/src/utils/input.util.js.map +1 -0
- package/dist/src/utils/noop.util.d.ts.map +1 -0
- package/dist/src/utils/noop.util.js.map +1 -0
- package/dist/src/utils/string.util.d.ts.map +1 -0
- package/dist/src/utils/string.util.js.map +1 -0
- package/dist/src/utils/version.util.d.ts.map +1 -0
- package/dist/src/utils/version.util.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +12 -100
- package/src/ability/ability.factory.ts +19 -0
- package/src/ability/ability.module.ts +8 -0
- package/src/ability/ability.util.ts +37 -0
- package/src/ability/action.enum.ts +9 -0
- package/src/ability/app-ability.type.ts +7 -0
- package/src/ability/index.ts +6 -0
- package/src/ability/services.enum.ts +7 -0
- package/src/decorator/index.ts +2 -0
- package/src/decorator/policies.decorator.ts +7 -0
- package/src/decorator/policies.handler.ts +16 -0
- package/src/guard/index.ts +1 -0
- package/src/guard/policies.guard.ts +65 -0
- package/src/types/index.ts +2 -0
- package/src/types/policy.type.ts +9 -0
- package/src/types/reqWithUser.type.ts +3 -0
- package/src/utils/index.ts +0 -1
- package/src/auth/auth.module.d.ts +0 -3
- package/src/auth/auth.module.js +0 -18
- package/src/auth/auth.module.ts +0 -10
- package/src/auth/auth.service.d.ts +0 -18
- package/src/auth/auth.service.js +0 -65
- package/src/auth/auth.service.ts +0 -80
- package/src/auth/index.d.ts +0 -3
- package/src/auth/index.js +0 -6
- package/src/auth/index.ts +0 -2
- package/src/guard/index.d.ts +0 -2
- package/src/types/index.d.ts +0 -3
- package/src/user/dtos/delete-user.request.dto.d.ts +0 -4
- package/src/user/dtos/delete-user.request.dto.js +0 -15
- package/src/user/dtos/delete-user.request.dto.ts +0 -8
- package/src/user/dtos/get-user.response.dto.d.ts +0 -7
- package/src/user/dtos/get-user.response.dto.js +0 -32
- package/src/user/dtos/get-user.response.dto.ts +0 -22
- package/src/user/dtos/index.d.ts +0 -9
- package/src/user/dtos/index.js +0 -12
- package/src/user/dtos/index.ts +0 -8
- package/src/user/dtos/phone-login-verify.request.dto.d.ts +0 -6
- package/src/user/dtos/phone-login-verify.request.dto.js +0 -25
- package/src/user/dtos/phone-login-verify.request.dto.ts +0 -16
- package/src/user/dtos/phone-login.request.dto.d.ts +0 -4
- package/src/user/dtos/phone-login.request.dto.js +0 -15
- package/src/user/dtos/phone-login.request.dto.ts +0 -8
- package/src/user/dtos/phone-login.response.dto.d.ts +0 -5
- package/src/user/dtos/phone-login.response.dto.js +0 -20
- package/src/user/dtos/phone-login.response.dto.ts +0 -12
- package/src/user/dtos/register.request.dto.d.ts +0 -5
- package/src/user/dtos/register.request.dto.js +0 -20
- package/src/user/dtos/register.request.dto.ts +0 -12
- package/src/user/dtos/register.response.dto.d.ts +0 -5
- package/src/user/dtos/register.response.dto.js +0 -16
- package/src/user/dtos/register.response.dto.ts +0 -10
- package/src/user/dtos/update-user.request.dto.d.ts +0 -8
- package/src/user/dtos/update-user.request.dto.js +0 -40
- package/src/user/dtos/update-user.request.dto.ts +0 -29
- package/src/user/index.d.ts +0 -7
- package/src/user/index.js +0 -10
- package/src/user/index.ts +0 -6
- package/src/user/schemas/delete-user.schema.d.ts +0 -5
- package/src/user/schemas/delete-user.schema.js +0 -9
- package/src/user/schemas/delete-user.schema.ts +0 -7
- package/src/user/schemas/index.d.ts +0 -6
- package/src/user/schemas/index.js +0 -9
- package/src/user/schemas/index.ts +0 -5
- package/src/user/schemas/phone-login-verify.schema.d.ts +0 -7
- package/src/user/schemas/phone-login-verify.schema.js +0 -11
- package/src/user/schemas/phone-login-verify.schema.ts +0 -9
- package/src/user/schemas/phone-login.schema.d.ts +0 -5
- package/src/user/schemas/phone-login.schema.js +0 -9
- package/src/user/schemas/phone-login.schema.ts +0 -7
- package/src/user/schemas/signup.schema.d.ts +0 -6
- package/src/user/schemas/signup.schema.js +0 -10
- package/src/user/schemas/signup.schema.ts +0 -8
- package/src/user/schemas/update-user.schema.d.ts +0 -9
- package/src/user/schemas/update-user.schema.js +0 -15
- package/src/user/schemas/update-user.schema.ts +0 -13
- package/src/user/user.controller.d.ts +0 -22
- package/src/user/user.controller.js +0 -279
- package/src/user/user.controller.ts +0 -321
- package/src/user/user.module.d.ts +0 -3
- package/src/user/user.module.js +0 -22
- package/src/user/user.module.ts +0 -16
- package/src/user/user.service.d.ts +0 -15
- package/src/user/user.service.js +0 -62
- package/src/user/user.service.ts +0 -68
- package/src/user/user.util.d.ts +0 -3
- package/src/user/user.util.js +0 -8
- package/src/user/user.util.ts +0 -5
- package/src/utils/schema.util.d.ts +0 -13
- package/src/utils/schema.util.js +0 -16
- package/src/utils/schema.util.ts +0 -13
- /package/{src → dist/src}/cron/cron.module.d.ts +0 -0
- /package/{src → dist/src}/cron/cron.module.js +0 -0
- /package/{src → dist/src}/cron/cron.service.d.ts +0 -0
- /package/{src → dist/src}/cron/cron.service.js +0 -0
- /package/{src → dist/src}/cron/cron.util.d.ts +0 -0
- /package/{src → dist/src}/cron/cron.util.js +0 -0
- /package/{src → dist/src}/cron/index.d.ts +0 -0
- /package/{src → dist/src}/cron/index.js +0 -0
- /package/{src → dist/src}/enums/humanDay.enum.d.ts +0 -0
- /package/{src → dist/src}/enums/humanDay.enum.js +0 -0
- /package/{src → dist/src}/enums/index.d.ts +0 -0
- /package/{src → dist/src}/enums/index.js +0 -0
- /package/{src → dist/src}/enums/serverDay.enum.d.ts +0 -0
- /package/{src → dist/src}/enums/serverDay.enum.js +0 -0
- /package/{src → dist/src}/guard/auth.guard.d.ts +0 -0
- /package/{src → dist/src}/guard/auth.guard.js +0 -0
- /package/{src → dist/src}/health/dtos/health.response.dto.d.ts +0 -0
- /package/{src → dist/src}/health/dtos/health.response.dto.js +0 -0
- /package/{src → dist/src}/health/dtos/index.d.ts +0 -0
- /package/{src → dist/src}/health/dtos/index.js +0 -0
- /package/{src → dist/src}/health/health.controller.d.ts +0 -0
- /package/{src → dist/src}/health/health.controller.js +0 -0
- /package/{src → dist/src}/health/health.module.d.ts +0 -0
- /package/{src → dist/src}/health/health.module.js +0 -0
- /package/{src → dist/src}/health/health.service.d.ts +0 -0
- /package/{src → dist/src}/health/health.service.js +0 -0
- /package/{src → dist/src}/health/index.d.ts +0 -0
- /package/{src → dist/src}/health/index.js +0 -0
- /package/{src → dist/src}/middleware/index.d.ts +0 -0
- /package/{src → dist/src}/middleware/index.js +0 -0
- /package/{src → dist/src}/middleware/logger.middleware.d.ts +0 -0
- /package/{src → dist/src}/middleware/logger.middleware.js +0 -0
- /package/{src → dist/src}/prisma/index.d.ts +0 -0
- /package/{src → dist/src}/prisma/index.js +0 -0
- /package/{src → dist/src}/prisma/prisma.module.d.ts +0 -0
- /package/{src → dist/src}/prisma/prisma.module.js +0 -0
- /package/{src → dist/src}/prisma/prisma.service.d.ts +0 -0
- /package/{src → dist/src}/prisma/prisma.service.js +0 -0
- /package/{src → dist/src}/push/index.d.ts +0 -0
- /package/{src → dist/src}/push/index.js +0 -0
- /package/{src → dist/src}/push/push.module.d.ts +0 -0
- /package/{src → dist/src}/push/push.module.js +0 -0
- /package/{src → dist/src}/push/push.service.d.ts +0 -0
- /package/{src → dist/src}/push/push.service.js +0 -0
- /package/{src → dist/src}/search/index.d.ts +0 -0
- /package/{src → dist/src}/search/index.js +0 -0
- /package/{src → dist/src}/search/search.module.d.ts +0 -0
- /package/{src → dist/src}/search/search.module.js +0 -0
- /package/{src → dist/src}/search/search.service.d.ts +0 -0
- /package/{src → dist/src}/search/search.service.js +0 -0
- /package/{src → dist/src}/services/index.d.ts +0 -0
- /package/{src → dist/src}/services/index.js +0 -0
- /package/{src → dist/src}/services/instrument-sentry.d.ts +0 -0
- /package/{src → dist/src}/services/instrument-sentry.js +0 -0
- /package/{src → dist/src}/types/req.type.d.ts +0 -0
- /package/{src → dist/src}/types/req.type.js +0 -0
- /package/{src → dist/src}/types/success.response.dto.d.ts +0 -0
- /package/{src → dist/src}/types/success.response.dto.js +0 -0
- /package/{src → dist/src}/utils/datetime.util.d.ts +0 -0
- /package/{src → dist/src}/utils/datetime.util.js +0 -0
- /package/{src → dist/src}/utils/error.util.d.ts +0 -0
- /package/{src → dist/src}/utils/error.util.js +0 -0
- /package/{src → dist/src}/utils/input.util.d.ts +0 -0
- /package/{src → dist/src}/utils/input.util.js +0 -0
- /package/{src → dist/src}/utils/noop.util.d.ts +0 -0
- /package/{src → dist/src}/utils/noop.util.js +0 -0
- /package/{src → dist/src}/utils/string.util.d.ts +0 -0
- /package/{src → dist/src}/utils/string.util.js +0 -0
- /package/{src → dist/src}/utils/version.util.d.ts +0 -0
- /package/{src → dist/src}/utils/version.util.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@laboratory-one/api-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"description": "API components for Laboratory One",
|
|
5
5
|
"author": "Laboratory One",
|
|
6
6
|
"private": false,
|
|
@@ -8,41 +8,8 @@
|
|
|
8
8
|
"type": "commonjs",
|
|
9
9
|
"typesVersions": {
|
|
10
10
|
"*": {
|
|
11
|
-
"
|
|
12
|
-
"src
|
|
13
|
-
],
|
|
14
|
-
"cron": [
|
|
15
|
-
"src/cron/index.d.ts"
|
|
16
|
-
],
|
|
17
|
-
"enums": [
|
|
18
|
-
"src/enums/index.d.ts"
|
|
19
|
-
],
|
|
20
|
-
"guard": [
|
|
21
|
-
"src/guard/index.d.ts"
|
|
22
|
-
],
|
|
23
|
-
"health": [
|
|
24
|
-
"src/health/index.d.ts"
|
|
25
|
-
],
|
|
26
|
-
"middleware": [
|
|
27
|
-
"src/middleware/index.d.ts"
|
|
28
|
-
],
|
|
29
|
-
"prisma": [
|
|
30
|
-
"src/prisma/index.d.ts"
|
|
31
|
-
],
|
|
32
|
-
"push": [
|
|
33
|
-
"src/push/index.d.ts"
|
|
34
|
-
],
|
|
35
|
-
"services": [
|
|
36
|
-
"src/services/index.d.ts"
|
|
37
|
-
],
|
|
38
|
-
"types": [
|
|
39
|
-
"src/types/index.d.ts"
|
|
40
|
-
],
|
|
41
|
-
"user": [
|
|
42
|
-
"src/user/index.d.ts"
|
|
43
|
-
],
|
|
44
|
-
"utils": [
|
|
45
|
-
"src/utils/index.d.ts"
|
|
11
|
+
"*": [
|
|
12
|
+
"dist/src/*/index.d.ts"
|
|
46
13
|
]
|
|
47
14
|
}
|
|
48
15
|
},
|
|
@@ -59,81 +26,27 @@
|
|
|
59
26
|
"dist"
|
|
60
27
|
],
|
|
61
28
|
"exports": {
|
|
62
|
-
"
|
|
63
|
-
"import": "./src
|
|
64
|
-
"require": "./src
|
|
65
|
-
"types": "./src
|
|
66
|
-
},
|
|
67
|
-
"./cron": {
|
|
68
|
-
"import": "./src/cron/index.js",
|
|
69
|
-
"require": "./src/cron/index.js",
|
|
70
|
-
"types": "./src/cron/index.d.ts"
|
|
71
|
-
},
|
|
72
|
-
"./enums": {
|
|
73
|
-
"import": "./src/enums/index.js",
|
|
74
|
-
"require": "./src/enums/index.js",
|
|
75
|
-
"types": "./src/enums/index.d.ts"
|
|
76
|
-
},
|
|
77
|
-
"./guard": {
|
|
78
|
-
"import": "./src/guard/index.js",
|
|
79
|
-
"require": "./src/guard/index.js",
|
|
80
|
-
"types": "./src/guard/index.d.ts"
|
|
81
|
-
},
|
|
82
|
-
"./health": {
|
|
83
|
-
"import": "./src/health/index.js",
|
|
84
|
-
"require": "./src/health/index.js",
|
|
85
|
-
"types": "./src/health/index.d.ts"
|
|
86
|
-
},
|
|
87
|
-
"./middleware": {
|
|
88
|
-
"import": "./src/middleware/index.js",
|
|
89
|
-
"require": "./src/middleware/index.js",
|
|
90
|
-
"types": "./src/middleware/index.d.ts"
|
|
91
|
-
},
|
|
92
|
-
"./prisma": {
|
|
93
|
-
"import": "./src/prisma/index.js",
|
|
94
|
-
"require": "./src/prisma/index.js",
|
|
95
|
-
"types": "./src/prisma/index.d.ts"
|
|
96
|
-
},
|
|
97
|
-
"./push": {
|
|
98
|
-
"import": "./src/push/index.js",
|
|
99
|
-
"require": "./src/push/index.js",
|
|
100
|
-
"types": "./src/push/index.d.ts"
|
|
101
|
-
},
|
|
102
|
-
"./services": {
|
|
103
|
-
"import": "./src/services/index.js",
|
|
104
|
-
"require": "./src/services/index.js",
|
|
105
|
-
"types": "./src/services/index.d.ts"
|
|
106
|
-
},
|
|
107
|
-
"./types": {
|
|
108
|
-
"import": "./src/types/index.js",
|
|
109
|
-
"require": "./src/types/index.js",
|
|
110
|
-
"types": "./src/types/index.d.ts"
|
|
111
|
-
},
|
|
112
|
-
"./user": {
|
|
113
|
-
"import": "./src/user/index.js",
|
|
114
|
-
"require": "./src/user/index.js",
|
|
115
|
-
"types": "./src/user/index.d.ts"
|
|
116
|
-
},
|
|
117
|
-
"./utils": {
|
|
118
|
-
"import": "./src/utils/index.js",
|
|
119
|
-
"require": "./src/utils/index.js",
|
|
120
|
-
"types": "./src/utils/index.d.ts"
|
|
29
|
+
"./*": {
|
|
30
|
+
"import": "./dist/src/*/index.js",
|
|
31
|
+
"require": "./dist/src/*/index.js",
|
|
32
|
+
"types": "./dist/src/*/index.d.ts"
|
|
121
33
|
}
|
|
122
34
|
},
|
|
123
35
|
"scripts": {
|
|
124
|
-
"build": "tsc
|
|
36
|
+
"build": "tsc",
|
|
125
37
|
"format": "prettier --write 'src/**/*.{js,ts}'",
|
|
126
|
-
"generate": "prisma generate",
|
|
38
|
+
"types:generate": "npx prisma generate",
|
|
127
39
|
"lint": "eslint 'src/**/*.{js,ts}'",
|
|
128
40
|
"lint:fix": "yarn format && yarn lint --fix",
|
|
129
41
|
"publish:local": "yalc publish",
|
|
130
42
|
"push": "yarn build && yalc push --replace",
|
|
131
|
-
"typecheck": "tsc
|
|
43
|
+
"typecheck": "tsc --noEmit",
|
|
132
44
|
"version:minor": "./scripts/version.sh minor",
|
|
133
45
|
"version:patch": "./scripts/version.sh patch",
|
|
134
46
|
"start:dev": "watchman watch . && watchman -- trigger . yalc-push-trigger \"**/*\" -- ./scripts/yalc-push-trigger.sh"
|
|
135
47
|
},
|
|
136
48
|
"dependencies": {
|
|
49
|
+
"@casl/ability": "6.7.3",
|
|
137
50
|
"@nestjs/axios": "4.0.1",
|
|
138
51
|
"@nestjs/common": "11.1.6",
|
|
139
52
|
"@nestjs/config": "4.0.2",
|
|
@@ -160,8 +73,7 @@
|
|
|
160
73
|
"prisma": "6.16.2",
|
|
161
74
|
"reflect-metadata": "0.2.2",
|
|
162
75
|
"rxjs": "7.8.2",
|
|
163
|
-
"stytch": "12.35.0"
|
|
164
|
-
"zod": "4.1.11"
|
|
76
|
+
"stytch": "12.35.0"
|
|
165
77
|
},
|
|
166
78
|
"devDependencies": {
|
|
167
79
|
"@babel/core": "7.28.4",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { AbilityBuilder, createMongoAbility } from '@casl/ability';
|
|
3
|
+
import { AppAbility } from './app-ability.type';
|
|
4
|
+
import { mapPermissionToAbility } from './ability.util';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class AbilityFactory {
|
|
8
|
+
createForUser(permissions: string[]): AppAbility {
|
|
9
|
+
const { can, build } = new AbilityBuilder<AppAbility>(createMongoAbility);
|
|
10
|
+
|
|
11
|
+
const abilities = mapPermissionToAbility(permissions);
|
|
12
|
+
|
|
13
|
+
abilities.forEach(({ action, subject }) => {
|
|
14
|
+
can(action, subject);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return build();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Action, ACTIONS } from './action.enum';
|
|
2
|
+
import { Subject } from './services.enum';
|
|
3
|
+
|
|
4
|
+
export const mapPermissionToAbility = (
|
|
5
|
+
permissions: string[],
|
|
6
|
+
): { action: Action; subject: Subject }[] => {
|
|
7
|
+
return permissions.map((permission: string) => {
|
|
8
|
+
const split: string[] = permission.split(':');
|
|
9
|
+
|
|
10
|
+
if (split.length !== 2) {
|
|
11
|
+
throw new Error(`Invalid permission format: ${permission}`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const action: Action = split[0] as Action;
|
|
15
|
+
const subject: Subject = split[1] as Subject;
|
|
16
|
+
|
|
17
|
+
switch (action) {
|
|
18
|
+
case ACTIONS.MANAGE:
|
|
19
|
+
return { action: ACTIONS.MANAGE, subject };
|
|
20
|
+
|
|
21
|
+
case ACTIONS.CREATE:
|
|
22
|
+
return { action: ACTIONS.CREATE, subject };
|
|
23
|
+
|
|
24
|
+
case ACTIONS.READ:
|
|
25
|
+
return { action: ACTIONS.READ, subject };
|
|
26
|
+
|
|
27
|
+
case ACTIONS.UPDATE:
|
|
28
|
+
return { action: ACTIONS.UPDATE, subject };
|
|
29
|
+
|
|
30
|
+
case ACTIONS.DELETE:
|
|
31
|
+
return { action: ACTIONS.DELETE, subject };
|
|
32
|
+
|
|
33
|
+
default:
|
|
34
|
+
throw new Error(`Invalid permission: ${permission}`);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AppAbility, Action, Subject } from '../ability';
|
|
2
|
+
import { IPolicyHandler } from '../types';
|
|
3
|
+
|
|
4
|
+
export class AuthPolicyHandler implements IPolicyHandler {
|
|
5
|
+
action: Action;
|
|
6
|
+
subject: Subject;
|
|
7
|
+
|
|
8
|
+
constructor(action: Action, subject: Subject) {
|
|
9
|
+
this.action = action;
|
|
10
|
+
this.subject = subject;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
handle(ability: AppAbility) {
|
|
14
|
+
return ability.can(this.action, this.subject);
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/guard/index.ts
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BadRequestException,
|
|
3
|
+
CanActivate,
|
|
4
|
+
ExecutionContext,
|
|
5
|
+
Injectable,
|
|
6
|
+
UnauthorizedException,
|
|
7
|
+
} from '@nestjs/common';
|
|
8
|
+
import { Reflector } from '@nestjs/core';
|
|
9
|
+
import { AbilityFactory, AppAbility } from '../ability';
|
|
10
|
+
import { CHECK_POLICIES_KEY } from '../decorator';
|
|
11
|
+
import { Request, Headers } from 'node-fetch';
|
|
12
|
+
import { PolicyHandler } from '../types';
|
|
13
|
+
|
|
14
|
+
@Injectable()
|
|
15
|
+
export class PoliciesGuard implements CanActivate {
|
|
16
|
+
constructor(
|
|
17
|
+
private reflector: Reflector,
|
|
18
|
+
private abilityFactory: AbilityFactory,
|
|
19
|
+
) {}
|
|
20
|
+
|
|
21
|
+
canActivate(context: ExecutionContext): boolean {
|
|
22
|
+
const policyHandlers =
|
|
23
|
+
this.reflector.get<PolicyHandler[]>(
|
|
24
|
+
CHECK_POLICIES_KEY,
|
|
25
|
+
context.getHandler(),
|
|
26
|
+
) || [];
|
|
27
|
+
|
|
28
|
+
const request: Request & { headers: Headers & { permissions: string } } =
|
|
29
|
+
context.switchToHttp().getRequest();
|
|
30
|
+
|
|
31
|
+
if (!request.headers.permissions) {
|
|
32
|
+
throw new UnauthorizedException('No permissions provided');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!request.headers['user-id']) {
|
|
36
|
+
throw new UnauthorizedException('No user provided');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
request['userId'] = request.headers['user-id'];
|
|
40
|
+
|
|
41
|
+
const userPermissions: string[] = JSON.parse(
|
|
42
|
+
request.headers.permissions,
|
|
43
|
+
) as string[];
|
|
44
|
+
|
|
45
|
+
if (!Array.isArray(userPermissions)) {
|
|
46
|
+
throw new BadRequestException('Permissions must be an array of strings');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const ability = this.abilityFactory.createForUser(userPermissions);
|
|
50
|
+
|
|
51
|
+
return policyHandlers.every((handler) =>
|
|
52
|
+
this.execPolicyHandler(handler, ability),
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private execPolicyHandler(
|
|
57
|
+
handler: PolicyHandler,
|
|
58
|
+
ability: AppAbility,
|
|
59
|
+
): boolean {
|
|
60
|
+
if (typeof handler === 'function') {
|
|
61
|
+
return handler(ability);
|
|
62
|
+
}
|
|
63
|
+
return handler.handle(ability);
|
|
64
|
+
}
|
|
65
|
+
}
|
package/src/types/index.ts
CHANGED
package/src/utils/index.ts
CHANGED
package/src/auth/auth.module.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AuthModule = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const auth_service_1 = require("./auth.service");
|
|
7
|
-
const config_1 = require("@nestjs/config");
|
|
8
|
-
let AuthModule = class AuthModule {
|
|
9
|
-
};
|
|
10
|
-
exports.AuthModule = AuthModule;
|
|
11
|
-
exports.AuthModule = AuthModule = tslib_1.__decorate([
|
|
12
|
-
(0, common_1.Module)({
|
|
13
|
-
imports: [config_1.ConfigModule],
|
|
14
|
-
providers: [auth_service_1.AuthService],
|
|
15
|
-
exports: [auth_service_1.AuthService],
|
|
16
|
-
})
|
|
17
|
-
], AuthModule);
|
|
18
|
-
//# sourceMappingURL=auth.module.js.map
|
package/src/auth/auth.module.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Module } from '@nestjs/common';
|
|
2
|
-
import { AuthService } from './auth.service';
|
|
3
|
-
import { ConfigModule } from '@nestjs/config';
|
|
4
|
-
|
|
5
|
-
@Module({
|
|
6
|
-
imports: [ConfigModule],
|
|
7
|
-
providers: [AuthService],
|
|
8
|
-
exports: [AuthService],
|
|
9
|
-
})
|
|
10
|
-
export class AuthModule {}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as stytch from 'stytch';
|
|
2
|
-
import { ConfigService } from '@nestjs/config';
|
|
3
|
-
import { RegisterRequestDto } from '../user';
|
|
4
|
-
export declare class AuthService {
|
|
5
|
-
private configService;
|
|
6
|
-
private readonly logger;
|
|
7
|
-
private authClient;
|
|
8
|
-
constructor(configService: ConfigService);
|
|
9
|
-
signup(data: RegisterRequestDto): Promise<stytch.PasswordsCreateResponse>;
|
|
10
|
-
login(data: RegisterRequestDto): Promise<boolean>;
|
|
11
|
-
phoneLoginOrCreate(phoneNumber: string): Promise<stytch.OTPsSmsLoginOrCreateResponse>;
|
|
12
|
-
phoneAuthenticate({ methodId, code, }: {
|
|
13
|
-
methodId: string;
|
|
14
|
-
code: string;
|
|
15
|
-
}): Promise<stytch.OTPsAuthenticateResponse>;
|
|
16
|
-
delete(externalId: string): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=auth.service.d.ts.map
|
package/src/auth/auth.service.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var AuthService_1;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.AuthService = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const common_1 = require("@nestjs/common");
|
|
7
|
-
const stytch = tslib_1.__importStar(require("stytch"));
|
|
8
|
-
const config_1 = require("@nestjs/config");
|
|
9
|
-
const utils_1 = require("../utils");
|
|
10
|
-
let AuthService = AuthService_1 = class AuthService {
|
|
11
|
-
constructor(configService) {
|
|
12
|
-
this.configService = configService;
|
|
13
|
-
this.logger = new common_1.Logger(AuthService_1.name);
|
|
14
|
-
this.authClient = new stytch.Client({
|
|
15
|
-
project_id: this.configService.get('STYTCH_PROJECT_ID'),
|
|
16
|
-
secret: this.configService.get('STYTCH_SECRET'),
|
|
17
|
-
env: this.configService.get('STYTCH_ENV') === 'test'
|
|
18
|
-
? stytch.envs.test
|
|
19
|
-
: stytch.envs.live,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
async signup(data) {
|
|
23
|
-
this.logger.debug('signup');
|
|
24
|
-
return await this.authClient.passwords.create(data);
|
|
25
|
-
}
|
|
26
|
-
async login(data) {
|
|
27
|
-
this.logger.debug('login');
|
|
28
|
-
try {
|
|
29
|
-
const res = await this.authClient.passwords.authenticate(data);
|
|
30
|
-
return res['status_code'] === 200;
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
if (error.error_type === 'email_not_found') {
|
|
34
|
-
(0, utils_1.handleError)('Email or password is wrong');
|
|
35
|
-
}
|
|
36
|
-
if (error.error_type === 'unauthorized_credentials') {
|
|
37
|
-
(0, utils_1.handleError)('Email or password is wrong');
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
async phoneLoginOrCreate(phoneNumber) {
|
|
42
|
-
this.logger.debug('phoneLoginOrCreate');
|
|
43
|
-
return await this.authClient.otps.sms.loginOrCreate({
|
|
44
|
-
phone_number: phoneNumber,
|
|
45
|
-
expiration_minutes: 5,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
async phoneAuthenticate({ methodId, code, }) {
|
|
49
|
-
this.logger.debug('phoneAuthenticate');
|
|
50
|
-
return await this.authClient.otps.authenticate({
|
|
51
|
-
method_id: methodId,
|
|
52
|
-
code,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
async delete(externalId) {
|
|
56
|
-
this.logger.debug('delete');
|
|
57
|
-
await this.authClient.users.delete({ user_id: externalId });
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
exports.AuthService = AuthService;
|
|
61
|
-
exports.AuthService = AuthService = AuthService_1 = tslib_1.__decorate([
|
|
62
|
-
(0, common_1.Injectable)(),
|
|
63
|
-
tslib_1.__metadata("design:paramtypes", [config_1.ConfigService])
|
|
64
|
-
], AuthService);
|
|
65
|
-
//# sourceMappingURL=auth.service.js.map
|
package/src/auth/auth.service.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { Injectable, Logger } from '@nestjs/common';
|
|
2
|
-
import * as stytch from 'stytch';
|
|
3
|
-
import { ConfigService } from '@nestjs/config';
|
|
4
|
-
|
|
5
|
-
import { RegisterRequestDto } from '../user';
|
|
6
|
-
import { handleError } from '../utils';
|
|
7
|
-
|
|
8
|
-
@Injectable()
|
|
9
|
-
export class AuthService {
|
|
10
|
-
private readonly logger: Logger = new Logger(AuthService.name);
|
|
11
|
-
private authClient: stytch.Client;
|
|
12
|
-
|
|
13
|
-
constructor(private configService: ConfigService) {
|
|
14
|
-
this.authClient = new stytch.Client({
|
|
15
|
-
project_id: this.configService.get<string>('STYTCH_PROJECT_ID'),
|
|
16
|
-
secret: this.configService.get<string>('STYTCH_SECRET'),
|
|
17
|
-
env:
|
|
18
|
-
this.configService.get<string>('STYTCH_ENV') === 'test'
|
|
19
|
-
? stytch.envs.test
|
|
20
|
-
: stytch.envs.live,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async signup(
|
|
25
|
-
data: RegisterRequestDto,
|
|
26
|
-
): Promise<stytch.PasswordsCreateResponse> {
|
|
27
|
-
this.logger.debug('signup');
|
|
28
|
-
|
|
29
|
-
return await this.authClient.passwords.create(data);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async login(data: RegisterRequestDto): Promise<boolean> {
|
|
33
|
-
this.logger.debug('login');
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
const res = await this.authClient.passwords.authenticate(data);
|
|
37
|
-
return res['status_code'] === 200;
|
|
38
|
-
} catch (error: any) {
|
|
39
|
-
if (error.error_type === 'email_not_found') {
|
|
40
|
-
handleError('Email or password is wrong');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (error.error_type === 'unauthorized_credentials') {
|
|
44
|
-
handleError('Email or password is wrong');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async phoneLoginOrCreate(
|
|
50
|
-
phoneNumber: string,
|
|
51
|
-
): Promise<stytch.OTPsSmsLoginOrCreateResponse> {
|
|
52
|
-
this.logger.debug('phoneLoginOrCreate');
|
|
53
|
-
|
|
54
|
-
return await this.authClient.otps.sms.loginOrCreate({
|
|
55
|
-
phone_number: phoneNumber,
|
|
56
|
-
expiration_minutes: 5,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async phoneAuthenticate({
|
|
61
|
-
methodId,
|
|
62
|
-
code,
|
|
63
|
-
}: {
|
|
64
|
-
methodId: string;
|
|
65
|
-
code: string;
|
|
66
|
-
}): Promise<stytch.OTPsAuthenticateResponse> {
|
|
67
|
-
this.logger.debug('phoneAuthenticate');
|
|
68
|
-
|
|
69
|
-
return await this.authClient.otps.authenticate({
|
|
70
|
-
method_id: methodId,
|
|
71
|
-
code,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async delete(externalId: string): Promise<void> {
|
|
76
|
-
this.logger.debug('delete');
|
|
77
|
-
|
|
78
|
-
await this.authClient.users.delete({ user_id: externalId });
|
|
79
|
-
}
|
|
80
|
-
}
|
package/src/auth/index.d.ts
DELETED
package/src/auth/index.js
DELETED
package/src/auth/index.ts
DELETED
package/src/guard/index.d.ts
DELETED
package/src/types/index.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DeleteUserRequestDto = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const class_validator_1 = require("class-validator");
|
|
6
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
7
|
-
class DeleteUserRequestDto {
|
|
8
|
-
}
|
|
9
|
-
exports.DeleteUserRequestDto = DeleteUserRequestDto;
|
|
10
|
-
tslib_1.__decorate([
|
|
11
|
-
(0, class_validator_1.IsString)(),
|
|
12
|
-
(0, swagger_1.ApiProperty)(),
|
|
13
|
-
tslib_1.__metadata("design:type", String)
|
|
14
|
-
], DeleteUserRequestDto.prototype, "phoneNumber", void 0);
|
|
15
|
-
//# sourceMappingURL=delete-user.request.dto.js.map
|