@elevasis/core 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/index.d.ts +69 -159
  2. package/dist/index.js +324 -613
  3. package/dist/organization-model/index.d.ts +69 -159
  4. package/dist/organization-model/index.js +324 -613
  5. package/dist/test-utils/index.d.ts +192 -45
  6. package/dist/test-utils/index.js +260 -600
  7. package/package.json +1 -1
  8. package/src/__tests__/template-core-compatibility.test.ts +73 -91
  9. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +94 -182
  10. package/src/auth/multi-tenancy/index.ts +20 -17
  11. package/src/auth/multi-tenancy/memberships/api-schemas.ts +142 -126
  12. package/src/auth/multi-tenancy/memberships/index.ts +26 -22
  13. package/src/auth/multi-tenancy/permissions.test.ts +42 -0
  14. package/src/auth/multi-tenancy/permissions.ts +104 -0
  15. package/src/organization-model/README.md +102 -97
  16. package/src/organization-model/__tests__/defaults.test.ts +19 -6
  17. package/src/organization-model/__tests__/domains/resource-mappings.test.ts +24 -93
  18. package/src/organization-model/__tests__/graph.test.ts +82 -894
  19. package/src/organization-model/__tests__/resolve.test.ts +59 -690
  20. package/src/organization-model/__tests__/schema.test.ts +83 -407
  21. package/src/organization-model/contracts.ts +4 -3
  22. package/src/organization-model/defaults.ts +277 -141
  23. package/src/organization-model/domains/features.ts +31 -22
  24. package/src/organization-model/domains/navigation.ts +27 -20
  25. package/src/organization-model/foundation.ts +42 -54
  26. package/src/organization-model/graph/build.ts +42 -217
  27. package/src/organization-model/graph/index.ts +4 -4
  28. package/src/organization-model/graph/link.ts +10 -0
  29. package/src/organization-model/graph/schema.ts +21 -16
  30. package/src/organization-model/graph/types.ts +10 -10
  31. package/src/organization-model/helpers.ts +74 -0
  32. package/src/organization-model/index.ts +7 -7
  33. package/src/organization-model/organization-graph.mdx +89 -272
  34. package/src/organization-model/organization-model.mdx +152 -320
  35. package/src/organization-model/published.ts +20 -19
  36. package/src/organization-model/resolve.ts +8 -33
  37. package/src/organization-model/schema.ts +63 -205
  38. package/src/organization-model/types.ts +12 -11
  39. package/src/platform/constants/versions.ts +3 -3
  40. package/src/platform/registry/__tests__/command-view.test.ts +6 -5
  41. package/src/platform/registry/__tests__/resource-link.test.ts +30 -0
  42. package/src/platform/registry/__tests__/resource-registry.integration.test.ts +15 -15
  43. package/src/platform/registry/command-view.ts +10 -12
  44. package/src/platform/registry/index.ts +93 -93
  45. package/src/platform/registry/resource-link.ts +32 -0
  46. package/src/platform/registry/resource-registry.ts +917 -876
  47. package/src/platform/registry/serialization.ts +56 -73
  48. package/src/platform/registry/serialized-types.ts +17 -12
  49. package/src/platform/registry/types.ts +14 -43
  50. package/src/reference/_generated/contracts.md +94 -182
  51. package/src/reference/glossary.md +71 -105
  52. package/src/scaffold-registry/__tests__/index.test.ts +125 -1
  53. package/src/scaffold-registry/__tests__/schema.test.ts +48 -20
  54. package/src/scaffold-registry/index.ts +236 -188
  55. package/src/scaffold-registry/schema.ts +47 -22
  56. package/src/supabase/database.types.ts +2880 -2719
  57. package/src/test-utils/fixtures/memberships.ts +82 -80
  58. package/src/platform/registry/domains.ts +0 -165
@@ -1,80 +1,82 @@
1
- import type { SupabaseOrgMembership, SupabaseMembershipWithOrganization } from '../../supabase'
2
- import { TEST_USERS } from './users'
3
- import { TEST_ORGS } from './organizations'
4
-
5
- /**
6
- * Test membership fixtures using actual Supabase types
7
- */
8
- export const TEST_MEMBERSHIPS: Record<string, SupabaseOrgMembership> = {
9
- regularUserAcme: {
10
- id: '00000000-0000-0000-0000-000000000020',
11
- user_id: TEST_USERS.regularUser.id,
12
- organization_id: TEST_ORGS.acme.id,
13
- workos_membership_id: 'mem_regular_acme',
14
- role_slug: 'admin',
15
- membership_status: 'active',
16
- config: {},
17
- created_at: '2025-01-01T00:00:00Z',
18
- updated_at: '2025-01-01T00:00:00Z'
19
- },
20
- regularUserBeta: {
21
- id: '00000000-0000-0000-0000-000000000021',
22
- user_id: TEST_USERS.regularUser.id,
23
- organization_id: TEST_ORGS.beta.id,
24
- workos_membership_id: 'mem_regular_beta',
25
- role_slug: 'member',
26
- membership_status: 'active',
27
- config: {},
28
- created_at: '2025-01-01T00:00:00Z',
29
- updated_at: '2025-01-01T00:00:00Z'
30
- },
31
- inactiveUserAcme: {
32
- id: '00000000-0000-0000-0000-000000000022',
33
- user_id: TEST_USERS.inactiveUser.id,
34
- organization_id: TEST_ORGS.acme.id,
35
- workos_membership_id: 'mem_inactive_acme',
36
- role_slug: 'member',
37
- membership_status: 'inactive',
38
- config: {},
39
- created_at: '2025-01-01T00:00:00Z',
40
- updated_at: '2025-01-01T00:00:00Z'
41
- }
42
- }
43
-
44
- /**
45
- * Composite memberships with organization data (for joined queries)
46
- */
47
- export const TEST_MEMBERSHIPS_WITH_ORG: Record<string, SupabaseMembershipWithOrganization> = {
48
- regularUserAcme: {
49
- ...TEST_MEMBERSHIPS.regularUserAcme,
50
- organization: TEST_ORGS.acme
51
- },
52
- regularUserBeta: {
53
- ...TEST_MEMBERSHIPS.regularUserBeta,
54
- organization: TEST_ORGS.beta
55
- },
56
- inactiveUserAcme: {
57
- ...TEST_MEMBERSHIPS.inactiveUserAcme,
58
- organization: TEST_ORGS.acme
59
- }
60
- }
61
-
62
- /**
63
- * Helper to create custom membership fixture
64
- */
65
- export function createTestMembership(
66
- overrides: Partial<SupabaseOrgMembership>
67
- ): SupabaseOrgMembership {
68
- return {
69
- id: '00000000-0000-0000-0000-999999999999',
70
- user_id: TEST_USERS.regularUser.id,
71
- organization_id: TEST_ORGS.acme.id,
72
- workos_membership_id: 'mem_custom_test',
73
- role_slug: 'member',
74
- membership_status: 'active',
75
- config: {},
76
- created_at: '2025-01-01T00:00:00Z',
77
- updated_at: '2025-01-01T00:00:00Z',
78
- ...overrides
79
- }
80
- }
1
+ import type { SupabaseOrgMembership, SupabaseMembershipWithOrganization } from '../../supabase'
2
+ import { TEST_USERS } from './users'
3
+ import { TEST_ORGS } from './organizations'
4
+
5
+ /**
6
+ * Test membership fixtures using actual Supabase types
7
+ */
8
+ export const TEST_MEMBERSHIPS: Record<string, SupabaseOrgMembership> = {
9
+ regularUserAcme: {
10
+ id: '00000000-0000-0000-0000-000000000020',
11
+ user_id: TEST_USERS.regularUser.id,
12
+ organization_id: TEST_ORGS.acme.id,
13
+ workos_membership_id: 'mem_regular_acme',
14
+ role_slug: 'admin',
15
+ membership_status: 'active',
16
+ config: {},
17
+ effective_permissions: [],
18
+ created_at: '2025-01-01T00:00:00Z',
19
+ updated_at: '2025-01-01T00:00:00Z'
20
+ },
21
+ regularUserBeta: {
22
+ id: '00000000-0000-0000-0000-000000000021',
23
+ user_id: TEST_USERS.regularUser.id,
24
+ organization_id: TEST_ORGS.beta.id,
25
+ workos_membership_id: 'mem_regular_beta',
26
+ role_slug: 'member',
27
+ membership_status: 'active',
28
+ config: {},
29
+ effective_permissions: [],
30
+ created_at: '2025-01-01T00:00:00Z',
31
+ updated_at: '2025-01-01T00:00:00Z'
32
+ },
33
+ inactiveUserAcme: {
34
+ id: '00000000-0000-0000-0000-000000000022',
35
+ user_id: TEST_USERS.inactiveUser.id,
36
+ organization_id: TEST_ORGS.acme.id,
37
+ workos_membership_id: 'mem_inactive_acme',
38
+ role_slug: 'member',
39
+ membership_status: 'inactive',
40
+ config: {},
41
+ effective_permissions: [],
42
+ created_at: '2025-01-01T00:00:00Z',
43
+ updated_at: '2025-01-01T00:00:00Z'
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Composite memberships with organization data (for joined queries)
49
+ */
50
+ export const TEST_MEMBERSHIPS_WITH_ORG: Record<string, SupabaseMembershipWithOrganization> = {
51
+ regularUserAcme: {
52
+ ...TEST_MEMBERSHIPS.regularUserAcme,
53
+ organization: TEST_ORGS.acme
54
+ },
55
+ regularUserBeta: {
56
+ ...TEST_MEMBERSHIPS.regularUserBeta,
57
+ organization: TEST_ORGS.beta
58
+ },
59
+ inactiveUserAcme: {
60
+ ...TEST_MEMBERSHIPS.inactiveUserAcme,
61
+ organization: TEST_ORGS.acme
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Helper to create custom membership fixture
67
+ */
68
+ export function createTestMembership(overrides: Partial<SupabaseOrgMembership>): SupabaseOrgMembership {
69
+ return {
70
+ id: '00000000-0000-0000-0000-999999999999',
71
+ user_id: TEST_USERS.regularUser.id,
72
+ organization_id: TEST_ORGS.acme.id,
73
+ workos_membership_id: 'mem_custom_test',
74
+ role_slug: 'member',
75
+ membership_status: 'active',
76
+ config: {},
77
+ effective_permissions: [],
78
+ created_at: '2025-01-01T00:00:00Z',
79
+ updated_at: '2025-01-01T00:00:00Z',
80
+ ...overrides
81
+ }
82
+ }
@@ -1,165 +0,0 @@
1
- /**
2
- * Standard Domain Definitions
3
- * Centralized domain constants and definitions for all organization resources.
4
- */
5
-
6
- import type { DomainDefinition } from './types'
7
-
8
- // ============================================================================
9
- // Standard Domain IDs
10
- // ============================================================================
11
-
12
- export const DOMAINS = {
13
- // Business domains
14
- INBOUND_PIPELINE: 'inbound-pipeline',
15
- LEAD_GEN_PIPELINE: 'lead-gen-pipeline',
16
- SUPPORT: 'support',
17
- CLIENT_SUPPORT: 'client-support',
18
- DELIVERY: 'delivery',
19
- OPERATIONS: 'operations',
20
- FINANCE: 'finance',
21
- EXECUTIVE: 'executive',
22
- INSTANTLY: 'instantly',
23
-
24
- // Technical domains
25
- TESTING: 'testing',
26
- INTERNAL: 'internal',
27
- INTEGRATION: 'integration',
28
- UTILITY: 'utility',
29
- DIAGNOSTIC: 'diagnostic'
30
- } as const
31
-
32
- /**
33
- * ResourceDomain - Strongly typed domain identifier
34
- * Use this type for all domain references to ensure compile-time validation.
35
- */
36
- export type ResourceDomain = (typeof DOMAINS)[keyof typeof DOMAINS]
37
-
38
- // ============================================================================
39
- // Domain Definitions
40
- // ============================================================================
41
-
42
- export const INBOUND_PIPELINE_DOMAIN: DomainDefinition = {
43
- id: DOMAINS.INBOUND_PIPELINE,
44
- name: 'Inbound Pipeline',
45
- description: 'End-to-end inbound client acquisition from first reply to onboarding',
46
- color: 'blue'
47
- }
48
-
49
- export const LEAD_GEN_PIPELINE_DOMAIN: DomainDefinition = {
50
- id: DOMAINS.LEAD_GEN_PIPELINE,
51
- name: 'Lead Gen Pipeline',
52
- description: 'Lead scraping, enrichment, qualification, and personalization',
53
- color: 'cyan'
54
- }
55
-
56
- export const SUPPORT_DOMAIN: DomainDefinition = {
57
- id: DOMAINS.SUPPORT,
58
- name: 'Customer Support',
59
- description: 'Ticket triage, knowledge base, escalations',
60
- color: 'green'
61
- }
62
-
63
- export const CLIENT_SUPPORT_DOMAIN: DomainDefinition = {
64
- id: DOMAINS.CLIENT_SUPPORT,
65
- name: 'Client Support',
66
- description: 'Client change requests, bug reports, and feature requests',
67
- color: 'teal'
68
- }
69
-
70
- export const DELIVERY_DOMAIN: DomainDefinition = {
71
- id: DOMAINS.DELIVERY,
72
- name: 'Client Delivery',
73
- description: 'Project execution and milestone tracking',
74
- color: 'orange'
75
- }
76
-
77
- export const OPERATIONS_DOMAIN: DomainDefinition = {
78
- id: DOMAINS.OPERATIONS,
79
- name: 'Operations',
80
- description: 'Internal business operations and administration',
81
- color: 'violet'
82
- }
83
-
84
- export const FINANCE_DOMAIN: DomainDefinition = {
85
- id: DOMAINS.FINANCE,
86
- name: 'Finance',
87
- description: 'Billing, invoicing, and financial operations',
88
- color: 'pink'
89
- }
90
-
91
- export const EXECUTIVE_DOMAIN: DomainDefinition = {
92
- id: DOMAINS.EXECUTIVE,
93
- name: 'Executive Operations',
94
- description: 'High-level business orchestration and decision-making',
95
- color: 'indigo'
96
- }
97
-
98
- export const TESTING_DOMAIN: DomainDefinition = {
99
- id: DOMAINS.TESTING,
100
- name: 'Testing',
101
- description: 'Test resources and development workflows',
102
- color: 'gray'
103
- }
104
-
105
- export const INTERNAL_DOMAIN: DomainDefinition = {
106
- id: DOMAINS.INTERNAL,
107
- name: 'Internal',
108
- description: 'Internal platform resources',
109
- color: 'dark'
110
- }
111
-
112
- export const INTEGRATION_DOMAIN: DomainDefinition = {
113
- id: DOMAINS.INTEGRATION,
114
- name: 'Integration',
115
- description: 'External service integrations',
116
- color: 'teal'
117
- }
118
-
119
- export const INSTANTLY_DOMAIN: DomainDefinition = {
120
- id: DOMAINS.INSTANTLY,
121
- name: 'Instantly Toolkit',
122
- description: 'Instantly campaign creation, analytics, and optimization',
123
- color: 'lime'
124
- }
125
-
126
- export const UTILITY_DOMAIN: DomainDefinition = {
127
- id: DOMAINS.UTILITY,
128
- name: 'Utility',
129
- description: 'Utility workflows for maintenance and diagnostics',
130
- color: 'grape'
131
- }
132
-
133
- export const DIAGNOSTIC_DOMAIN: DomainDefinition = {
134
- id: DOMAINS.DIAGNOSTIC,
135
- name: 'Diagnostic',
136
- description: 'Diagnostic workflows for testing integrations and services',
137
- color: 'yellow'
138
- }
139
-
140
- /**
141
- * Domain lookup map for O(1) access during serialization
142
- */
143
- export const DOMAIN_MAP: Record<ResourceDomain, DomainDefinition> = {
144
- [DOMAINS.INBOUND_PIPELINE]: INBOUND_PIPELINE_DOMAIN,
145
- [DOMAINS.LEAD_GEN_PIPELINE]: LEAD_GEN_PIPELINE_DOMAIN,
146
- [DOMAINS.SUPPORT]: SUPPORT_DOMAIN,
147
- [DOMAINS.CLIENT_SUPPORT]: CLIENT_SUPPORT_DOMAIN,
148
- [DOMAINS.DELIVERY]: DELIVERY_DOMAIN,
149
- [DOMAINS.OPERATIONS]: OPERATIONS_DOMAIN,
150
- [DOMAINS.FINANCE]: FINANCE_DOMAIN,
151
- [DOMAINS.EXECUTIVE]: EXECUTIVE_DOMAIN,
152
- [DOMAINS.TESTING]: TESTING_DOMAIN,
153
- [DOMAINS.INTERNAL]: INTERNAL_DOMAIN,
154
- [DOMAINS.INSTANTLY]: INSTANTLY_DOMAIN,
155
- [DOMAINS.INTEGRATION]: INTEGRATION_DOMAIN,
156
- [DOMAINS.UTILITY]: UTILITY_DOMAIN,
157
- [DOMAINS.DIAGNOSTIC]: DIAGNOSTIC_DOMAIN
158
- }
159
-
160
- /**
161
- * Get domain definition by ID
162
- */
163
- export function getDomainDefinition(id: ResourceDomain): DomainDefinition {
164
- return DOMAIN_MAP[id]
165
- }