@happyvertical/smrt-places 0.37.2 → 0.37.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.
- package/dist/chunks/PlaceTypeCollection-zFJu53le.js +152 -0
- package/dist/chunks/PlaceTypeCollection-zFJu53le.js.map +1 -0
- package/dist/index.js +649 -949
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +2 -2
- package/dist/smrt-knowledge.json +7 -7
- package/dist/types.js +0 -2
- package/dist/utils.js +77 -92
- package/dist/utils.js.map +1 -1
- package/package.json +15 -15
- package/dist/types.js.map +0 -1
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { SmrtCollection, SmrtObject, field, smrt } from "@happyvertical/smrt-core";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __defProp$1 = Object.defineProperty;
|
|
4
|
+
var __exportAll = (all, no_symbols) => {
|
|
5
|
+
let target = {};
|
|
6
|
+
for (var name in all) __defProp$1(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
if (!no_symbols) __defProp$1(target, Symbol.toStringTag, { value: "Module" });
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/models/PlaceType.ts
|
|
15
|
+
var __defProp = Object.defineProperty;
|
|
16
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
17
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
18
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
19
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
20
|
+
if (kind && result) __defProp(target, key, result);
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
var PlaceType = class extends SmrtObject {
|
|
24
|
+
name = "";
|
|
25
|
+
description;
|
|
26
|
+
createdAt = /* @__PURE__ */ new Date();
|
|
27
|
+
updatedAt = /* @__PURE__ */ new Date();
|
|
28
|
+
constructor(options = {}) {
|
|
29
|
+
super(options);
|
|
30
|
+
if (options.name) this.name = options.name;
|
|
31
|
+
if (options.description !== void 0) this.description = options.description;
|
|
32
|
+
if (options.createdAt) this.createdAt = options.createdAt;
|
|
33
|
+
if (options.updatedAt) this.updatedAt = options.updatedAt;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Convenience method for slug-based lookup
|
|
37
|
+
*
|
|
38
|
+
* @param slug - The slug to search for
|
|
39
|
+
* @returns PlaceType instance or null if not found
|
|
40
|
+
*/
|
|
41
|
+
static async getBySlug(_slug) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
__decorateClass([field({ required: true })], PlaceType.prototype, "name", 2);
|
|
46
|
+
PlaceType = __decorateClass([smrt({
|
|
47
|
+
tableStrategy: "sti",
|
|
48
|
+
api: { include: [
|
|
49
|
+
"list",
|
|
50
|
+
"get",
|
|
51
|
+
"create",
|
|
52
|
+
"update",
|
|
53
|
+
"delete"
|
|
54
|
+
] },
|
|
55
|
+
mcp: { include: [
|
|
56
|
+
"list",
|
|
57
|
+
"get",
|
|
58
|
+
"create"
|
|
59
|
+
] },
|
|
60
|
+
cli: true
|
|
61
|
+
})], PlaceType);
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/collections/PlaceTypeCollection.ts
|
|
64
|
+
var PlaceTypeCollection_exports = /* @__PURE__ */ __exportAll({ PlaceTypeCollection: () => PlaceTypeCollection });
|
|
65
|
+
var PlaceTypeCollection = class extends SmrtCollection {
|
|
66
|
+
static _itemClass = PlaceType;
|
|
67
|
+
/**
|
|
68
|
+
* Get or create a place type by slug
|
|
69
|
+
*
|
|
70
|
+
* @param slug - PlaceType slug (e.g., 'city', 'building')
|
|
71
|
+
* @param name - Optional display name (defaults to capitalized slug)
|
|
72
|
+
* @returns PlaceType instance
|
|
73
|
+
*/
|
|
74
|
+
async getOrCreate(slug, name) {
|
|
75
|
+
const existing = await this.get({ slug });
|
|
76
|
+
if (existing) return existing;
|
|
77
|
+
const displayName = name || slug.replace(/-/g, " ").replace(/\b\w/g, (l) => l.toUpperCase());
|
|
78
|
+
return await this.create({
|
|
79
|
+
slug,
|
|
80
|
+
name: displayName
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get a place type by slug
|
|
85
|
+
*
|
|
86
|
+
* @param slug - PlaceType slug to search for
|
|
87
|
+
* @returns PlaceType instance or null if not found
|
|
88
|
+
*/
|
|
89
|
+
async getBySlug(slug) {
|
|
90
|
+
return await this.get({ slug });
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Initialize default place types
|
|
94
|
+
*
|
|
95
|
+
* Creates standard types if they don't exist:
|
|
96
|
+
* - country
|
|
97
|
+
* - region (state/province)
|
|
98
|
+
* - city
|
|
99
|
+
* - address
|
|
100
|
+
* - building
|
|
101
|
+
* - room
|
|
102
|
+
* - zone (for abstract/virtual places)
|
|
103
|
+
*
|
|
104
|
+
* @returns Array of created/existing place types
|
|
105
|
+
*/
|
|
106
|
+
async initializeDefaults() {
|
|
107
|
+
const defaults = [
|
|
108
|
+
{
|
|
109
|
+
slug: "country",
|
|
110
|
+
name: "Country"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
slug: "region",
|
|
114
|
+
name: "Region"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
slug: "city",
|
|
118
|
+
name: "City"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
slug: "address",
|
|
122
|
+
name: "Address"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
slug: "building",
|
|
126
|
+
name: "Building"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
slug: "room",
|
|
130
|
+
name: "Room"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
slug: "zone",
|
|
134
|
+
name: "Zone"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
slug: "point_of_interest",
|
|
138
|
+
name: "Point of Interest"
|
|
139
|
+
}
|
|
140
|
+
];
|
|
141
|
+
const types = [];
|
|
142
|
+
for (const def of defaults) {
|
|
143
|
+
const type = await this.getOrCreate(def.slug, def.name);
|
|
144
|
+
types.push(type);
|
|
145
|
+
}
|
|
146
|
+
return types;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
//#endregion
|
|
150
|
+
export { __exportAll as i, PlaceTypeCollection_exports as n, PlaceType as r, PlaceTypeCollection as t };
|
|
151
|
+
|
|
152
|
+
//# sourceMappingURL=PlaceTypeCollection-zFJu53le.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaceTypeCollection-zFJu53le.js","names":[],"sources":["../../src/models/PlaceType.ts","../../src/collections/PlaceTypeCollection.ts"],"sourcesContent":["/**\n * PlaceType model - Defines types/categories of places\n *\n * Examples: 'country', 'city', 'building', 'zone', 'room', 'region'\n */\n\nimport { field, SmrtObject, smrt } from '@happyvertical/smrt-core';\nimport type { PlaceTypeOptions } from '../types';\n\n@smrt({\n tableStrategy: 'sti',\n api: { include: ['list', 'get', 'create', 'update', 'delete'] },\n mcp: { include: ['list', 'get', 'create'] },\n cli: true,\n})\nexport class PlaceType extends SmrtObject {\n // id and slug are inherited from SmrtObject\n @field({ required: true })\n name: string = ''; // Type name (e.g., 'Town', 'City', 'Country')\n\n description?: string; // Optional description\n\n // Timestamps\n createdAt = new Date();\n updatedAt = new Date();\n\n constructor(options: PlaceTypeOptions = {}) {\n super(options);\n if (options.name) this.name = options.name;\n if (options.description !== undefined)\n this.description = options.description;\n if (options.createdAt) this.createdAt = options.createdAt;\n if (options.updatedAt) this.updatedAt = options.updatedAt;\n }\n\n /**\n * Convenience method for slug-based lookup\n *\n * @param slug - The slug to search for\n * @returns PlaceType instance or null if not found\n */\n static async getBySlug(_slug: string): Promise<PlaceType | null> {\n // Will be auto-implemented by SMRT\n return null;\n }\n}\n","/**\n * PlaceTypeCollection - Collection manager for PlaceType objects\n *\n * Provides simple lookup and creation for place types.\n */\n\nimport { SmrtCollection } from '@happyvertical/smrt-core';\nimport { PlaceType } from '../models/PlaceType';\n\nexport class PlaceTypeCollection extends SmrtCollection<PlaceType> {\n static readonly _itemClass = PlaceType;\n\n /**\n * Get or create a place type by slug\n *\n * @param slug - PlaceType slug (e.g., 'city', 'building')\n * @param name - Optional display name (defaults to capitalized slug)\n * @returns PlaceType instance\n */\n async getOrCreate(slug: string, name?: string): Promise<PlaceType> {\n // First try to find existing type with this slug\n const existing = await this.get({ slug });\n\n if (existing) {\n return existing;\n }\n\n // Create new type with auto-generated name if not provided\n const displayName =\n name || slug.replace(/-/g, ' ').replace(/\\b\\w/g, (l) => l.toUpperCase());\n\n return await this.create({\n slug,\n name: displayName,\n });\n }\n\n /**\n * Get a place type by slug\n *\n * @param slug - PlaceType slug to search for\n * @returns PlaceType instance or null if not found\n */\n async getBySlug(slug: string): Promise<PlaceType | null> {\n return await this.get({ slug });\n }\n\n /**\n * Initialize default place types\n *\n * Creates standard types if they don't exist:\n * - country\n * - region (state/province)\n * - city\n * - address\n * - building\n * - room\n * - zone (for abstract/virtual places)\n *\n * @returns Array of created/existing place types\n */\n async initializeDefaults(): Promise<PlaceType[]> {\n const defaults = [\n { slug: 'country', name: 'Country' },\n { slug: 'region', name: 'Region' },\n { slug: 'city', name: 'City' },\n { slug: 'address', name: 'Address' },\n { slug: 'building', name: 'Building' },\n { slug: 'room', name: 'Room' },\n { slug: 'zone', name: 'Zone' },\n { slug: 'point_of_interest', name: 'Point of Interest' },\n ];\n\n const types: PlaceType[] = [];\n for (const def of defaults) {\n const type = await this.getOrCreate(def.slug, def.name);\n types.push(type);\n }\n\n return types;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAeO,IAAM,YAAN,cAAwB,WAAW;CAGxC,OAAe;CAEf;CAGA,4BAAY,IAAI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