@happyvertical/smrt-properties 0.51.31 → 0.51.33

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/dist/index.d.ts CHANGED
@@ -1,445 +1,68 @@
1
- import { PromptDefinition } from '@happyvertical/smrt-prompts';
2
- import { ResolvedPromptAI } from '@happyvertical/smrt-prompts';
3
- import { SmrtCollection } from '@happyvertical/smrt-core';
4
- import { SmrtHierarchical } from '@happyvertical/smrt-core';
5
- import { SmrtObject } from '@happyvertical/smrt-core';
6
- import { SmrtObjectOptions } from '@happyvertical/smrt-core';
7
-
8
- export declare function promptMessageOptions(ai: ResolvedPromptAI): {
9
- maxTokens?: number | undefined;
10
- temperature?: number | undefined;
11
- model?: string | undefined;
12
- };
13
-
14
- export declare class Property extends SmrtObject {
15
- /**
16
- * Tenant ID for multi-tenant isolation
17
- */
18
- tenantId: string | null;
19
- /**
20
- * Display name of the property
21
- */
22
- name: string;
23
- /**
24
- * Domain name (e.g., "oakcreeknews.com")
25
- */
26
- domain: string;
27
- /**
28
- * Full URL (e.g., "https://oakcreeknews.com")
29
- */
30
- url: string;
31
- /**
32
- * Property description
33
- */
34
- description: string;
35
- /**
36
- * Link to Repository (from smrt-projects)
37
- * Optional - used when property is backed by a git repository
38
- */
39
- repositoryId: string | null;
40
- /**
41
- * Link to Profile (from smrt-profiles)
42
- * Optional - owner/publisher of the property
43
- */
44
- ownerId: string | null;
45
- /**
46
- * Property status
47
- */
48
- status: PropertyStatus;
49
- /**
50
- * Extensible metadata (analytics IDs, config, etc.)
51
- */
52
- metadata: Record<string, unknown>;
53
- constructor(options?: PropertyOptions);
54
- /**
55
- * Get all zones for this property
56
- */
57
- getZones(): Promise< Zone[]>;
58
- /**
59
- * Get zone tree for this property
60
- */
61
- getZoneTree(): Promise< ZoneTree<Zone>>;
62
- /**
63
- * Create a zone on this property
64
- */
65
- createZone(options: Omit< ZoneOptions, 'propertyId'>): Promise< Zone>;
66
- /**
67
- * Check if property is active
68
- */
69
- isActive(): boolean;
70
- /**
71
- * AI-powered: Generate a summary of the property and its zones.
72
- *
73
- * Uses the `smrtProperties.property.summarize` prompt registered via
74
- * `@happyvertical/smrt-prompts`, allowing tenant- or instance-level
75
- * overrides of the template, model, and parameters at runtime.
76
- *
77
- * Only non-PII fields (name, domain, description, status) plus aggregate
78
- * zone information are sent to the AI provider. Internal foreign-key
79
- * fields and the extensible `metadata` blob are intentionally excluded.
80
- *
81
- * @returns Generated summary text
82
- */
83
- summarize(): Promise<string>;
84
- }
85
-
86
- export declare class PropertyCollection extends SmrtCollection<Property> {
87
- static readonly _itemClass: typeof Property;
88
- /**
89
- * Find a property by domain
90
- *
91
- * @param domain - Domain name
92
- * @returns Property or null
93
- */
94
- findByDomain(domain: string): Promise<Property | null>;
95
- /**
96
- * Find properties by repository ID
97
- *
98
- * @param repositoryId - Repository ID
99
- * @returns Array of properties
100
- */
101
- findByRepository(repositoryId: string): Promise<Property[]>;
102
- /**
103
- * Find properties by owner ID
104
- *
105
- * @param ownerId - Owner profile ID
106
- * @returns Array of properties
107
- */
108
- findByOwner(ownerId: string): Promise<Property[]>;
109
- /**
110
- * Find active properties
111
- *
112
- * @returns Array of active properties
113
- */
114
- findActive(): Promise<Property[]>;
115
- /**
116
- * Find properties by status
117
- *
118
- * @param status - Property status
119
- * @returns Array of properties with the given status
120
- */
121
- findByStatus(status: PropertyStatus): Promise<Property[]>;
122
- /**
123
- * Get or create a property by domain
124
- *
125
- * @param domain - Domain name
126
- * @param defaults - Default values for creation
127
- * @returns Property (existing or newly created)
128
- */
129
- getOrCreateByDomain(domain: string, defaults?: {
130
- name?: string;
131
- url?: string;
132
- repositoryId?: string | null;
133
- ownerId?: string | null;
134
- }): Promise<Property>;
135
- /**
136
- * Count properties by status
137
- *
138
- * @returns Object with counts per status
139
- */
140
- countByStatus(): Promise<Record<PropertyStatus, number>>;
141
- /**
142
- * Find properties belonging to a specific tenant
143
- *
144
- * @param tenantId - Tenant ID to filter by
145
- * @returns Array of properties for the tenant
146
- */
147
- findByTenant(tenantId: string): Promise<Property[]>;
148
- /**
149
- * Find all global properties (no tenant association).
150
- *
151
- * Routes through the shared tenant-global helper so it does not throw under
152
- * an active tenant context (an explicit `tenant_id IS NULL` filter would be
153
- * flagged as an isolation violation). (#1600)
154
- *
155
- * @returns Array of global properties
156
- */
157
- findGlobal(): Promise<Property[]>;
158
- /**
159
- * Find properties for a tenant plus all global properties.
160
- *
161
- * Fails closed if an active tenant context requests a different tenant's
162
- * rows; the admin/system path keeps the cross-tenant capability. (#1600)
163
- *
164
- * @param tenantId - Tenant ID to filter by
165
- * @returns Array of tenant-specific and global properties
166
- */
167
- findWithGlobals(tenantId: string): Promise<Property[]>;
168
- }
169
-
170
- /**
171
- * Options for creating a Property instance
172
- */
173
- export declare interface PropertyOptions extends SmrtObjectOptions {
174
- tenantId?: string | null;
175
- name?: string;
176
- domain?: string;
177
- url?: string;
178
- description?: string;
179
- repositoryId?: string | null;
180
- ownerId?: string | null;
181
- status?: PropertyStatus;
182
- metadata?: Record<string, unknown>;
183
- }
184
-
185
- /**
186
- * Status of a digital property
187
- */
188
- export declare type PropertyStatus = 'active' | 'inactive' | 'pending';
189
-
190
- export declare const smrtPropertiesSummarizePrompt: PromptDefinition;
191
-
192
- export declare class Zone extends SmrtHierarchical {
193
- /**
194
- * Tenant ID for multi-tenant isolation
195
- */
196
- tenantId: string | null;
197
- /**
198
- * Parent property ID (required)
199
- */
200
- propertyId: string;
201
- /**
202
- * Display name
203
- */
204
- name: string;
205
- /**
206
- * Zone type (descriptive, not structural)
207
- * Common values: "page", "section", "slot", "container", "widget"
208
- */
209
- type: string;
210
- /**
211
- * URL path pattern (e.g., "/", "/articles/*")
212
- */
213
- path: string;
214
- /**
215
- * CSS selector for placement (e.g., "#header", ".sidebar")
216
- */
217
- selector: string;
218
- /**
219
- * Position hint (e.g., "top", "after-paragraph-3")
220
- */
221
- position: string;
222
- /**
223
- * Width in pixels (null = fluid)
224
- */
225
- width: number | null;
226
- /**
227
- * Height in pixels (null = fluid)
228
- */
229
- height: number | null;
230
- /**
231
- * Allowed content/ad formats
232
- */
233
- allowedFormats: string[];
234
- /**
235
- * Default content/asset ID for fallback
236
- */
237
- defaultContentId: string | null;
238
- /**
239
- * Extensible metadata
240
- */
241
- metadata: Record<string, unknown>;
242
- constructor(options?: ZoneOptions);
243
- /**
244
- * Check if this is a top-level zone (no parent)
245
- */
246
- isTopLevel(): boolean;
247
- /**
248
- * Check if this zone has dimensions set
249
- */
250
- hasDimensions(): boolean;
251
- /**
252
- * Get dimensions as string (e.g., "728x90")
253
- */
254
- getDimensionString(): string | null;
255
- /**
256
- * Get the parent property
257
- */
258
- getProperty(): Promise< Property | null>;
259
- /**
260
- * Get the full path from root to this zone
261
- */
262
- getFullPath(): Promise<string>;
263
- /**
264
- * Get the depth in the hierarchy (0 = top-level)
265
- */
266
- getDepth(): Promise<number>;
267
- /**
268
- * Create a child zone under this zone
269
- */
270
- createChild(options: Omit<ZoneOptions, 'propertyId' | 'parentId'>): Promise<Zone>;
271
- /**
272
- * Build tree node for this zone and its children
273
- */
274
- toTreeNode(): Promise<ZoneTreeNode<Zone>>;
275
- /**
276
- * Check if a format is allowed in this zone
277
- */
278
- isFormatAllowed(format: string): boolean;
279
- }
280
-
281
- export declare class ZoneCollection extends SmrtCollection<Zone> {
282
- static readonly _itemClass: typeof Zone;
283
- /**
284
- * Find all zones for a property
285
- *
286
- * @param propertyId - Property ID
287
- * @returns Array of zones
288
- */
289
- findByProperty(propertyId: string): Promise<Zone[]>;
290
- /**
291
- * Find top-level zones for a property (no parent)
292
- *
293
- * @param propertyId - Property ID
294
- * @returns Array of top-level zones
295
- */
296
- findTopLevel(propertyId: string): Promise<Zone[]>;
297
- /**
298
- * Find direct children of a zone
299
- *
300
- * @param parentId - Parent zone ID
301
- * @returns Array of child zones
302
- */
303
- findChildren(parentId: string): Promise<Zone[]>;
304
- /**
305
- * Find zones by path pattern
306
- *
307
- * @param propertyId - Property ID
308
- * @param path - URL path to match
309
- * @returns Array of matching zones
310
- */
311
- findByPath(propertyId: string, path: string): Promise<Zone[]>;
312
- /**
313
- * Find zones by type
314
- *
315
- * @param propertyId - Property ID
316
- * @param type - Zone type
317
- * @returns Array of zones of the given type
318
- */
319
- findByType(propertyId: string, type: string): Promise<Zone[]>;
320
- /**
321
- * Get the complete zone tree for a property
322
- *
323
- * @param propertyId - Property ID
324
- * @returns ZoneTree structure
325
- */
326
- getTree(propertyId: string): Promise<ZoneTree<Zone>>;
327
- /**
328
- * Get all ancestors of a zone (path to root)
329
- *
330
- * @param zoneId - Zone ID
331
- * @returns Array of ancestors (from root to parent)
332
- */
333
- getAncestors(zoneId: string): Promise<Zone[]>;
334
- /**
335
- * Get all descendants of a zone recursively
336
- *
337
- * @param zoneId - Zone ID
338
- * @returns Array of all descendant zones
339
- */
340
- getDescendants(zoneId: string): Promise<Zone[]>;
341
- /**
342
- * Get the depth of the deepest zone in a property
343
- *
344
- * @param propertyId - Property ID
345
- * @returns Maximum depth (0 = only top-level zones)
346
- */
347
- getMaxDepth(propertyId: string): Promise<number>;
348
- /**
349
- * Find zones with specific dimensions
350
- *
351
- * @param propertyId - Property ID
352
- * @param width - Required width
353
- * @param height - Required height
354
- * @returns Array of matching zones
355
- */
356
- findByDimensions(propertyId: string, width: number, height: number): Promise<Zone[]>;
357
- /**
358
- * Find zones that allow a specific format
359
- *
360
- * @param propertyId - Property ID
361
- * @param format - Format to check
362
- * @returns Array of zones allowing the format
363
- */
364
- findByAllowedFormat(propertyId: string, format: string): Promise<Zone[]>;
365
- /**
366
- * Move a zone to a new parent
367
- *
368
- * @param zoneId - Zone ID to move
369
- * @param newParentId - New parent ID (null for top-level)
370
- * @returns Updated zone
371
- */
372
- moveZone(zoneId: string, newParentId: string | null): Promise<Zone | null>;
373
- /**
374
- * Delete a zone and optionally its descendants
375
- *
376
- * @param zoneId - Zone ID to delete
377
- * @param cascade - Whether to delete descendants
378
- * @returns Number of zones deleted
379
- */
380
- deleteZone(zoneId: string, cascade?: boolean): Promise<number>;
381
- /**
382
- * Find zones belonging to a specific tenant
383
- *
384
- * @param tenantId - Tenant ID to filter by
385
- * @returns Array of zones for the tenant
386
- */
387
- findByTenant(tenantId: string): Promise<Zone[]>;
388
- /**
389
- * Find all global zones (no tenant association).
390
- *
391
- * Routes through the shared tenant-global helper so it does not throw under
392
- * an active tenant context (an explicit `tenant_id IS NULL` filter would be
393
- * flagged as an isolation violation). (#1600)
394
- *
395
- * @returns Array of global zones
396
- */
397
- findGlobal(): Promise<Zone[]>;
398
- /**
399
- * Find zones for a tenant plus all global zones.
400
- *
401
- * Fails closed if an active tenant context requests a different tenant's
402
- * rows; the admin/system path keeps the cross-tenant capability. (#1600)
403
- *
404
- * @param tenantId - Tenant ID to filter by
405
- * @returns Array of tenant-specific and global zones
406
- */
407
- findWithGlobals(tenantId: string): Promise<Zone[]>;
408
- }
409
-
410
- /**
411
- * Options for creating a Zone instance
412
- */
413
- export declare interface ZoneOptions extends SmrtObjectOptions {
414
- tenantId?: string | null;
415
- propertyId?: string;
416
- parentId?: string | null;
417
- name?: string;
418
- type?: string;
419
- path?: string;
420
- selector?: string;
421
- position?: string;
422
- width?: number | null;
423
- height?: number | null;
424
- allowedFormats?: string[];
425
- defaultContentId?: string | null;
426
- metadata?: Record<string, unknown>;
427
- }
428
-
429
- /**
430
- * Complete zone tree for a property
431
- */
432
- export declare interface ZoneTree<T = unknown> {
433
- propertyId: string;
434
- roots: ZoneTreeNode<T>[];
435
- }
436
-
437
- /**
438
- * A node in the zone tree hierarchy
439
- */
440
- export declare interface ZoneTreeNode<T = unknown> {
441
- zone: T;
442
- children: ZoneTreeNode<T>[];
443
- }
444
-
445
- export { }
1
+ /**
2
+ * @happyvertical/smrt-properties
3
+ *
4
+ * Digital property and zone management for the SMRT framework.
5
+ *
6
+ * This package provides models for managing digital properties (websites, apps)
7
+ * and their hierarchical zones (pages, sections, slots).
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import {
12
+ * Property,
13
+ * PropertyCollection,
14
+ * Zone,
15
+ * ZoneCollection
16
+ * } from '@happyvertical/smrt-properties';
17
+ *
18
+ * // Create collections
19
+ * const properties = await PropertyCollection.create({
20
+ * db: { type: 'sqlite', url: 'properties.db' }
21
+ * });
22
+ * const zones = await ZoneCollection.create({
23
+ * db: { type: 'sqlite', url: 'properties.db' }
24
+ * });
25
+ *
26
+ * // Create a property
27
+ * const site = await properties.create({
28
+ * name: 'Oak Creek News',
29
+ * domain: 'oakcreeknews.com',
30
+ * url: 'https://oakcreeknews.com',
31
+ * status: 'active'
32
+ * });
33
+ * await site.save();
34
+ *
35
+ * // Create hierarchical zones (IDs are guaranteed after save())
36
+ * const homePage = await zones.create({
37
+ * propertyId: site.id!,
38
+ * name: 'Home Page',
39
+ * type: 'page',
40
+ * path: '/'
41
+ * });
42
+ * await homePage.save();
43
+ *
44
+ * const headerSlot = await zones.create({
45
+ * propertyId: site.id!,
46
+ * parentId: homePage.id!,
47
+ * name: 'Header Leaderboard',
48
+ * type: 'slot',
49
+ * width: 728,
50
+ * height: 90
51
+ * });
52
+ * await headerSlot.save();
53
+ *
54
+ * // Get zone tree
55
+ * const tree = await zones.getTree(site.id!);
56
+ * ```
57
+ *
58
+ * @packageDocumentation
59
+ */
60
+ import './__smrt-register__.js';
61
+ import './prompts.js';
62
+ export { PropertyCollection } from './collections/Properties';
63
+ export { ZoneCollection } from './collections/Zones';
64
+ export { Property } from './models/Property';
65
+ export { Zone } from './models/Zone';
66
+ export { promptMessageOptions, smrtPropertiesSummarizePrompt, } from './prompts';
67
+ export type { PropertyOptions, PropertyStatus, ZoneOptions, ZoneTree, ZoneTreeNode, } from './types';
68
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAKH,OAAO,wBAAwB,CAAC;AAGhC,OAAO,cAAc,CAAC;AAGtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAIrC,OAAO,EACL,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,WAAW,CAAC;AAGnB,YAAY,EACV,eAAe,EACf,cAAc,EACd,WAAW,EACX,QAAQ,EACR,YAAY,GACb,MAAM,SAAS,CAAC"}