@happyvertical/smrt-profiles 0.37.2 → 0.37.4

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 (61) hide show
  1. package/dist/chunks/ApiKey-3DlNEc91.js +145 -0
  2. package/dist/chunks/ApiKey-3DlNEc91.js.map +1 -0
  3. package/dist/chunks/ApiKeyCollection-PwVs0qDb.js +83 -0
  4. package/dist/chunks/ApiKeyCollection-PwVs0qDb.js.map +1 -0
  5. package/dist/chunks/AuditLogCollection-CnIYU0aK.js +191 -0
  6. package/dist/chunks/AuditLogCollection-CnIYU0aK.js.map +1 -0
  7. package/dist/chunks/NostrIdentityCollection-CG6HGf6c.js +3267 -0
  8. package/dist/chunks/NostrIdentityCollection-CG6HGf6c.js.map +1 -0
  9. package/dist/chunks/OidcIdentityCollection-DiLneB7J.js +158 -0
  10. package/dist/chunks/OidcIdentityCollection-DiLneB7J.js.map +1 -0
  11. package/dist/chunks/ProfileAssetCollection-BY2Wbem3.js +93 -0
  12. package/dist/chunks/ProfileAssetCollection-BY2Wbem3.js.map +1 -0
  13. package/dist/chunks/ProfileCollection-DlhdOnDr.js +641 -0
  14. package/dist/chunks/ProfileCollection-DlhdOnDr.js.map +1 -0
  15. package/dist/chunks/ProfileMetadataCollection-CGcO4Iw_.js +105 -0
  16. package/dist/chunks/ProfileMetadataCollection-CGcO4Iw_.js.map +1 -0
  17. package/dist/chunks/ProfileMetafieldCollection-C8TX9HvN.js +142 -0
  18. package/dist/chunks/ProfileMetafieldCollection-C8TX9HvN.js.map +1 -0
  19. package/dist/chunks/ProfileRelationshipCollection-JnskbZTd.js +159 -0
  20. package/dist/chunks/ProfileRelationshipCollection-JnskbZTd.js.map +1 -0
  21. package/dist/chunks/ProfileRelationshipTermCollection-UopP7sja.js +105 -0
  22. package/dist/chunks/ProfileRelationshipTermCollection-UopP7sja.js.map +1 -0
  23. package/dist/chunks/ProfileRelationshipType-OMBn5cWR.js +98 -0
  24. package/dist/chunks/ProfileRelationshipType-OMBn5cWR.js.map +1 -0
  25. package/dist/chunks/ProfileRelationshipTypeCollection-CQu08kxF.js +54 -0
  26. package/dist/chunks/ProfileRelationshipTypeCollection-CQu08kxF.js.map +1 -0
  27. package/dist/index.js +690 -69
  28. package/dist/index.js.map +1 -1
  29. package/dist/manifest.json +2 -2
  30. package/dist/smrt-knowledge.json +9 -9
  31. package/dist/types.js +0 -2
  32. package/dist/utils.js +18 -36
  33. package/dist/utils.js.map +1 -1
  34. package/package.json +16 -16
  35. package/dist/chunks/ApiKey-B2LKEaP8.js +0 -143
  36. package/dist/chunks/ApiKey-B2LKEaP8.js.map +0 -1
  37. package/dist/chunks/ApiKeyCollection-B6Op817e.js +0 -91
  38. package/dist/chunks/ApiKeyCollection-B6Op817e.js.map +0 -1
  39. package/dist/chunks/AuditLogCollection-BYqCj0uE.js +0 -195
  40. package/dist/chunks/AuditLogCollection-BYqCj0uE.js.map +0 -1
  41. package/dist/chunks/NostrIdentityCollection-DadQBHWy.js +0 -3065
  42. package/dist/chunks/NostrIdentityCollection-DadQBHWy.js.map +0 -1
  43. package/dist/chunks/ProfileAssetCollection-CUM5QfuJ.js +0 -122
  44. package/dist/chunks/ProfileAssetCollection-CUM5QfuJ.js.map +0 -1
  45. package/dist/chunks/ProfileCollection-M2PK8bp-.js +0 -800
  46. package/dist/chunks/ProfileCollection-M2PK8bp-.js.map +0 -1
  47. package/dist/chunks/ProfileMetadataCollection-DEhmljMY.js +0 -120
  48. package/dist/chunks/ProfileMetadataCollection-DEhmljMY.js.map +0 -1
  49. package/dist/chunks/ProfileMetafieldCollection-DMKhSHXX.js +0 -184
  50. package/dist/chunks/ProfileMetafieldCollection-DMKhSHXX.js.map +0 -1
  51. package/dist/chunks/ProfileRelationshipCollection-_TsY7MHL.js +0 -189
  52. package/dist/chunks/ProfileRelationshipCollection-_TsY7MHL.js.map +0 -1
  53. package/dist/chunks/ProfileRelationshipTermCollection-CXem_qT-.js +0 -117
  54. package/dist/chunks/ProfileRelationshipTermCollection-CXem_qT-.js.map +0 -1
  55. package/dist/chunks/ProfileRelationshipType-BXBLldea.js +0 -103
  56. package/dist/chunks/ProfileRelationshipType-BXBLldea.js.map +0 -1
  57. package/dist/chunks/ProfileRelationshipTypeCollection-CF8YvLTV.js +0 -48
  58. package/dist/chunks/ProfileRelationshipTypeCollection-CF8YvLTV.js.map +0 -1
  59. package/dist/chunks/index-B9lXQy7N.js +0 -1029
  60. package/dist/chunks/index-B9lXQy7N.js.map +0 -1
  61. package/dist/types.js.map +0 -1
@@ -0,0 +1,105 @@
1
+ import { x as __exportAll } from "./NostrIdentityCollection-CG6HGf6c.js";
2
+ import { SmrtCollection, SmrtObject, field, foreignKey, smrt } from "@happyvertical/smrt-core";
3
+ //#region src/models/ProfileRelationshipTerm.ts
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __decorateClass = (decorators, target, key, kind) => {
7
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
8
+ for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
9
+ if (kind && result) __defProp(target, key, result);
10
+ return result;
11
+ };
12
+ var ProfileRelationshipTerm = class extends SmrtObject {
13
+ relationshipId;
14
+ startedAt = /* @__PURE__ */ new Date();
15
+ endedAt;
16
+ constructor(options = {}) {
17
+ super(options);
18
+ if (options.relationshipId !== void 0) this.relationshipId = options.relationshipId;
19
+ if (options.startedAt) this.startedAt = options.startedAt;
20
+ if (options.endedAt !== void 0) this.endedAt = options.endedAt;
21
+ }
22
+ /**
23
+ * Check if this term is currently active
24
+ *
25
+ * @returns True if active (no end date or end date in future)
26
+ */
27
+ isActive() {
28
+ if (!this.endedAt) return true;
29
+ return this.endedAt > /* @__PURE__ */ new Date();
30
+ }
31
+ /**
32
+ * End this term
33
+ *
34
+ * @param endedAt - End date for the term (defaults to now)
35
+ */
36
+ async end(endedAt = /* @__PURE__ */ new Date()) {
37
+ this.endedAt = endedAt;
38
+ await this.save();
39
+ }
40
+ /**
41
+ * Get the duration of this term in days
42
+ *
43
+ * @returns Duration in days
44
+ */
45
+ getDurationDays() {
46
+ const diffMs = (this.endedAt || /* @__PURE__ */ new Date()).getTime() - this.startedAt.getTime();
47
+ return Math.floor(diffMs / (1e3 * 60 * 60 * 24));
48
+ }
49
+ };
50
+ __decorateClass([foreignKey("ProfileRelationship", { required: true })], ProfileRelationshipTerm.prototype, "relationshipId", 2);
51
+ __decorateClass([field({ required: true })], ProfileRelationshipTerm.prototype, "startedAt", 2);
52
+ ProfileRelationshipTerm = __decorateClass([smrt({
53
+ tableStrategy: "sti",
54
+ api: { include: [
55
+ "list",
56
+ "get",
57
+ "create",
58
+ "update",
59
+ "delete"
60
+ ] },
61
+ mcp: { include: ["list", "get"] },
62
+ cli: true
63
+ })], ProfileRelationshipTerm);
64
+ //#endregion
65
+ //#region src/collections/ProfileRelationshipTermCollection.ts
66
+ var ProfileRelationshipTermCollection_exports = /* @__PURE__ */ __exportAll({ ProfileRelationshipTermCollection: () => ProfileRelationshipTermCollection });
67
+ var ProfileRelationshipTermCollection = class extends SmrtCollection {
68
+ static _itemClass = ProfileRelationshipTerm;
69
+ /**
70
+ * Get all terms for a relationship
71
+ *
72
+ * @param relationshipId - The relationship UUID
73
+ * @returns Array of ProfileRelationshipTerm instances
74
+ */
75
+ async getByRelationship(relationshipId) {
76
+ return await this.list({
77
+ where: { relationshipId },
78
+ orderBy: ["startedAt DESC"]
79
+ });
80
+ }
81
+ /**
82
+ * Get the active term for a relationship (no end date or future end date)
83
+ *
84
+ * @param relationshipId - The relationship UUID
85
+ * @returns Active term or null
86
+ */
87
+ async getActiveTerm(relationshipId) {
88
+ const terms = await this.getByRelationship(relationshipId);
89
+ for (const term of terms) if (term.isActive()) return term;
90
+ return null;
91
+ }
92
+ /**
93
+ * Get all historical (ended) terms for a relationship
94
+ *
95
+ * @param relationshipId - The relationship UUID
96
+ * @returns Array of ended ProfileRelationshipTerm instances
97
+ */
98
+ async getHistoricalTerms(relationshipId) {
99
+ return (await this.getByRelationship(relationshipId)).filter((term) => !term.isActive());
100
+ }
101
+ };
102
+ //#endregion
103
+ export { ProfileRelationshipTermCollection_exports as n, ProfileRelationshipTerm as r, ProfileRelationshipTermCollection as t };
104
+
105
+ //# sourceMappingURL=ProfileRelationshipTermCollection-UopP7sja.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProfileRelationshipTermCollection-UopP7sja.js","names":[],"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"],"mappings":";;;;;;;;;;;AA2BO,IAAM,0BAAN,cAAsC,WAAW;CAGtD;CAGA,4BAAkB,IAAI,KAAK;CAE3B;CAEA,YAAY,UAA0C,CAAC,GAAG;EACxD,MAAM,OA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AAI,KAAK,SAAS,GAChB,OAAO;EAIX,OAAO;CACT;;;;;;;CAQA,MAAM,mBACJ,gBACoC;EAEpC,QAAO,MADa,KAAK,kBAAkB,cAAc,EAAA,CAC5C,QAAQ,SAAS,CAAC,KAAK,SAAS,CAAC;CAChD;AACF"}
@@ -0,0 +1,98 @@
1
+ import { x as __exportAll } from "./NostrIdentityCollection-CG6HGf6c.js";
2
+ import { SmrtObject, field, smrt } from "@happyvertical/smrt-core";
3
+ //#region src/models/ProfileRelationshipType.ts
4
+ var ProfileRelationshipType_exports = /* @__PURE__ */ __exportAll({ ProfileRelationshipType: () => ProfileRelationshipType });
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __decorateClass = (decorators, target, key, kind) => {
8
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
9
+ for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
10
+ if (kind && result) __defProp(target, key, result);
11
+ return result;
12
+ };
13
+ function getReciprocalHandlers() {
14
+ if (!globalThis.__smrtProfileRelationshipHandlers) globalThis.__smrtProfileRelationshipHandlers = /* @__PURE__ */ new Map();
15
+ return globalThis.__smrtProfileRelationshipHandlers;
16
+ }
17
+ var DEFAULT_HANDLERS = {
18
+ friend: async (from, to, context) => {
19
+ await to.addRelationship(from, "friend", context);
20
+ },
21
+ spouse: async (from, to) => {
22
+ await to.addRelationship(from, "spouse");
23
+ },
24
+ partner: async (from, to, context) => {
25
+ await to.addRelationship(from, "partner", context);
26
+ },
27
+ colleague: async (from, to, context) => {
28
+ await to.addRelationship(from, "colleague", context);
29
+ },
30
+ sibling: async (from, to) => {
31
+ await to.addRelationship(from, "sibling");
32
+ }
33
+ };
34
+ if (!globalThis.__smrtProfileRelationshipHandlersInitialized) {
35
+ globalThis.__smrtProfileRelationshipHandlersInitialized = true;
36
+ for (const [slug, handler] of Object.entries(DEFAULT_HANDLERS)) getReciprocalHandlers().set(slug, handler);
37
+ }
38
+ var ProfileRelationshipType = class extends SmrtObject {
39
+ name = "";
40
+ reciprocal = true;
41
+ constructor(options = {}) {
42
+ super(options);
43
+ if (options.name) this.name = options.name;
44
+ if (options.reciprocal !== void 0) this.reciprocal = options.reciprocal;
45
+ }
46
+ /**
47
+ * Convenience method for slug-based lookup
48
+ *
49
+ * @param slug - The slug to search for
50
+ * @returns ProfileRelationshipType instance or null if not found
51
+ */
52
+ static async getBySlug(_slug) {
53
+ return null;
54
+ }
55
+ /**
56
+ * Register a custom reciprocal handler for a relationship type
57
+ *
58
+ * @param slug - The relationship type slug
59
+ * @param handler - The handler function to execute when creating reciprocal relationship
60
+ */
61
+ static registerReciprocalHandler(slug, handler) {
62
+ getReciprocalHandlers().set(slug, handler);
63
+ }
64
+ /**
65
+ * Get the reciprocal handler for a relationship type
66
+ *
67
+ * @param slug - The relationship type slug
68
+ * @returns The handler function or undefined
69
+ */
70
+ static getReciprocalHandler(slug) {
71
+ return getReciprocalHandlers().get(slug);
72
+ }
73
+ /**
74
+ * Check if a relationship type is reciprocal
75
+ *
76
+ * @param slug - The relationship type slug
77
+ * @returns True if reciprocal, false otherwise
78
+ */
79
+ static async isReciprocal(slug) {
80
+ return (await ProfileRelationshipType.getBySlug(slug))?.reciprocal || false;
81
+ }
82
+ };
83
+ __decorateClass([field({ required: true })], ProfileRelationshipType.prototype, "name", 2);
84
+ ProfileRelationshipType = __decorateClass([smrt({
85
+ tableStrategy: "sti",
86
+ api: { include: [
87
+ "list",
88
+ "get",
89
+ "create",
90
+ "update"
91
+ ] },
92
+ mcp: { include: ["list", "get"] },
93
+ cli: true
94
+ })], ProfileRelationshipType);
95
+ //#endregion
96
+ export { ProfileRelationshipType_exports as n, ProfileRelationshipType as t };
97
+
98
+ //# sourceMappingURL=ProfileRelationshipType-OMBn5cWR.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProfileRelationshipType-OMBn5cWR.js","names":[],"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"],"mappings":";;;;;;;;;;;;AAyCA,SAAS,wBAAwD;CAC/D,IAAI,CAAC,WAAW,mCACd,WAAW,oDAAoC,IAAI,IAGjD;CAEJ,OAAO,WAAW;AACpB;AAKA,IAAM,mBAAsD;CAE1D,QAA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J,eAAe;CACf,KAAK,EAAE,SAAS;EAAC;EAAQ;EAAO;EAAU;CAAQ,EAAE;CACpD,KAAK,EAAE,SAAS,CAAC,QAAQ,KAAK,EAAE;CAChC,KAAK;AACP,CAAC,CAAA,GACY,uBAAA"}
@@ -0,0 +1,54 @@
1
+ import { x as __exportAll } from "./NostrIdentityCollection-CG6HGf6c.js";
2
+ import { t as ProfileRelationshipType } from "./ProfileRelationshipType-OMBn5cWR.js";
3
+ import { SmrtCollection } from "@happyvertical/smrt-core";
4
+ //#region src/collections/ProfileRelationshipTypeCollection.ts
5
+ var ProfileRelationshipTypeCollection_exports = /* @__PURE__ */ __exportAll({ ProfileRelationshipTypeCollection: () => ProfileRelationshipTypeCollection });
6
+ var ProfileRelationshipTypeCollection = class extends SmrtCollection {
7
+ static _itemClass = ProfileRelationshipType;
8
+ /**
9
+ * Get relationship type by slug
10
+ *
11
+ * @param slug - The slug to search for
12
+ * @returns ProfileRelationshipType instance or null
13
+ */
14
+ async getBySlug(slug) {
15
+ return await this.get({ slug });
16
+ }
17
+ /**
18
+ * Get or create a relationship type by slug
19
+ *
20
+ * @param slug - The slug to search for
21
+ * @param defaults - Default values if creating
22
+ * @returns ProfileRelationshipType instance
23
+ */
24
+ async getOrCreateBySlug(slug, defaults) {
25
+ const existing = await this.getBySlug(slug);
26
+ if (existing) return existing;
27
+ const relationshipType = await this.create({
28
+ slug,
29
+ ...defaults
30
+ });
31
+ await relationshipType.save();
32
+ return relationshipType;
33
+ }
34
+ /**
35
+ * Get all reciprocal relationship types
36
+ *
37
+ * @returns Array of reciprocal ProfileRelationshipType instances
38
+ */
39
+ async getReciprocal() {
40
+ return await this.list({ where: { reciprocal: true } });
41
+ }
42
+ /**
43
+ * Get all directional (non-reciprocal) relationship types
44
+ *
45
+ * @returns Array of directional ProfileRelationshipType instances
46
+ */
47
+ async getDirectional() {
48
+ return await this.list({ where: { reciprocal: false } });
49
+ }
50
+ };
51
+ //#endregion
52
+ export { ProfileRelationshipTypeCollection_exports as n, ProfileRelationshipTypeCollection as t };
53
+
54
+ //# sourceMappingURL=ProfileRelationshipTypeCollection-CQu08kxF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProfileRelationshipTypeCollection-CQu08kxF.js","names":[],"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"],"mappings":";;;;;AASO,IAAM,oCAAN,cAAgD,eAAwC;CAC7F,OAAgB,aAAa;;;;;;;CAQ7B,MAAM,UAAU,MAAuD;EACrE,OAAO,MAAM,KAAK,IAAI,EAAE,KAAK,CAAC;CAChC;;;;;;;;CASA,MAAM,kBACJ,MACA,UACkC;EAClC,MAAM,WAAW,MAAM,KAAK,UAAU,IAAI;EAC1C,IAAI,UAAU,OAAO;EAErB,MAAM,mBAAmB,MAAM,KAAK,OAAO;GAAE;GAAM,GAAG;EAAS,CAAC;EAChE,MAAM,iBAAiB,KAAK;EAC5B,OAAO;CACT;;;;;;CAOA,MAAM,gBAAoD;EACxD,OAAO,MAAM,KAAK,KAAK,EAAE,OAAO,EAAE,YAAY,KAAK,EAAE,CAAC;CACxD;;;;;;CAOA,MAAM,iBAAqD;EACzD,OAAO,MAAM,KAAK,KAAK,EAAE,OAAO,EAAE,YAAY,MAAM,EAAE,CAAC;CACzD;AACF"}