@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.
- package/AGENTS.md +53 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +7 -0
- package/README.md +176 -0
- package/dist/chunks/ApiKey-B2LKEaP8.js +143 -0
- package/dist/chunks/ApiKey-B2LKEaP8.js.map +1 -0
- package/dist/chunks/ApiKeyCollection-B6Op817e.js +91 -0
- package/dist/chunks/ApiKeyCollection-B6Op817e.js.map +1 -0
- package/dist/chunks/AuditLogCollection-BYqCj0uE.js +195 -0
- package/dist/chunks/AuditLogCollection-BYqCj0uE.js.map +1 -0
- package/dist/chunks/NostrIdentityCollection-DadQBHWy.js +3065 -0
- package/dist/chunks/NostrIdentityCollection-DadQBHWy.js.map +1 -0
- package/dist/chunks/ProfileAssetCollection-D_tk1kKG.js +122 -0
- package/dist/chunks/ProfileAssetCollection-D_tk1kKG.js.map +1 -0
- package/dist/chunks/ProfileCollection-DU6wUJTO.js +782 -0
- package/dist/chunks/ProfileCollection-DU6wUJTO.js.map +1 -0
- package/dist/chunks/ProfileMetadataCollection-DEhmljMY.js +120 -0
- package/dist/chunks/ProfileMetadataCollection-DEhmljMY.js.map +1 -0
- package/dist/chunks/ProfileMetafieldCollection-DMKhSHXX.js +184 -0
- package/dist/chunks/ProfileMetafieldCollection-DMKhSHXX.js.map +1 -0
- package/dist/chunks/ProfileRelationshipCollection-C0IM8UQR.js +177 -0
- package/dist/chunks/ProfileRelationshipCollection-C0IM8UQR.js.map +1 -0
- package/dist/chunks/ProfileRelationshipTermCollection-CXem_qT-.js +117 -0
- package/dist/chunks/ProfileRelationshipTermCollection-CXem_qT-.js.map +1 -0
- package/dist/chunks/ProfileRelationshipType-BXBLldea.js +103 -0
- package/dist/chunks/ProfileRelationshipType-BXBLldea.js.map +1 -0
- package/dist/chunks/ProfileRelationshipTypeCollection-CF8YvLTV.js +48 -0
- package/dist/chunks/ProfileRelationshipTypeCollection-CF8YvLTV.js.map +1 -0
- package/dist/chunks/index-jFtOWsAV.js +1014 -0
- package/dist/chunks/index-jFtOWsAV.js.map +1 -0
- package/dist/index.d.ts +1848 -0
- package/dist/index.js +70 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.json +11829 -0
- package/dist/smrt-knowledge.json +3846 -0
- package/dist/types.d.ts +41 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +61 -0
- package/dist/utils.js +49 -0
- package/dist/utils.js.map +1 -0
- package/package.json +75 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript type definitions for @have/profiles package
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Handler function interface for reciprocal relationships
|
|
6
|
+
*
|
|
7
|
+
* @param from - The profile initiating the relationship
|
|
8
|
+
* @param to - The target profile
|
|
9
|
+
* @param context - Optional context profile for tertiary relationships
|
|
10
|
+
* @param options - Additional options for the handler
|
|
11
|
+
*/
|
|
12
|
+
export declare type ReciprocalHandler = (from: any, to: any, context?: any, options?: any) => Promise<void>;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Validation schema structure for profile metadata fields
|
|
16
|
+
*/
|
|
17
|
+
export declare interface ValidationSchema {
|
|
18
|
+
/** Type constraint */
|
|
19
|
+
type?: 'string' | 'number' | 'boolean' | 'date' | 'json';
|
|
20
|
+
/** Regex pattern for string validation */
|
|
21
|
+
pattern?: string;
|
|
22
|
+
/** Minimum string length */
|
|
23
|
+
minLength?: number;
|
|
24
|
+
/** Maximum string length */
|
|
25
|
+
maxLength?: number;
|
|
26
|
+
/** Minimum numeric value */
|
|
27
|
+
min?: number;
|
|
28
|
+
/** Maximum numeric value */
|
|
29
|
+
max?: number;
|
|
30
|
+
/** Custom validator function name */
|
|
31
|
+
custom?: string;
|
|
32
|
+
/** Custom validation error message */
|
|
33
|
+
message?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Custom validator function type
|
|
38
|
+
*/
|
|
39
|
+
export declare type ValidatorFunction = (value: any) => boolean | Promise<boolean>;
|
|
40
|
+
|
|
41
|
+
export { }
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for profile operations
|
|
3
|
+
*
|
|
4
|
+
* Provides standalone helper functions for metadata management,
|
|
5
|
+
* relationship operations, and validation.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Create a reciprocal relationship between two profiles
|
|
12
|
+
*
|
|
13
|
+
* This is a convenience function that creates a relationship and automatically
|
|
14
|
+
* handles the reciprocal relationship based on the relationship type configuration.
|
|
15
|
+
*
|
|
16
|
+
* @param fromProfile - The initiating profile
|
|
17
|
+
* @param toProfile - The target profile
|
|
18
|
+
* @param relationshipSlug - The type of relationship
|
|
19
|
+
* @param contextProfile - Optional context profile for tertiary relationships
|
|
20
|
+
*/
|
|
21
|
+
export declare function createReciprocalRelationship(fromProfile: any, toProfile: any, relationshipSlug: string, contextProfile?: any): Promise<void>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Find profiles with a specific metadata key-value pair
|
|
25
|
+
*
|
|
26
|
+
* @param metafieldSlug - The slug of the metafield to search
|
|
27
|
+
* @param value - The value to match
|
|
28
|
+
* @param options - Database and configuration options
|
|
29
|
+
* @returns Array of matching profile IDs
|
|
30
|
+
*/
|
|
31
|
+
export declare function findProfilesByMeta(metafieldSlug: string, value: any, options?: any): Promise<string[]>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Retrieve all metadata for a profile as a key-value object
|
|
35
|
+
*
|
|
36
|
+
* @param profileId - The UUID of the profile
|
|
37
|
+
* @param options - Database and configuration options
|
|
38
|
+
* @returns Object with metafield slugs as keys and values as values
|
|
39
|
+
*/
|
|
40
|
+
export declare function getProfileMetadata(profileId: string, options?: any): Promise<Record<string, any>>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Set a single metadata value for a profile
|
|
44
|
+
*
|
|
45
|
+
* @param profileId - The UUID of the profile
|
|
46
|
+
* @param metafieldSlug - The slug of the metafield
|
|
47
|
+
* @param value - The value to set
|
|
48
|
+
* @param options - Database and configuration options
|
|
49
|
+
*/
|
|
50
|
+
export declare function setProfileMetadata(profileId: string, metafieldSlug: string, value: any, options?: any): Promise<void>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Validate a metadata value against a metafield's validation schema
|
|
54
|
+
*
|
|
55
|
+
* @param metafield - The metafield with validation rules
|
|
56
|
+
* @param value - The value to validate
|
|
57
|
+
* @returns True if valid, throws error if invalid
|
|
58
|
+
*/
|
|
59
|
+
export declare function validateMetadataValue(metafield: any, value: any): Promise<boolean>;
|
|
60
|
+
|
|
61
|
+
export { }
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
async function getProfileMetadata(profileId, options = {}) {
|
|
2
|
+
const { ProfileMetadataCollection } = await import("./chunks/ProfileMetadataCollection-DEhmljMY.js").then((n) => n.b);
|
|
3
|
+
const metadataCollection = await ProfileMetadataCollection.create(
|
|
4
|
+
options
|
|
5
|
+
);
|
|
6
|
+
return await metadataCollection.getMetadataObject(profileId);
|
|
7
|
+
}
|
|
8
|
+
async function setProfileMetadata(profileId, metafieldSlug, value, options = {}) {
|
|
9
|
+
const { ProfileCollection } = await import("./chunks/ProfileCollection-DU6wUJTO.js").then((n) => n.d);
|
|
10
|
+
const profileCollection = await ProfileCollection.create(options);
|
|
11
|
+
const profile = await profileCollection.get({ id: profileId });
|
|
12
|
+
if (!profile) {
|
|
13
|
+
throw new Error(`Profile '${profileId}' not found`);
|
|
14
|
+
}
|
|
15
|
+
await profile.addMetadata(metafieldSlug, value);
|
|
16
|
+
}
|
|
17
|
+
async function findProfilesByMeta(metafieldSlug, value, options = {}) {
|
|
18
|
+
const { ProfileMetafieldCollection } = await import("./chunks/ProfileMetafieldCollection-DMKhSHXX.js").then((n) => n.b);
|
|
19
|
+
const { ProfileMetadataCollection } = await import("./chunks/ProfileMetadataCollection-DEhmljMY.js").then((n) => n.b);
|
|
20
|
+
const metafieldCollection = await ProfileMetafieldCollection.create(
|
|
21
|
+
options
|
|
22
|
+
);
|
|
23
|
+
const metafield = await metafieldCollection.getBySlug(metafieldSlug);
|
|
24
|
+
if (!metafield) {
|
|
25
|
+
throw new Error(`Metafield '${metafieldSlug}' not found`);
|
|
26
|
+
}
|
|
27
|
+
const metadataCollection = await ProfileMetadataCollection.create(
|
|
28
|
+
options
|
|
29
|
+
);
|
|
30
|
+
return await metadataCollection.findProfilesByMetadata(metafield.id, value);
|
|
31
|
+
}
|
|
32
|
+
async function createReciprocalRelationship(fromProfile, toProfile, relationshipSlug, contextProfile) {
|
|
33
|
+
await fromProfile.addRelationship(
|
|
34
|
+
toProfile,
|
|
35
|
+
relationshipSlug,
|
|
36
|
+
contextProfile
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
async function validateMetadataValue(metafield, value) {
|
|
40
|
+
return await metafield.validateValue(value);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
createReciprocalRelationship,
|
|
44
|
+
findProfilesByMeta,
|
|
45
|
+
getProfileMetadata,
|
|
46
|
+
setProfileMetadata,
|
|
47
|
+
validateMetadataValue
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["/**\n * Utility functions for profile operations\n *\n * Provides standalone helper functions for metadata management,\n * relationship operations, and validation.\n *\n * @packageDocumentation\n */\n\n// Utility functions will be implemented as part of Phase 2\n// This file serves as a placeholder for the API structure\n\n/**\n * Retrieve all metadata for a profile as a key-value object\n *\n * @param profileId - The UUID of the profile\n * @param options - Database and configuration options\n * @returns Object with metafield slugs as keys and values as values\n */\nexport async function getProfileMetadata(\n profileId: string,\n options: any = {},\n): Promise<Record<string, any>> {\n const { ProfileMetadataCollection } = await import(\n './collections/ProfileMetadataCollection'\n );\n\n const metadataCollection = await (ProfileMetadataCollection as any).create(\n options,\n );\n\n return await metadataCollection.getMetadataObject(profileId);\n}\n\n/**\n * Set a single metadata value for a profile\n *\n * @param profileId - The UUID of the profile\n * @param metafieldSlug - The slug of the metafield\n * @param value - The value to set\n * @param options - Database and configuration options\n */\nexport async function setProfileMetadata(\n profileId: string,\n metafieldSlug: string,\n value: any,\n options: any = {},\n): Promise<void> {\n const { ProfileCollection } = await import('./collections/ProfileCollection');\n\n const profileCollection = await (ProfileCollection as any).create(options);\n\n const profile = await profileCollection.get({ id: profileId });\n if (!profile) {\n throw new Error(`Profile '${profileId}' not found`);\n }\n\n await profile.addMetadata(metafieldSlug, value);\n}\n\n/**\n * Find profiles with a specific metadata key-value pair\n *\n * @param metafieldSlug - The slug of the metafield to search\n * @param value - The value to match\n * @param options - Database and configuration options\n * @returns Array of matching profile IDs\n */\nexport async function findProfilesByMeta(\n metafieldSlug: string,\n value: any,\n options: any = {},\n): Promise<string[]> {\n const { ProfileMetafieldCollection } = await import(\n './collections/ProfileMetafieldCollection'\n );\n const { ProfileMetadataCollection } = await import(\n './collections/ProfileMetadataCollection'\n );\n\n // Get metafield by slug\n const metafieldCollection = await (ProfileMetafieldCollection as any).create(\n options,\n );\n\n const metafield = await metafieldCollection.getBySlug(metafieldSlug);\n if (!metafield) {\n throw new Error(`Metafield '${metafieldSlug}' not found`);\n }\n\n // Find all metadata with this metafield and value\n const metadataCollection = await (ProfileMetadataCollection as any).create(\n options,\n );\n\n return await metadataCollection.findProfilesByMetadata(metafield.id, value);\n}\n\n/**\n * Create a reciprocal relationship between two profiles\n *\n * This is a convenience function that creates a relationship and automatically\n * handles the reciprocal relationship based on the relationship type configuration.\n *\n * @param fromProfile - The initiating profile\n * @param toProfile - The target profile\n * @param relationshipSlug - The type of relationship\n * @param contextProfile - Optional context profile for tertiary relationships\n */\nexport async function createReciprocalRelationship(\n fromProfile: any,\n toProfile: any,\n relationshipSlug: string,\n contextProfile?: any,\n): Promise<void> {\n // The Profile.addRelationship method already handles reciprocal relationships\n await fromProfile.addRelationship(\n toProfile,\n relationshipSlug,\n contextProfile,\n );\n}\n\n/**\n * Validate a metadata value against a metafield's validation schema\n *\n * @param metafield - The metafield with validation rules\n * @param value - The value to validate\n * @returns True if valid, throws error if invalid\n */\nexport async function validateMetadataValue(\n metafield: any,\n value: any,\n): Promise<boolean> {\n // The ProfileMetafield.validateValue method already implements validation\n return await metafield.validateValue(value);\n}\n"],"names":[],"mappings":"AAmBA,eAAsB,mBACpB,WACA,UAAe,IACe;AAC9B,QAAM,EAAE,0BAAA,IAA8B,MAAM,OAC1C,gDACF,EAAA,KAAA,OAAA,EAAA,CAAA;AAEA,QAAM,qBAAqB,MAAO,0BAAkC;AAAA,IAClE;AAAA,EAAA;AAGF,SAAO,MAAM,mBAAmB,kBAAkB,SAAS;AAC7D;AAUA,eAAsB,mBACpB,WACA,eACA,OACA,UAAe,CAAA,GACA;AACf,QAAM,EAAE,kBAAA,IAAsB,MAAM,OAAO,wCAAiC,EAAA,KAAA,OAAA,EAAA,CAAA;AAE5E,QAAM,oBAAoB,MAAO,kBAA0B,OAAO,OAAO;AAEzE,QAAM,UAAU,MAAM,kBAAkB,IAAI,EAAE,IAAI,WAAW;AAC7D,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,YAAY,SAAS,aAAa;AAAA,EACpD;AAEA,QAAM,QAAQ,YAAY,eAAe,KAAK;AAChD;AAUA,eAAsB,mBACpB,eACA,OACA,UAAe,CAAA,GACI;AACnB,QAAM,EAAE,2BAAA,IAA+B,MAAM,OAC3C,iDACF,EAAA,KAAA,OAAA,EAAA,CAAA;AACA,QAAM,EAAE,0BAAA,IAA8B,MAAM,OAC1C,gDACF,EAAA,KAAA,OAAA,EAAA,CAAA;AAGA,QAAM,sBAAsB,MAAO,2BAAmC;AAAA,IACpE;AAAA,EAAA;AAGF,QAAM,YAAY,MAAM,oBAAoB,UAAU,aAAa;AACnE,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,cAAc,aAAa,aAAa;AAAA,EAC1D;AAGA,QAAM,qBAAqB,MAAO,0BAAkC;AAAA,IAClE;AAAA,EAAA;AAGF,SAAO,MAAM,mBAAmB,uBAAuB,UAAU,IAAI,KAAK;AAC5E;AAaA,eAAsB,6BACpB,aACA,WACA,kBACA,gBACe;AAEf,QAAM,YAAY;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AASA,eAAsB,sBACpB,WACA,OACkB;AAElB,SAAO,MAAM,UAAU,cAAc,KAAK;AAC5C;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@happyvertical/smrt-profiles",
|
|
3
|
+
"version": "0.30.0",
|
|
4
|
+
"description": "Profile management system with relationships, metadata, and reciprocal associations for SMRT framework",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"CLAUDE.md",
|
|
11
|
+
"AGENTS.md"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./utils": {
|
|
19
|
+
"types": "./dist/utils.d.ts",
|
|
20
|
+
"import": "./dist/utils.js"
|
|
21
|
+
},
|
|
22
|
+
"./manifest": "./dist/manifest.json",
|
|
23
|
+
"./manifest.json": "./dist/manifest.json"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@happyvertical/ai": "^0.74.7",
|
|
27
|
+
"@happyvertical/files": "^0.74.7",
|
|
28
|
+
"@happyvertical/logger": "^0.74.7",
|
|
29
|
+
"@happyvertical/sql": "^0.74.7",
|
|
30
|
+
"@happyvertical/utils": "^0.74.7",
|
|
31
|
+
"@noble/curves": "^1.8.1",
|
|
32
|
+
"bech32": "^2.0.0",
|
|
33
|
+
"@happyvertical/smrt-assets": "0.30.0",
|
|
34
|
+
"@happyvertical/smrt-core": "0.30.0",
|
|
35
|
+
"@happyvertical/smrt-prompts": "0.30.0",
|
|
36
|
+
"@happyvertical/smrt-tenancy": "0.30.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@faker-js/faker": "^10.2.0",
|
|
40
|
+
"@types/node": "25.0.9",
|
|
41
|
+
"fast-glob": "3.3.3",
|
|
42
|
+
"typescript": "^5.9.3",
|
|
43
|
+
"vite": "^7.3.1",
|
|
44
|
+
"vitest": "^4.0.17",
|
|
45
|
+
"@happyvertical/smrt-vitest": "0.30.0"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"ai",
|
|
49
|
+
"agents",
|
|
50
|
+
"profiles",
|
|
51
|
+
"relationships",
|
|
52
|
+
"metadata",
|
|
53
|
+
"smrt"
|
|
54
|
+
],
|
|
55
|
+
"author": "HappyVertical",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"registry": "https://registry.npmjs.org",
|
|
59
|
+
"access": "public"
|
|
60
|
+
},
|
|
61
|
+
"repository": {
|
|
62
|
+
"type": "git",
|
|
63
|
+
"url": "https://github.com/happyvertical/smrt.git",
|
|
64
|
+
"directory": "packages/profiles"
|
|
65
|
+
},
|
|
66
|
+
"scripts": {
|
|
67
|
+
"build": "vite build --mode library",
|
|
68
|
+
"build:watch": "vite build --mode library --watch",
|
|
69
|
+
"clean": "rm -rf dist",
|
|
70
|
+
"dev": "vite dev",
|
|
71
|
+
"test": "vitest run",
|
|
72
|
+
"test:watch": "vitest",
|
|
73
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
74
|
+
}
|
|
75
|
+
}
|