@happyvertical/smrt-profiles 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/ApiKey-3DlNEc91.js +145 -0
- package/dist/chunks/ApiKey-3DlNEc91.js.map +1 -0
- package/dist/chunks/ApiKeyCollection-PwVs0qDb.js +83 -0
- package/dist/chunks/ApiKeyCollection-PwVs0qDb.js.map +1 -0
- package/dist/chunks/AuditLogCollection-CnIYU0aK.js +191 -0
- package/dist/chunks/AuditLogCollection-CnIYU0aK.js.map +1 -0
- package/dist/chunks/NostrIdentityCollection-CG6HGf6c.js +3267 -0
- package/dist/chunks/NostrIdentityCollection-CG6HGf6c.js.map +1 -0
- package/dist/chunks/OidcIdentityCollection-DiLneB7J.js +158 -0
- package/dist/chunks/OidcIdentityCollection-DiLneB7J.js.map +1 -0
- package/dist/chunks/ProfileAssetCollection-BY2Wbem3.js +93 -0
- package/dist/chunks/ProfileAssetCollection-BY2Wbem3.js.map +1 -0
- package/dist/chunks/ProfileCollection-DlhdOnDr.js +641 -0
- package/dist/chunks/ProfileCollection-DlhdOnDr.js.map +1 -0
- package/dist/chunks/ProfileMetadataCollection-CGcO4Iw_.js +105 -0
- package/dist/chunks/ProfileMetadataCollection-CGcO4Iw_.js.map +1 -0
- package/dist/chunks/ProfileMetafieldCollection-C8TX9HvN.js +142 -0
- package/dist/chunks/ProfileMetafieldCollection-C8TX9HvN.js.map +1 -0
- package/dist/chunks/ProfileRelationshipCollection-JnskbZTd.js +159 -0
- package/dist/chunks/ProfileRelationshipCollection-JnskbZTd.js.map +1 -0
- package/dist/chunks/ProfileRelationshipTermCollection-UopP7sja.js +105 -0
- package/dist/chunks/ProfileRelationshipTermCollection-UopP7sja.js.map +1 -0
- package/dist/chunks/ProfileRelationshipType-OMBn5cWR.js +98 -0
- package/dist/chunks/ProfileRelationshipType-OMBn5cWR.js.map +1 -0
- package/dist/chunks/ProfileRelationshipTypeCollection-CQu08kxF.js +54 -0
- package/dist/chunks/ProfileRelationshipTypeCollection-CQu08kxF.js.map +1 -0
- package/dist/index.js +690 -69
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +2 -2
- package/dist/smrt-knowledge.json +9 -9
- package/dist/types.js +0 -2
- package/dist/utils.js +18 -36
- package/dist/utils.js.map +1 -1
- package/package.json +16 -16
- package/dist/chunks/ApiKey-B2LKEaP8.js +0 -143
- package/dist/chunks/ApiKey-B2LKEaP8.js.map +0 -1
- package/dist/chunks/ApiKeyCollection-B6Op817e.js +0 -91
- package/dist/chunks/ApiKeyCollection-B6Op817e.js.map +0 -1
- package/dist/chunks/AuditLogCollection-BYqCj0uE.js +0 -195
- package/dist/chunks/AuditLogCollection-BYqCj0uE.js.map +0 -1
- package/dist/chunks/NostrIdentityCollection-DadQBHWy.js +0 -3065
- package/dist/chunks/NostrIdentityCollection-DadQBHWy.js.map +0 -1
- package/dist/chunks/ProfileAssetCollection-CUM5QfuJ.js +0 -122
- package/dist/chunks/ProfileAssetCollection-CUM5QfuJ.js.map +0 -1
- package/dist/chunks/ProfileCollection-M2PK8bp-.js +0 -800
- package/dist/chunks/ProfileCollection-M2PK8bp-.js.map +0 -1
- package/dist/chunks/ProfileMetadataCollection-DEhmljMY.js +0 -120
- package/dist/chunks/ProfileMetadataCollection-DEhmljMY.js.map +0 -1
- package/dist/chunks/ProfileMetafieldCollection-DMKhSHXX.js +0 -184
- package/dist/chunks/ProfileMetafieldCollection-DMKhSHXX.js.map +0 -1
- package/dist/chunks/ProfileRelationshipCollection-_TsY7MHL.js +0 -189
- package/dist/chunks/ProfileRelationshipCollection-_TsY7MHL.js.map +0 -1
- package/dist/chunks/ProfileRelationshipTermCollection-CXem_qT-.js +0 -117
- package/dist/chunks/ProfileRelationshipTermCollection-CXem_qT-.js.map +0 -1
- package/dist/chunks/ProfileRelationshipType-BXBLldea.js +0 -103
- package/dist/chunks/ProfileRelationshipType-BXBLldea.js.map +0 -1
- package/dist/chunks/ProfileRelationshipTypeCollection-CF8YvLTV.js +0 -48
- package/dist/chunks/ProfileRelationshipTypeCollection-CF8YvLTV.js.map +0 -1
- package/dist/chunks/index-B9lXQy7N.js +0 -1029
- package/dist/chunks/index-B9lXQy7N.js.map +0 -1
- package/dist/types.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileRelationshipCollection-_TsY7MHL.js","sources":["../../src/models/ProfileRelationship.ts","../../src/collections/ProfileRelationshipCollection.ts"],"sourcesContent":["/**\n * ProfileRelationship model - Connects two profiles with a relationship type\n *\n * Represents directional or reciprocal relationships between profiles.\n * Uses UUID primary key with foreign keys to profiles and relationship type.\n */\n\nimport {\n foreignKey,\n oneToMany,\n SmrtObject,\n type SmrtObjectOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\nimport type { ProfileRelationshipTerm } from './ProfileRelationshipTerm';\n\nexport interface ProfileRelationshipOptions extends SmrtObjectOptions {\n fromProfileId?: string;\n toProfileId?: string;\n typeId?: string;\n contextProfileId?: string;\n tenantId?: string | null;\n}\n\n@TenantScoped({ mode: 'optional' })\n@smrt({\n tableStrategy: 'sti',\n api: { include: ['list', 'get', 'create', 'delete'] },\n mcp: { include: ['list', 'get'] },\n cli: true,\n})\nexport class ProfileRelationship extends SmrtObject {\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n // id: UUID (auto-generated by SmrtObject)\n @foreignKey('Profile', { required: true })\n fromProfileId?: string; // Origin profile\n\n @foreignKey('Profile', { required: true })\n toProfileId?: string; // Target profile\n\n @foreignKey('ProfileRelationshipType', { required: true })\n typeId?: string; // Relationship type\n\n @foreignKey('Profile')\n contextProfileId?: string; // Optional tertiary context\n\n // Relationships\n @oneToMany('ProfileRelationshipTerm')\n terms: ProfileRelationshipTerm[] = [];\n\n constructor(options: ProfileRelationshipOptions = {}) {\n super(options);\n if (options.fromProfileId !== undefined)\n this.fromProfileId = options.fromProfileId;\n if (options.toProfileId !== undefined)\n this.toProfileId = options.toProfileId;\n if (options.typeId !== undefined) this.typeId = options.typeId;\n if (options.contextProfileId !== undefined)\n this.contextProfileId = options.contextProfileId;\n }\n\n /**\n * Get the relationship type slug\n *\n * @returns The slug of the relationship type\n */\n async getTypeSlug(): Promise<string> {\n const type = await this.loadRelated('typeId');\n return type?.slug || '';\n }\n\n /**\n * Add a term (time period) to this relationship\n *\n * @param startedAt - Start date of the term\n * @param endedAt - Optional end date of the term\n */\n async addTerm(startedAt: Date, endedAt?: Date): Promise<void> {\n if (!this.id) {\n throw new Error(\n 'ProfileRelationship.addTerm requires a persisted relationship (missing id)',\n );\n }\n const relationshipId = this.id;\n\n const { ProfileRelationshipTermCollection } = await import(\n '../collections/ProfileRelationshipTermCollection'\n );\n\n const termCollection = await ProfileRelationshipTermCollection.create(\n this.options,\n );\n\n const term = await termCollection.create({\n relationshipId,\n startedAt,\n endedAt,\n });\n\n await term.save();\n }\n\n /**\n * End the current active term\n *\n * @param endedAt - End date for the term\n */\n async endCurrentTerm(endedAt: Date): Promise<void> {\n const activeTerm = await this.getActiveTerm();\n if (activeTerm) {\n await activeTerm.end(endedAt);\n }\n }\n\n /**\n * Get all terms for this relationship\n *\n * @returns Array of ProfileRelationshipTerm instances\n */\n async getTerms(): Promise<ProfileRelationshipTerm[]> {\n const { ProfileRelationshipTermCollection } = await import(\n '../collections/ProfileRelationshipTermCollection'\n );\n\n const termCollection = await ProfileRelationshipTermCollection.create(\n this.options,\n );\n\n return await termCollection.getByRelationship(this.id as string);\n }\n\n /**\n * Get the active term (no end date)\n *\n * @returns Current term or null if none active\n */\n async getActiveTerm(): Promise<ProfileRelationshipTerm | null> {\n const { ProfileRelationshipTermCollection } = await import(\n '../collections/ProfileRelationshipTermCollection'\n );\n\n const termCollection = await ProfileRelationshipTermCollection.create(\n this.options,\n );\n\n return await termCollection.getActiveTerm(this.id as string);\n }\n}\n","/**\n * ProfileRelationshipCollection - Collection manager for ProfileRelationship objects\n *\n * Provides querying for relationships between profiles.\n */\n\nimport { SmrtCollection } from '@happyvertical/smrt-core';\nimport { ProfileRelationship } from '../models/ProfileRelationship';\n\nexport class ProfileRelationshipCollection extends SmrtCollection<ProfileRelationship> {\n static readonly _itemClass = ProfileRelationship;\n\n /**\n * Get all relationships from a profile\n *\n * @param fromProfileId - The origin profile UUID\n * @param typeId - Optional filter by relationship type UUID\n * @returns Array of ProfileRelationship instances\n */\n async getFromProfile(\n fromProfileId: string,\n typeId?: string,\n ): Promise<ProfileRelationship[]> {\n const where: Record<string, unknown> = { fromProfileId };\n if (typeId) where.typeId = typeId;\n\n return await this.list({ where });\n }\n\n /**\n * Get all relationships to a profile\n *\n * @param toProfileId - The target profile UUID\n * @param typeId - Optional filter by relationship type UUID\n * @returns Array of ProfileRelationship instances\n */\n async getToProfile(\n toProfileId: string,\n typeId?: string,\n ): Promise<ProfileRelationship[]> {\n const where: Record<string, unknown> = { toProfileId };\n if (typeId) where.typeId = typeId;\n\n return await this.list({ where });\n }\n\n /**\n * Get all relationships for a profile (both directions)\n *\n * @param profileId - The profile UUID\n * @param typeId - Optional filter by relationship type UUID\n * @returns Array of ProfileRelationship instances\n */\n async getForProfile(\n profileId: string,\n typeId?: string,\n ): Promise<ProfileRelationship[]> {\n const fromRelationships = await this.getFromProfile(profileId, typeId);\n const toRelationships = await this.getToProfile(profileId, typeId);\n\n return [...fromRelationships, ...toRelationships];\n }\n\n /**\n * Check if a relationship exists between two profiles\n *\n * @param fromProfileId - The origin profile UUID\n * @param toProfileId - The target profile UUID\n * @param typeId - The relationship type UUID\n * @returns True if relationship exists\n */\n async exists(\n fromProfileId: string,\n toProfileId: string,\n typeId: string,\n ): Promise<boolean> {\n const matches = await this.list({\n where: { fromProfileId, toProfileId, typeId },\n limit: 1,\n });\n\n return matches.length > 0;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAgCO,IAAM,sBAAN,cAAkC,WAAW;AAAA,EAElD,WAA0B;AAAA,EAI1B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F,OAAgB,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAS7B,MAAM,eACJ,eACA,QACgC;AAChC,UAAM,QAAiC,EAAE,cAAA;AACzC,QAAI,cAAc,SAAS;AAE3B,WAAO,MAAM,KAAK,KAAK,EAAE,OAAO;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,aACJ,aACA,QACgC;AAChC,UAAM,QAAiC,EAAE,YAAA;AACzC,QAAI,cAAc,SAAS;AAE3B,WAAO,MAAM,KAAK,KAAK,EAAE,OAAO;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,cACJ,WACA,QACgC;AAChC,UAAM,oBAAoB,MAAM,KAAK,eAAe,WAAW,MAAM;AACrE,UAAM,kBAAkB,MAAM,KAAK,aAAa,WAAW,MAAM;AAEjE,WAAO,CAAC,GAAG,mBAAmB,GAAG,eAAe;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,MAAM,OACJ,eACA,aACA,QACkB;AAClB,UAAM,UAAU,MAAM,KAAK,KAAK;AAAA,MAC9B,OAAO,EAAE,eAAe,aAAa,OAAA;AAAA,MACrC,OAAO;AAAA,IAAA,CACR;AAED,WAAO,QAAQ,SAAS;AAAA,EAC1B;AACF;;;;;"}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { foreignKey, field, smrt, SmrtObject, SmrtCollection } from "@happyvertical/smrt-core";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
5
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
6
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7
|
-
if (decorator = decorators[i])
|
|
8
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
9
|
-
if (kind && result) __defProp(target, key, result);
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
let ProfileRelationshipTerm = class extends SmrtObject {
|
|
13
|
-
relationshipId;
|
|
14
|
-
startedAt = /* @__PURE__ */ new Date();
|
|
15
|
-
// Start date of the term
|
|
16
|
-
endedAt;
|
|
17
|
-
// Optional end date
|
|
18
|
-
constructor(options = {}) {
|
|
19
|
-
super(options);
|
|
20
|
-
if (options.relationshipId !== void 0)
|
|
21
|
-
this.relationshipId = options.relationshipId;
|
|
22
|
-
if (options.startedAt) this.startedAt = options.startedAt;
|
|
23
|
-
if (options.endedAt !== void 0) this.endedAt = options.endedAt;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Check if this term is currently active
|
|
27
|
-
*
|
|
28
|
-
* @returns True if active (no end date or end date in future)
|
|
29
|
-
*/
|
|
30
|
-
isActive() {
|
|
31
|
-
if (!this.endedAt) return true;
|
|
32
|
-
return this.endedAt > /* @__PURE__ */ new Date();
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* End this term
|
|
36
|
-
*
|
|
37
|
-
* @param endedAt - End date for the term (defaults to now)
|
|
38
|
-
*/
|
|
39
|
-
async end(endedAt = /* @__PURE__ */ new Date()) {
|
|
40
|
-
this.endedAt = endedAt;
|
|
41
|
-
await this.save();
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Get the duration of this term in days
|
|
45
|
-
*
|
|
46
|
-
* @returns Duration in days
|
|
47
|
-
*/
|
|
48
|
-
getDurationDays() {
|
|
49
|
-
const endValue = this.endedAt || /* @__PURE__ */ new Date();
|
|
50
|
-
const diffMs = endValue.getTime() - this.startedAt.getTime();
|
|
51
|
-
return Math.floor(diffMs / (1e3 * 60 * 60 * 24));
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
__decorateClass([
|
|
55
|
-
foreignKey("ProfileRelationship", { required: true })
|
|
56
|
-
], ProfileRelationshipTerm.prototype, "relationshipId", 2);
|
|
57
|
-
__decorateClass([
|
|
58
|
-
field({ required: true })
|
|
59
|
-
], ProfileRelationshipTerm.prototype, "startedAt", 2);
|
|
60
|
-
ProfileRelationshipTerm = __decorateClass([
|
|
61
|
-
smrt({
|
|
62
|
-
tableStrategy: "sti",
|
|
63
|
-
api: { include: ["list", "get", "create", "update", "delete"] },
|
|
64
|
-
mcp: { include: ["list", "get"] },
|
|
65
|
-
cli: true
|
|
66
|
-
})
|
|
67
|
-
], ProfileRelationshipTerm);
|
|
68
|
-
class ProfileRelationshipTermCollection extends SmrtCollection {
|
|
69
|
-
static _itemClass = ProfileRelationshipTerm;
|
|
70
|
-
/**
|
|
71
|
-
* Get all terms for a relationship
|
|
72
|
-
*
|
|
73
|
-
* @param relationshipId - The relationship UUID
|
|
74
|
-
* @returns Array of ProfileRelationshipTerm instances
|
|
75
|
-
*/
|
|
76
|
-
async getByRelationship(relationshipId) {
|
|
77
|
-
return await this.list({
|
|
78
|
-
where: { relationshipId },
|
|
79
|
-
orderBy: ["startedAt DESC"]
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Get the active term for a relationship (no end date or future end date)
|
|
84
|
-
*
|
|
85
|
-
* @param relationshipId - The relationship UUID
|
|
86
|
-
* @returns Active term or null
|
|
87
|
-
*/
|
|
88
|
-
async getActiveTerm(relationshipId) {
|
|
89
|
-
const terms = await this.getByRelationship(relationshipId);
|
|
90
|
-
for (const term of terms) {
|
|
91
|
-
if (term.isActive()) {
|
|
92
|
-
return term;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Get all historical (ended) terms for a relationship
|
|
99
|
-
*
|
|
100
|
-
* @param relationshipId - The relationship UUID
|
|
101
|
-
* @returns Array of ended ProfileRelationshipTerm instances
|
|
102
|
-
*/
|
|
103
|
-
async getHistoricalTerms(relationshipId) {
|
|
104
|
-
const terms = await this.getByRelationship(relationshipId);
|
|
105
|
-
return terms.filter((term) => !term.isActive());
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
const ProfileRelationshipTermCollection$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
109
|
-
__proto__: null,
|
|
110
|
-
ProfileRelationshipTermCollection
|
|
111
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
112
|
-
export {
|
|
113
|
-
ProfileRelationshipTerm as P,
|
|
114
|
-
ProfileRelationshipTermCollection as a,
|
|
115
|
-
ProfileRelationshipTermCollection$1 as b
|
|
116
|
-
};
|
|
117
|
-
//# sourceMappingURL=ProfileRelationshipTermCollection-CXem_qT-.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileRelationshipTermCollection-CXem_qT-.js","sources":["../../src/models/ProfileRelationshipTerm.ts","../../src/collections/ProfileRelationshipTermCollection.ts"],"sourcesContent":["/**\n * ProfileRelationshipTerm model - Temporal data for relationships\n *\n * Defines the duration or terms of a specific relationship.\n * Uses UUID primary key with foreign key to ProfileRelationship.\n */\n\nimport {\n field,\n foreignKey,\n SmrtObject,\n type SmrtObjectOptions,\n smrt,\n} from '@happyvertical/smrt-core';\n\nexport interface ProfileRelationshipTermOptions extends SmrtObjectOptions {\n relationshipId?: string;\n startedAt?: Date;\n endedAt?: Date;\n}\n\n@smrt({\n tableStrategy: 'sti',\n api: { include: ['list', 'get', 'create', 'update', 'delete'] },\n mcp: { include: ['list', 'get'] },\n cli: true,\n})\nexport class ProfileRelationshipTerm extends SmrtObject {\n // id: UUID (auto-generated by SmrtObject)\n @foreignKey('ProfileRelationship', { required: true })\n relationshipId?: string; // References ProfileRelationship.id\n\n @field({ required: true })\n startedAt: Date = new Date(); // Start date of the term\n\n endedAt?: Date; // Optional end date\n\n constructor(options: ProfileRelationshipTermOptions = {}) {\n super(options);\n if (options.relationshipId !== undefined)\n this.relationshipId = options.relationshipId;\n if (options.startedAt) this.startedAt = options.startedAt;\n if (options.endedAt !== undefined) this.endedAt = options.endedAt;\n }\n\n /**\n * Check if this term is currently active\n *\n * @returns True if active (no end date or end date in future)\n */\n isActive(): boolean {\n if (!this.endedAt) return true;\n return this.endedAt > new Date();\n }\n\n /**\n * End this term\n *\n * @param endedAt - End date for the term (defaults to now)\n */\n async end(endedAt: Date = new Date()): Promise<void> {\n this.endedAt = endedAt;\n await this.save();\n }\n\n /**\n * Get the duration of this term in days\n *\n * @returns Duration in days\n */\n getDurationDays(): number {\n const endValue = this.endedAt || new Date();\n const diffMs = endValue.getTime() - this.startedAt.getTime();\n return Math.floor(diffMs / (1000 * 60 * 60 * 24));\n }\n}\n","/**\n * ProfileRelationshipTermCollection - Collection manager for ProfileRelationshipTerm objects\n *\n * Provides querying for relationship terms (temporal data).\n */\n\nimport { SmrtCollection } from '@happyvertical/smrt-core';\nimport { ProfileRelationshipTerm } from '../models/ProfileRelationshipTerm';\n\nexport class ProfileRelationshipTermCollection extends SmrtCollection<ProfileRelationshipTerm> {\n static readonly _itemClass = ProfileRelationshipTerm;\n\n /**\n * Get all terms for a relationship\n *\n * @param relationshipId - The relationship UUID\n * @returns Array of ProfileRelationshipTerm instances\n */\n async getByRelationship(\n relationshipId: string,\n ): Promise<ProfileRelationshipTerm[]> {\n return await this.list({\n where: { relationshipId },\n orderBy: ['startedAt DESC'],\n });\n }\n\n /**\n * Get the active term for a relationship (no end date or future end date)\n *\n * @param relationshipId - The relationship UUID\n * @returns Active term or null\n */\n async getActiveTerm(\n relationshipId: string,\n ): Promise<ProfileRelationshipTerm | null> {\n const terms = await this.getByRelationship(relationshipId);\n\n for (const term of terms) {\n if (term.isActive()) {\n return term;\n }\n }\n\n return null;\n }\n\n /**\n * Get all historical (ended) terms for a relationship\n *\n * @param relationshipId - The relationship UUID\n * @returns Array of ended ProfileRelationshipTerm instances\n */\n async getHistoricalTerms(\n relationshipId: string,\n ): Promise<ProfileRelationshipTerm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,CAAC,QAAQ,KAAK,EAAA;AAAA,IAC9B,KAAK;AAAA,EAAA,CACN;AAAA,GACY,uBAAA;AClBN,MAAM,0CAA0C,eAAwC;AAAA,EAC7F,OAAgB,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,MAAM,kBACJ,gBACoC;AACpC,WAAO,MAAM,KAAK,KAAK;AAAA,MACrB,OAAO,EAAE,eAAA;AAAA,MACT,SAAS,CAAC,gBAAgB;AAAA,IAAA,CAC3B;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,cACJ,gBACyC;AACzC,UAAM,QAAQ,MAAM,KAAK,kBAAkB,cAAc;AAEzD,eAAW,QAAQ,OAAO;AACxB,UAAI,KAAK,YAAY;AACnB,eAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,mBACJ,gBACoC;AACpC,UAAM,QAAQ,MAAM,KAAK,kBAAkB,cAAc;AACzD,WAAO,MAAM,OAAO,CAAC,SAAS,CAAC,KAAK,UAAU;AAAA,EAChD;AACF;;;;;"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { field, smrt, SmrtObject } from "@happyvertical/smrt-core";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
5
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
6
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7
|
-
if (decorator = decorators[i])
|
|
8
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
9
|
-
if (kind && result) __defProp(target, key, result);
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
function getReciprocalHandlers() {
|
|
13
|
-
if (!globalThis.__smrtProfileRelationshipHandlers) {
|
|
14
|
-
globalThis.__smrtProfileRelationshipHandlers = /* @__PURE__ */ new Map();
|
|
15
|
-
}
|
|
16
|
-
return globalThis.__smrtProfileRelationshipHandlers;
|
|
17
|
-
}
|
|
18
|
-
const DEFAULT_HANDLERS = {
|
|
19
|
-
// Symmetric relationships (same type in both directions)
|
|
20
|
-
friend: async (from, to, context) => {
|
|
21
|
-
await to.addRelationship(from, "friend", context);
|
|
22
|
-
},
|
|
23
|
-
spouse: async (from, to) => {
|
|
24
|
-
await to.addRelationship(from, "spouse");
|
|
25
|
-
},
|
|
26
|
-
partner: async (from, to, context) => {
|
|
27
|
-
await to.addRelationship(from, "partner", context);
|
|
28
|
-
},
|
|
29
|
-
colleague: async (from, to, context) => {
|
|
30
|
-
await to.addRelationship(from, "colleague", context);
|
|
31
|
-
},
|
|
32
|
-
sibling: async (from, to) => {
|
|
33
|
-
await to.addRelationship(from, "sibling");
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
if (!globalThis.__smrtProfileRelationshipHandlersInitialized) {
|
|
37
|
-
globalThis.__smrtProfileRelationshipHandlersInitialized = true;
|
|
38
|
-
for (const [slug, handler] of Object.entries(DEFAULT_HANDLERS)) {
|
|
39
|
-
getReciprocalHandlers().set(slug, handler);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
let ProfileRelationshipType = class extends SmrtObject {
|
|
43
|
-
name = "";
|
|
44
|
-
reciprocal = true;
|
|
45
|
-
// True for two-way relationships
|
|
46
|
-
constructor(options = {}) {
|
|
47
|
-
super(options);
|
|
48
|
-
if (options.name) this.name = options.name;
|
|
49
|
-
if (options.reciprocal !== void 0) this.reciprocal = options.reciprocal;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Convenience method for slug-based lookup
|
|
53
|
-
*
|
|
54
|
-
* @param slug - The slug to search for
|
|
55
|
-
* @returns ProfileRelationshipType instance or null if not found
|
|
56
|
-
*/
|
|
57
|
-
static async getBySlug(_slug) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Register a custom reciprocal handler for a relationship type
|
|
62
|
-
*
|
|
63
|
-
* @param slug - The relationship type slug
|
|
64
|
-
* @param handler - The handler function to execute when creating reciprocal relationship
|
|
65
|
-
*/
|
|
66
|
-
static registerReciprocalHandler(slug, handler) {
|
|
67
|
-
getReciprocalHandlers().set(slug, handler);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Get the reciprocal handler for a relationship type
|
|
71
|
-
*
|
|
72
|
-
* @param slug - The relationship type slug
|
|
73
|
-
* @returns The handler function or undefined
|
|
74
|
-
*/
|
|
75
|
-
static getReciprocalHandler(slug) {
|
|
76
|
-
return getReciprocalHandlers().get(slug);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Check if a relationship type is reciprocal
|
|
80
|
-
*
|
|
81
|
-
* @param slug - The relationship type slug
|
|
82
|
-
* @returns True if reciprocal, false otherwise
|
|
83
|
-
*/
|
|
84
|
-
static async isReciprocal(slug) {
|
|
85
|
-
const type = await ProfileRelationshipType.getBySlug(slug);
|
|
86
|
-
return type?.reciprocal || false;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
__decorateClass([
|
|
90
|
-
field({ required: true })
|
|
91
|
-
], ProfileRelationshipType.prototype, "name", 2);
|
|
92
|
-
ProfileRelationshipType = __decorateClass([
|
|
93
|
-
smrt({
|
|
94
|
-
tableStrategy: "sti",
|
|
95
|
-
api: { include: ["list", "get", "create", "update"] },
|
|
96
|
-
mcp: { include: ["list", "get"] },
|
|
97
|
-
cli: true
|
|
98
|
-
})
|
|
99
|
-
], ProfileRelationshipType);
|
|
100
|
-
export {
|
|
101
|
-
ProfileRelationshipType
|
|
102
|
-
};
|
|
103
|
-
//# sourceMappingURL=ProfileRelationshipType-BXBLldea.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileRelationshipType-BXBLldea.js","sources":["../../src/models/ProfileRelationshipType.ts"],"sourcesContent":["/**\n * ProfileRelationshipType model - Lookup table for relationship types\n *\n * Defines the kinds of relationships that can exist between profiles.\n * Uses UUID primary key with unique slug for human-readable lookups.\n */\n\nimport {\n field,\n SmrtObject,\n type SmrtObjectOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport type { ReciprocalHandler } from '../types';\n\nexport interface ProfileRelationshipTypeOptions extends SmrtObjectOptions {\n slug?: string;\n name?: string;\n reciprocal?: boolean;\n}\n\n/**\n * Extend globalThis to include reciprocal handlers registry.\n * Using globalThis ensures all module instances share the same handlers,\n * which is critical in monorepos where the same package can be loaded\n * from different paths (e.g., pnpm store vs workspace symlink).\n *\n * @see https://github.com/happyvertical/smrt/issues/543\n */\ndeclare global {\n // eslint-disable-next-line no-var\n var __smrtProfileRelationshipHandlers:\n | Map<string, ReciprocalHandler>\n | undefined;\n // eslint-disable-next-line no-var\n var __smrtProfileRelationshipHandlersInitialized: boolean | undefined;\n}\n\n/**\n * Get the reciprocal handlers Map from globalThis\n */\nfunction getReciprocalHandlers(): Map<string, ReciprocalHandler> {\n if (!globalThis.__smrtProfileRelationshipHandlers) {\n globalThis.__smrtProfileRelationshipHandlers = new Map<\n string,\n ReciprocalHandler\n >();\n }\n return globalThis.__smrtProfileRelationshipHandlers;\n}\n\n/**\n * Default handlers for common reciprocal relationship patterns\n */\nconst DEFAULT_HANDLERS: Record<string, ReciprocalHandler> = {\n // Symmetric relationships (same type in both directions)\n friend: async (from, to, context) => {\n await to.addRelationship(from, 'friend', context);\n },\n\n spouse: async (from, to) => {\n await to.addRelationship(from, 'spouse');\n },\n\n partner: async (from, to, context) => {\n await to.addRelationship(from, 'partner', context);\n },\n\n colleague: async (from, to, context) => {\n await to.addRelationship(from, 'colleague', context);\n },\n\n sibling: async (from, to) => {\n await to.addRelationship(from, 'sibling');\n },\n};\n\n// Register default handlers (only once across all module instances)\nif (!globalThis.__smrtProfileRelationshipHandlersInitialized) {\n globalThis.__smrtProfileRelationshipHandlersInitialized = true;\n for (const [slug, handler] of Object.entries(DEFAULT_HANDLERS)) {\n getReciprocalHandlers().set(slug, handler);\n }\n}\n\n@smrt({\n tableStrategy: 'sti',\n api: { include: ['list', 'get', 'create', 'update'] },\n mcp: { include: ['list', 'get'] },\n cli: true,\n})\nexport class ProfileRelationshipType extends SmrtObject {\n // id: UUID (auto-generated by SmrtObject)\n // slug is inherited from SmrtObject (auto-generated from name)\n @field({ required: true })\n name: string = '';\n\n reciprocal: boolean = true; // True for two-way relationships\n\n constructor(options: ProfileRelationshipTypeOptions = {}) {\n super(options);\n if (options.name) this.name = options.name;\n if (options.reciprocal !== undefined) this.reciprocal = options.reciprocal;\n }\n\n /**\n * Convenience method for slug-based lookup\n *\n * @param slug - The slug to search for\n * @returns ProfileRelationshipType instance or null if not found\n */\n static async getBySlug(\n _slug: string,\n ): Promise<ProfileRelationshipType | null> {\n // Will be auto-implemented by SMRT\n return null;\n }\n\n /**\n * Register a custom reciprocal handler for a relationship type\n *\n * @param slug - The relationship type slug\n * @param handler - The handler function to execute when creating reciprocal relationship\n */\n static registerReciprocalHandler(\n slug: string,\n handler: ReciprocalHandler,\n ): void {\n getReciprocalHandlers().set(slug, handler);\n }\n\n /**\n * Get the reciprocal handler for a relationship type\n *\n * @param slug - The relationship type slug\n * @returns The handler function or undefined\n */\n static getReciprocalHandler(slug: string): ReciprocalHandler | undefined {\n return getReciprocalHandlers().get(slug);\n }\n\n /**\n * Check if a relationship type is reciprocal\n *\n * @param slug - The relationship type slug\n * @returns True if reciprocal, false otherwise\n */\n static async isReciprocal(slug: string): Promise<boolean> {\n const type = await ProfileRelationshipType.getBySlug(slug);\n return type?.reciprocal || false;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAyCA,SAAS,wBAAwD;AAC/D,MAAI,CAAC,WAAW,mCAAmC;AACjD,eAAW,wDAAwC,IAAA;AAAA,EAIrD;AACA,SAAO,WAAW;AACpB;AAKA,MAAM,mBAAsD;A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AAAA;AAAA;AAAA;AAAA,EAQA,aAAa,aAAa,MAAgC;AACxD,UAAM,OAAO,MAAM,wBAAwB,UAAU,IAAI;AACzD,WAAO,MAAM,cAAc;AAAA,EAC7B;AACF;AAxDE,gBAAA;AAAA,EADC,MAAM,EAAE,UAAU,KAAA,CAAM;AAAA,GAHd,wBAIX,WAAA,QAAA,CAAA;AAJW,0BAAN,gBAAA;AAAA,EANN,KAAK;AAAA,IACJ,eAAe;AAAA,IACf,KAAK,EAAE,SAAS,CAAC,QAAQ,OAAO,UAAU,QAAQ,EAAA;AAAA,IAClD,KAAK,EAAE,SAAS,CAAC,QAAQ,KAAK,EAAA;AAAA,IAC9B,KAAK;AAAA,EAAA,CACN;AAAA,GACY,uBAAA;"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { SmrtCollection } from "@happyvertical/smrt-core";
|
|
2
|
-
import { ProfileRelationshipType } from "./ProfileRelationshipType-BXBLldea.js";
|
|
3
|
-
class ProfileRelationshipTypeCollection extends SmrtCollection {
|
|
4
|
-
static _itemClass = ProfileRelationshipType;
|
|
5
|
-
/**
|
|
6
|
-
* Get relationship type by slug
|
|
7
|
-
*
|
|
8
|
-
* @param slug - The slug to search for
|
|
9
|
-
* @returns ProfileRelationshipType instance or null
|
|
10
|
-
*/
|
|
11
|
-
async getBySlug(slug) {
|
|
12
|
-
return await this.get({ slug });
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Get or create a relationship type by slug
|
|
16
|
-
*
|
|
17
|
-
* @param slug - The slug to search for
|
|
18
|
-
* @param defaults - Default values if creating
|
|
19
|
-
* @returns ProfileRelationshipType instance
|
|
20
|
-
*/
|
|
21
|
-
async getOrCreateBySlug(slug, defaults) {
|
|
22
|
-
const existing = await this.getBySlug(slug);
|
|
23
|
-
if (existing) return existing;
|
|
24
|
-
const relationshipType = await this.create({ slug, ...defaults });
|
|
25
|
-
await relationshipType.save();
|
|
26
|
-
return relationshipType;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Get all reciprocal relationship types
|
|
30
|
-
*
|
|
31
|
-
* @returns Array of reciprocal ProfileRelationshipType instances
|
|
32
|
-
*/
|
|
33
|
-
async getReciprocal() {
|
|
34
|
-
return await this.list({ where: { reciprocal: true } });
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Get all directional (non-reciprocal) relationship types
|
|
38
|
-
*
|
|
39
|
-
* @returns Array of directional ProfileRelationshipType instances
|
|
40
|
-
*/
|
|
41
|
-
async getDirectional() {
|
|
42
|
-
return await this.list({ where: { reciprocal: false } });
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export {
|
|
46
|
-
ProfileRelationshipTypeCollection
|
|
47
|
-
};
|
|
48
|
-
//# sourceMappingURL=ProfileRelationshipTypeCollection-CF8YvLTV.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProfileRelationshipTypeCollection-CF8YvLTV.js","sources":["../../src/collections/ProfileRelationshipTypeCollection.ts"],"sourcesContent":["/**\n * ProfileRelationshipTypeCollection - Collection manager for ProfileRelationshipType objects\n *\n * Provides querying for relationship type lookup table.\n */\n\nimport { SmrtCollection } from '@happyvertical/smrt-core';\nimport { ProfileRelationshipType } from '../models/ProfileRelationshipType';\n\nexport class ProfileRelationshipTypeCollection extends SmrtCollection<ProfileRelationshipType> {\n static readonly _itemClass = ProfileRelationshipType;\n\n /**\n * Get relationship type by slug\n *\n * @param slug - The slug to search for\n * @returns ProfileRelationshipType instance or null\n */\n async getBySlug(slug: string): Promise<ProfileRelationshipType | null> {\n return await this.get({ slug });\n }\n\n /**\n * Get or create a relationship type by slug\n *\n * @param slug - The slug to search for\n * @param defaults - Default values if creating\n * @returns ProfileRelationshipType instance\n */\n async getOrCreateBySlug(\n slug: string,\n defaults: { name: string; reciprocal?: boolean },\n ): Promise<ProfileRelationshipType> {\n const existing = await this.getBySlug(slug);\n if (existing) return existing;\n\n const relationshipType = await this.create({ slug, ...defaults });\n await relationshipType.save();\n return relationshipType;\n }\n\n /**\n * Get all reciprocal relationship types\n *\n * @returns Array of reciprocal ProfileRelationshipType instances\n */\n async getReciprocal(): Promise<ProfileRelationshipType[]> {\n return await this.list({ where: { reciprocal: true } });\n }\n\n /**\n * Get all directional (non-reciprocal) relationship types\n *\n * @returns Array of directional ProfileRelationshipType instances\n */\n async getDirectional(): Promise<ProfileRelationshipType[]> {\n return await this.list({ where: { reciprocal: false } });\n }\n}\n"],"names":[],"mappings":";;AASO,MAAM,0CAA0C,eAAwC;AAAA,EAC7F,OAAgB,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7B,MAAM,UAAU,MAAuD;AACrE,WAAO,MAAM,KAAK,IAAI,EAAE,MAAM;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,kBACJ,MACA,UACkC;AAClC,UAAM,WAAW,MAAM,KAAK,UAAU,IAAI;AAC1C,QAAI,SAAU,QAAO;AAErB,UAAM,mBAAmB,MAAM,KAAK,OAAO,EAAE,MAAM,GAAG,UAAU;AAChE,UAAM,iBAAiB,KAAA;AACvB,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,gBAAoD;AACxD,WAAO,MAAM,KAAK,KAAK,EAAE,OAAO,EAAE,YAAY,KAAA,GAAQ;AAAA,EACxD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,iBAAqD;AACzD,WAAO,MAAM,KAAK,KAAK,EAAE,OAAO,EAAE,YAAY,MAAA,GAAS;AAAA,EACzD;AACF;"}
|