@elevasis/core 0.3.0 → 0.5.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.
@@ -0,0 +1,215 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Base Entity Contracts
5
+ *
6
+ * Typed base interfaces for CRM, Lead-Gen (Acquisition), and Projects domains.
7
+ * Each uses a `<TMeta>` generic parameter so client projects can narrow the
8
+ * metadata type in their own `foundations/types/` directory.
9
+ *
10
+ * These are PARALLEL abstractions — they do NOT replace or modify the existing
11
+ * row types (ProjectRow, AcqDealRow, etc.). Use these as the SDK-facing contract
12
+ * layer; use the row types internally for direct Supabase access.
13
+ *
14
+ * Usage in a client project:
15
+ * import { BaseProject } from '@elevasis/core' (or '@repo/core' internally)
16
+ * type Project = BaseProject<{ budget: number; riskScore: 'low' | 'medium' | 'high' }>
17
+ *
18
+ * Extending a Zod schema in a client project:
19
+ * import { BaseProjectSchema } from '@elevasis/core'
20
+ * const ProjectMetaSchema = z.object({ budget: z.number(), riskScore: z.enum(['low','medium','high']) })
21
+ * const ProjectSchema = BaseProjectSchema.extend({ metadata: ProjectMetaSchema })
22
+ */
23
+ /**
24
+ * Common fields shared across all project implementations.
25
+ * `TMeta` narrows the `metadata` JSONB column (prj_projects.metadata).
26
+ */
27
+ interface BaseProject<TMeta = Record<string, unknown>> {
28
+ id: string;
29
+ organizationId: string;
30
+ name: string;
31
+ kind: string;
32
+ status: string;
33
+ description: string | null;
34
+ metadata: TMeta;
35
+ createdAt: string;
36
+ updatedAt: string;
37
+ }
38
+ /**
39
+ * Common fields shared across all milestone implementations.
40
+ * `TMeta` narrows the `metadata` JSONB column (prj_milestones.metadata).
41
+ */
42
+ interface BaseMilestone<TMeta = Record<string, unknown>> {
43
+ id: string;
44
+ organizationId: string;
45
+ projectId: string;
46
+ name: string;
47
+ status: string;
48
+ description: string | null;
49
+ metadata: TMeta;
50
+ createdAt: string;
51
+ updatedAt: string;
52
+ }
53
+ /**
54
+ * Common fields shared across all task implementations.
55
+ * `TMeta` narrows the `metadata` JSONB column (prj_tasks.metadata).
56
+ */
57
+ interface BaseTask<TMeta = Record<string, unknown>> {
58
+ id: string;
59
+ organizationId: string;
60
+ projectId: string;
61
+ name: string;
62
+ status: string;
63
+ type: string;
64
+ description: string | null;
65
+ metadata: TMeta;
66
+ createdAt: string;
67
+ updatedAt: string;
68
+ }
69
+ /**
70
+ * Common fields shared across all deal implementations.
71
+ * `TMeta` is an extension point for client-specific deal metadata.
72
+ * Note: The underlying acq_deals table does not have a `metadata` column;
73
+ * this field serves as a typed extension slot for SDK consumers.
74
+ */
75
+ interface BaseDeal<TMeta = Record<string, unknown>> {
76
+ id: string;
77
+ organizationId: string;
78
+ contactEmail: string;
79
+ stage: string | null;
80
+ metadata: TMeta;
81
+ createdAt: string;
82
+ updatedAt: string;
83
+ }
84
+ /**
85
+ * Common fields shared across all company implementations.
86
+ * `TMeta` is an extension point for client-specific company metadata.
87
+ */
88
+ interface BaseCompany<TMeta = Record<string, unknown>> {
89
+ id: string;
90
+ organizationId: string;
91
+ name: string;
92
+ domain: string | null;
93
+ status: string;
94
+ metadata: TMeta;
95
+ createdAt: string;
96
+ updatedAt: string;
97
+ }
98
+ /**
99
+ * Common fields shared across all contact implementations.
100
+ * `TMeta` is an extension point for client-specific contact metadata.
101
+ */
102
+ interface BaseContact<TMeta = Record<string, unknown>> {
103
+ id: string;
104
+ organizationId: string;
105
+ email: string;
106
+ firstName: string | null;
107
+ lastName: string | null;
108
+ status: string;
109
+ metadata: TMeta;
110
+ createdAt: string;
111
+ updatedAt: string;
112
+ }
113
+ /**
114
+ * Base Zod schema for a project record.
115
+ * Extend with `BaseProjectSchema.extend({ metadata: ProjectMetaSchema })`.
116
+ */
117
+ declare const BaseProjectSchema: z.ZodObject<{
118
+ id: z.ZodString;
119
+ organizationId: z.ZodString;
120
+ name: z.ZodString;
121
+ kind: z.ZodString;
122
+ status: z.ZodString;
123
+ description: z.ZodNullable<z.ZodString>;
124
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
125
+ createdAt: z.ZodString;
126
+ updatedAt: z.ZodString;
127
+ }, z.core.$strip>;
128
+ /**
129
+ * Base Zod schema for a milestone record.
130
+ * Extend with `BaseMilestoneSchema.extend({ metadata: MilestoneMetaSchema })`.
131
+ */
132
+ declare const BaseMilestoneSchema: z.ZodObject<{
133
+ id: z.ZodString;
134
+ organizationId: z.ZodString;
135
+ projectId: z.ZodString;
136
+ name: z.ZodString;
137
+ status: z.ZodString;
138
+ description: z.ZodNullable<z.ZodString>;
139
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
140
+ createdAt: z.ZodString;
141
+ updatedAt: z.ZodString;
142
+ }, z.core.$strip>;
143
+ /**
144
+ * Base Zod schema for a task record.
145
+ * Extend with `BaseTaskSchema.extend({ metadata: TaskMetaSchema })`.
146
+ */
147
+ declare const BaseTaskSchema: z.ZodObject<{
148
+ id: z.ZodString;
149
+ organizationId: z.ZodString;
150
+ projectId: z.ZodString;
151
+ name: z.ZodString;
152
+ status: z.ZodString;
153
+ type: z.ZodString;
154
+ description: z.ZodNullable<z.ZodString>;
155
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
156
+ createdAt: z.ZodString;
157
+ updatedAt: z.ZodString;
158
+ }, z.core.$strip>;
159
+ /**
160
+ * Base Zod schema for a deal record.
161
+ * Extend with `BaseDealSchema.extend({ metadata: DealMetaSchema })`.
162
+ */
163
+ declare const BaseDealSchema: z.ZodObject<{
164
+ id: z.ZodString;
165
+ organizationId: z.ZodString;
166
+ contactEmail: z.ZodString;
167
+ stage: z.ZodNullable<z.ZodString>;
168
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
169
+ createdAt: z.ZodString;
170
+ updatedAt: z.ZodString;
171
+ }, z.core.$strip>;
172
+ /**
173
+ * Base Zod schema for a company record.
174
+ * Extend with `BaseCompanySchema.extend({ metadata: CompanyMetaSchema })`.
175
+ */
176
+ declare const BaseCompanySchema: z.ZodObject<{
177
+ id: z.ZodString;
178
+ organizationId: z.ZodString;
179
+ name: z.ZodString;
180
+ domain: z.ZodNullable<z.ZodString>;
181
+ status: z.ZodString;
182
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
183
+ createdAt: z.ZodString;
184
+ updatedAt: z.ZodString;
185
+ }, z.core.$strip>;
186
+ /**
187
+ * Base Zod schema for a contact record.
188
+ * Extend with `BaseContactSchema.extend({ metadata: ContactMetaSchema })`.
189
+ */
190
+ declare const BaseContactSchema: z.ZodObject<{
191
+ id: z.ZodString;
192
+ organizationId: z.ZodString;
193
+ email: z.ZodString;
194
+ firstName: z.ZodNullable<z.ZodString>;
195
+ lastName: z.ZodNullable<z.ZodString>;
196
+ status: z.ZodString;
197
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
198
+ createdAt: z.ZodString;
199
+ updatedAt: z.ZodString;
200
+ }, z.core.$strip>;
201
+ /** Default (unnarrowed) inferred type from BaseProjectSchema */
202
+ type BaseProjectInput = z.infer<typeof BaseProjectSchema>;
203
+ /** Default (unnarrowed) inferred type from BaseMilestoneSchema */
204
+ type BaseMilestoneInput = z.infer<typeof BaseMilestoneSchema>;
205
+ /** Default (unnarrowed) inferred type from BaseTaskSchema */
206
+ type BaseTaskInput = z.infer<typeof BaseTaskSchema>;
207
+ /** Default (unnarrowed) inferred type from BaseDealSchema */
208
+ type BaseDealInput = z.infer<typeof BaseDealSchema>;
209
+ /** Default (unnarrowed) inferred type from BaseCompanySchema */
210
+ type BaseCompanyInput = z.infer<typeof BaseCompanySchema>;
211
+ /** Default (unnarrowed) inferred type from BaseContactSchema */
212
+ type BaseContactInput = z.infer<typeof BaseContactSchema>;
213
+
214
+ export { BaseCompanySchema, BaseContactSchema, BaseDealSchema, BaseMilestoneSchema, BaseProjectSchema, BaseTaskSchema };
215
+ export type { BaseCompany, BaseCompanyInput, BaseContact, BaseContactInput, BaseDeal, BaseDealInput, BaseMilestone, BaseMilestoneInput, BaseProject, BaseProjectInput, BaseTask, BaseTaskInput };
@@ -0,0 +1,69 @@
1
+ import { z } from 'zod';
2
+
3
+ // src/business/base-entities.ts
4
+ var BaseProjectSchema = z.object({
5
+ id: z.string(),
6
+ organizationId: z.string(),
7
+ name: z.string(),
8
+ kind: z.string(),
9
+ status: z.string(),
10
+ description: z.string().nullable(),
11
+ metadata: z.record(z.string(), z.unknown()).default({}),
12
+ createdAt: z.string(),
13
+ updatedAt: z.string()
14
+ });
15
+ var BaseMilestoneSchema = z.object({
16
+ id: z.string(),
17
+ organizationId: z.string(),
18
+ projectId: z.string(),
19
+ name: z.string(),
20
+ status: z.string(),
21
+ description: z.string().nullable(),
22
+ metadata: z.record(z.string(), z.unknown()).default({}),
23
+ createdAt: z.string(),
24
+ updatedAt: z.string()
25
+ });
26
+ var BaseTaskSchema = z.object({
27
+ id: z.string(),
28
+ organizationId: z.string(),
29
+ projectId: z.string(),
30
+ name: z.string(),
31
+ status: z.string(),
32
+ type: z.string(),
33
+ description: z.string().nullable(),
34
+ metadata: z.record(z.string(), z.unknown()).default({}),
35
+ createdAt: z.string(),
36
+ updatedAt: z.string()
37
+ });
38
+ var BaseDealSchema = z.object({
39
+ id: z.string(),
40
+ organizationId: z.string(),
41
+ contactEmail: z.string(),
42
+ stage: z.string().nullable(),
43
+ metadata: z.record(z.string(), z.unknown()).default({}),
44
+ createdAt: z.string(),
45
+ updatedAt: z.string()
46
+ });
47
+ var BaseCompanySchema = z.object({
48
+ id: z.string(),
49
+ organizationId: z.string(),
50
+ name: z.string(),
51
+ domain: z.string().nullable(),
52
+ status: z.string(),
53
+ metadata: z.record(z.string(), z.unknown()).default({}),
54
+ createdAt: z.string(),
55
+ updatedAt: z.string()
56
+ });
57
+ var BaseContactSchema = z.object({
58
+ id: z.string(),
59
+ organizationId: z.string(),
60
+ email: z.string(),
61
+ firstName: z.string().nullable(),
62
+ lastName: z.string().nullable(),
63
+ status: z.string(),
64
+ metadata: z.record(z.string(), z.unknown()).default({}),
65
+ createdAt: z.string(),
66
+ updatedAt: z.string()
67
+ });
68
+
69
+ export { BaseCompanySchema, BaseContactSchema, BaseDealSchema, BaseMilestoneSchema, BaseProjectSchema, BaseTaskSchema };
package/dist/index.d.ts CHANGED
@@ -32,13 +32,14 @@ declare const OrganizationModelSchema: z.ZodObject<{
32
32
  path: z.ZodString;
33
33
  surfaceType: z.ZodEnum<{
34
34
  list: "list";
35
+ settings: "settings";
35
36
  page: "page";
36
37
  dashboard: "dashboard";
37
38
  graph: "graph";
38
39
  detail: "detail";
39
- settings: "settings";
40
40
  }>;
41
41
  description: z.ZodOptional<z.ZodString>;
42
+ enabled: z.ZodDefault<z.ZodBoolean>;
42
43
  icon: z.ZodOptional<z.ZodString>;
43
44
  featureId: z.ZodOptional<z.ZodString>;
44
45
  featureIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
@@ -174,6 +175,15 @@ declare const FeatureSchema: z.ZodObject<{
174
175
  declare const PROJECTS_FEATURE_ID: "projects";
175
176
  declare const PROJECTS_INDEX_SURFACE_ID: "projects.index";
176
177
  declare const DELIVERY_PROJECTS_VIEW_CAPABILITY_ID: "delivery.projects.view";
178
+ declare const CRM_FEATURE_ID: "crm";
179
+ declare const LEAD_GEN_FEATURE_ID: "lead-gen";
180
+ declare const OPERATIONS_FEATURE_ID: "operations";
181
+ declare const MONITORING_FEATURE_ID: "monitoring";
182
+ declare const SETTINGS_FEATURE_ID: "settings";
183
+ declare const SEO_FEATURE_ID: "seo";
184
+ declare const CRM_PIPELINE_SURFACE_ID: "crm.pipeline";
185
+ declare const LEAD_GEN_LISTS_SURFACE_ID: "lead-gen.lists";
186
+ declare const OPERATIONS_ORGANIZATION_GRAPH_SURFACE_ID: "operations.organization-graph";
177
187
 
178
188
  declare const OrganizationModelBrandingSchema: z.ZodObject<{
179
189
  organizationName: z.ZodString;
@@ -273,13 +283,14 @@ declare const SurfaceDefinitionSchema: z.ZodObject<{
273
283
  path: z.ZodString;
274
284
  surfaceType: z.ZodEnum<{
275
285
  list: "list";
286
+ settings: "settings";
276
287
  page: "page";
277
288
  dashboard: "dashboard";
278
289
  graph: "graph";
279
290
  detail: "detail";
280
- settings: "settings";
281
291
  }>;
282
292
  description: z.ZodOptional<z.ZodString>;
293
+ enabled: z.ZodDefault<z.ZodBoolean>;
283
294
  icon: z.ZodOptional<z.ZodString>;
284
295
  featureId: z.ZodOptional<z.ZodString>;
285
296
  featureIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
@@ -296,13 +307,14 @@ declare const OrganizationModelNavigationSchema: z.ZodObject<{
296
307
  path: z.ZodString;
297
308
  surfaceType: z.ZodEnum<{
298
309
  list: "list";
310
+ settings: "settings";
299
311
  page: "page";
300
312
  dashboard: "dashboard";
301
313
  graph: "graph";
302
314
  detail: "detail";
303
- settings: "settings";
304
315
  }>;
305
316
  description: z.ZodOptional<z.ZodString>;
317
+ enabled: z.ZodDefault<z.ZodBoolean>;
306
318
  icon: z.ZodOptional<z.ZodString>;
307
319
  featureId: z.ZodOptional<z.ZodString>;
308
320
  featureIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
@@ -380,7 +392,7 @@ interface FoundationBranding {
380
392
  productName: string;
381
393
  shortName: string;
382
394
  }
383
- declare function createFoundationOrganizationModel(branding: FoundationBranding): {
395
+ declare function createFoundationOrganizationModel(override: DeepPartial<OrganizationModel>): {
384
396
  canonical: OrganizationModel;
385
397
  model: FoundationOrganizationModel;
386
398
  homeLabel: string;
@@ -388,5 +400,5 @@ declare function createFoundationOrganizationModel(branding: FoundationBranding)
388
400
  getOrganizationSurface: (surfaceId: string) => FoundationNavigationSurface | undefined;
389
401
  };
390
402
 
391
- export { DEFAULT_ORGANIZATION_MODEL, DELIVERY_PROJECTS_VIEW_CAPABILITY_ID, FeatureSchema, OrganizationModelSchema, PROJECTS_FEATURE_ID, PROJECTS_INDEX_SURFACE_ID, createFoundationOrganizationModel, defineOrganizationModel, resolveOrganizationModel };
403
+ export { CRM_FEATURE_ID, CRM_PIPELINE_SURFACE_ID, DEFAULT_ORGANIZATION_MODEL, DELIVERY_PROJECTS_VIEW_CAPABILITY_ID, FeatureSchema, LEAD_GEN_FEATURE_ID, LEAD_GEN_LISTS_SURFACE_ID, MONITORING_FEATURE_ID, OPERATIONS_FEATURE_ID, OPERATIONS_ORGANIZATION_GRAPH_SURFACE_ID, OrganizationModelSchema, PROJECTS_FEATURE_ID, PROJECTS_INDEX_SURFACE_ID, SEO_FEATURE_ID, SETTINGS_FEATURE_ID, createFoundationOrganizationModel, defineOrganizationModel, resolveOrganizationModel };
392
404
  export type { DeepPartial, FoundationBranding, FoundationNavigationSurface, FoundationOrganizationModel, FoundationSurfaceIcon, FoundationSurfaceType, OrganizationModel, OrganizationModelBranding, OrganizationModelCrm, OrganizationModelDelivery, OrganizationModelFeature, OrganizationModelLeadGen, OrganizationModelNavigation, OrganizationModelResourceMapping, OrganizationModelSurface };