@things-factory/auth-base 9.0.0-beta.3 → 9.0.0-beta.32
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/config/config.development.js +46 -0
- package/config/config.production.js +45 -0
- package/dist-client/auth.js +0 -3
- package/dist-client/auth.js.map +1 -1
- package/dist-client/bootstrap.d.ts +1 -1
- package/dist-client/bootstrap.js +4 -4
- package/dist-client/bootstrap.js.map +1 -1
- package/dist-client/directive/privileged.d.ts +1 -1
- package/dist-client/directive/privileged.js +1 -1
- package/dist-client/directive/privileged.js.map +1 -1
- package/dist-client/index.d.ts +4 -4
- package/dist-client/index.js +4 -4
- package/dist-client/index.js.map +1 -1
- package/dist-client/profiled.js +1 -1
- package/dist-client/profiled.js.map +1 -1
- package/dist-client/reducers/auth.js +1 -1
- package/dist-client/reducers/auth.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/auth.d.ts +5 -5
- package/dist-server/controllers/auth.js +5 -5
- package/dist-server/controllers/auth.js.map +1 -1
- package/dist-server/controllers/change-pwd.js +19 -19
- package/dist-server/controllers/change-pwd.js.map +1 -1
- package/dist-server/controllers/checkin.js +4 -4
- package/dist-server/controllers/checkin.js.map +1 -1
- package/dist-server/controllers/delete-user.js +9 -9
- package/dist-server/controllers/delete-user.js.map +1 -1
- package/dist-server/controllers/invitation.js +19 -19
- package/dist-server/controllers/invitation.js.map +1 -1
- package/dist-server/controllers/profile.d.ts +5 -5
- package/dist-server/controllers/profile.js +10 -10
- package/dist-server/controllers/profile.js.map +1 -1
- package/dist-server/controllers/reset-password.js +24 -24
- package/dist-server/controllers/reset-password.js.map +1 -1
- package/dist-server/controllers/signin.d.ts +1 -1
- package/dist-server/controllers/signin.js +24 -24
- package/dist-server/controllers/signin.js.map +1 -1
- package/dist-server/controllers/signup.d.ts +1 -1
- package/dist-server/controllers/signup.js +13 -13
- package/dist-server/controllers/signup.js.map +1 -1
- package/dist-server/controllers/unlock-user.js +17 -17
- package/dist-server/controllers/unlock-user.js.map +1 -1
- package/dist-server/controllers/utils/password-rule.js +4 -4
- package/dist-server/controllers/utils/password-rule.js.map +1 -1
- package/dist-server/controllers/utils/save-invitation-token.d.ts +1 -1
- package/dist-server/controllers/utils/save-invitation-token.js +2 -2
- package/dist-server/controllers/utils/save-invitation-token.js.map +1 -1
- package/dist-server/controllers/utils/save-verification-token.d.ts +1 -1
- package/dist-server/controllers/utils/save-verification-token.js +3 -3
- package/dist-server/controllers/utils/save-verification-token.js.map +1 -1
- package/dist-server/controllers/verification.js +23 -23
- package/dist-server/controllers/verification.js.map +1 -1
- package/dist-server/errors/auth-error.js +1 -1
- package/dist-server/errors/auth-error.js.map +1 -1
- package/dist-server/errors/index.d.ts +2 -2
- package/dist-server/errors/index.js +2 -2
- package/dist-server/errors/index.js.map +1 -1
- package/dist-server/errors/user-domain-not-match-error.d.ts +1 -1
- package/dist-server/errors/user-domain-not-match-error.js +8 -8
- package/dist-server/errors/user-domain-not-match-error.js.map +1 -1
- package/dist-server/index.d.ts +16 -16
- package/dist-server/index.js +18 -18
- package/dist-server/index.js.map +1 -1
- package/dist-server/middlewares/authenticate-401-middleware.js +11 -11
- package/dist-server/middlewares/authenticate-401-middleware.js.map +1 -1
- package/dist-server/middlewares/bypass-signin-middleware.d.ts +1 -0
- package/dist-server/middlewares/bypass-signin-middleware.js +20 -0
- package/dist-server/middlewares/bypass-signin-middleware.js.map +1 -0
- package/dist-server/middlewares/domain-authenticate-middleware.d.ts +1 -1
- package/dist-server/middlewares/domain-authenticate-middleware.js +9 -13
- package/dist-server/middlewares/domain-authenticate-middleware.js.map +1 -1
- package/dist-server/middlewares/graphql-authenticate-middleware.js +4 -4
- package/dist-server/middlewares/graphql-authenticate-middleware.js.map +1 -1
- package/dist-server/middlewares/index.d.ts +5 -5
- package/dist-server/middlewares/index.js +24 -19
- package/dist-server/middlewares/index.js.map +1 -1
- package/dist-server/middlewares/jwt-authenticate-middleware.js +15 -15
- package/dist-server/middlewares/jwt-authenticate-middleware.js.map +1 -1
- package/dist-server/middlewares/signin-middleware.js +2 -2
- package/dist-server/middlewares/signin-middleware.js.map +1 -1
- package/dist-server/middlewares/verify-recaptcha-middleware.d.ts +3 -0
- package/dist-server/middlewares/verify-recaptcha-middleware.js +95 -0
- package/dist-server/middlewares/verify-recaptcha-middleware.js.map +1 -0
- package/dist-server/middlewares/webauthn-middleware.js +16 -13
- package/dist-server/middlewares/webauthn-middleware.js.map +1 -1
- package/dist-server/migrations/1548206416130-SeedUser.js +6 -6
- package/dist-server/migrations/1548206416130-SeedUser.js.map +1 -1
- package/dist-server/migrations/1566805283882-SeedPrivilege.js +2 -2
- package/dist-server/migrations/1566805283882-SeedPrivilege.js.map +1 -1
- package/dist-server/migrations/index.js.map +1 -1
- package/dist-server/router/auth-checkin-router.js +18 -17
- package/dist-server/router/auth-checkin-router.js.map +1 -1
- package/dist-server/router/auth-private-process-router.js +27 -19
- package/dist-server/router/auth-private-process-router.js.map +1 -1
- package/dist-server/router/auth-public-process-router.js +30 -30
- package/dist-server/router/auth-public-process-router.js.map +1 -1
- package/dist-server/router/auth-signin-router.js +6 -6
- package/dist-server/router/auth-signin-router.js.map +1 -1
- package/dist-server/router/auth-signup-router.js +13 -9
- package/dist-server/router/auth-signup-router.js.map +1 -1
- package/dist-server/router/index.d.ts +9 -9
- package/dist-server/router/index.js +9 -9
- package/dist-server/router/index.js.map +1 -1
- package/dist-server/router/oauth2/index.d.ts +2 -2
- package/dist-server/router/oauth2/index.js +2 -2
- package/dist-server/router/oauth2/index.js.map +1 -1
- package/dist-server/router/oauth2/oauth2-authorize-router.js +6 -6
- package/dist-server/router/oauth2/oauth2-authorize-router.js.map +1 -1
- package/dist-server/router/oauth2/oauth2-router.d.ts +1 -1
- package/dist-server/router/oauth2/oauth2-router.js +21 -21
- package/dist-server/router/oauth2/oauth2-router.js.map +1 -1
- package/dist-server/router/oauth2/oauth2-server.js +21 -21
- package/dist-server/router/oauth2/oauth2-server.js.map +1 -1
- package/dist-server/router/site-root-router.js +4 -4
- package/dist-server/router/site-root-router.js.map +1 -1
- package/dist-server/router/webauthn-router.js +9 -9
- package/dist-server/router/webauthn-router.js.map +1 -1
- package/dist-server/routes.js +77 -51
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/app-binding/app-binding-mutation.js +4 -4
- package/dist-server/service/app-binding/app-binding-mutation.js.map +1 -1
- package/dist-server/service/app-binding/app-binding-query.d.ts +4 -4
- package/dist-server/service/app-binding/app-binding-query.js +22 -22
- package/dist-server/service/app-binding/app-binding-query.js.map +1 -1
- package/dist-server/service/app-binding/app-binding-types.d.ts +1 -1
- package/dist-server/service/app-binding/app-binding-types.js +2 -2
- package/dist-server/service/app-binding/app-binding-types.js.map +1 -1
- package/dist-server/service/app-binding/app-binding.d.ts +2 -2
- package/dist-server/service/app-binding/app-binding.js +4 -4
- package/dist-server/service/app-binding/app-binding.js.map +1 -1
- package/dist-server/service/app-binding/index.d.ts +2 -2
- package/dist-server/service/app-binding/index.js +3 -3
- package/dist-server/service/app-binding/index.js.map +1 -1
- package/dist-server/service/appliance/appliance-mutation.d.ts +2 -2
- package/dist-server/service/appliance/appliance-mutation.js +21 -21
- package/dist-server/service/appliance/appliance-mutation.js.map +1 -1
- package/dist-server/service/appliance/appliance-query.d.ts +3 -3
- package/dist-server/service/appliance/appliance-query.js +17 -17
- package/dist-server/service/appliance/appliance-query.js.map +1 -1
- package/dist-server/service/appliance/appliance-types.d.ts +1 -1
- package/dist-server/service/appliance/appliance-types.js +2 -2
- package/dist-server/service/appliance/appliance-types.js.map +1 -1
- package/dist-server/service/appliance/appliance.d.ts +1 -1
- package/dist-server/service/appliance/appliance.js +8 -8
- package/dist-server/service/appliance/appliance.js.map +1 -1
- package/dist-server/service/appliance/index.d.ts +3 -3
- package/dist-server/service/appliance/index.js +5 -5
- package/dist-server/service/appliance/index.js.map +1 -1
- package/dist-server/service/application/application-mutation.d.ts +8 -8
- package/dist-server/service/application/application-mutation.js +20 -20
- package/dist-server/service/application/application-mutation.js.map +1 -1
- package/dist-server/service/application/application-query.d.ts +2 -2
- package/dist-server/service/application/application-query.js +16 -16
- package/dist-server/service/application/application-query.js.map +1 -1
- package/dist-server/service/application/application-types.d.ts +1 -1
- package/dist-server/service/application/application-types.js +4 -4
- package/dist-server/service/application/application-types.js.map +1 -1
- package/dist-server/service/application/application.d.ts +1 -1
- package/dist-server/service/application/application.js +12 -12
- package/dist-server/service/application/application.js.map +1 -1
- package/dist-server/service/application/index.d.ts +3 -3
- package/dist-server/service/application/index.js +5 -5
- package/dist-server/service/application/index.js.map +1 -1
- package/dist-server/service/auth-provider/auth-provider-mutation.d.ts +2 -2
- package/dist-server/service/auth-provider/auth-provider-mutation.js +20 -20
- package/dist-server/service/auth-provider/auth-provider-mutation.js.map +1 -1
- package/dist-server/service/auth-provider/auth-provider-query.d.ts +3 -3
- package/dist-server/service/auth-provider/auth-provider-query.js +20 -20
- package/dist-server/service/auth-provider/auth-provider-query.js.map +1 -1
- package/dist-server/service/auth-provider/auth-provider-type.d.ts +1 -1
- package/dist-server/service/auth-provider/auth-provider-type.js +2 -2
- package/dist-server/service/auth-provider/auth-provider-type.js.map +1 -1
- package/dist-server/service/auth-provider/auth-provider.d.ts +3 -3
- package/dist-server/service/auth-provider/auth-provider.js +12 -12
- package/dist-server/service/auth-provider/auth-provider.js.map +1 -1
- package/dist-server/service/auth-provider/index.d.ts +3 -3
- package/dist-server/service/auth-provider/index.js +5 -5
- package/dist-server/service/auth-provider/index.js.map +1 -1
- package/dist-server/service/domain-generator/domain-generator-mutation.d.ts +1 -1
- package/dist-server/service/domain-generator/domain-generator-mutation.js +11 -11
- package/dist-server/service/domain-generator/domain-generator-mutation.js.map +1 -1
- package/dist-server/service/domain-generator/domain-generator-types.d.ts +1 -1
- package/dist-server/service/domain-generator/domain-generator-types.js +3 -3
- package/dist-server/service/domain-generator/domain-generator-types.js.map +1 -1
- package/dist-server/service/domain-generator/index.d.ts +1 -1
- package/dist-server/service/domain-generator/index.js +2 -2
- package/dist-server/service/domain-generator/index.js.map +1 -1
- package/dist-server/service/granted-role/granted-role-mutation.d.ts +3 -3
- package/dist-server/service/granted-role/granted-role-mutation.js +17 -17
- package/dist-server/service/granted-role/granted-role-mutation.js.map +1 -1
- package/dist-server/service/granted-role/granted-role-query.d.ts +2 -2
- package/dist-server/service/granted-role/granted-role-query.js +13 -13
- package/dist-server/service/granted-role/granted-role-query.js.map +1 -1
- package/dist-server/service/granted-role/granted-role.d.ts +1 -1
- package/dist-server/service/granted-role/granted-role.js +3 -3
- package/dist-server/service/granted-role/granted-role.js.map +1 -1
- package/dist-server/service/granted-role/index.d.ts +3 -3
- package/dist-server/service/granted-role/index.js +5 -5
- package/dist-server/service/granted-role/index.js.map +1 -1
- package/dist-server/service/index.d.ts +25 -25
- package/dist-server/service/index.js +70 -70
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/invitation/index.d.ts +3 -3
- package/dist-server/service/invitation/index.js +5 -5
- package/dist-server/service/invitation/index.js.map +1 -1
- package/dist-server/service/invitation/invitation-mutation.d.ts +2 -2
- package/dist-server/service/invitation/invitation-mutation.js +10 -10
- package/dist-server/service/invitation/invitation-mutation.js.map +1 -1
- package/dist-server/service/invitation/invitation-query.d.ts +1 -1
- package/dist-server/service/invitation/invitation-query.js +7 -7
- package/dist-server/service/invitation/invitation-query.js.map +1 -1
- package/dist-server/service/invitation/invitation-types.d.ts +1 -1
- package/dist-server/service/invitation/invitation-types.js +2 -2
- package/dist-server/service/invitation/invitation-types.js.map +1 -1
- package/dist-server/service/invitation/invitation.d.ts +1 -1
- package/dist-server/service/invitation/invitation.js +5 -5
- package/dist-server/service/invitation/invitation.js.map +1 -1
- package/dist-server/service/login-history/index.d.ts +2 -2
- package/dist-server/service/login-history/index.js +4 -4
- package/dist-server/service/login-history/index.js.map +1 -1
- package/dist-server/service/login-history/login-history-query.d.ts +3 -3
- package/dist-server/service/login-history/login-history-query.js +11 -11
- package/dist-server/service/login-history/login-history-query.js.map +1 -1
- package/dist-server/service/login-history/login-history-type.d.ts +1 -1
- package/dist-server/service/login-history/login-history-type.js +2 -2
- package/dist-server/service/login-history/login-history-type.js.map +1 -1
- package/dist-server/service/login-history/login-history.d.ts +1 -1
- package/dist-server/service/login-history/login-history.js +4 -4
- package/dist-server/service/login-history/login-history.js.map +1 -1
- package/dist-server/service/partner/index.d.ts +3 -3
- package/dist-server/service/partner/index.js +5 -5
- package/dist-server/service/partner/index.js.map +1 -1
- package/dist-server/service/partner/partner-mutation.js +8 -8
- package/dist-server/service/partner/partner-mutation.js.map +1 -1
- package/dist-server/service/partner/partner-query.d.ts +3 -3
- package/dist-server/service/partner/partner-query.js +17 -17
- package/dist-server/service/partner/partner-query.js.map +1 -1
- package/dist-server/service/partner/partner-types.d.ts +1 -1
- package/dist-server/service/partner/partner-types.js +2 -2
- package/dist-server/service/partner/partner-types.js.map +1 -1
- package/dist-server/service/partner/partner.d.ts +1 -1
- package/dist-server/service/partner/partner.js +5 -5
- package/dist-server/service/partner/partner.js.map +1 -1
- package/dist-server/service/password-history/index.d.ts +1 -1
- package/dist-server/service/password-history/index.js +2 -2
- package/dist-server/service/password-history/index.js.map +1 -1
- package/dist-server/service/privilege/index.d.ts +3 -3
- package/dist-server/service/privilege/index.js +5 -5
- package/dist-server/service/privilege/index.js.map +1 -1
- package/dist-server/service/privilege/privilege-directive.js +2 -2
- package/dist-server/service/privilege/privilege-directive.js.map +1 -1
- package/dist-server/service/privilege/privilege-mutation.d.ts +2 -2
- package/dist-server/service/privilege/privilege-mutation.js +15 -15
- package/dist-server/service/privilege/privilege-mutation.js.map +1 -1
- package/dist-server/service/privilege/privilege-query.d.ts +4 -4
- package/dist-server/service/privilege/privilege-query.js +20 -20
- package/dist-server/service/privilege/privilege-query.js.map +1 -1
- package/dist-server/service/privilege/privilege-types.d.ts +1 -1
- package/dist-server/service/privilege/privilege-types.js +2 -2
- package/dist-server/service/privilege/privilege-types.js.map +1 -1
- package/dist-server/service/privilege/privilege.d.ts +2 -2
- package/dist-server/service/privilege/privilege.js +10 -10
- package/dist-server/service/privilege/privilege.js.map +1 -1
- package/dist-server/service/role/index.d.ts +3 -3
- package/dist-server/service/role/index.js +5 -5
- package/dist-server/service/role/index.js.map +1 -1
- package/dist-server/service/role/role-mutation.d.ts +2 -2
- package/dist-server/service/role/role-mutation.js +19 -19
- package/dist-server/service/role/role-mutation.js.map +1 -1
- package/dist-server/service/role/role-query.d.ts +4 -4
- package/dist-server/service/role/role-query.js +29 -29
- package/dist-server/service/role/role-query.js.map +1 -1
- package/dist-server/service/role/role-types.d.ts +1 -1
- package/dist-server/service/role/role-types.js +2 -2
- package/dist-server/service/role/role-types.js.map +1 -1
- package/dist-server/service/role/role.d.ts +2 -2
- package/dist-server/service/role/role.js +12 -12
- package/dist-server/service/role/role.js.map +1 -1
- package/dist-server/service/user/domain-query.d.ts +1 -1
- package/dist-server/service/user/domain-query.js +3 -3
- package/dist-server/service/user/domain-query.js.map +1 -1
- package/dist-server/service/user/index.d.ts +4 -4
- package/dist-server/service/user/index.js +6 -6
- package/dist-server/service/user/index.js.map +1 -1
- package/dist-server/service/user/user-mutation.d.ts +3 -3
- package/dist-server/service/user/user-mutation.js +42 -42
- package/dist-server/service/user/user-mutation.js.map +1 -1
- package/dist-server/service/user/user-query.d.ts +3 -3
- package/dist-server/service/user/user-query.js +21 -21
- package/dist-server/service/user/user-query.js.map +1 -1
- package/dist-server/service/user/user-types.d.ts +1 -1
- package/dist-server/service/user/user-types.js +2 -2
- package/dist-server/service/user/user-types.js.map +1 -1
- package/dist-server/service/user/user.d.ts +3 -3
- package/dist-server/service/user/user.js +40 -40
- package/dist-server/service/user/user.js.map +1 -1
- package/dist-server/service/users-auth-providers/index.d.ts +1 -1
- package/dist-server/service/users-auth-providers/index.js +2 -2
- package/dist-server/service/users-auth-providers/index.js.map +1 -1
- package/dist-server/service/users-auth-providers/users-auth-providers.d.ts +2 -2
- package/dist-server/service/users-auth-providers/users-auth-providers.js +8 -8
- package/dist-server/service/users-auth-providers/users-auth-providers.js.map +1 -1
- package/dist-server/service/verification-token/index.d.ts +1 -1
- package/dist-server/service/verification-token/index.js +2 -2
- package/dist-server/service/verification-token/index.js.map +1 -1
- package/dist-server/service/web-auth-credential/index.d.ts +1 -1
- package/dist-server/service/web-auth-credential/index.js +2 -2
- package/dist-server/service/web-auth-credential/index.js.map +1 -1
- package/dist-server/service/web-auth-credential/web-auth-credential.d.ts +1 -1
- package/dist-server/service/web-auth-credential/web-auth-credential.js +10 -10
- package/dist-server/service/web-auth-credential/web-auth-credential.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/dist-server/types.d.ts +1 -1
- package/dist-server/types.js.map +1 -1
- package/dist-server/utils/access-token-cookie.js +2 -11
- package/dist-server/utils/access-token-cookie.js.map +1 -1
- package/dist-server/utils/check-permission.d.ts +2 -2
- package/dist-server/utils/check-permission.js +3 -3
- package/dist-server/utils/check-permission.js.map +1 -1
- package/dist-server/utils/check-user-belongs-domain.d.ts +1 -1
- package/dist-server/utils/check-user-belongs-domain.js +2 -2
- package/dist-server/utils/check-user-belongs-domain.js.map +1 -1
- package/dist-server/utils/check-user-has-role.d.ts +1 -1
- package/dist-server/utils/check-user-has-role.js +2 -2
- package/dist-server/utils/check-user-has-role.js.map +1 -1
- package/dist-server/utils/get-domain-users.d.ts +1 -1
- package/dist-server/utils/get-domain-users.js +2 -2
- package/dist-server/utils/get-domain-users.js.map +1 -1
- package/dist-server/utils/get-user-domains.d.ts +2 -3
- package/dist-server/utils/get-user-domains.js +30 -26
- package/dist-server/utils/get-user-domains.js.map +1 -1
- package/helps/config/recaptcha.ja.md +49 -0
- package/helps/config/recaptcha.ko.md +49 -0
- package/helps/config/recaptcha.md +49 -0
- package/helps/config/recaptcha.ms.md +49 -0
- package/helps/config/recaptcha.zh.md +49 -0
- package/package.json +10 -9
- package/dist-server/utils/get-domain-from-hostname.d.ts +0 -1
- package/dist-server/utils/get-domain-from-hostname.js +0 -9
- package/dist-server/utils/get-domain-from-hostname.js.map +0 -1
@@ -4,30 +4,30 @@ exports.ApplianceMutation = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
6
6
|
const shell_1 = require("@things-factory/shell");
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
7
|
+
const user_js_1 = require("../user/user.js");
|
8
|
+
const appliance_js_1 = require("./appliance.js");
|
9
|
+
const appliance_types_js_1 = require("./appliance-types.js");
|
10
10
|
const crypto = require('crypto');
|
11
11
|
let ApplianceMutation = class ApplianceMutation {
|
12
12
|
async createAppliance(appliance, context) {
|
13
|
-
return await (0, shell_1.getRepository)(
|
13
|
+
return await (0, shell_1.getRepository)(appliance_js_1.Appliance).save(Object.assign({ domain: context.state.domain, creator: context.state.user, updater: context.state.user }, appliance));
|
14
14
|
}
|
15
15
|
async deleteAppliance(id, context) {
|
16
16
|
const { domain } = context.state;
|
17
17
|
// TODO 이 사용자가 이 도메인에 속한 사용자인지 확인해야함.
|
18
18
|
// TODO 다른 도메인에도 포함되어있다면, domains-users 관게와 해당 도메인 관련 정보만 삭제해야 함.
|
19
|
-
await (0, shell_1.getRepository)(
|
19
|
+
await (0, shell_1.getRepository)(user_js_1.User).delete({
|
20
20
|
reference: id,
|
21
21
|
userType: 'appliance'
|
22
22
|
});
|
23
|
-
await (0, shell_1.getRepository)(
|
23
|
+
await (0, shell_1.getRepository)(appliance_js_1.Appliance).delete({ domain: { id: domain.id }, id });
|
24
24
|
return true;
|
25
25
|
}
|
26
26
|
async generateApplianceSecret(id, context) {
|
27
27
|
const { domain, user } = context.state;
|
28
|
-
const appliance = await (0, shell_1.getRepository)(
|
28
|
+
const appliance = await (0, shell_1.getRepository)(appliance_js_1.Appliance).findOneBy({ domain: { id: domain.id }, id });
|
29
29
|
const appuserEmail = `${crypto.randomUUID()}@${domain === null || domain === void 0 ? void 0 : domain.subdomain}`;
|
30
|
-
let appuser = await (0, shell_1.getRepository)(
|
30
|
+
let appuser = await (0, shell_1.getRepository)(user_js_1.User).findOne({
|
31
31
|
where: {
|
32
32
|
reference: id,
|
33
33
|
userType: 'appliance'
|
@@ -36,12 +36,12 @@ let ApplianceMutation = class ApplianceMutation {
|
|
36
36
|
});
|
37
37
|
if (!appuser) {
|
38
38
|
/* newly create appuser */
|
39
|
-
appuser = await (0, shell_1.getRepository)(
|
39
|
+
appuser = await (0, shell_1.getRepository)(user_js_1.User).save({
|
40
40
|
email: appuserEmail,
|
41
41
|
name: appliance.name,
|
42
42
|
userType: 'appliance',
|
43
43
|
reference: id,
|
44
|
-
status:
|
44
|
+
status: user_js_1.UserStatus.ACTIVATED,
|
45
45
|
domains: [domain],
|
46
46
|
updater: user,
|
47
47
|
creator: user
|
@@ -50,14 +50,14 @@ let ApplianceMutation = class ApplianceMutation {
|
|
50
50
|
if (!appuser.domains.find(d => d.id === domain.id)) {
|
51
51
|
context.throw(401, 'appliance is not allowed for this domain');
|
52
52
|
}
|
53
|
-
appuser.password =
|
54
|
-
await (0, shell_1.getRepository)(
|
55
|
-
return await (0, shell_1.getRepository)(
|
53
|
+
appuser.password = appliance_js_1.Appliance.generateAccessToken(domain, appuser, appliance);
|
54
|
+
await (0, shell_1.getRepository)(user_js_1.User).save(appuser);
|
55
|
+
return await (0, shell_1.getRepository)(appliance_js_1.Appliance).save(Object.assign(Object.assign({}, appliance), { accessToken: appuser.password, updater: user }));
|
56
56
|
}
|
57
57
|
async updateAppliance(id, patch, context) {
|
58
58
|
const { domain } = context.state;
|
59
|
-
const applianceRepository = (0, shell_1.getRepository)(
|
60
|
-
const userRepository = (0, shell_1.getRepository)(
|
59
|
+
const applianceRepository = (0, shell_1.getRepository)(appliance_js_1.Appliance);
|
60
|
+
const userRepository = (0, shell_1.getRepository)(user_js_1.User);
|
61
61
|
const appliance = await applianceRepository.findOne({ where: { domain: { id: domain.id }, id } });
|
62
62
|
const user = await userRepository.findOne({ where: { reference: id, userType: 'appliance' } });
|
63
63
|
userRepository.save(Object.assign(Object.assign({}, user), { name: (patch === null || patch === void 0 ? void 0 : patch.name) || user.name }));
|
@@ -67,11 +67,11 @@ let ApplianceMutation = class ApplianceMutation {
|
|
67
67
|
exports.ApplianceMutation = ApplianceMutation;
|
68
68
|
tslib_1.__decorate([
|
69
69
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "mutation", domainOwnerGranted: true)'),
|
70
|
-
(0, type_graphql_1.Mutation)(returns =>
|
70
|
+
(0, type_graphql_1.Mutation)(returns => appliance_js_1.Appliance, { description: 'To create new appliance' }),
|
71
71
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('appliance')),
|
72
72
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
73
73
|
tslib_1.__metadata("design:type", Function),
|
74
|
-
tslib_1.__metadata("design:paramtypes", [
|
74
|
+
tslib_1.__metadata("design:paramtypes", [appliance_types_js_1.NewAppliance, Object]),
|
75
75
|
tslib_1.__metadata("design:returntype", Promise)
|
76
76
|
], ApplianceMutation.prototype, "createAppliance", null);
|
77
77
|
tslib_1.__decorate([
|
@@ -85,7 +85,7 @@ tslib_1.__decorate([
|
|
85
85
|
], ApplianceMutation.prototype, "deleteAppliance", null);
|
86
86
|
tslib_1.__decorate([
|
87
87
|
(0, type_graphql_1.Directive)('@privilege(category: "security", privilege: "mutation", domainOwnerGranted: true)'),
|
88
|
-
(0, type_graphql_1.Mutation)(returns =>
|
88
|
+
(0, type_graphql_1.Mutation)(returns => appliance_js_1.Appliance),
|
89
89
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
90
90
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
91
91
|
tslib_1.__metadata("design:type", Function),
|
@@ -94,15 +94,15 @@ tslib_1.__decorate([
|
|
94
94
|
], ApplianceMutation.prototype, "generateApplianceSecret", null);
|
95
95
|
tslib_1.__decorate([
|
96
96
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "mutation", domainOwnerGranted: true)'),
|
97
|
-
(0, type_graphql_1.Mutation)(returns =>
|
97
|
+
(0, type_graphql_1.Mutation)(returns => appliance_js_1.Appliance),
|
98
98
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
99
99
|
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
|
100
100
|
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
101
101
|
tslib_1.__metadata("design:type", Function),
|
102
|
-
tslib_1.__metadata("design:paramtypes", [String,
|
102
|
+
tslib_1.__metadata("design:paramtypes", [String, appliance_types_js_1.AppliancePatch, Object]),
|
103
103
|
tslib_1.__metadata("design:returntype", Promise)
|
104
104
|
], ApplianceMutation.prototype, "updateAppliance", null);
|
105
105
|
exports.ApplianceMutation = ApplianceMutation = tslib_1.__decorate([
|
106
|
-
(0, type_graphql_1.Resolver)(
|
106
|
+
(0, type_graphql_1.Resolver)(appliance_js_1.Appliance)
|
107
107
|
], ApplianceMutation);
|
108
108
|
//# sourceMappingURL=appliance-mutation.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"appliance-mutation.js","sourceRoot":"","sources":["../../../server/service/appliance/appliance-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AAEtE,iDAAqD;AAErD,
|
1
|
+
{"version":3,"file":"appliance-mutation.js","sourceRoot":"","sources":["../../../server/service/appliance/appliance-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AAEtE,iDAAqD;AAErD,6CAAkD;AAClD,iDAA0C;AAC1C,6DAAmE;AAEnE,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAGzB,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAGtB,AAAN,KAAK,CAAC,eAAe,CACD,SAAuB,EAClC,OAAwB;QAE/B,OAAO,MAAM,IAAA,qBAAa,EAAC,wBAAS,CAAC,CAAC,IAAI,iBACxC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAC5B,OAAO,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,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gEAyC1D;AAIK;IAFL,IAAA,wBAAS,EAAC,+EAA+E,CAAC;IAC1F,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,wBAAS,CAAC;IAE5B,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IACT,mBAAA,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;IACZ,mBAAA,IAAA,kBAAG,GAAE,CAAA;;qDADe,mCAAc;;wDAoBpC;4BApGU,iBAAiB;IAD7B,IAAA,uBAAQ,EAAC,wBAAS,CAAC;GACP,iBAAiB,CAqG7B","sourcesContent":["import { Directive, Arg, Ctx, Mutation, Resolver } from 'type-graphql'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { User, UserStatus } from '../user/user.js'\nimport { Appliance } from './appliance.js'\nimport { AppliancePatch, NewAppliance } from './appliance-types.js'\n\nconst crypto = require('crypto')\n\n@Resolver(Appliance)\nexport class ApplianceMutation {\n @Directive('@privilege(category: \"user\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Appliance, { description: 'To create new appliance' })\n async createAppliance(\n @Arg('appliance') appliance: NewAppliance,\n @Ctx() context: ResolverContext\n ): Promise<Appliance> {\n return await getRepository(Appliance).save({\n domain: context.state.domain,\n creator: context.state.user,\n updater: context.state.user,\n ...appliance\n })\n }\n\n @Directive('@privilege(category: \"user\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete appliance' })\n async deleteAppliance(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Boolean> {\n const { domain } = context.state\n // TODO 이 사용자가 이 도메인에 속한 사용자인지 확인해야함.\n // TODO 다른 도메인에도 포함되어있다면, domains-users 관게와 해당 도메인 관련 정보만 삭제해야 함.\n await getRepository(User).delete({\n reference: id,\n userType: 'appliance'\n })\n\n await getRepository(Appliance).delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@privilege(category: \"security\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Appliance)\n async generateApplianceSecret(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Appliance> {\n const { domain, user } = context.state\n\n const appliance: Appliance = await getRepository(Appliance).findOneBy({ domain: { id: domain.id }, id })\n\n const appuserEmail = `${crypto.randomUUID()}@${domain?.subdomain}`\n let appuser: User = await getRepository(User).findOne({\n where: {\n reference: id,\n userType: 'appliance'\n },\n relations: ['domains']\n })\n\n if (!appuser) {\n /* newly create appuser */\n appuser = await getRepository(User).save({\n email: appuserEmail,\n name: appliance.name,\n userType: 'appliance',\n reference: id,\n status: UserStatus.ACTIVATED,\n domains: [domain],\n updater: user,\n creator: user\n })\n }\n\n if (!appuser.domains.find(d => d.id === domain.id)) {\n context.throw(401, 'appliance is not allowed for this domain')\n }\n\n appuser.password = Appliance.generateAccessToken(domain, appuser, appliance)\n\n await getRepository(User).save(appuser)\n\n return await getRepository(Appliance).save({\n ...appliance,\n accessToken: appuser.password,\n updater: user\n })\n }\n\n @Directive('@privilege(category: \"user\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Appliance)\n async updateAppliance(\n @Arg('id') id: string,\n @Arg('patch') patch: AppliancePatch,\n @Ctx() context: ResolverContext\n ): Promise<Appliance> {\n const { domain } = context.state\n\n const applianceRepository = getRepository(Appliance)\n const userRepository = getRepository(User)\n const appliance = await applianceRepository.findOne({ where: { domain: { id: domain.id }, id } })\n const user = await userRepository.findOne({ where: { reference: id, userType: 'appliance' } })\n\n userRepository.save({\n ...user,\n name: patch?.name || user.name\n })\n\n return await applianceRepository.save({\n ...appliance,\n ...patch,\n updater: context.state.user\n })\n }\n}\n"]}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Domain, ListParam } from '@things-factory/shell';
|
2
|
-
import { Appliance } from '../appliance/appliance';
|
3
|
-
import { User } from '../user/user';
|
4
|
-
import { ApplianceList } from './appliance-types';
|
2
|
+
import { Appliance } from '../appliance/appliance.js';
|
3
|
+
import { User } from '../user/user.js';
|
4
|
+
import { ApplianceList } from './appliance-types.js';
|
5
5
|
export declare class ApplianceQuery {
|
6
6
|
appliance(id: string, context: ResolverContext): Promise<Appliance>;
|
7
7
|
appliances(params: ListParam, context: ResolverContext): Promise<ApplianceList>;
|
@@ -4,20 +4,20 @@ exports.ApplianceQuery = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
6
6
|
const shell_1 = require("@things-factory/shell");
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
7
|
+
const appliance_js_1 = require("../appliance/appliance.js");
|
8
|
+
const user_js_1 = require("../user/user.js");
|
9
|
+
const appliance_types_js_1 = require("./appliance-types.js");
|
10
10
|
let ApplianceQuery = class ApplianceQuery {
|
11
11
|
async appliance(id, context) {
|
12
12
|
const { domain } = context.state;
|
13
|
-
return await (0, shell_1.getRepository)(
|
13
|
+
return await (0, shell_1.getRepository)(appliance_js_1.Appliance).findOneBy({ domain: { id: domain.id }, id });
|
14
14
|
}
|
15
15
|
async appliances(params, context) {
|
16
16
|
const { domain } = context.state;
|
17
17
|
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
18
18
|
domain,
|
19
19
|
params,
|
20
|
-
repository: (0, shell_1.getRepository)(
|
20
|
+
repository: (0, shell_1.getRepository)(appliance_js_1.Appliance),
|
21
21
|
alias: 'appliance',
|
22
22
|
searchables: ['name', 'description']
|
23
23
|
});
|
@@ -29,7 +29,7 @@ let ApplianceQuery = class ApplianceQuery {
|
|
29
29
|
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
30
30
|
domain,
|
31
31
|
params,
|
32
|
-
repository: (0, shell_1.getRepository)(
|
32
|
+
repository: (0, shell_1.getRepository)(appliance_js_1.Appliance),
|
33
33
|
alias: 'appliance',
|
34
34
|
searchables: ['name', 'description']
|
35
35
|
});
|
@@ -43,16 +43,16 @@ let ApplianceQuery = class ApplianceQuery {
|
|
43
43
|
return context.state.domain;
|
44
44
|
}
|
45
45
|
async updater(appliance) {
|
46
|
-
return await (0, shell_1.getRepository)(
|
46
|
+
return await (0, shell_1.getRepository)(user_js_1.User).findOneBy({ id: appliance.updaterId });
|
47
47
|
}
|
48
48
|
async creator(appliance) {
|
49
|
-
return await (0, shell_1.getRepository)(
|
49
|
+
return await (0, shell_1.getRepository)(user_js_1.User).findOneBy({ id: appliance.creatorId });
|
50
50
|
}
|
51
51
|
};
|
52
52
|
exports.ApplianceQuery = ApplianceQuery;
|
53
53
|
tslib_1.__decorate([
|
54
54
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
|
55
|
-
(0, type_graphql_1.Query)(returns =>
|
55
|
+
(0, type_graphql_1.Query)(returns => appliance_js_1.Appliance, { description: ' To fetch appliance' }),
|
56
56
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
57
57
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
58
58
|
tslib_1.__metadata("design:type", Function),
|
@@ -61,7 +61,7 @@ tslib_1.__decorate([
|
|
61
61
|
], ApplianceQuery.prototype, "appliance", null);
|
62
62
|
tslib_1.__decorate([
|
63
63
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
|
64
|
-
(0, type_graphql_1.Query)(returns =>
|
64
|
+
(0, type_graphql_1.Query)(returns => appliance_types_js_1.ApplianceList, { description: 'To fetch multiple appliance' }),
|
65
65
|
tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
|
66
66
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
67
67
|
tslib_1.__metadata("design:type", Function),
|
@@ -70,7 +70,7 @@ tslib_1.__decorate([
|
|
70
70
|
], ApplianceQuery.prototype, "appliances", null);
|
71
71
|
tslib_1.__decorate([
|
72
72
|
(0, type_graphql_1.Directive)('@privilege(category: "user", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
|
73
|
-
(0, type_graphql_1.Query)(returns =>
|
73
|
+
(0, type_graphql_1.Query)(returns => appliance_types_js_1.ApplianceList, { description: 'To fetch multiple appliance' }),
|
74
74
|
tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
|
75
75
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
76
76
|
tslib_1.__metadata("design:type", Function),
|
@@ -82,7 +82,7 @@ tslib_1.__decorate([
|
|
82
82
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
83
83
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
84
84
|
tslib_1.__metadata("design:type", Function),
|
85
|
-
tslib_1.__metadata("design:paramtypes", [
|
85
|
+
tslib_1.__metadata("design:paramtypes", [appliance_js_1.Appliance, Object]),
|
86
86
|
tslib_1.__metadata("design:returntype", Promise)
|
87
87
|
], ApplianceQuery.prototype, "accessToken", null);
|
88
88
|
tslib_1.__decorate([
|
@@ -93,20 +93,20 @@ tslib_1.__decorate([
|
|
93
93
|
tslib_1.__metadata("design:returntype", Promise)
|
94
94
|
], ApplianceQuery.prototype, "domain", null);
|
95
95
|
tslib_1.__decorate([
|
96
|
-
(0, type_graphql_1.FieldResolver)(type =>
|
96
|
+
(0, type_graphql_1.FieldResolver)(type => user_js_1.User),
|
97
97
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
98
98
|
tslib_1.__metadata("design:type", Function),
|
99
|
-
tslib_1.__metadata("design:paramtypes", [
|
99
|
+
tslib_1.__metadata("design:paramtypes", [appliance_js_1.Appliance]),
|
100
100
|
tslib_1.__metadata("design:returntype", Promise)
|
101
101
|
], ApplianceQuery.prototype, "updater", null);
|
102
102
|
tslib_1.__decorate([
|
103
|
-
(0, type_graphql_1.FieldResolver)(type =>
|
103
|
+
(0, type_graphql_1.FieldResolver)(type => user_js_1.User),
|
104
104
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
105
105
|
tslib_1.__metadata("design:type", Function),
|
106
|
-
tslib_1.__metadata("design:paramtypes", [
|
106
|
+
tslib_1.__metadata("design:paramtypes", [appliance_js_1.Appliance]),
|
107
107
|
tslib_1.__metadata("design:returntype", Promise)
|
108
108
|
], ApplianceQuery.prototype, "creator", null);
|
109
109
|
exports.ApplianceQuery = ApplianceQuery = tslib_1.__decorate([
|
110
|
-
(0, type_graphql_1.Resolver)(
|
110
|
+
(0, type_graphql_1.Resolver)(appliance_js_1.Appliance)
|
111
111
|
], ApplianceQuery);
|
112
112
|
//# sourceMappingURL=appliance-query.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"appliance-query.js","sourceRoot":"","sources":["../../../server/service/appliance/appliance-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,iDAAuG;AAEvG,
|
1
|
+
{"version":3,"file":"appliance-query.js","sourceRoot":"","sources":["../../../server/service/appliance/appliance-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,iDAAuG;AAEvG,4DAAqD;AACrD,6CAAsC;AACtC,6DAAoD;AAG7C,IAAM,cAAc,GAApB,MAAM,cAAc;IAGnB,AAAN,KAAK,CAAC,SAAS,CAAY,EAAU,EAAS,OAAwB;QACpE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAChC,OAAO,MAAM,IAAA,qBAAa,EAAC,wBAAS,CAAC,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IACpF,CAAC;IAIK,AAAN,KAAK,CAAC,UAAU,CACW,MAAiB,EACnC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,MAAM;YACN,MAAM;YACN,UAAU,EAAE,IAAA,qBAAa,EAAC,w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,CAAC,EAAE,CAAC,cAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,wBAAS;;6CAEzC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAY,wBAAS;;6CAEzC;yBAjEU,cAAc;IAD1B,IAAA,uBAAQ,EAAC,wBAAS,CAAC;GACP,cAAc,CAkE1B","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { getQueryBuilderFromListParams, Domain, getRepository, ListParam } from '@things-factory/shell'\n\nimport { Appliance } from '../appliance/appliance.js'\nimport { User } from '../user/user.js'\nimport { ApplianceList } from './appliance-types.js'\n\n@Resolver(Appliance)\nexport class ApplianceQuery {\n @Directive('@privilege(category: \"user\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => Appliance, { description: ' To fetch appliance' })\n async appliance(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Appliance> {\n const { domain } = context.state\n return await getRepository(Appliance).findOneBy({ domain: { id: domain.id }, id })\n }\n\n @Directive('@privilege(category: \"user\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ApplianceList, { description: 'To fetch multiple appliance' })\n async appliances(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<ApplianceList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: getRepository(Appliance),\n alias: 'appliance',\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @Directive('@privilege(category: \"user\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ApplianceList, { description: 'To fetch multiple appliance' })\n async edges(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<ApplianceList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: getRepository(Appliance),\n alias: 'appliance',\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => String)\n async accessToken(@Root() appliance: Appliance, @Ctx() context: ResolverContext) {\n return appliance.accessToken\n }\n\n @FieldResolver(type => Domain)\n async domain(@Ctx() context: ResolverContext) {\n return context.state.domain\n }\n\n @FieldResolver(type => User)\n async updater(@Root() appliance: Appliance): Promise<User> {\n return await getRepository(User).findOneBy({ id: appliance.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() appliance: Appliance): Promise<User> {\n return await getRepository(User).findOneBy({ id: appliance.creatorId })\n }\n}\n"]}
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NewAppliance = exports.AppliancePatch = exports.ApplianceList = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
6
|
-
const
|
6
|
+
const appliance_js_1 = require("./appliance.js");
|
7
7
|
let ApplianceList = class ApplianceList {
|
8
8
|
};
|
9
9
|
exports.ApplianceList = ApplianceList;
|
10
10
|
tslib_1.__decorate([
|
11
|
-
(0, type_graphql_1.Field)(type => [
|
11
|
+
(0, type_graphql_1.Field)(type => [appliance_js_1.Appliance], { nullable: true }),
|
12
12
|
tslib_1.__metadata("design:type", Array)
|
13
13
|
], ApplianceList.prototype, "items", void 0);
|
14
14
|
tslib_1.__decorate([
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"appliance-types.js","sourceRoot":"","sources":["../../../server/service/appliance/appliance-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AACpE,
|
1
|
+
{"version":3,"file":"appliance-types.js","sourceRoot":"","sources":["../../../server/service/appliance/appliance-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AACpE,iDAA0C;AAGnC,IAAM,aA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A,oBAAK,GAAE;;2CACK;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACV;uBAjBL,YAAY;IADxB,IAAA,wBAAS,GAAE;GACC,YAAY,CAkBxB","sourcesContent":["import { ObjectType, InputType, Field, ID, Int } from 'type-graphql'\nimport { Appliance } from './appliance.js'\n\n@ObjectType()\nexport class ApplianceList {\n @Field(type => [Appliance], { nullable: true })\n items?: Appliance[]\n\n @Field(type => Int, { nullable: true })\n total?: number\n}\n\n@InputType()\nexport class AppliancePatch {\n @Field(type => ID, { nullable: true })\n id?: string\n\n @Field({ nullable: true })\n serialNo?: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n brand?: string\n\n @Field({ nullable: true })\n model?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n netmask?: string\n}\n\n@InputType()\nexport class NewAppliance {\n @Field()\n serialNo: string\n\n @Field()\n name: string\n\n @Field()\n brand: string\n\n @Field()\n model: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n netmask?: string\n}\n"]}
|
@@ -4,10 +4,10 @@ exports.Appliance = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const typeorm_1 = require("typeorm");
|
6
6
|
const type_graphql_1 = require("type-graphql");
|
7
|
-
const user_1 = require("../user/user");
|
8
7
|
const shell_1 = require("@things-factory/shell");
|
9
|
-
const get_secret_1 = require("../../utils/get-secret");
|
10
8
|
const env_1 = require("@things-factory/env");
|
9
|
+
const user_js_1 = require("../user/user.js");
|
10
|
+
const get_secret_js_1 = require("../../utils/get-secret.js");
|
11
11
|
const jsonwebtoken_1 = tslib_1.__importDefault(require("jsonwebtoken"));
|
12
12
|
const ORMCONFIG = env_1.config.get('ormconfig', {});
|
13
13
|
const DATABASE_TYPE = ORMCONFIG.type;
|
@@ -20,12 +20,12 @@ let Appliance = class Appliance {
|
|
20
20
|
appliance: {
|
21
21
|
id: appliance.id
|
22
22
|
},
|
23
|
-
status:
|
23
|
+
status: user_js_1.UserStatus.ACTIVATED,
|
24
24
|
domain: {
|
25
25
|
subdomain: domain.subdomain
|
26
26
|
}
|
27
27
|
};
|
28
|
-
return jsonwebtoken_1.default.sign(credential,
|
28
|
+
return jsonwebtoken_1.default.sign(credential, get_secret_js_1.SECRET, {
|
29
29
|
expiresIn,
|
30
30
|
issuer: 'hatiolab.com',
|
31
31
|
subject
|
@@ -105,18 +105,18 @@ tslib_1.__decorate([
|
|
105
105
|
tslib_1.__metadata("design:type", String)
|
106
106
|
], Appliance.prototype, "accessToken", void 0);
|
107
107
|
tslib_1.__decorate([
|
108
|
-
(0, typeorm_1.ManyToOne)(type =>
|
108
|
+
(0, typeorm_1.ManyToOne)(type => user_js_1.User, { nullable: true }),
|
109
109
|
(0, type_graphql_1.Field)({ nullable: true }),
|
110
|
-
tslib_1.__metadata("design:type",
|
110
|
+
tslib_1.__metadata("design:type", user_js_1.User)
|
111
111
|
], Appliance.prototype, "creator", void 0);
|
112
112
|
tslib_1.__decorate([
|
113
113
|
(0, typeorm_1.RelationId)((appliance) => appliance.creator),
|
114
114
|
tslib_1.__metadata("design:type", String)
|
115
115
|
], Appliance.prototype, "creatorId", void 0);
|
116
116
|
tslib_1.__decorate([
|
117
|
-
(0, typeorm_1.ManyToOne)(type =>
|
117
|
+
(0, typeorm_1.ManyToOne)(type => user_js_1.User, { nullable: true }),
|
118
118
|
(0, type_graphql_1.Field)({ nullable: true }),
|
119
|
-
tslib_1.__metadata("design:type",
|
119
|
+
tslib_1.__metadata("design:type", user_js_1.User)
|
120
120
|
], Appliance.prototype, "updater", void 0);
|
121
121
|
tslib_1.__decorate([
|
122
122
|
(0, typeorm_1.RelationId)((appliance) => appliance.updater),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"appliance.js","sourceRoot":"","sources":["../../../server/service/appliance/appliance.ts"],"names":[],"mappings":";;;;AAAA,qCASgB;AAChB,+CAA+D;AAC/D,
|
1
|
+
{"version":3,"file":"appliance.js","sourceRoot":"","sources":["../../../server/service/appliance/appliance.ts"],"names":[],"mappings":";;;;AAAA,qCASgB;AAChB,+CAA+D;AAC/D,iDAA8C;AAC9C,6CAA4C;AAE5C,6CAAkD;AAClD,6DAAkD;AAClD,wEAA8B;AAE9B,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAO7B,IAAM,SAAS,GAAf,MAAM,SAAS;IAgFpB,8BAA8B;IAC9B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS;QACrD,IAAI,UAAU,GAAG;YACf,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,QAAQ,EAAE,WAAW;YACrB,SAAS,EAAE;gBACT,EAAE,EAAE,SAAS,CAAC,EAAE;aACjB;YACD,MAAM,EAAE,oBAAU,CAAC,SAAS;YAC5B,MAAM,EAAE;gBACN,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B;SACF,CAAA;QAED,OAAO,sBAAG,CAAC,IAAI,CAAC,UAAU,EAAE,sBAAM,EAAE;YAClC,SAAS;YACT,MAAM,EAAE,cAAc;YACtB,OAAO;SACR,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS;QAChD,uDAAuD;QACvD,IAAI,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAA;QACzD,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,CAAA;IACtE,CAAC;CACF,CAAA;AA1GY,8BAAS;AAGX;IAFR,IAA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CAAC,IAAI,CAAC,EAAE;QACrF,MAAM,EAAE,IAAI;KACb,CAAC;IACD,IAAA,yBAAU,GAAE;GACA,SAAS,CA0GrB","sourcesContent":["import {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\nimport { Directive, Field, ID, ObjectType } from 'type-graphql'\nimport { Domain } from '@things-factory/shell'\nimport { config } from '@things-factory/env'\n\nimport { User, UserStatus } from '../user/user.js'\nimport { SECRET } from '../../utils/get-secret.js'\nimport jwt from 'jsonwebtoken'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\n@Entity()\n@Index('ix_appliance_0', (appliance: Appliance) => [appliance.domain, appliance.name], {\n unique: true\n})\n@ObjectType()\nexport class Appliance {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain)\n domain?: Domain\n\n @RelationId((appliance: Appliance) => appliance.domain)\n domainId: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n serialNo: string\n\n @Column()\n @Field()\n name: string\n\n @Column()\n @Field({ nullable: true })\n brand: string\n\n @Column()\n @Field({ nullable: true })\n model: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n netmask: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n description: string\n\n @Column({\n nullable: true,\n type:\n DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'longtext'\n : DATABASE_TYPE == 'oracle'\n ? 'clob'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'varchar',\n length: DATABASE_TYPE == 'mssql' ? 'MAX' : undefined\n })\n @Field({ nullable: true })\n @Directive('@privilege(category: \"security\", privilege: \"query\", domainOwnerGranted: true)')\n accessToken: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n creator: User\n\n @RelationId((appliance: Appliance) => appliance.creator)\n creatorId: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n updater: User\n\n @RelationId((appliance: Appliance) => appliance.updater)\n updaterId: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt: Date\n\n /* signing for jsonwebtoken */\n static sign(subject, expiresIn, domain, user, appliance) {\n var credential = {\n id: user.id,\n userType: 'appliance',\n appliance: {\n id: appliance.id\n },\n status: UserStatus.ACTIVATED,\n domain: {\n subdomain: domain.subdomain\n }\n }\n\n return jwt.sign(credential, SECRET, {\n expiresIn,\n issuer: 'hatiolab.com',\n subject\n })\n }\n\n static generateAccessToken(domain, user, appliance) {\n /* how to set expiresIn https://github.com/vercel/ms */\n let expiresIn = config.get('applianceJwtExpiresIn', '1y')\n return this.sign('access-token', expiresIn, domain, user, appliance)\n }\n}\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Appliance } from './appliance';
|
2
|
-
import { ApplianceQuery } from './appliance-query';
|
3
|
-
import { ApplianceMutation } from './appliance-mutation';
|
1
|
+
import { Appliance } from './appliance.js';
|
2
|
+
import { ApplianceQuery } from './appliance-query.js';
|
3
|
+
import { ApplianceMutation } from './appliance-mutation.js';
|
4
4
|
export declare const entities: (typeof Appliance)[];
|
5
5
|
export declare const resolvers: (typeof ApplianceQuery | typeof ApplianceMutation)[];
|
@@ -1,9 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.resolvers = exports.entities = void 0;
|
4
|
-
const
|
5
|
-
const
|
6
|
-
const
|
7
|
-
exports.entities = [
|
8
|
-
exports.resolvers = [
|
4
|
+
const appliance_js_1 = require("./appliance.js");
|
5
|
+
const appliance_query_js_1 = require("./appliance-query.js");
|
6
|
+
const appliance_mutation_js_1 = require("./appliance-mutation.js");
|
7
|
+
exports.entities = [appliance_js_1.Appliance];
|
8
|
+
exports.resolvers = [appliance_query_js_1.ApplianceQuery, appliance_mutation_js_1.ApplianceMutation];
|
9
9
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/appliance/index.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/appliance/index.ts"],"names":[],"mappings":";;;AAAA,iDAA0C;AAC1C,6DAAqD;AACrD,mEAA2D;AAE9C,QAAA,QAAQ,GAAG,CAAC,wBAAS,CAAC,CAAA;AACtB,QAAA,SAAS,GAAG,CAAC,mCAAc,EAAE,yCAAiB,CAAC,CAAA","sourcesContent":["import { Appliance } from './appliance.js'\nimport { ApplianceQuery } from './appliance-query.js'\nimport { ApplianceMutation } from './appliance-mutation.js'\n\nexport const entities = [Appliance]\nexport const resolvers = [ApplianceQuery, ApplianceMutation]\n"]}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { User } from '../user/user';
|
2
|
-
import { Application } from './application';
|
3
|
-
import { ApplicationPatch, NewApplication } from './application-types';
|
1
|
+
import { User } from '../user/user.js';
|
2
|
+
import { Application } from './application.js';
|
3
|
+
import { ApplicationPatch, NewApplication } from './application-types.js';
|
4
4
|
export declare class ApplicationMutation {
|
5
5
|
createApplication(application: NewApplication, context: ResolverContext): Promise<{
|
6
6
|
domain: import("@things-factory/shell").Domain;
|
@@ -15,7 +15,7 @@ export declare class ApplicationMutation {
|
|
15
15
|
icon?: string;
|
16
16
|
redirectUrl?: string;
|
17
17
|
webhook?: string;
|
18
|
-
type?: import("./application").ApplicationType;
|
18
|
+
type?: import("./application.js").ApplicationType;
|
19
19
|
} & Application>;
|
20
20
|
deleteApplication(id: string, context: ResolverContext): Promise<boolean>;
|
21
21
|
generateApplicationSecret(id: string, context: ResolverContext): Promise<{
|
@@ -32,8 +32,8 @@ export declare class ApplicationMutation {
|
|
32
32
|
redirectUrl?: string;
|
33
33
|
webhook?: string;
|
34
34
|
appKey?: string;
|
35
|
-
status?: import("./application").ApplicationStatus;
|
36
|
-
type?: import("./application").ApplicationType;
|
35
|
+
status?: import("./application.js").ApplicationStatus;
|
36
|
+
type?: import("./application.js").ApplicationType;
|
37
37
|
createdAt?: Date;
|
38
38
|
updatedAt?: Date;
|
39
39
|
creator?: User;
|
@@ -53,13 +53,13 @@ export declare class ApplicationMutation {
|
|
53
53
|
icon?: string;
|
54
54
|
redirectUrl?: string;
|
55
55
|
webhook?: string;
|
56
|
-
type?: import("./application").ApplicationType;
|
56
|
+
type?: import("./application.js").ApplicationType;
|
57
57
|
id?: string;
|
58
58
|
domain?: import("@things-factory/shell").Domain;
|
59
59
|
domainId?: string;
|
60
60
|
appKey?: string;
|
61
61
|
appSecret?: string;
|
62
|
-
status?: import("./application").ApplicationStatus;
|
62
|
+
status?: import("./application.js").ApplicationStatus;
|
63
63
|
createdAt?: Date;
|
64
64
|
updatedAt?: Date;
|
65
65
|
creator?: User;
|