@happyvertical/smrt-profiles 0.30.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.
Files changed (42) hide show
  1. package/AGENTS.md +53 -0
  2. package/CLAUDE.md +1 -0
  3. package/LICENSE +7 -0
  4. package/README.md +176 -0
  5. package/dist/chunks/ApiKey-B2LKEaP8.js +143 -0
  6. package/dist/chunks/ApiKey-B2LKEaP8.js.map +1 -0
  7. package/dist/chunks/ApiKeyCollection-B6Op817e.js +91 -0
  8. package/dist/chunks/ApiKeyCollection-B6Op817e.js.map +1 -0
  9. package/dist/chunks/AuditLogCollection-BYqCj0uE.js +195 -0
  10. package/dist/chunks/AuditLogCollection-BYqCj0uE.js.map +1 -0
  11. package/dist/chunks/NostrIdentityCollection-DadQBHWy.js +3065 -0
  12. package/dist/chunks/NostrIdentityCollection-DadQBHWy.js.map +1 -0
  13. package/dist/chunks/ProfileAssetCollection-D_tk1kKG.js +122 -0
  14. package/dist/chunks/ProfileAssetCollection-D_tk1kKG.js.map +1 -0
  15. package/dist/chunks/ProfileCollection-DU6wUJTO.js +782 -0
  16. package/dist/chunks/ProfileCollection-DU6wUJTO.js.map +1 -0
  17. package/dist/chunks/ProfileMetadataCollection-DEhmljMY.js +120 -0
  18. package/dist/chunks/ProfileMetadataCollection-DEhmljMY.js.map +1 -0
  19. package/dist/chunks/ProfileMetafieldCollection-DMKhSHXX.js +184 -0
  20. package/dist/chunks/ProfileMetafieldCollection-DMKhSHXX.js.map +1 -0
  21. package/dist/chunks/ProfileRelationshipCollection-C0IM8UQR.js +177 -0
  22. package/dist/chunks/ProfileRelationshipCollection-C0IM8UQR.js.map +1 -0
  23. package/dist/chunks/ProfileRelationshipTermCollection-CXem_qT-.js +117 -0
  24. package/dist/chunks/ProfileRelationshipTermCollection-CXem_qT-.js.map +1 -0
  25. package/dist/chunks/ProfileRelationshipType-BXBLldea.js +103 -0
  26. package/dist/chunks/ProfileRelationshipType-BXBLldea.js.map +1 -0
  27. package/dist/chunks/ProfileRelationshipTypeCollection-CF8YvLTV.js +48 -0
  28. package/dist/chunks/ProfileRelationshipTypeCollection-CF8YvLTV.js.map +1 -0
  29. package/dist/chunks/index-jFtOWsAV.js +1014 -0
  30. package/dist/chunks/index-jFtOWsAV.js.map +1 -0
  31. package/dist/index.d.ts +1848 -0
  32. package/dist/index.js +70 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/manifest.json +11829 -0
  35. package/dist/smrt-knowledge.json +3846 -0
  36. package/dist/types.d.ts +41 -0
  37. package/dist/types.js +2 -0
  38. package/dist/types.js.map +1 -0
  39. package/dist/utils.d.ts +61 -0
  40. package/dist/utils.js +49 -0
  41. package/dist/utils.js.map +1 -0
  42. package/package.json +75 -0
@@ -0,0 +1,117 @@
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
@@ -0,0 +1 @@
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[]> {\n const terms = await this.getByRelationship(relationshipId);\n return terms.filter((term) => !term.isActive());\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;AA2BO,IAAM,0BAAN,cAAsC,WAAW;AAAA,EAGtD;AAAA,EAGA,gCAAsB,KAAA;AAAA;AAAA,EAEtB;AAAA;AAAA,EAEA,YAAY,UAA0C,IAAI;AACxD,UAAM,OAAO;AACb,QAAI,QAAQ,mBAAmB;AAC7B,WAAK,iBAAiB,QAAQ;AAChC,QAAI,QAAQ,UAAW,MAAK,YAAY,QAAQ;AAChD,QAAI,QAAQ,YAAY,OAAW,MAAK,UAAU,QAAQ;AAAA,EAC5D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,WAAoB;AAClB,QAAI,CAAC,KAAK,QAAS,QAAO;AAC1B,WAAO,KAAK,UAAU,oBAAI,KAAA;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,IAAI,UAAgB,oBAAI,QAAuB;AACnD,SAAK,UAAU;AACf,UAAM,KAAK,KAAA;AAAA,EACb;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,kBAA0B;AACxB,UAAM,WAAW,KAAK,WAAW,oBAAI,KAAA;AACrC,UAAM,SAAS,SAAS,QAAA,IAAY,KAAK,UAAU,QAAA;AACnD,WAAO,KAAK,MAAM,UAAU,MAAO,KAAK,KAAK,GAAG;AAAA,EAClD;AACF;AA7CE,gBAAA;AAAA,EADC,WAAW,uBAAuB,EAAE,UAAU,MAAM;AAAA,GAF1C,wBAGX,WAAA,kBAAA,CAAA;AAGA,gBAAA;AAAA,EADC,MAAM,EAAE,UAAU,KAAA,CAAM;AAAA,GALd,wBAMX,WAAA,aAAA,CAAA;AANW,0BAAN,gBAAA;AAAA,EANN,KAAK;AAAA,IACJ,eAAe;AAAA,IACf,KAAK,EAAE,SAAS,CAAC,QAAQ,OAAO,UAAU,UAAU,QAAQ,EAAA;AAAA,IAC5D,KAAK,EAAE,SAAS,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;;;;;"}
@@ -0,0 +1,103 @@
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
@@ -0,0 +1 @@
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;AAAA;AAAA,EAE1D,QAAQ,OAAO,MAAM,IAAI,YAAY;AACnC,UAAM,GAAG,gBAAgB,MAAM,UAAU,OAAO;AAAA,EAClD;AAAA,EAEA,QAAQ,OAAO,MAAM,OAAO;AAC1B,UAAM,GAAG,gBAAgB,MAAM,QAAQ;AAAA,EACzC;AAAA,EAEA,SAAS,OAAO,MAAM,IAAI,YAAY;AACpC,UAAM,GAAG,gBAAgB,MAAM,WAAW,OAAO;AAAA,EACnD;AAAA,EAEA,WAAW,OAAO,MAAM,IAAI,YAAY;AACtC,UAAM,GAAG,gBAAgB,MAAM,aAAa,OAAO;AAAA,EACrD;AAAA,EAEA,SAAS,OAAO,MAAM,OAAO;AAC3B,UAAM,GAAG,gBAAgB,MAAM,SAAS;AAAA,EAC1C;AACF;AAGA,IAAI,CAAC,WAAW,8CAA8C;AAC5D,aAAW,+CAA+C;AAC1D,aAAW,CAAC,MAAM,OAAO,KAAK,OAAO,QAAQ,gBAAgB,GAAG;AAC9D,4BAAwB,IAAI,MAAM,OAAO;AAAA,EAC3C;AACF;AAQO,IAAM,0BAAN,cAAsC,WAAW;AAAA,EAItD,OAAe;AAAA,EAEf,aAAsB;AAAA;AAAA,EAEtB,YAAY,UAA0C,IAAI;AACxD,UAAM,OAAO;AACb,QAAI,QAAQ,KAAM,MAAK,OAAO,QAAQ;AACtC,QAAI,QAAQ,eAAe,OAAW,MAAK,aAAa,QAAQ;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,aAAa,UACX,OACyC;AAEzC,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,0BACL,MACA,SACM;AACN,4BAAwB,IAAI,MAAM,OAAO;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,qBAAqB,MAA6C;AACvE,WAAO,sBAAA,EAAwB,IAAI,IAAI;AAAA,EACzC;AAAA;AAAA;AAAA;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;"}
@@ -0,0 +1,48 @@
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
@@ -0,0 +1 @@
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;"}