prow-authority 3.6.3

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.
Files changed (168) hide show
  1. package/.claude/settings.local.json +11 -0
  2. package/.dockerignore +11 -0
  3. package/.github/workflows/_deploy.yml +191 -0
  4. package/.github/workflows/deploy-dev.yml +30 -0
  5. package/.github/workflows/deploy-prod.yml +34 -0
  6. package/CLAUDE.md +114 -0
  7. package/Dockerfile +61 -0
  8. package/Dockerfile.dev +24 -0
  9. package/README.md +1 -0
  10. package/package.json +61 -0
  11. package/src/App.ts +40 -0
  12. package/src/helpers/api-error.ts +21 -0
  13. package/src/helpers/authority.ts +216 -0
  14. package/src/helpers/config.ts +4 -0
  15. package/src/helpers/holded.ts +105 -0
  16. package/src/helpers/mysql.ts +15 -0
  17. package/src/helpers/notifications.ts +55 -0
  18. package/src/helpers/random.ts +18 -0
  19. package/src/helpers/s3.ts +43 -0
  20. package/src/helpers/stripe.ts +8 -0
  21. package/src/index.ts +47 -0
  22. package/src/v1/common-types.ts +12 -0
  23. package/src/v1/controllers/admin/accounting-seat-controller.ts +148 -0
  24. package/src/v1/controllers/admin/billing-cycle-controller.ts +171 -0
  25. package/src/v1/controllers/admin/invoice-controller.ts +222 -0
  26. package/src/v1/controllers/admin/license-controller.ts +190 -0
  27. package/src/v1/controllers/admin/license-limit-controller.ts +160 -0
  28. package/src/v1/controllers/admin/notification-controller.ts +115 -0
  29. package/src/v1/controllers/admin/organization-controller.ts +210 -0
  30. package/src/v1/controllers/admin/organization-license-controller.ts +224 -0
  31. package/src/v1/controllers/admin/organization-license-limit-controller.ts +196 -0
  32. package/src/v1/controllers/admin/organization-usage-controller.ts +167 -0
  33. package/src/v1/controllers/admin/payment-method-controller.ts +173 -0
  34. package/src/v1/controllers/admin/policy-controller.ts +138 -0
  35. package/src/v1/controllers/admin/policy-version-controller.ts +143 -0
  36. package/src/v1/controllers/admin/schedule-controller.ts +181 -0
  37. package/src/v1/controllers/admin/service-controller.ts +206 -0
  38. package/src/v1/controllers/admin/service-notification-controller.ts +166 -0
  39. package/src/v1/controllers/admin/user-controller.ts +282 -0
  40. package/src/v1/controllers/admin/user-organization-controller.ts +172 -0
  41. package/src/v1/controllers/admin/user-policy-controller.ts +164 -0
  42. package/src/v1/controllers/auth/@deprecated oauth-controller.ts +191 -0
  43. package/src/v1/controllers/auth/identity-token-controller.ts +286 -0
  44. package/src/v1/controllers/auth/organization-token-controller.ts +277 -0
  45. package/src/v1/controllers/auth/temp-code-controller.ts +60 -0
  46. package/src/v1/controllers/billing/billing-controller.ts +805 -0
  47. package/src/v1/controllers/organizations/public-organization-controller.ts +1796 -0
  48. package/src/v1/controllers/policies/public-policy-controller.ts +68 -0
  49. package/src/v1/controllers/services/public-service-controller.ts +177 -0
  50. package/src/v1/controllers/services/service-controller.ts +474 -0
  51. package/src/v1/controllers/users/public-user-controller.ts +471 -0
  52. package/src/v1/daos/@deprecated auth-dao.ts +173 -0
  53. package/src/v1/daos/accounting-seat-dao.ts +111 -0
  54. package/src/v1/daos/billing-cycle-dao.ts +107 -0
  55. package/src/v1/daos/invoice-dao.ts +131 -0
  56. package/src/v1/daos/license-dao.ts +152 -0
  57. package/src/v1/daos/license-limit-dao.ts +120 -0
  58. package/src/v1/daos/organization-dao.ts +109 -0
  59. package/src/v1/daos/organization-license-dao.ts +117 -0
  60. package/src/v1/daos/organization-license-limit-dao.ts +157 -0
  61. package/src/v1/daos/organization-usage-dao.ts +115 -0
  62. package/src/v1/daos/payment-method-dao.ts +110 -0
  63. package/src/v1/daos/policy-dao.ts +105 -0
  64. package/src/v1/daos/policy-version-dao.ts +112 -0
  65. package/src/v1/daos/redis-dao.ts +38 -0
  66. package/src/v1/daos/schema.sql +462 -0
  67. package/src/v1/daos/service-dao.ts +118 -0
  68. package/src/v1/daos/service-notification-dao.ts +120 -0
  69. package/src/v1/daos/user-dao.ts +127 -0
  70. package/src/v1/daos/user-organization-dao.ts +123 -0
  71. package/src/v1/daos/user-policy-dao.ts +109 -0
  72. package/src/v1/middlewares/auth/identity-token-middleware.ts +51 -0
  73. package/src/v1/middlewares/auth/organization-token-middleware.ts +73 -0
  74. package/src/v1/middlewares/auth/service-token-middleware.ts +167 -0
  75. package/src/v1/middlewares/authority-middleware.ts +97 -0
  76. package/src/v1/middlewares/organizations/organization-middleware.ts +94 -0
  77. package/src/v1/middlewares/static/static-middleware.ts +41 -0
  78. package/src/v1/middlewares/users/user-middleware.ts +41 -0
  79. package/src/v1/routes/admin/accounting-seat-router.ts +89 -0
  80. package/src/v1/routes/admin/admin-router.ts +61 -0
  81. package/src/v1/routes/admin/billing-cycle-router.ts +89 -0
  82. package/src/v1/routes/admin/invoice-router.ts +89 -0
  83. package/src/v1/routes/admin/license-limit-router.ts +89 -0
  84. package/src/v1/routes/admin/license-router.ts +89 -0
  85. package/src/v1/routes/admin/notification-router.ts +61 -0
  86. package/src/v1/routes/admin/organization-license-limit-router.ts +89 -0
  87. package/src/v1/routes/admin/organization-license-router.ts +89 -0
  88. package/src/v1/routes/admin/organization-router.ts +89 -0
  89. package/src/v1/routes/admin/payment-method-router.ts +89 -0
  90. package/src/v1/routes/admin/policy-router.ts +89 -0
  91. package/src/v1/routes/admin/policy-version-router.ts +89 -0
  92. package/src/v1/routes/admin/schedule-router.ts +75 -0
  93. package/src/v1/routes/admin/service-notification-router.ts +98 -0
  94. package/src/v1/routes/admin/service-router.ts +89 -0
  95. package/src/v1/routes/admin/user-organization-router.ts +89 -0
  96. package/src/v1/routes/admin/user-policy-router.ts +89 -0
  97. package/src/v1/routes/admin/user-router.ts +89 -0
  98. package/src/v1/routes/auth/@deprecated auth-router.ts +199 -0
  99. package/src/v1/routes/auth/identity-token-router.ts +147 -0
  100. package/src/v1/routes/auth/organization-token-router.ts +70 -0
  101. package/src/v1/routes/billing/billing-router.ts +227 -0
  102. package/src/v1/routes/organizations/invoices-router.ts +48 -0
  103. package/src/v1/routes/organizations/payments-router.ts +104 -0
  104. package/src/v1/routes/organizations/public-organization-router.ts +319 -0
  105. package/src/v1/routes/organizations/users-router.ts +139 -0
  106. package/src/v1/routes/policies/public-policy-router.ts +50 -0
  107. package/src/v1/routes/services/public-service-router.ts +89 -0
  108. package/src/v1/routes/services/service-router.ts +197 -0
  109. package/src/v1/routes/users/public-user-router.ts +230 -0
  110. package/src/v1/routes/v1-router.ts +50 -0
  111. package/src/v1/schemas/admin/accounting-seat-schemas.ts +22 -0
  112. package/src/v1/schemas/admin/billing-cycle-schemas.ts +20 -0
  113. package/src/v1/schemas/admin/invoice-schemas.ts +41 -0
  114. package/src/v1/schemas/admin/license-limit-schemas.ts +25 -0
  115. package/src/v1/schemas/admin/license-schemas.ts +30 -0
  116. package/src/v1/schemas/admin/organization-license-limit-schemas.ts +29 -0
  117. package/src/v1/schemas/admin/organization-license-schemas.ts +43 -0
  118. package/src/v1/schemas/admin/organization-schemas.ts +67 -0
  119. package/src/v1/schemas/admin/organization-usage-schemas.ts +15 -0
  120. package/src/v1/schemas/admin/payment-method-schemas.ts +40 -0
  121. package/src/v1/schemas/admin/policy-schemas.ts +31 -0
  122. package/src/v1/schemas/admin/service-notification-schemas.ts +23 -0
  123. package/src/v1/schemas/admin/service-schemas.ts +56 -0
  124. package/src/v1/schemas/admin/user-organization-schemas.ts +24 -0
  125. package/src/v1/schemas/admin/user-policy-schemas.ts +17 -0
  126. package/src/v1/schemas/admin/user-schemas.ts +52 -0
  127. package/src/v1/schemas/auth/auth-schemas.ts +55 -0
  128. package/src/v1/schemas/billing/billing-schemas.ts +32 -0
  129. package/src/v1/schemas/organizations/public-organization-schemas.ts +77 -0
  130. package/src/v1/schemas/payments/payment-method-schemas.ts +0 -0
  131. package/src/v1/schemas/services/public-service-schemas.ts +5 -0
  132. package/src/v1/schemas/services/service-schemas.ts +27 -0
  133. package/src/v1/schemas/users/public-user-schemas.ts +73 -0
  134. package/src/v1/types/admin/accounting-seat-types.ts +16 -0
  135. package/src/v1/types/admin/billing-cycle-types.ts +14 -0
  136. package/src/v1/types/admin/invoice-types.ts +39 -0
  137. package/src/v1/types/admin/license-limit-types.ts +16 -0
  138. package/src/v1/types/admin/license-types.ts +29 -0
  139. package/src/v1/types/admin/organization-license-limit-types.ts +13 -0
  140. package/src/v1/types/admin/organization-license-types.ts +21 -0
  141. package/src/v1/types/admin/organization-types.ts +60 -0
  142. package/src/v1/types/admin/organization-usage-types.ts +17 -0
  143. package/src/v1/types/admin/payment-method-types.ts +30 -0
  144. package/src/v1/types/admin/policy-types.ts +9 -0
  145. package/src/v1/types/admin/policy-version-types.ts +12 -0
  146. package/src/v1/types/admin/service-notification-types.ts +20 -0
  147. package/src/v1/types/admin/service-types.ts +36 -0
  148. package/src/v1/types/admin/user-organization-types.ts +31 -0
  149. package/src/v1/types/admin/user-types.ts +44 -0
  150. package/src/v1/types/auth/@deprecated auth-types.ts +26 -0
  151. package/src/v1/types/auth/common-types.ts +7 -0
  152. package/src/v1/types/auth/confirmation-types.ts +5 -0
  153. package/src/v1/types/auth/identity-token-types.ts +8 -0
  154. package/src/v1/types/auth/organization-token-types.ts +23 -0
  155. package/src/v1/types/auth/otp-types.ts +12 -0
  156. package/src/v1/types/billing/billing-types.ts +37 -0
  157. package/src/v1/types/billing/ue-types.ts +29 -0
  158. package/src/v1/types/organizations/public-organization-types.ts +76 -0
  159. package/src/v1/types/policies/public-policy-types.ts +7 -0
  160. package/src/v1/types/services/public-service-types.ts +20 -0
  161. package/src/v1/types/services/service-types.ts +43 -0
  162. package/src/v1/types/users/public-user-types.ts +15 -0
  163. package/src/v1/types/users/user-policy-types.ts +11 -0
  164. package/static/error.html +55 -0
  165. package/static/grant.html +117 -0
  166. package/static/login.html +54 -0
  167. package/static/oauth-client-logo.webp +0 -0
  168. package/tsconfig.json +20 -0
@@ -0,0 +1,50 @@
1
+ import { Router } from 'express';
2
+ import adminRouter from './admin/admin-router';
3
+ import identityTokenRouter from './auth/identity-token-router';
4
+ import organizationTokenRouter from './auth/organization-token-router';
5
+ import publicOrganizationRouter from './organizations/public-organization-router';
6
+ import publicPolicyRouter from './policies/public-policy-router';
7
+ import publicServiceRouter from './services/public-service-router';
8
+ import serviceRouter from './services/service-router';
9
+ import publicUserRouter from './users/public-user-router';
10
+ import billingRouter from './billing/billing-router';
11
+
12
+
13
+ class V1Router {
14
+ router: Router;
15
+
16
+ constructor() {
17
+ this.router = Router();
18
+ this.init();
19
+ }
20
+
21
+ private readonly init = () => {
22
+ // admin scope
23
+ this.router.use(`/admin`, adminRouter);
24
+
25
+ // public scope: services and licenses
26
+ this.router.use(`/services`, publicServiceRouter);
27
+
28
+ // public scope: policies
29
+ this.router.use(`/policies`, publicPolicyRouter);
30
+
31
+ // user authentication and scope
32
+ this.router.use(`/auth/identity`, identityTokenRouter);
33
+ this.router.use(`/user`, publicUserRouter);
34
+
35
+ // organization authentication and scope
36
+ this.router.use(`/auth/organization`, organizationTokenRouter);
37
+ this.router.use(`/organization`, publicOrganizationRouter);
38
+
39
+ // service scope
40
+ this.router.use(`/service`, serviceRouter);
41
+
42
+ // billing scope
43
+ this.router.use(`/billing`, billingRouter);
44
+ };
45
+ }
46
+
47
+ const v1Router = (new V1Router()).router;
48
+ export default v1Router;
49
+
50
+
@@ -0,0 +1,22 @@
1
+ import { Formats } from "@beseif-solutions/utility-functions/dist/utils/date-utils";
2
+ import { Schema } from "@beseif-solutions/utility-functions/dist/utils/validation-utils";
3
+
4
+ export const addAccountingSeatSchema = Schema.object({
5
+ organization: Schema.requiredNumber(),
6
+ invoice: Schema.requiredNumber(),
7
+ date: Schema.requiredDate({ strict: false, format: Formats.ISO }),
8
+ amount: Schema.requiredNumber(),
9
+ done: Schema.requiredBool(),
10
+ metadata: Schema.object(),
11
+ internal: Schema.object(),
12
+ });
13
+
14
+ export const updateAccountingSeatSchema = Schema.object({
15
+ organization: Schema.number(),
16
+ invoice: Schema.number(),
17
+ date: Schema.date({ strict: false, format: Formats.ISO }),
18
+ amount: Schema.number(),
19
+ done: Schema.bool(),
20
+ metadata: Schema.object(),
21
+ internal: Schema.object(),
22
+ });
@@ -0,0 +1,20 @@
1
+ import { Formats } from "@beseif-solutions/utility-functions/dist/utils/date-utils";
2
+ import { Schema } from "@beseif-solutions/utility-functions/dist/utils/validation-utils";
3
+
4
+ export const addBillingCycleSchema = Schema.object({
5
+ organization: Schema.requiredNumber(),
6
+ trial: Schema.requiredBool(),
7
+ start_date: Schema.requiredDate({ strict: false, format: Formats.ISO }),
8
+ end_date: Schema.requiredDate({ strict: false, format: Formats.ISO }),
9
+ metadata: Schema.object(),
10
+ internal: Schema.object(),
11
+ });
12
+
13
+ export const updateBillingCycleSchema = Schema.object({
14
+ organization: Schema.number(),
15
+ trial: Schema.bool(),
16
+ start_date: Schema.date({ strict: false, format: Formats.ISO }),
17
+ end_date: Schema.date({ strict: false, format: Formats.ISO }),
18
+ metadata: Schema.object(),
19
+ internal: Schema.object(),
20
+ });
@@ -0,0 +1,41 @@
1
+ import { Formats } from "@beseif-solutions/utility-functions/dist/utils/date-utils";
2
+ import { Schema } from "@beseif-solutions/utility-functions/dist/utils/validation-utils";
3
+ import { InvoiceStatus } from "../../types/admin/invoice-types";
4
+
5
+ const conceptSchema = Schema.object({
6
+ name: Schema.requiredString(),
7
+ description: Schema.requiredString(),
8
+ price: Schema.requiredNumber(),
9
+ });
10
+
11
+ export const addInvoiceSchema = Schema.object({
12
+ organization: Schema.requiredNumber(),
13
+ date: Schema.requiredDate({ strict: false, format: Formats.ISO }),
14
+ tax_code: Schema.requiredString(),
15
+ tax_percentage: Schema.requiredNumber(),
16
+ concepts: Schema.requiredArray({ items: conceptSchema, min: 1 }),
17
+ billing: Schema.requiredObject(),
18
+ status: Schema.requiredString({ valid: Object.values(InvoiceStatus) }),
19
+ invoice: Schema.string({ allow: [null] }),
20
+ number: Schema.string({ allow: [null] }),
21
+ payment: Schema.string({ allow: [null] }),
22
+ method: Schema.number({ allow: [null] }),
23
+ metadata: Schema.object(),
24
+ internal: Schema.object(),
25
+ });
26
+
27
+ export const updateInvoiceSchema = Schema.object({
28
+ organization: Schema.number(),
29
+ date: Schema.date({ strict: false, format: Formats.ISO }),
30
+ tax_code: Schema.string(),
31
+ tax_percentage: Schema.number(),
32
+ concepts: Schema.array({ items: conceptSchema }),
33
+ billing: Schema.object(),
34
+ status: Schema.string({ valid: Object.values(InvoiceStatus) }),
35
+ invoice: Schema.string({ allow: [null] }),
36
+ number: Schema.string({ allow: [null] }),
37
+ payment: Schema.string({ allow: [null] }),
38
+ method: Schema.number({ allow: [null] }),
39
+ metadata: Schema.object(),
40
+ internal: Schema.object(),
41
+ });
@@ -0,0 +1,25 @@
1
+ import { Schema } from "@beseif-solutions/utility-functions/dist/utils/validation-utils";
2
+
3
+ export const addLicenseLimitSchema = Schema.object({
4
+ license: Schema.requiredNumber(),
5
+ name: Schema.requiredString({ max: 100 }),
6
+ limit: Schema.requiredNumber(),
7
+ period: Schema.requiredString({ valid: [`monthly`, `lifetime`] }),
8
+ monthly_price_abs: Schema.requiredNumber(),
9
+ annual_price_abs: Schema.requiredNumber(),
10
+ overconsume_monthly_price_per_unit: Schema.requiredNumber().allow(null),
11
+ overconsume_annual_price_per_unit: Schema.requiredNumber().allow(null),
12
+ metadata: Schema.object(),
13
+ });
14
+
15
+ export const updateLicenseLimitSchema = Schema.object({
16
+ license: Schema.number(),
17
+ name: Schema.string({ max: 100 }),
18
+ limit: Schema.number(),
19
+ period: Schema.string({ valid: [`monthly`, `lifetime`] }),
20
+ monthly_price_abs: Schema.number(),
21
+ annual_price_abs: Schema.number(),
22
+ overconsume_monthly_price_per_unit: Schema.number().allow(null),
23
+ overconsume_annual_price_per_unit: Schema.number().allow(null),
24
+ metadata: Schema.object(),
25
+ });
@@ -0,0 +1,30 @@
1
+ import { Schema } from "@beseif-solutions/utility-functions/dist/utils/validation-utils";
2
+ import { LicenseType } from "../../types/admin/license-types";
3
+
4
+ export const addLicenseSchema = Schema.object({
5
+ service: Schema.requiredNumber(),
6
+ type: Schema.requiredString({ valid: Object.values(LicenseType) }),
7
+ associated: Schema.number(),
8
+ properties: Schema.requiredObject({
9
+ name: Schema.requiredString(),
10
+ description: Schema.requiredString(),
11
+ }),
12
+ data: Schema.requiredObject(),
13
+ public: Schema.requiredBool(),
14
+ enabled: Schema.requiredBool(),
15
+ metadata: Schema.object(),
16
+ });
17
+
18
+ export const updateLicenseSchema = Schema.object({
19
+ service: Schema.number(),
20
+ type: Schema.string({ valid: Object.values(LicenseType) }),
21
+ associated: Schema.number(),
22
+ properties: Schema.object({
23
+ name: Schema.string(),
24
+ description: Schema.string(),
25
+ }),
26
+ data: Schema.object(),
27
+ public: Schema.bool(),
28
+ enabled: Schema.bool(),
29
+ metadata: Schema.object(),
30
+ });
@@ -0,0 +1,29 @@
1
+ import { Schema } from "@beseif-solutions/utility-functions/dist/utils/validation-utils";
2
+
3
+ export const addOrganizationLicenseLimitSchema = Schema.object({
4
+ organization: Schema.requiredNumber(),
5
+ license: Schema.requiredNumber(),
6
+ name: Schema.requiredString({ max: 100 }),
7
+ limit: Schema.requiredNumber(),
8
+ period: Schema.requiredString({ valid: [`monthly`, `lifetime`] }),
9
+ monthly_price_abs: Schema.requiredNumber(),
10
+ annual_price_abs: Schema.requiredNumber(),
11
+ overconsume: Schema.requiredBool(),
12
+ overconsume_monthly_price_per_unit: Schema.requiredNumber().allow(null),
13
+ overconsume_annual_price_per_unit: Schema.requiredNumber().allow(null),
14
+ metadata: Schema.object(),
15
+ });
16
+
17
+ export const updateOrganizationLicenseLimitSchema = Schema.object({
18
+ organization: Schema.number(),
19
+ license: Schema.number(),
20
+ name: Schema.string({ max: 100 }),
21
+ limit: Schema.number(),
22
+ period: Schema.string({ valid: [`monthly`, `lifetime`] }),
23
+ monthly_price_abs: Schema.number(),
24
+ annual_price_abs: Schema.number(),
25
+ overconsume: Schema.bool(),
26
+ overconsume_monthly_price_per_unit: Schema.number().allow(null),
27
+ overconsume_annual_price_per_unit: Schema.number().allow(null),
28
+ metadata: Schema.object(),
29
+ });
@@ -0,0 +1,43 @@
1
+ import { Formats } from "@beseif-solutions/utility-functions/dist/utils/date-utils";
2
+ import { Schema } from "@beseif-solutions/utility-functions/dist/utils/validation-utils";
3
+ import { LicenseType } from "../../types/admin/license-types";
4
+
5
+ export const addOrganizationLicenseSchema = Schema.object({
6
+ organization: Schema.requiredNumber(),
7
+ service: Schema.requiredNumber(),
8
+ type: Schema.requiredString({ valid: Object.values(LicenseType) }),
9
+ associated: Schema.number(),
10
+ original: Schema.requiredNumber(),
11
+ billing: Schema.requiredString({ valid: [`monthly`, `annual`, `lifetime`] }),
12
+ properties: Schema.requiredObject({
13
+ name: Schema.requiredString(),
14
+ description: Schema.requiredString(),
15
+ }),
16
+ data: Schema.requiredObject(),
17
+ start_date: Schema.requiredDate({ strict: false, format: Formats.ISO }),
18
+ end_date: Schema.requiredDate({ strict: false, format: Formats.ISO, allow: [null] }),
19
+ metadata: Schema.object(),
20
+ internal: Schema.object({
21
+ notified: Schema.bool().allow(null),
22
+ }),
23
+ });
24
+
25
+ export const updateOrganizationLicenseSchema = Schema.object({
26
+ organization: Schema.number(),
27
+ service: Schema.number(),
28
+ type: Schema.string({ valid: Object.values(LicenseType) }),
29
+ associated: Schema.number(),
30
+ original: Schema.number(),
31
+ billing: Schema.string({ valid: [`monthly`, `annual`, `lifetime`] }),
32
+ properties: Schema.object({
33
+ name: Schema.string(),
34
+ description: Schema.string(),
35
+ }),
36
+ data: Schema.object(),
37
+ start_date: Schema.date({ strict: false, format: Formats.ISO }),
38
+ end_date: Schema.date({ strict: false, format: Formats.ISO, allow: [null] }),
39
+ metadata: Schema.object(),
40
+ internal: Schema.object({
41
+ notified: Schema.bool().allow(null),
42
+ }),
43
+ });
@@ -0,0 +1,67 @@
1
+ import { Schema } from "@beseif-solutions/utility-functions/dist/utils/validation-utils";
2
+ import { OrganizationStatus } from "../../types/admin/organization-types";
3
+
4
+ export const addOrganizationSchema = Schema.object({
5
+ properties: Schema.requiredObject({
6
+ name: Schema.requiredString(),
7
+ activity: Schema.string(),
8
+ image: Schema.string({ allow: [null] }),
9
+ cover: Schema.string({ allow: [null] }),
10
+ }),
11
+ billing: Schema.object({
12
+ name: Schema.requiredString(),
13
+ document: Schema.requiredString(),
14
+ email: Schema.email(),
15
+ phone: Schema.string(),
16
+ address: Schema.object({
17
+ address: Schema.requiredString(),
18
+ city: Schema.requiredString(),
19
+ zip: Schema.requiredString(),
20
+ province: Schema.requiredString(),
21
+ country: Schema.requiredString(),
22
+ }),
23
+ individual: Schema.bool(),
24
+ }),
25
+ preferences: Schema.requiredObject({
26
+ timezone: Schema.requiredString(),
27
+ }),
28
+ status: Schema.requiredString({ valid: Object.values(OrganizationStatus) }),
29
+ metadata: Schema.object(),
30
+ internal: Schema.object({
31
+ customer: Schema.string(),
32
+ services: Schema.object(),
33
+ }),
34
+ });
35
+
36
+ export const updateOrganizationSchema = (deletion = false) => Schema.object({
37
+ properties: Schema.object({
38
+ name: Schema.string(),
39
+ activity: Schema.string(),
40
+ image: Schema.string({ allow: [null] }),
41
+ cover: Schema.string({ allow: [null] }),
42
+ }),
43
+ billing: Schema.object({
44
+ name: Schema.string(),
45
+ document: Schema.string(),
46
+ email: Schema.email(),
47
+ phone: Schema.string(),
48
+ address: Schema.object({
49
+ address: Schema.string(),
50
+ city: Schema.string(),
51
+ zip: Schema.string(),
52
+ province: Schema.string(),
53
+ country: Schema.string(),
54
+ }),
55
+ individual: Schema.bool(),
56
+ }),
57
+ preferences: Schema.object({
58
+ timezone: Schema.string(),
59
+ }),
60
+ status: Schema.string({ valid: deletion ? [`deleted`] : Object.values(OrganizationStatus) }),
61
+ metadata: Schema.object(),
62
+ internal: Schema.object({
63
+ customer: Schema.string(),
64
+ services: Schema.object(),
65
+ deleted_date: Schema.string(),
66
+ }).unknown(),
67
+ });
@@ -0,0 +1,15 @@
1
+ import { Schema } from "@beseif-solutions/utility-functions/dist/utils/validation-utils";
2
+
3
+ export const addOrganizationUsageSchema = Schema.object({
4
+ organization: Schema.requiredNumber(),
5
+ service: Schema.requiredNumber(),
6
+ name: Schema.requiredString(),
7
+ count: Schema.requiredNumber(),
8
+ });
9
+
10
+ export const updateOrganizationUsageSchema = Schema.object({
11
+ organization: Schema.number(),
12
+ service: Schema.number(),
13
+ name: Schema.string(),
14
+ count: Schema.number(),
15
+ });
@@ -0,0 +1,40 @@
1
+ import { Schema } from "@beseif-solutions/utility-functions/dist/utils/validation-utils";
2
+ import { PaymentMethodType } from "../../types/admin/payment-method-types";
3
+
4
+ export const addPaymentMethodSchema = Schema.object({
5
+ organization: Schema.requiredNumber(),
6
+ type: Schema.requiredString({ valid: Object.values(PaymentMethodType) }),
7
+ properties: Schema.requiredObject({
8
+ alias: Schema.string({ allow: [null] }),
9
+ name: Schema.requiredString(),
10
+ brand: Schema.string(),
11
+ country: Schema.string(),
12
+ exp_year: Schema.number(),
13
+ exp_month: Schema.number(),
14
+ }),
15
+ enabled: Schema.requiredBool(),
16
+ metadata: Schema.object(),
17
+ internal: Schema.object({
18
+ payment_method_id: Schema.requiredString(),
19
+ fingerprint: Schema.string(),
20
+ }),
21
+ });
22
+
23
+ export const updatePaymentMethodSchema = Schema.object({
24
+ organization: Schema.number(),
25
+ type: Schema.string({ valid: Object.values(PaymentMethodType) }),
26
+ properties: Schema.object({
27
+ alias: Schema.string({ allow: [null] }),
28
+ name: Schema.string(),
29
+ brand: Schema.string({ allow: [null] }),
30
+ country: Schema.string({ allow: [null] }),
31
+ exp_year: Schema.number({ allow: [null] }),
32
+ exp_month: Schema.number({ allow: [null] }),
33
+ }),
34
+ enabled: Schema.bool(),
35
+ metadata: Schema.object(),
36
+ internal: Schema.object({
37
+ payment_method_id: Schema.string(),
38
+ fingerprint: Schema.string(),
39
+ }),
40
+ });
@@ -0,0 +1,31 @@
1
+ import { Schema } from "@beseif-solutions/utility-functions/dist/utils/validation-utils";
2
+
3
+ export const addPolicySchema = Schema.object({
4
+ name: Schema.requiredString({ min: 1, max: 100 }),
5
+ metadata: Schema.object(),
6
+ internal: Schema.object(),
7
+ });
8
+
9
+ export const updatePolicySchema = Schema.object({
10
+ name: Schema.string({ min: 1, max: 100 }),
11
+ metadata: Schema.object(),
12
+ internal: Schema.object(),
13
+ });
14
+
15
+ export const addPolicyVersionSchema = Schema.object({
16
+ policy: Schema.requiredNumber({ min: 1 }),
17
+ version: Schema.requiredString({ min: 1, max: 20 }),
18
+ url: Schema.requiredString({ min: 1, max: 255 }),
19
+ effective_date: Schema.string(),
20
+ metadata: Schema.object(),
21
+ internal: Schema.object(),
22
+ });
23
+
24
+ export const updatePolicyVersionSchema = Schema.object({
25
+ policy: Schema.number({ min: 1 }),
26
+ version: Schema.string({ min: 1, max: 20 }),
27
+ url: Schema.string({ min: 1, max: 255 }),
28
+ effective_date: Schema.string(),
29
+ metadata: Schema.object(),
30
+ internal: Schema.object(),
31
+ });
@@ -0,0 +1,23 @@
1
+ import { Schema } from '@beseif-solutions/utility-functions/dist/utils/validation-utils';
2
+
3
+
4
+ export const addServiceNotificationSchema = Schema.object({
5
+ service: Schema.requiredNumber(),
6
+ event: Schema.requiredString(),
7
+ template: Schema.requiredString(),
8
+ scope: Schema.requiredObject(),
9
+ default: Schema.bool(),
10
+ enabled: Schema.bool(),
11
+ metadata: Schema.object(),
12
+ });
13
+
14
+
15
+ export const updateServiceNotificationSchema = Schema.object({
16
+ service: Schema.number(),
17
+ event: Schema.string(),
18
+ template: Schema.string(),
19
+ scope: Schema.object(),
20
+ default: Schema.bool(),
21
+ enabled: Schema.bool(),
22
+ metadata: Schema.object(),
23
+ });
@@ -0,0 +1,56 @@
1
+ import { Schema } from "@beseif-solutions/utility-functions/dist/utils/validation-utils";
2
+
3
+ const authoritySchema = Schema.object({
4
+ host: Schema.string(),
5
+ user: Schema.object({
6
+ information: Schema.string(),
7
+ // created: Schema.string(),
8
+ deleted: Schema.string(),
9
+ }).allow(null),
10
+ organization: Schema.object({
11
+ information: Schema.string(),
12
+ created: Schema.string(),
13
+ modified: Schema.string(),
14
+ deleted: Schema.string(),
15
+ }).allow(null),
16
+ });
17
+
18
+ export const addServiceSchema = Schema.object({
19
+ properties: Schema.requiredObject({
20
+ name: Schema.requiredString(),
21
+ description: Schema.requiredString(),
22
+ home: Schema.string(),
23
+ image: Schema.requiredString(),
24
+ }),
25
+ preferences: Schema.requiredObject({
26
+ // TODO
27
+ }),
28
+ metadata: Schema.object(),
29
+ internal: Schema.requiredObject()
30
+ .concat(authoritySchema),
31
+ });
32
+
33
+ export const updateServiceSchema = Schema.object({
34
+ token: Schema.bool(),
35
+ properties: Schema.object({
36
+ name: Schema.string(),
37
+ description: Schema.string(),
38
+ home: Schema.string({ allow: [null] }),
39
+ image: Schema.string(),
40
+ }),
41
+ preferences: Schema.object({
42
+ // TODO
43
+ }),
44
+ enabled: Schema.bool(),
45
+ metadata: Schema.object(),
46
+ internal: Schema.object()
47
+ .concat(authoritySchema),
48
+ });
49
+
50
+ export const informationResponseSchema = Schema.array({
51
+ items: Schema.object({
52
+ type: Schema.requiredString({ valid: [`shared`, `owner`] }),
53
+ model: Schema.requiredString(),
54
+ count: Schema.requiredNumber({ sign: Schema.Sign.Positive }),
55
+ }),
56
+ });
@@ -0,0 +1,24 @@
1
+ import { Schema } from "@beseif-solutions/utility-functions/dist/utils/validation-utils";
2
+ import { UserOrganizationRole } from "../../types/admin/user-organization-types";
3
+
4
+ export const addUserOrganizationSchema = Schema.object({
5
+ user: Schema.requiredNumber(),
6
+ organization: Schema.requiredNumber(),
7
+ role: Schema.requiredString({ valid: Object.values(UserOrganizationRole) }),
8
+ invite: Schema.string({ allow: [null] }),
9
+ invited_by: Schema.number().allow(null),
10
+ preferences: Schema.object(),
11
+ enabled: Schema.requiredBool(),
12
+ metadata: Schema.object(),
13
+ });
14
+
15
+ export const updateUserOrganizationSchema = Schema.object({
16
+ user: Schema.number(),
17
+ organization: Schema.number(),
18
+ role: Schema.string({ valid: Object.values(UserOrganizationRole) }),
19
+ invite: Schema.string({ allow: [null] }),
20
+ invited_by: Schema.number().allow(null),
21
+ preferences: Schema.object(),
22
+ enabled: Schema.bool(),
23
+ metadata: Schema.object(),
24
+ });
@@ -0,0 +1,17 @@
1
+ import { Schema } from "@beseif-solutions/utility-functions/dist/utils/validation-utils";
2
+
3
+ export const addUserPolicySchema = Schema.object({
4
+ user: Schema.requiredNumber({ min: 1 }),
5
+ policy: Schema.requiredNumber({ min: 1 }),
6
+ version: Schema.requiredNumber({ min: 1 }),
7
+ metadata: Schema.object(),
8
+ internal: Schema.object(),
9
+ });
10
+
11
+ export const updateUserPolicySchema = Schema.object({
12
+ user: Schema.number({ min: 1 }),
13
+ policy: Schema.number({ min: 1 }),
14
+ version: Schema.number({ min: 1 }),
15
+ metadata: Schema.object(),
16
+ internal: Schema.object(),
17
+ });
@@ -0,0 +1,52 @@
1
+ import { Schema } from "@beseif-solutions/utility-functions/dist/utils/validation-utils";
2
+ import { CommunicationType } from "../../types/admin/user-types";
3
+
4
+ export const addUserSchema = Schema.object({
5
+ email: Schema.requiredEmail({ max: 200 }),
6
+ password: Schema.string({ min: 8, allow: [null] }),
7
+ properties: Schema.object({
8
+ name: Schema.string(),
9
+ surnames: Schema.string(),
10
+ image: Schema.string(),
11
+ }),
12
+ preferences: Schema.object({
13
+ language: Schema.string({ length: 2 }),
14
+ communications: Schema.object({
15
+ [CommunicationType.Commercial]: Schema.bool(),
16
+ [CommunicationType.Newsletter]: Schema.bool(),
17
+ }),
18
+ }),
19
+ utm: Schema.object({
20
+ medium: Schema.string(),
21
+ source: Schema.string(),
22
+ campaign: Schema.string(),
23
+ }),
24
+ referrer: Schema.string().optional(),
25
+ omnipotent: Schema.bool(),
26
+ metadata: Schema.object(),
27
+ });
28
+
29
+ export const updateUserSchema = Schema.object({
30
+ email: Schema.email({ max: 200 }),
31
+ password: Schema.string({ min: 8 }),
32
+ properties: Schema.object({
33
+ name: Schema.string(),
34
+ surnames: Schema.string(),
35
+ image: Schema.string({ allow: [null] }),
36
+ }),
37
+ preferences: Schema.object({
38
+ language: Schema.string({ length: 2 }),
39
+ communications: Schema.object({
40
+ [CommunicationType.Commercial]: Schema.bool(),
41
+ [CommunicationType.Newsletter]: Schema.bool(),
42
+ }),
43
+ }),
44
+ utm: Schema.object({
45
+ medium: Schema.string(),
46
+ source: Schema.string(),
47
+ campaign: Schema.string(),
48
+ }).optional(),
49
+ referrer: Schema.string().optional(),
50
+ omnipotent: Schema.bool(),
51
+ metadata: Schema.object(),
52
+ });
@@ -0,0 +1,55 @@
1
+ import { Schema } from "@beseif-solutions/utility-functions/dist/utils/validation-utils";
2
+ import { TempCodeType } from "../../types/auth/otp-types";
3
+
4
+ export const identityAdminSchema = Schema.object({
5
+ email: Schema.requiredEmail(),
6
+ });
7
+
8
+ export const identityTokenSchema = Schema.object({
9
+ email: Schema.requiredEmail(),
10
+ password: Schema.requiredString(),
11
+ });
12
+
13
+ export const confirmSchema = Schema.object({
14
+ code: Schema.requiredString(),
15
+ });
16
+
17
+ export const refreshSchema = Schema.object({
18
+ refresh_token: Schema.requiredString(),
19
+ });
20
+
21
+ export const organizationTokenSchema = Schema.object({
22
+ organization: Schema.requiredString(),
23
+ });
24
+
25
+ export const newOTPSchema = Schema.object({
26
+ email: Schema.requiredEmail(),
27
+ flow: Schema.requiredString({ valid: [TempCodeType.OTP, TempCodeType.Password] }),
28
+ });
29
+
30
+ export const validateOTPSchema = Schema.object({
31
+ email: Schema.requiredEmail(),
32
+ code: Schema.requiredString(),
33
+ flow: Schema.requiredString({ valid: [TempCodeType.OTP, TempCodeType.Password] }),
34
+ });
35
+
36
+ export const validateRecaptchaSchema = Schema.object({
37
+ token: Schema.requiredString(),
38
+ });
39
+
40
+ export const a = Schema.object({
41
+ client_id: Schema.requiredString(),
42
+ client_secret: Schema.requiredString(),
43
+ grant_type: Schema.requiredString({ valid: [`refresh_token`] }),
44
+ refresh_token: Schema.requiredString(),
45
+ });
46
+
47
+ export const b = Schema.object({
48
+ client_id: Schema.requiredString(),
49
+ client_secret: Schema.requiredString(),
50
+ grant_type: Schema.requiredString({ valid: [`authorization_code`] }),
51
+ scope: Schema.requiredString(),
52
+ redirect_uri: Schema.requiredString(),
53
+ code: Schema.requiredString(),
54
+ });
55
+