@nuxt-customer-portal/core 0.3.0

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 (66) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/LICENSE +21 -0
  3. package/README.md +35 -0
  4. package/app/composables/useAutoPagination.ts +30 -0
  5. package/app/composables/useOrganization.ts +117 -0
  6. package/app/composables/usePaginatedResource.ts +167 -0
  7. package/app/composables/usePortalFeatures.ts +74 -0
  8. package/app/composables/usePortalSession.ts +20 -0
  9. package/app/composables/useUserStore.ts +460 -0
  10. package/app/middleware/auth.global.ts +32 -0
  11. package/app/plugins/auth.ts +28 -0
  12. package/app/plugins/portal-core-feature.ts +3 -0
  13. package/app/types/index.d.ts +75 -0
  14. package/app/utils/auth-client.ts +31 -0
  15. package/app/utils/permission-utils.ts +21 -0
  16. package/app/utils/random.ts +9 -0
  17. package/i18n/locales/en.json +81 -0
  18. package/i18n/locales/nl.json +81 -0
  19. package/migrations/0000_baseline.sql +119 -0
  20. package/migrations/0001_organization_types.sql +12 -0
  21. package/migrations/0002_invitation_created_at.sql +1 -0
  22. package/migrations/0003_system_admin_role.sql +5 -0
  23. package/migrations/0004_provider_organization_type.sql +16 -0
  24. package/migrations/0005_portal_email_settings.sql +15 -0
  25. package/migrations/meta/0000_snapshot.json +880 -0
  26. package/migrations/meta/_journal.json +13 -0
  27. package/nuxt.config.ts +55 -0
  28. package/package.json +66 -0
  29. package/portal.manifest.mjs +8 -0
  30. package/server/api/auth/[...].ts +18 -0
  31. package/server/api/auth/permissions.get.ts +64 -0
  32. package/server/api/notifications.ts +294 -0
  33. package/server/db/core-schema.ts +1 -0
  34. package/server/db/schema/auth-schema.ts +198 -0
  35. package/server/db/schema/index.ts +1 -0
  36. package/server/middleware/api-docs-auth.ts +26 -0
  37. package/server/middleware/auth.ts +61 -0
  38. package/server/portal.ts +212 -0
  39. package/server/routes/api-docs/openapi.json.get.ts +22 -0
  40. package/server/utils/admin-email-allowlist.ts +12 -0
  41. package/server/utils/auth.ts +326 -0
  42. package/server/utils/business-hooks.ts +28 -0
  43. package/server/utils/db.ts +18 -0
  44. package/server/utils/email-template.html +105 -0
  45. package/server/utils/email-texts.ts +110 -0
  46. package/server/utils/email.ts +37 -0
  47. package/server/utils/invitation-management.ts +29 -0
  48. package/server/utils/openapi-auth.ts +67 -0
  49. package/server/utils/openapi-contracts.ts +129 -0
  50. package/server/utils/openapi-order.ts +136 -0
  51. package/server/utils/permissions.ts +179 -0
  52. package/server/utils/portal-email.ts +424 -0
  53. package/server/utils/query-builder.ts +270 -0
  54. package/server/utils/route-meta.ts +28 -0
  55. package/shared/core-feature.ts +152 -0
  56. package/shared/feature-registry.ts +62 -0
  57. package/shared/invitation-validation.ts +8 -0
  58. package/shared/organization-avatar.ts +11 -0
  59. package/shared/permissions.ts +26 -0
  60. package/shared/portal-session.ts +17 -0
  61. package/shared/types/feature.ts +130 -0
  62. package/shared/types/index.ts +40 -0
  63. package/shared/types/sections/api.ts +134 -0
  64. package/shared/types/sections/auth.ts +71 -0
  65. package/shared/types/sections/database.ts +86 -0
  66. package/shared/types/sections/queryBuilder.ts +31 -0
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Database entity types based on db/schema/auth-schema.ts
3
+ * These types represent the database entities as they appear in the database
4
+ */
5
+
6
+ export interface User {
7
+ id: string
8
+ name: string
9
+ email: string
10
+ emailVerified: boolean
11
+ image?: string
12
+ createdAt: Date
13
+ updatedAt: Date
14
+ role?: string
15
+ banned?: boolean
16
+ banReason?: string
17
+ banExpires?: Date
18
+ }
19
+
20
+ export interface Organization {
21
+ id: string
22
+ name: string
23
+ slug: string
24
+ logo?: string
25
+ createdAt: Date
26
+ metadata?: string
27
+ organizationType: 'PROVIDER' | 'CLIENT'
28
+ }
29
+
30
+ export interface Member {
31
+ id: string
32
+ organizationId: string
33
+ userId: string
34
+ role: string
35
+ phone?: string | null
36
+ jobTitle?: string | null
37
+ createdAt: Date
38
+ }
39
+
40
+ export interface Invitation {
41
+ id: string
42
+ organizationId: string
43
+ email: string
44
+ role?: string
45
+ status: string
46
+ expiresAt: Date
47
+ inviterId: string
48
+ }
49
+
50
+ export interface Session {
51
+ id: string
52
+ expiresAt: Date
53
+ token: string
54
+ createdAt: Date
55
+ updatedAt: Date
56
+ ipAddress?: string
57
+ userAgent?: string
58
+ userId: string
59
+ activeOrganizationId?: string
60
+ impersonatedBy?: string
61
+ }
62
+
63
+ export interface Account {
64
+ id: string
65
+ accountId: string
66
+ providerId: string
67
+ userId: string
68
+ accessToken: string
69
+ refreshToken: string
70
+ idToken: string
71
+ accessTokenExpiresAt: Date
72
+ refreshTokenExpiresAt: Date
73
+ scope: string
74
+ password: string
75
+ createdAt: Date
76
+ updatedAt: Date
77
+ }
78
+
79
+ export interface Verification {
80
+ id: string
81
+ identifier: string
82
+ value: string
83
+ expiresAt: Date
84
+ createdAt: Date
85
+ updatedAt: Date
86
+ }
@@ -0,0 +1,31 @@
1
+ export type FilterOperator =
2
+ | 'eq' // Equals
3
+ | 'neq' // Not equals
4
+ | 'gt' // Greater than
5
+ | 'lt' // Less than
6
+ | 'gte' // Greater than or equal
7
+ | 'lte' // Less than or equal
8
+ | 'contains' // String contains (case-insensitive)
9
+ | 'startsWith' // String starts with
10
+ | 'endsWith' // String ends with
11
+ | 'in' // Value in array
12
+ | 'notIn' // Value not in array
13
+
14
+ export interface Filter {
15
+ field: string // e.g., "name", "price", "createdAt"
16
+ operator: FilterOperator
17
+ value: unknown // string, number, boolean, array, etc.
18
+ }
19
+
20
+ export interface QueryInput {
21
+ filters?: Filter[] // Array of filters (implicit AND)
22
+ sortField?: string // Sorting options
23
+ sortDirection?: 'asc' | 'desc'
24
+ take?: number // Number of records to return
25
+ skip?: number // Number of records to skip
26
+ }
27
+
28
+ export interface QueryResult<T> {
29
+ items: T[]
30
+ totalCount: number
31
+ }