@happyvertical/smrt-cli 0.53.3 → 0.53.5

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 (76) hide show
  1. package/AGENTS.md +3 -0
  2. package/README.md +64 -0
  3. package/agents/app-commands.md +118 -0
  4. package/bin/smrt-web.mjs +19 -0
  5. package/bin/smrt.js +18 -12
  6. package/dist/{ApiKey-BZmbOTnL-DchyhIPA.js → ApiKey-BZmbOTnL-BbZupUZ3.js} +2 -2
  7. package/dist/ApiKeyCollection-Bfb_nw81-DYAZwx0O.js +87 -0
  8. package/dist/AuditLogCollection-B1YonCAP-Bkj2Ezon.js +193 -0
  9. package/dist/{NostrIdentity-n70E0vck-CLGPdJ1W.js → NostrIdentity-n70E0vck-Di3_eNCq.js} +4 -4
  10. package/dist/NostrIdentityCollection-Ca74dkaL-DvjOg9Xy.js +127 -0
  11. package/dist/{OidcIdentity-Cb1bxreM-DPBTZddF.js → OidcIdentity-Cb1bxreM-LXmC7uAf.js} +2 -2
  12. package/dist/OidcIdentityCollection-TV8VdK69-Cv1ZTeuk.js +86 -0
  13. package/dist/ProfileAssetCollection-B9hacUJa-CPuaWLk4.js +101 -0
  14. package/dist/{ProfileCollection-DuJT7Mum-BUYQQ9xZ.js → ProfileCollection-DuJT7Mum-nXbHrPpX.js} +31 -31
  15. package/dist/ProfileLinkCollection-4uNURz32-CbKZYmYm.js +233 -0
  16. package/dist/ProfileMetadataCollection-DQhbfEfa-_1rQCLTR.js +108 -0
  17. package/dist/ProfileMetafieldCollection-CoBuM_5G-CPjW3l5r.js +145 -0
  18. package/dist/ProfileRelationshipCollection-DUVgaIqf-RCDqYz6O.js +161 -0
  19. package/dist/ProfileRelationshipTermCollection-DtA9OM23-BoGhQBSQ.js +107 -0
  20. package/dist/{ProfileRelationshipType-BRiRka6t-xzRfZRFG.js → ProfileRelationshipType-BRiRka6t-Dezjv5jP.js} +1 -1
  21. package/dist/ProfileRelationshipTypeCollection-BdXwd7Kf-HoTmV1q-.js +57 -0
  22. package/dist/app/cli.d.ts +51 -0
  23. package/dist/app/cli.d.ts.map +1 -0
  24. package/dist/app/errors.d.ts +55 -0
  25. package/dist/app/errors.d.ts.map +1 -0
  26. package/dist/app/identity.d.ts +24 -0
  27. package/dist/app/identity.d.ts.map +1 -0
  28. package/dist/app/index.d.ts +20 -0
  29. package/dist/app/index.d.ts.map +1 -0
  30. package/dist/app/launchers.d.ts +51 -0
  31. package/dist/app/launchers.d.ts.map +1 -0
  32. package/dist/app/operations.d.ts +30 -0
  33. package/dist/app/operations.d.ts.map +1 -0
  34. package/dist/app/portability-assets.d.ts +151 -0
  35. package/dist/app/portability-assets.d.ts.map +1 -0
  36. package/dist/app/portability.d.ts +117 -0
  37. package/dist/app/portability.d.ts.map +1 -0
  38. package/dist/app/process-record.d.ts +54 -0
  39. package/dist/app/process-record.d.ts.map +1 -0
  40. package/dist/app/runtime.d.ts +98 -0
  41. package/dist/app/runtime.d.ts.map +1 -0
  42. package/dist/app/tokens.d.ts +21 -0
  43. package/dist/app/tokens.d.ts.map +1 -0
  44. package/dist/app.d.ts +1 -0
  45. package/dist/app.js +4 -0
  46. package/dist/cli-OZsH5cdL.js +1602 -0
  47. package/dist/cli-generator.d.ts.map +1 -1
  48. package/dist/commands/init.d.ts.map +1 -1
  49. package/dist/commands/utilities.d.ts.map +1 -1
  50. package/dist/{commands-B8N38deG.js → commands-UXK2F_0j.js} +49 -336
  51. package/dist/database-environment-D_Gk1Brf.js +20 -0
  52. package/dist/database-environment.d.ts +43 -0
  53. package/dist/database-environment.d.ts.map +1 -0
  54. package/dist/dist-BVjJWjT-.js +20 -0
  55. package/dist/{dist-B62O-xH6.js → dist-C87Ib9Vx.js} +2 -2
  56. package/dist/{dist-CL9KGm1j.js → dist-DLw_E34G.js} +1654 -1748
  57. package/dist/{dist-BBQyIRsO.js → dist-GIaWaUho.js} +4 -4
  58. package/dist/{dist-C8BOgli4.js → dist-RSE5hCY4.js} +3 -3
  59. package/dist/index.js +19 -9
  60. package/dist/mcp-apps-packaging-CixRnxz_.js +286 -0
  61. package/dist/{oidcProvisioningPrimitives-D9OYu5-F-l8afZs4F.js → oidcProvisioningPrimitives-D9OYu5-F-T9KkkDCd.js} +5 -5
  62. package/dist/portability-CES1YC2m.js +859 -0
  63. package/dist/resolveIdentity-B-PK6RwU-C9ogf8YG.js +269 -0
  64. package/package.json +19 -14
  65. package/dist/ApiKeyCollection-Bfb_nw81-DR5XF_SZ.js +0 -2
  66. package/dist/AuditLogCollection-B1YonCAP-PbzALncL.js +0 -2
  67. package/dist/NostrIdentityCollection-Ca74dkaL-C2r-uDlC.js +0 -2
  68. package/dist/OidcIdentityCollection-TV8VdK69-2fZROnih.js +0 -2
  69. package/dist/ProfileAssetCollection-B9hacUJa-D33sifgF.js +0 -2
  70. package/dist/ProfileLinkCollection-4uNURz32-CHDTinax.js +0 -2
  71. package/dist/ProfileMetadataCollection-DQhbfEfa-BQTogfVX.js +0 -2
  72. package/dist/ProfileMetafieldCollection-CoBuM_5G-BXtoIP02.js +0 -2
  73. package/dist/ProfileRelationshipCollection-DUVgaIqf-CNMliUF3.js +0 -2
  74. package/dist/ProfileRelationshipTermCollection-DtA9OM23-DPOMtMr7.js +0 -2
  75. package/dist/ProfileRelationshipTypeCollection-BdXwd7Kf-Co3PdH01.js +0 -2
  76. package/dist/resolveIdentity-B-PK6RwU-B306Ch1I.js +0 -2
@@ -0,0 +1,127 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
+ import { n as __exportAll$1, o as encryptPrivkey, s as generateNostrKeypair, t as NostrIdentity } from "./NostrIdentity-n70E0vck-Di3_eNCq.js";
3
+ import { SmrtCollection } from "@happyvertical/smrt-core";
4
+ //#region ../profiles/dist/chunks/NostrIdentityCollection-Ca74dkaL.js
5
+ var NostrIdentityCollection_Ca74dkaL_exports = /* @__PURE__ */ __exportAll({
6
+ n: () => NostrIdentityCollection_exports,
7
+ t: () => NostrIdentityCollection
8
+ });
9
+ var NostrIdentityCollection_exports = /* @__PURE__ */ __exportAll$1({ NostrIdentityCollection: () => NostrIdentityCollection });
10
+ var NostrIdentityCollection = class extends SmrtCollection {
11
+ static _itemClass = NostrIdentity;
12
+ /**
13
+ * Find identities for a profile
14
+ */
15
+ async findByProfile(profileId) {
16
+ return await this.list({ where: { profileId } });
17
+ }
18
+ /**
19
+ * Find identity by public key
20
+ */
21
+ async findByPubkey(pubkey) {
22
+ return await this.findOne({ where: { pubkey } });
23
+ }
24
+ /**
25
+ * Find identity by email
26
+ */
27
+ async findByEmail(email) {
28
+ return await this.findOne({ where: { email: email.toLowerCase() } });
29
+ }
30
+ /**
31
+ * Find identity by NIP-05 username
32
+ */
33
+ async findByNip05(username) {
34
+ return await this.findOne({ where: { nip05Username: username.toLowerCase() } });
35
+ }
36
+ /**
37
+ * Link a new Nostr identity to a profile with a new keypair
38
+ * @param profile - The profile to link to
39
+ * @param email - Email address for this identity
40
+ * @param masterSecret - Server master secret for encryption
41
+ * @param nip05Username - Optional NIP-05 username (defaults to email local part)
42
+ */
43
+ async createForProfile(profile, email, masterSecret, nip05Username) {
44
+ const normalizedEmail = email.toLowerCase();
45
+ if (await this.findByEmail(normalizedEmail)) throw new Error(`Nostr identity already exists for email: ${email}`);
46
+ const keypair = generateNostrKeypair();
47
+ const encrypted = encryptPrivkey(keypair.privkey, masterSecret);
48
+ const username = nip05Username?.toLowerCase() || normalizedEmail.split("@")[0];
49
+ const identity = new NostrIdentity({
50
+ ...this.options,
51
+ profileId: profile.id,
52
+ pubkey: keypair.pubkey,
53
+ encryptedPrivkey: encrypted.ciphertext,
54
+ encryptionIv: encrypted.iv,
55
+ encryptionTag: encrypted.tag,
56
+ email: normalizedEmail,
57
+ nip05Username: username
58
+ });
59
+ await identity.initialize();
60
+ await identity.save();
61
+ return identity;
62
+ }
63
+ /**
64
+ * Link an existing Nostr identity (with encrypted keypair) to a profile
65
+ */
66
+ async linkToProfile(profile, nostrData) {
67
+ if (await this.findByPubkey(nostrData.pubkey)) throw new Error("Nostr identity with this public key already exists");
68
+ if (await this.findByEmail(nostrData.email)) throw new Error("Nostr identity with this email already exists");
69
+ const identity = new NostrIdentity({
70
+ ...this.options,
71
+ profileId: profile.id,
72
+ pubkey: nostrData.pubkey,
73
+ encryptedPrivkey: nostrData.encryptedPrivkey,
74
+ encryptionIv: nostrData.encryptionIv,
75
+ encryptionTag: nostrData.encryptionTag,
76
+ email: nostrData.email.toLowerCase(),
77
+ nip05Username: nostrData.nip05Username?.toLowerCase() || nostrData.email.toLowerCase().split("@")[0]
78
+ });
79
+ await identity.initialize();
80
+ await identity.save();
81
+ return identity;
82
+ }
83
+ /**
84
+ * Unlink a Nostr identity from a profile
85
+ */
86
+ async unlinkFromProfile(profileId, pubkey) {
87
+ const identity = await this.findOne({ where: {
88
+ profileId,
89
+ pubkey
90
+ } });
91
+ if (identity) {
92
+ await identity.delete();
93
+ return true;
94
+ }
95
+ return false;
96
+ }
97
+ /**
98
+ * Get NIP-05 response data for the /.well-known/nostr.json endpoint
99
+ * @param username - Optional username filter, returns all if not provided
100
+ */
101
+ async getNip05Response(username) {
102
+ const where = username ? { nip05Username: username.toLowerCase() } : {};
103
+ const identities = await this.list({ where });
104
+ const names = {};
105
+ for (const identity of identities) if (identity.nip05Username && identity.pubkey) names[identity.nip05Username] = identity.pubkey;
106
+ return { names };
107
+ }
108
+ /**
109
+ * Check if a NIP-05 username is available
110
+ */
111
+ async isNip05Available(username) {
112
+ return await this.findByNip05(username) === null;
113
+ }
114
+ /**
115
+ * Update NIP-05 username for an identity
116
+ */
117
+ async updateNip05Username(identity, newUsername) {
118
+ const normalizedUsername = newUsername.toLowerCase();
119
+ const existing = await this.findByNip05(normalizedUsername);
120
+ if (existing && existing.id !== identity.id) throw new Error(`NIP-05 username "${newUsername}" is already taken`);
121
+ identity.nip05Username = normalizedUsername;
122
+ await identity.save();
123
+ return identity;
124
+ }
125
+ };
126
+ //#endregion
127
+ export { NostrIdentityCollection_Ca74dkaL_exports as n, NostrIdentityCollection as t };
@@ -35,7 +35,7 @@ var OidcIdentity = class extends SmrtObject {
35
35
  * Find identity by issuer and subject
36
36
  */
37
37
  static async findBySubject(issuer, subject, options = {}) {
38
- const { OidcIdentityCollection } = await import("./OidcIdentityCollection-TV8VdK69-2fZROnih.js").then((n) => n.r);
38
+ const { OidcIdentityCollection } = await import("./OidcIdentityCollection-TV8VdK69-Cv1ZTeuk.js").then((n) => n.r).then((n) => n.r);
39
39
  return await (await OidcIdentityCollection.create(options)).findBySubject(issuer, subject);
40
40
  }
41
41
  /** Build the collision-free natural key for one OIDC issuer subject. */
@@ -58,7 +58,7 @@ var OidcIdentity = class extends SmrtObject {
58
58
  static async findOrCreate(profile, oidcData, options = {}) {
59
59
  const profileId = profile.id;
60
60
  if (typeof profileId !== "string" || !profileId) throw new Error("OidcIdentity.findOrCreate() requires a saved Profile.");
61
- const { reuseExistingOidcIdentityForProfile } = await import("./resolveIdentity-B-PK6RwU-B306Ch1I.js").then((n) => n.i);
61
+ const { reuseExistingOidcIdentityForProfile } = await import("./resolveIdentity-B-PK6RwU-C9ogf8YG.js").then((n) => n.i).then((n) => n.i);
62
62
  const profileOptions = profile.options ?? {};
63
63
  return (await reuseExistingOidcIdentityForProfile(profileId, {
64
64
  email: oidcData.email,
@@ -0,0 +1,86 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
+ import { n as __exportAll$1 } from "./NostrIdentity-n70E0vck-Di3_eNCq.js";
3
+ import { t as OidcIdentity } from "./OidcIdentity-Cb1bxreM-LXmC7uAf.js";
4
+ import { SmrtCollection } from "@happyvertical/smrt-core";
5
+ //#region ../profiles/dist/chunks/OidcIdentityCollection-TV8VdK69.js
6
+ var OidcIdentityCollection_TV8VdK69_exports = /* @__PURE__ */ __exportAll({
7
+ n: () => OidcIdentityCollection,
8
+ r: () => OidcIdentityCollection_exports,
9
+ t: () => AmbiguousOidcIdentityError
10
+ });
11
+ var OidcIdentityCollection_exports = /* @__PURE__ */ __exportAll$1({
12
+ AmbiguousOidcIdentityError: () => AmbiguousOidcIdentityError,
13
+ OidcIdentityCollection: () => OidcIdentityCollection
14
+ });
15
+ var AmbiguousOidcIdentityError = class extends Error {
16
+ constructor(issuer, subject) {
17
+ super("Multiple OIDC identities match the same issuer and subject.");
18
+ this.issuer = issuer;
19
+ this.subject = subject;
20
+ this.name = "AmbiguousOidcIdentityError";
21
+ }
22
+ issuer;
23
+ subject;
24
+ };
25
+ var OidcIdentityCollection = class extends SmrtCollection {
26
+ static _itemClass = OidcIdentity;
27
+ /**
28
+ * Find identities for a profile
29
+ */
30
+ async findByProfile(profileId) {
31
+ return await this.list({ where: { profileId } });
32
+ }
33
+ /**
34
+ * Find identity by issuer and subject
35
+ */
36
+ async findBySubject(issuer, subject) {
37
+ const result = await this.db.query(`SELECT CAST(id AS VARCHAR) AS id,
38
+ CAST(profile_id AS VARCHAR) AS profile_id
39
+ FROM oidc_identities
40
+ WHERE issuer = ? AND subject = ?
41
+ LIMIT 2`, issuer, subject);
42
+ if (result.rows.length > 1) throw new AmbiguousOidcIdentityError(issuer, subject);
43
+ const row = result.rows[0];
44
+ const id = row?.id;
45
+ const profileId = row?.profile_id;
46
+ if (typeof id !== "string" || typeof profileId !== "string") return null;
47
+ const identity = await this.get({ id });
48
+ if (!identity) return null;
49
+ identity.id = id;
50
+ identity.profileId = profileId;
51
+ return identity;
52
+ }
53
+ /**
54
+ * Find identities by provider
55
+ */
56
+ async findByProvider(provider) {
57
+ return await this.list({ where: { provider } });
58
+ }
59
+ /**
60
+ * Reuse an existing exact OIDC identity for its unchanged Profile.
61
+ *
62
+ * @deprecated New authentication links require the owner-aware,
63
+ * transactional provisioning APIs. This compatibility helper may refresh a
64
+ * legacy Profile type, but refuses to create or rebind authority.
65
+ */
66
+ async linkToProfile(profile, oidcData) {
67
+ return OidcIdentity.findOrCreate(profile, oidcData, this.options);
68
+ }
69
+ /**
70
+ * Unlink an OIDC identity from a profile
71
+ */
72
+ async unlinkFromProfile(profileId, issuer, subject) {
73
+ const identity = await this.findOne({ where: {
74
+ profileId,
75
+ issuer,
76
+ subject
77
+ } });
78
+ if (identity) {
79
+ await identity.delete();
80
+ return true;
81
+ }
82
+ return false;
83
+ }
84
+ };
85
+ //#endregion
86
+ export { OidcIdentityCollection as n, OidcIdentityCollection_TV8VdK69_exports as r, AmbiguousOidcIdentityError as t };
@@ -0,0 +1,101 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
+ import { i as tenantId, r as TenantScoped } from "./dist-C87Ib9Vx.js";
3
+ import { n as __exportAll$1 } from "./NostrIdentity-n70E0vck-Di3_eNCq.js";
4
+ import { a as getOwnedAssetsFromCollection, o as removeOwnedAssetFromCollection, t as addOwnedAssetFromCollection } from "./dist-RSE5hCY4.js";
5
+ import { SmrtJunction, SmrtObject, crossPackageRef, field, foreignKey, smrt } from "@happyvertical/smrt-core";
6
+ //#region ../profiles/dist/chunks/ProfileAssetCollection-B9hacUJa.js
7
+ var ProfileAssetCollection_B9hacUJa_exports = /* @__PURE__ */ __exportAll({
8
+ n: () => ProfileAssetCollection_exports,
9
+ r: () => ProfileAsset,
10
+ t: () => ProfileAssetCollection
11
+ });
12
+ var __defProp$1 = Object.defineProperty;
13
+ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
14
+ var __decorateClass$1 = (decorators, target, key, kind) => {
15
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
16
+ for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
17
+ if (kind && result) __defProp$1(target, key, result);
18
+ return result;
19
+ };
20
+ var ProfileAsset = class extends SmrtObject {
21
+ tenantId = null;
22
+ profileId = "";
23
+ assetId = "";
24
+ relationship = "attachment";
25
+ sortOrder = 0;
26
+ constructor(options = {}) {
27
+ super(options);
28
+ if (options.profileId) this.profileId = options.profileId;
29
+ if (options.assetId) this.assetId = options.assetId;
30
+ if (options.relationship) this.relationship = options.relationship;
31
+ if (options.sortOrder !== void 0) this.sortOrder = options.sortOrder;
32
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
33
+ }
34
+ };
35
+ __decorateClass$1([tenantId({ nullable: true })], ProfileAsset.prototype, "tenantId", 2);
36
+ __decorateClass$1([foreignKey("Profile", {
37
+ required: true,
38
+ onDelete: "CASCADE"
39
+ })], ProfileAsset.prototype, "profileId", 2);
40
+ __decorateClass$1([crossPackageRef("@happyvertical/smrt-assets:Asset", {
41
+ required: true,
42
+ onDelete: "CASCADE"
43
+ })], ProfileAsset.prototype, "assetId", 2);
44
+ __decorateClass$1([field({ required: true })], ProfileAsset.prototype, "relationship", 2);
45
+ __decorateClass$1([field()], ProfileAsset.prototype, "sortOrder", 2);
46
+ ProfileAsset = __decorateClass$1([TenantScoped({ mode: "optional" }), smrt({
47
+ tableName: "profile_assets",
48
+ conflictColumns: [
49
+ "profile_id",
50
+ "asset_id",
51
+ "relationship"
52
+ ],
53
+ api: false,
54
+ mcp: false,
55
+ cli: false
56
+ })], ProfileAsset);
57
+ var ProfileAssetCollection_exports = /* @__PURE__ */ __exportAll$1({ ProfileAssetCollection: () => ProfileAssetCollection });
58
+ var __defProp = Object.defineProperty;
59
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
60
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
61
+ enumerable: true,
62
+ configurable: true,
63
+ writable: true,
64
+ value
65
+ }) : obj[key] = value;
66
+ var __decorateClass = (decorators, target, key, kind) => {
67
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
68
+ for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
69
+ if (kind && result) __defProp(target, key, result);
70
+ return result;
71
+ };
72
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
73
+ var ProfileAssetCollection = class extends SmrtJunction {
74
+ leftField = "profileId";
75
+ rightField = "assetId";
76
+ profileCollectionPromise = null;
77
+ async getProfileCollection() {
78
+ if (!this.profileCollectionPromise) {
79
+ const { ProfileCollection } = await import("./ProfileCollection-DuJT7Mum-nXbHrPpX.js").then((n) => n.o).then((n) => n.r);
80
+ this.profileCollectionPromise = ProfileCollection.create({ db: this.db });
81
+ }
82
+ return this.profileCollectionPromise;
83
+ }
84
+ async getAssets(profileId, relationship) {
85
+ return getOwnedAssetsFromCollection(await this.getProfileCollection(), profileId, relationship);
86
+ }
87
+ async addAsset(profileId, asset, relationship = "attachment", sortOrder = 0) {
88
+ await addOwnedAssetFromCollection(await this.getProfileCollection(), "Profile", profileId, asset, relationship, sortOrder);
89
+ }
90
+ async removeAsset(profileId, assetId, relationship) {
91
+ await removeOwnedAssetFromCollection(await this.getProfileCollection(), "Profile", profileId, assetId, relationship);
92
+ }
93
+ };
94
+ __publicField(ProfileAssetCollection, "_itemClass", ProfileAsset);
95
+ ProfileAssetCollection = __decorateClass([smrt({
96
+ api: false,
97
+ mcp: false,
98
+ cli: false
99
+ })], ProfileAssetCollection);
100
+ //#endregion
101
+ export { ProfileAssetCollection as n, ProfileAssetCollection_B9hacUJa_exports as r, ProfileAsset as t };
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
2
- import { a as queryGlobal, i as tenantId, l as withSystemContext, n as resolvePrompt, o as queryWithGlobals, r as TenantScoped, s as getTenantId, t as definePrompt } from "./dist-B62O-xH6.js";
3
- import { n as __exportAll$1 } from "./NostrIdentity-n70E0vck-CLGPdJ1W.js";
4
- import { a as getOwnedAssetsFromCollection, i as assertValidOwnedAssetSortOrder, n as assertAssetLinkable, o as removeOwnedAssetFromCollection, r as assertValidOwnedAssetRelationship, s as resolveOwnedAssetsById, t as addOwnedAssetFromCollection } from "./dist-C8BOgli4.js";
2
+ import { a as queryGlobal, i as tenantId, l as withSystemContext, n as resolvePrompt, o as queryWithGlobals, r as TenantScoped, s as getTenantId, t as definePrompt } from "./dist-C87Ib9Vx.js";
3
+ import { n as __exportAll$1 } from "./NostrIdentity-n70E0vck-Di3_eNCq.js";
4
+ import { a as getOwnedAssetsFromCollection, i as assertValidOwnedAssetSortOrder, n as assertAssetLinkable, o as removeOwnedAssetFromCollection, r as assertValidOwnedAssetRelationship, s as resolveOwnedAssetsById, t as addOwnedAssetFromCollection } from "./dist-RSE5hCY4.js";
5
5
  import { RuntimeError, SmrtCollection, SmrtObject, ValidationError, field, foreignKey, isAbortedTransactionError, oneToMany, smrt } from "@happyvertical/smrt-core";
6
6
  import { BackfillTableUnavailableError, BackfillTracker } from "@happyvertical/smrt-core/migrations";
7
7
  //#region ../profiles/dist/chunks/ProfileCollection-DuJT7Mum.js
@@ -134,7 +134,7 @@ async function coordinateOidcProvisioning(options) {
134
134
  });
135
135
  }
136
136
  async function withProvisioningLocks(db, lockKeys, callback) {
137
- const keys = [.../* @__PURE__ */ new Set([...!isPostgresDatabase(db) || typeof db.beginTransaction !== "function" ? ["adapter-transaction"] : [], ...lockKeys])].sort();
137
+ const keys = [.../* @__PURE__ */ new Set([...!isPostgresDatabase$1(db) || typeof db.beginTransaction !== "function" ? ["adapter-transaction"] : [], ...lockKeys])].sort();
138
138
  const acquire = (index) => index >= keys.length ? callback() : withProvisioningLock(db, keys[index], () => acquire(index + 1));
139
139
  return acquire(0);
140
140
  }
@@ -198,10 +198,10 @@ async function withProvisioningLock(db, lockKey, callback) {
198
198
  }
199
199
  function getDatabaseLockKey(db) {
200
200
  const url = db.url;
201
- if (isPostgresDatabase(db) && typeof db.beginTransaction !== "function" && db.client !== null && (typeof db.client === "object" || typeof db.client === "function")) return db.client;
202
- return url && !isPostgresDatabase(db) ? url : db;
201
+ if (isPostgresDatabase$1(db) && typeof db.beginTransaction !== "function" && db.client !== null && (typeof db.client === "object" || typeof db.client === "function")) return db.client;
202
+ return url && !isPostgresDatabase$1(db) ? url : db;
203
203
  }
204
- function isPostgresDatabase(db) {
204
+ function isPostgresDatabase$1(db) {
205
205
  return /^postgres(?:ql)?:/iu.test(db.url ?? "");
206
206
  }
207
207
  async function retryProvisioning(options, callback) {
@@ -430,8 +430,8 @@ var Profile = class extends SmrtObject {
430
430
  * @param value - The value to set
431
431
  */
432
432
  async addMetadata(metafieldSlug, value) {
433
- const { ProfileMetafieldCollection } = await import("./ProfileMetafieldCollection-CoBuM_5G-BXtoIP02.js").then((n) => n.n);
434
- const { ProfileMetadataCollection } = await import("./ProfileMetadataCollection-DQhbfEfa-BQTogfVX.js").then((n) => n.n);
433
+ const { ProfileMetafieldCollection } = await import("./ProfileMetafieldCollection-CoBuM_5G-CPjW3l5r.js").then((n) => n.r).then((n) => n.n);
434
+ const { ProfileMetadataCollection } = await import("./ProfileMetadataCollection-DQhbfEfa-_1rQCLTR.js").then((n) => n.r).then((n) => n.n);
435
435
  const metafield = await this.resolveMetafield(await ProfileMetafieldCollection.create(this.options), metafieldSlug);
436
436
  if (!metafield) throw new Error(`Metafield '${metafieldSlug}' not found`);
437
437
  await metafield.validateValue(value);
@@ -464,7 +464,7 @@ var Profile = class extends SmrtObject {
464
464
  * @returns Object with metafield slugs as keys
465
465
  */
466
466
  async getMetadata() {
467
- const { ProfileMetadataCollection } = await import("./ProfileMetadataCollection-DQhbfEfa-BQTogfVX.js").then((n) => n.n);
467
+ const { ProfileMetadataCollection } = await import("./ProfileMetadataCollection-DQhbfEfa-_1rQCLTR.js").then((n) => n.r).then((n) => n.n);
468
468
  return await (await ProfileMetadataCollection.create(this.options)).getMetadataObject(this.id);
469
469
  }
470
470
  /**
@@ -481,8 +481,8 @@ var Profile = class extends SmrtObject {
481
481
  * @param metafieldSlug - The slug of the metafield to remove
482
482
  */
483
483
  async removeMetadata(metafieldSlug) {
484
- const { ProfileMetafieldCollection } = await import("./ProfileMetafieldCollection-CoBuM_5G-BXtoIP02.js").then((n) => n.n);
485
- const { ProfileMetadataCollection } = await import("./ProfileMetadataCollection-DQhbfEfa-BQTogfVX.js").then((n) => n.n);
484
+ const { ProfileMetafieldCollection } = await import("./ProfileMetafieldCollection-CoBuM_5G-CPjW3l5r.js").then((n) => n.r).then((n) => n.n);
485
+ const { ProfileMetadataCollection } = await import("./ProfileMetadataCollection-DQhbfEfa-_1rQCLTR.js").then((n) => n.r).then((n) => n.n);
486
486
  const metafield = await this.resolveMetafield(await ProfileMetafieldCollection.create(this.options), metafieldSlug);
487
487
  if (!metafield) throw new Error(`Metafield '${metafieldSlug}' not found`);
488
488
  const existing = await (await ProfileMetadataCollection.create(this.options)).list({
@@ -507,7 +507,7 @@ var Profile = class extends SmrtObject {
507
507
  return candidates.find((candidate) => ownerTenantId && candidate.tenantId === ownerTenantId) ?? candidates.find((candidate) => !candidate.tenantId) ?? null;
508
508
  }
509
509
  async getProfileLinkCollection() {
510
- const { ProfileLinkCollection } = await import("./ProfileLinkCollection-4uNURz32-CHDTinax.js").then((n) => n.r);
510
+ const { ProfileLinkCollection } = await import("./ProfileLinkCollection-4uNURz32-CbKZYmYm.js").then((n) => n.i).then((n) => n.r);
511
511
  return ProfileLinkCollection.create({ db: this.db });
512
512
  }
513
513
  /** This profile's web links in display order. */
@@ -524,7 +524,7 @@ var Profile = class extends SmrtObject {
524
524
  return (await this.getProfileLinkCollection()).replaceForProfile(this.id, links);
525
525
  }
526
526
  async getProfileAssetCollection() {
527
- const { ProfileAssetCollection } = await import("./ProfileAssetCollection-B9hacUJa-D33sifgF.js").then((n) => n.n);
527
+ const { ProfileAssetCollection } = await import("./ProfileAssetCollection-B9hacUJa-CPuaWLk4.js").then((n) => n.r).then((n) => n.n);
528
528
  return ProfileAssetCollection.create({ db: this.db });
529
529
  }
530
530
  async getAssets(relationship) {
@@ -555,9 +555,9 @@ var Profile = class extends SmrtObject {
555
555
  * @param contextProfile - Optional context profile for tertiary relationships
556
556
  */
557
557
  async addRelationship(toProfile, relationshipSlug, contextProfile) {
558
- const { ProfileRelationshipTypeCollection } = await import("./ProfileRelationshipTypeCollection-BdXwd7Kf-Co3PdH01.js").then((n) => n.n);
559
- const { ProfileRelationshipCollection } = await import("./ProfileRelationshipCollection-DUVgaIqf-CNMliUF3.js").then((n) => n.n);
560
- const { ProfileRelationshipType } = await import("./ProfileRelationshipType-BRiRka6t-xzRfZRFG.js").then((n) => n.n).then((n) => n.n);
558
+ const { ProfileRelationshipTypeCollection } = await import("./ProfileRelationshipTypeCollection-BdXwd7Kf-HoTmV1q-.js").then((n) => n.n).then((n) => n.n);
559
+ const { ProfileRelationshipCollection } = await import("./ProfileRelationshipCollection-DUVgaIqf-RCDqYz6O.js").then((n) => n.r).then((n) => n.n);
560
+ const { ProfileRelationshipType } = await import("./ProfileRelationshipType-BRiRka6t-Dezjv5jP.js").then((n) => n.n).then((n) => n.n);
561
561
  const relationshipType = await (await ProfileRelationshipTypeCollection.create(this.options)).getBySlug(relationshipSlug);
562
562
  if (!relationshipType) throw new Error(`Relationship type '${relationshipSlug}' not found`);
563
563
  const relationshipCollection = await ProfileRelationshipCollection.create(this.options);
@@ -581,8 +581,8 @@ var Profile = class extends SmrtObject {
581
581
  * @returns Array of ProfileRelationship instances
582
582
  */
583
583
  async getRelationships(options) {
584
- const { ProfileRelationshipCollection } = await import("./ProfileRelationshipCollection-DUVgaIqf-CNMliUF3.js").then((n) => n.n);
585
- const { ProfileRelationshipTypeCollection } = await import("./ProfileRelationshipTypeCollection-BdXwd7Kf-Co3PdH01.js").then((n) => n.n);
584
+ const { ProfileRelationshipCollection } = await import("./ProfileRelationshipCollection-DUVgaIqf-RCDqYz6O.js").then((n) => n.r).then((n) => n.n);
585
+ const { ProfileRelationshipTypeCollection } = await import("./ProfileRelationshipTypeCollection-BdXwd7Kf-HoTmV1q-.js").then((n) => n.n).then((n) => n.n);
586
586
  const relationshipCollection = await ProfileRelationshipCollection.create(this.options);
587
587
  const direction = options?.direction || "all";
588
588
  let typeId;
@@ -625,8 +625,8 @@ var Profile = class extends SmrtObject {
625
625
  * @param relationshipSlug - The type of relationship to remove
626
626
  */
627
627
  async removeRelationship(toProfile, relationshipSlug) {
628
- const { ProfileRelationshipTypeCollection } = await import("./ProfileRelationshipTypeCollection-BdXwd7Kf-Co3PdH01.js").then((n) => n.n);
629
- const { ProfileRelationshipCollection } = await import("./ProfileRelationshipCollection-DUVgaIqf-CNMliUF3.js").then((n) => n.n);
628
+ const { ProfileRelationshipTypeCollection } = await import("./ProfileRelationshipTypeCollection-BdXwd7Kf-HoTmV1q-.js").then((n) => n.n).then((n) => n.n);
629
+ const { ProfileRelationshipCollection } = await import("./ProfileRelationshipCollection-DUVgaIqf-RCDqYz6O.js").then((n) => n.r).then((n) => n.n);
630
630
  const relationshipType = await (await ProfileRelationshipTypeCollection.create(this.options)).getBySlug(relationshipSlug);
631
631
  if (!relationshipType) throw new Error(`Relationship type '${relationshipSlug}' not found`);
632
632
  const relationshipCollection = await ProfileRelationshipCollection.create(this.options);
@@ -719,7 +719,7 @@ var Profile = class extends SmrtObject {
719
719
  * @returns Array of API keys
720
720
  */
721
721
  async getApiKeys() {
722
- const { ApiKeyCollection } = await import("./ApiKeyCollection-Bfb_nw81-DR5XF_SZ.js").then((n) => n.n);
722
+ const { ApiKeyCollection } = await import("./ApiKeyCollection-Bfb_nw81-DYAZwx0O.js").then((n) => n.n).then((n) => n.n);
723
723
  return await (await ApiKeyCollection.create(this.options)).findByProfile(this.id);
724
724
  }
725
725
  /**
@@ -728,7 +728,7 @@ var Profile = class extends SmrtObject {
728
728
  * @returns Array of active API keys
729
729
  */
730
730
  async getActiveApiKeys() {
731
- const { ApiKeyCollection } = await import("./ApiKeyCollection-Bfb_nw81-DR5XF_SZ.js").then((n) => n.n);
731
+ const { ApiKeyCollection } = await import("./ApiKeyCollection-Bfb_nw81-DYAZwx0O.js").then((n) => n.n).then((n) => n.n);
732
732
  return await (await ApiKeyCollection.create(this.options)).findActiveByProfile(this.id);
733
733
  }
734
734
  /**
@@ -738,7 +738,7 @@ var Profile = class extends SmrtObject {
738
738
  * @returns The generated key (plaintext) and ApiKey record
739
739
  */
740
740
  async generateApiKey(options) {
741
- const { ApiKey } = await import("./ApiKey-BZmbOTnL-DchyhIPA.js").then((n) => n.n).then((n) => n.n);
741
+ const { ApiKey } = await import("./ApiKey-BZmbOTnL-BbZupUZ3.js").then((n) => n.n).then((n) => n.n);
742
742
  return await ApiKey.generate(this, {
743
743
  ...options,
744
744
  db: this.options?.db
@@ -750,7 +750,7 @@ var Profile = class extends SmrtObject {
750
750
  * @returns Array of OIDC identity records
751
751
  */
752
752
  async getOidcIdentities() {
753
- const { OidcIdentityCollection } = await import("./OidcIdentityCollection-TV8VdK69-2fZROnih.js").then((n) => n.r);
753
+ const { OidcIdentityCollection } = await import("./OidcIdentityCollection-TV8VdK69-Cv1ZTeuk.js").then((n) => n.r).then((n) => n.r);
754
754
  return await (await OidcIdentityCollection.create(this.options)).findByProfile(this.id);
755
755
  }
756
756
  /**
@@ -763,7 +763,7 @@ var Profile = class extends SmrtObject {
763
763
  * type, but refuses to create or rebind authority.
764
764
  */
765
765
  async linkOidcIdentity(oidcData) {
766
- const { OidcIdentityCollection } = await import("./OidcIdentityCollection-TV8VdK69-2fZROnih.js").then((n) => n.r);
766
+ const { OidcIdentityCollection } = await import("./OidcIdentityCollection-TV8VdK69-Cv1ZTeuk.js").then((n) => n.r).then((n) => n.r);
767
767
  return await (await OidcIdentityCollection.create(this.options)).linkToProfile(this, oidcData);
768
768
  }
769
769
  /**
@@ -772,7 +772,7 @@ var Profile = class extends SmrtObject {
772
772
  * @returns Array of Nostr identity records
773
773
  */
774
774
  async getNostrIdentities() {
775
- const { NostrIdentityCollection } = await import("./NostrIdentityCollection-Ca74dkaL-C2r-uDlC.js").then((n) => n.n);
775
+ const { NostrIdentityCollection } = await import("./NostrIdentityCollection-Ca74dkaL-DvjOg9Xy.js").then((n) => n.n).then((n) => n.n);
776
776
  return await (await NostrIdentityCollection.create(this.options)).findByProfile(this.id);
777
777
  }
778
778
  /**
@@ -782,7 +782,7 @@ var Profile = class extends SmrtObject {
782
782
  * @returns The linked Nostr identity record
783
783
  */
784
784
  async linkNostrIdentity(nostrData) {
785
- const { NostrIdentityCollection } = await import("./NostrIdentityCollection-Ca74dkaL-C2r-uDlC.js").then((n) => n.n);
785
+ const { NostrIdentityCollection } = await import("./NostrIdentityCollection-Ca74dkaL-DvjOg9Xy.js").then((n) => n.n).then((n) => n.n);
786
786
  return await (await NostrIdentityCollection.create(this.options)).linkToProfile(this, nostrData);
787
787
  }
788
788
  /**
@@ -792,7 +792,7 @@ var Profile = class extends SmrtObject {
792
792
  * @returns Array of audit log entries
793
793
  */
794
794
  async getAuditLogs(limit = 50) {
795
- const { AuditLogCollection } = await import("./AuditLogCollection-B1YonCAP-PbzALncL.js").then((n) => n.n);
795
+ const { AuditLogCollection } = await import("./AuditLogCollection-B1YonCAP-Bkj2Ezon.js").then((n) => n.r).then((n) => n.n);
796
796
  return await (await AuditLogCollection.create(this.options)).getRecentActivity(this.id, limit);
797
797
  }
798
798
  /**
@@ -802,7 +802,7 @@ var Profile = class extends SmrtObject {
802
802
  * @returns The created audit log entry
803
803
  */
804
804
  async recordAction(options) {
805
- const { AuditLogCollection } = await import("./AuditLogCollection-B1YonCAP-PbzALncL.js").then((n) => n.n);
805
+ const { AuditLogCollection } = await import("./AuditLogCollection-B1YonCAP-Bkj2Ezon.js").then((n) => n.r).then((n) => n.n);
806
806
  return await (await AuditLogCollection.create(this.options)).record({
807
807
  profile: this,
808
808
  ...options
@@ -1165,4 +1165,4 @@ function readRequiredString(row, key) {
1165
1165
  return value;
1166
1166
  }
1167
1167
  //#endregion
1168
- export { coordinateOidcProvisioning as a, saveOidcRaceArbiter as c, ProfileType as i, ProfileCollection as n, isOidcProvisioningRaceConflict as o, ProfileCollection_DuJT7Mum_exports as r, normalizeIdentityEmail as s, Profile as t };
1168
+ export { ProfileCollection as a, coordinateOidcProvisioning as c, promptMessageOptions as d, saveOidcRaceArbiter as f, Profile as i, isOidcProvisioningRaceConflict as l, OidcProfileEmailReservation as n, ProfileCollection_DuJT7Mum_exports as o, smrtProfilesGenerateBioPrompt as p, OidcProfileEmailReservationCollection as r, ProfileType as s, CanonicalPersonProfileError as t, normalizeIdentityEmail as u };