@happyvertical/smrt-profiles 0.51.13 → 0.51.14

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 (47) hide show
  1. package/dist/chunks/{ApiKey-DIqCzx-g.js → ApiKey-BZmbOTnL.js} +3 -3
  2. package/dist/chunks/{ApiKey-DIqCzx-g.js.map → ApiKey-BZmbOTnL.js.map} +1 -1
  3. package/dist/chunks/{ApiKeyCollection-CNFptBxU.js → ApiKeyCollection-Bfb_nw81.js} +3 -3
  4. package/dist/chunks/{ApiKeyCollection-CNFptBxU.js.map → ApiKeyCollection-Bfb_nw81.js.map} +1 -1
  5. package/dist/chunks/{AuditLogCollection-DxR3ZG6_.js → AuditLogCollection-B1YonCAP.js} +2 -2
  6. package/dist/chunks/{AuditLogCollection-DxR3ZG6_.js.map → AuditLogCollection-B1YonCAP.js.map} +1 -1
  7. package/dist/chunks/NostrIdentity-n70E0vck.js +4279 -0
  8. package/dist/chunks/NostrIdentity-n70E0vck.js.map +1 -0
  9. package/dist/chunks/{NostrIdentityCollection-BXtvB0Sd.js → NostrIdentityCollection-Ca74dkaL.js} +2 -2
  10. package/dist/chunks/{NostrIdentityCollection-BXtvB0Sd.js.map → NostrIdentityCollection-Ca74dkaL.js.map} +1 -1
  11. package/dist/chunks/{OidcIdentity-DISriiph.js → OidcIdentity-CChQnYNH.js} +3 -3
  12. package/dist/chunks/{OidcIdentity-DISriiph.js.map → OidcIdentity-CChQnYNH.js.map} +1 -1
  13. package/dist/chunks/{OidcIdentityCollection-B6im_oL_.js → OidcIdentityCollection-D3L0WYbM.js} +3 -3
  14. package/dist/chunks/{OidcIdentityCollection-B6im_oL_.js.map → OidcIdentityCollection-D3L0WYbM.js.map} +1 -1
  15. package/dist/chunks/{ProfileAssetCollection-CuwaiTOk.js → ProfileAssetCollection-V8u4wqSL.js} +3 -3
  16. package/dist/chunks/{ProfileAssetCollection-CuwaiTOk.js.map → ProfileAssetCollection-V8u4wqSL.js.map} +1 -1
  17. package/dist/chunks/{ProfileCollection-BAC5weFA.js → ProfileCollection-BvhD2cfL.js} +24 -24
  18. package/dist/chunks/{ProfileCollection-BAC5weFA.js.map → ProfileCollection-BvhD2cfL.js.map} +1 -1
  19. package/dist/chunks/{ProfileMetadataCollection-DyVxb-Tn.js → ProfileMetadataCollection-DxX_BJKV.js} +2 -2
  20. package/dist/chunks/{ProfileMetadataCollection-DyVxb-Tn.js.map → ProfileMetadataCollection-DxX_BJKV.js.map} +1 -1
  21. package/dist/chunks/{ProfileMetafieldCollection-KSYFXBxU.js → ProfileMetafieldCollection-CMKhVi2I.js} +2 -2
  22. package/dist/chunks/{ProfileMetafieldCollection-KSYFXBxU.js.map → ProfileMetafieldCollection-CMKhVi2I.js.map} +1 -1
  23. package/dist/chunks/{ProfileRelationshipCollection-DigPX3kC.js → ProfileRelationshipCollection-DUVgaIqf.js} +5 -5
  24. package/dist/chunks/{ProfileRelationshipCollection-DigPX3kC.js.map → ProfileRelationshipCollection-DUVgaIqf.js.map} +1 -1
  25. package/dist/chunks/{ProfileRelationshipTermCollection-UkhmGHcr.js → ProfileRelationshipTermCollection-DtA9OM23.js} +2 -2
  26. package/dist/chunks/{ProfileRelationshipTermCollection-UkhmGHcr.js.map → ProfileRelationshipTermCollection-DtA9OM23.js.map} +1 -1
  27. package/dist/chunks/{ProfileRelationshipType-D1WLqC2B.js → ProfileRelationshipType-BRiRka6t.js} +2 -2
  28. package/dist/chunks/{ProfileRelationshipType-D1WLqC2B.js.map → ProfileRelationshipType-BRiRka6t.js.map} +1 -1
  29. package/dist/chunks/{ProfileRelationshipTypeCollection-BapU-NS3.js → ProfileRelationshipTypeCollection-BdXwd7Kf.js} +3 -3
  30. package/dist/chunks/{ProfileRelationshipTypeCollection-BapU-NS3.js.map → ProfileRelationshipTypeCollection-BdXwd7Kf.js.map} +1 -1
  31. package/dist/chunks/{oidcProvisioningPrimitives-BPWWsNb7.js → oidcProvisioningPrimitives-CjOkg3Zd.js} +4 -4
  32. package/dist/chunks/{oidcProvisioningPrimitives-BPWWsNb7.js.map → oidcProvisioningPrimitives-CjOkg3Zd.js.map} +1 -1
  33. package/dist/chunks/{resolveIdentity-QEWj65PQ.js → resolveIdentity-73HQnTlT.js} +16 -16
  34. package/dist/chunks/{resolveIdentity-QEWj65PQ.js.map → resolveIdentity-73HQnTlT.js.map} +1 -1
  35. package/dist/index.d.ts +27 -0
  36. package/dist/index.js +22 -22
  37. package/dist/internal/oidc-provisioning.d.ts +119 -14
  38. package/dist/internal/oidc-provisioning.js +2 -2
  39. package/dist/manifest.json +1 -1
  40. package/dist/smrt-knowledge.json +6 -6
  41. package/dist/types.d.ts +27 -0
  42. package/dist/utils.d.ts +27 -0
  43. package/dist/utils.js +4 -4
  44. package/package.json +10 -10
  45. package/dist/chunks/NostrIdentity-CbnAJgg9.js +0 -3155
  46. package/dist/chunks/NostrIdentity-CbnAJgg9.js.map +0 -1
  47. package/dist/oidc-provisioning.d.ts +0 -95
@@ -1,17 +1,122 @@
1
- import { getDatabase } from '@happyvertical/sql';
2
- import { OidcProvisioningIdentityInput, OidcProvisioningPersonInput } from '../auth/oidcProvisioningPrimitives';
3
- export { coordinateOidcProvisioning, isOidcAbortedTransactionError, isOidcProvisioningRaceConflict, type OidcProvisioningCoordinatorOptions, type OidcProvisioningRaceClassifierOptions, saveOidcRaceArbiter, } from '../auth/oidcProvisioningCoordinator.js';
4
- type DatabaseInterface = Awaited<ReturnType<typeof getDatabase>>;
5
- export type { OidcProvisioningIdentityInput, OidcProvisioningPersonInput };
1
+ import { getDatabase } from '@happyvertical/sql';
2
+
3
+ /**
4
+ * Coordinate one OIDC provisioning operation across adapters.
5
+ *
6
+ * Root adapters must expose `beginTransaction`. Already-bound adapters must
7
+ * support savepoints. An adapter that exposes only `transaction()` is
8
+ * intentionally ambiguous and fails closed instead of risking a nested
9
+ * transaction that could roll back its caller's work.
10
+ */
11
+ export declare function coordinateOidcProvisioning<T>(options: OidcProvisioningCoordinatorOptions<T>): Promise<T>;
12
+
13
+ /**
14
+ * Trusted integration surface for framework packages participating in the
15
+ * owner-aware OIDC provisioning transaction.
16
+ *
17
+ * Application code should use UserCollection.getOrCreateFromOidc() instead.
18
+ * The generic result avoids duplicating nominal SMRT model declarations across
19
+ * package entry bundles; trusted callers bind it to the root package model.
20
+ */
21
+ export declare function createOidcProvisioningPerson<TProfile>(db: DatabaseInterface, input: OidcProvisioningPersonInput): Promise<TProfile>;
22
+
23
+ declare type DatabaseInterface = Awaited<ReturnType<typeof getDatabase>>;
24
+
25
+ declare type DatabaseInterface_2 = Awaited<ReturnType<typeof getDatabase>>;
26
+
27
+ /** Trusted integration insert after the caller proves Profile ownership. */
28
+ export declare function insertOidcProvisioningIdentity<TIdentity>(db: DatabaseInterface, input: OidcProvisioningIdentityInput): Promise<TIdentity>;
29
+
30
+ /**
31
+ * Detect an adapter error caused by an aborted transaction.
32
+ *
33
+ * Reduced to the framework contract in #2366. The heuristic this replaced
34
+ * matched a bare `/transaction.*aborted/` against every message in the chain,
35
+ * which would misclassify a genuine foreign-key or check violation whose text
36
+ * happened to mention a transaction. Core now recognizes PostgreSQL's
37
+ * `25P02 in_failed_sql_transaction` from the driver's own SQLSTATE, whichever
38
+ * layer wrapped it.
39
+ *
40
+ * Kept as a named export because it is part of this package's provisioning
41
+ * API surface; the body is now a single delegation.
42
+ */
43
+ export declare function isOidcAbortedTransactionError(error: unknown): boolean;
44
+
45
+ /** Classify only the durable constraints used to converge OIDC retries. */
46
+ export declare function isOidcProvisioningRaceConflict(error: unknown, options?: OidcProvisioningRaceClassifierOptions): boolean;
47
+
48
+ /** Shared transaction and concurrency policy for OIDC provisioning. */
49
+ export declare interface OidcProvisioningCoordinatorOptions<T> {
50
+ /** Root or transaction-bound database used for every provisioning write. */
51
+ db: DatabaseInterface_2;
52
+ /**
53
+ * Stable keys used for local serialization. Supply both the exact
54
+ * issuer/subject key and normalized email when available.
55
+ */
56
+ lockKeys: readonly string[];
57
+ /** Package-specific durable race-arbiter classifier. */
58
+ isRaceConflict: (error: unknown) => boolean;
59
+ /** Package-specific transaction failure mapping. */
60
+ createTransactionError: (message: string, cause?: unknown) => Error;
61
+ /** Package-specific terminal concurrency failure mapping. */
62
+ createConcurrencyError: (cause?: unknown) => Error;
63
+ /** Provision atomically using the supplied transaction-bound handle. */
64
+ provision: (tx: DatabaseInterface_2) => Promise<T>;
65
+ /**
66
+ * Rehydrate root-owned results after commit so models do not retain a
67
+ * released transaction client. Omit for non-model results.
68
+ */
69
+ rebindRootResult?: (result: T, rootDb: DatabaseInterface_2) => Promise<T>;
70
+ }
71
+
72
+ export declare interface OidcProvisioningIdentityInput {
73
+ email?: string;
74
+ issuer: string;
75
+ profileId: string;
76
+ provider: string;
77
+ subject: string;
78
+ }
79
+
80
+ export declare interface OidcProvisioningPersonInput {
81
+ email?: string;
82
+ name?: string;
83
+ preferredUsername?: string;
84
+ subject: string;
85
+ }
86
+
87
+ export declare interface OidcProvisioningRaceClassifierOptions {
88
+ /** Package-specific database constraint messages. */
89
+ messagePatterns?: readonly RegExp[];
90
+ }
91
+
92
+ /** Wrap a known OIDC arbiter write so only its unique failure is retryable. */
93
+ export declare function saveOidcRaceArbiter<T>(operation: () => Promise<T>): Promise<T>;
94
+
95
+ export { }
96
+
97
+
6
98
  /**
7
- * Trusted integration surface for framework packages participating in the
8
- * owner-aware OIDC provisioning transaction.
99
+ * Extend globalThis to include custom validators registry.
100
+ * Using globalThis ensures all module instances share the same validators,
101
+ * which is critical in monorepos where the same package can be loaded
102
+ * from different paths (e.g., pnpm store vs workspace symlink).
9
103
  *
10
- * Application code should use UserCollection.getOrCreateFromOidc() instead.
11
- * The generic result avoids duplicating nominal SMRT model declarations across
12
- * package entry bundles; trusted callers bind it to the root package model.
104
+ * @see https://github.com/happyvertical/smrt/issues/543
13
105
  */
14
- export declare function createOidcProvisioningPerson<TProfile>(db: DatabaseInterface, input: OidcProvisioningPersonInput): Promise<TProfile>;
15
- /** Trusted integration insert after the caller proves Profile ownership. */
16
- export declare function insertOidcProvisioningIdentity<TIdentity>(db: DatabaseInterface, input: OidcProvisioningIdentityInput): Promise<TIdentity>;
17
- //# sourceMappingURL=oidc-provisioning.d.ts.map
106
+ declare global {
107
+ var __smrtProfileMetafieldValidators: Map<string, ValidatorFunction> | undefined;
108
+ }
109
+
110
+
111
+ /**
112
+ * Extend globalThis to include reciprocal handlers registry.
113
+ * Using globalThis ensures all module instances share the same handlers,
114
+ * which is critical in monorepos where the same package can be loaded
115
+ * from different paths (e.g., pnpm store vs workspace symlink).
116
+ *
117
+ * @see https://github.com/happyvertical/smrt/issues/543
118
+ */
119
+ declare global {
120
+ var __smrtProfileRelationshipHandlers: Map<string, ReciprocalHandler> | undefined;
121
+ var __smrtProfileRelationshipHandlersInitialized: boolean | undefined;
122
+ }
@@ -1,5 +1,5 @@
1
- import { d as isOidcProvisioningRaceConflict, f as saveOidcRaceArbiter, l as coordinateOidcProvisioning, u as isOidcAbortedTransactionError } from "../chunks/ProfileCollection-BAC5weFA.js";
2
- import { n as insertOidcProvisioningIdentity$1, t as createOidcProvisioningPerson$1 } from "../chunks/oidcProvisioningPrimitives-BPWWsNb7.js";
1
+ import { d as isOidcProvisioningRaceConflict, f as saveOidcRaceArbiter, l as coordinateOidcProvisioning, u as isOidcAbortedTransactionError } from "../chunks/ProfileCollection-BvhD2cfL.js";
2
+ import { n as insertOidcProvisioningIdentity$1, t as createOidcProvisioningPerson$1 } from "../chunks/oidcProvisioningPrimitives-CjOkg3Zd.js";
3
3
  //#region src/internal/oidc-provisioning.ts
4
4
  async function createOidcProvisioningPerson(db, input) {
5
5
  return await createOidcProvisioningPerson$1(db, input);
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-profiles",
5
- "packageVersion": "0.51.13",
5
+ "packageVersion": "0.51.14",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-profiles:ApiKeyCollection": {
8
8
  "name": "apikeycollection",
@@ -3,12 +3,12 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-profiles",
6
- "packageVersion": "0.51.13",
6
+ "packageVersion": "0.51.14",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "7be5d453d8a676acd73e4a996264afac31d7d280ee9aa2bfee5b3ed16d629dbf",
11
- "packageJson": "d7c7edb4c6635aaaa3a8bfe419dbfbbe193433b466e74224500f3e5e616cc630",
10
+ "manifest": "fd4b885e86b483bc28e909108df790e00f4ee0963883efda4fcf2d4e1a8ab71d",
11
+ "packageJson": "b16df0713df2f1d01d371175a71780c776cd4fd36bf4001c7e54481f8d5de35d",
12
12
  "agents": "a6646a088f8c421b5556f945946db6f83d3a23d77b34c40bb02b726af30b4bd2"
13
13
  },
14
14
  "exports": [
@@ -28,11 +28,11 @@
28
28
  "@happyvertical/smrt-tenancy": "workspace:*",
29
29
  "@happyvertical/sql": "catalog:",
30
30
  "@happyvertical/utils": "catalog:",
31
- "@noble/curves": "^1.9.7",
31
+ "@noble/curves": "^2.4.0",
32
32
  "bech32": "^2.0.0",
33
- "@faker-js/faker": "^10.5.0",
33
+ "@faker-js/faker": "^10.6.0",
34
34
  "@happyvertical/smrt-vitest": "workspace:*",
35
- "@types/node": "24.13.2",
35
+ "@types/node": "24.13.6",
36
36
  "fast-glob": "3.3.3",
37
37
  "typescript": "5.9.3",
38
38
  "vite": "8.1.4",
package/dist/types.d.ts CHANGED
@@ -709,3 +709,30 @@ export declare interface ValidationSchema {
709
709
  export declare type ValidatorFunction = (value: unknown) => boolean | Promise<boolean>;
710
710
 
711
711
  export { }
712
+
713
+
714
+ /**
715
+ * Extend globalThis to include custom validators registry.
716
+ * Using globalThis ensures all module instances share the same validators,
717
+ * which is critical in monorepos where the same package can be loaded
718
+ * from different paths (e.g., pnpm store vs workspace symlink).
719
+ *
720
+ * @see https://github.com/happyvertical/smrt/issues/543
721
+ */
722
+ declare global {
723
+ var __smrtProfileMetafieldValidators: Map<string, ValidatorFunction> | undefined;
724
+ }
725
+
726
+
727
+ /**
728
+ * Extend globalThis to include reciprocal handlers registry.
729
+ * Using globalThis ensures all module instances share the same handlers,
730
+ * which is critical in monorepos where the same package can be loaded
731
+ * from different paths (e.g., pnpm store vs workspace symlink).
732
+ *
733
+ * @see https://github.com/happyvertical/smrt/issues/543
734
+ */
735
+ declare global {
736
+ var __smrtProfileRelationshipHandlers: Map<string, ReciprocalHandler> | undefined;
737
+ var __smrtProfileRelationshipHandlersInitialized: boolean | undefined;
738
+ }
package/dist/utils.d.ts CHANGED
@@ -794,3 +794,30 @@ declare interface ValidationSchema {
794
794
  declare type ValidatorFunction = (value: unknown) => boolean | Promise<boolean>;
795
795
 
796
796
  export { }
797
+
798
+
799
+ /**
800
+ * Extend globalThis to include custom validators registry.
801
+ * Using globalThis ensures all module instances share the same validators,
802
+ * which is critical in monorepos where the same package can be loaded
803
+ * from different paths (e.g., pnpm store vs workspace symlink).
804
+ *
805
+ * @see https://github.com/happyvertical/smrt/issues/543
806
+ */
807
+ declare global {
808
+ var __smrtProfileMetafieldValidators: Map<string, ValidatorFunction> | undefined;
809
+ }
810
+
811
+
812
+ /**
813
+ * Extend globalThis to include reciprocal handlers registry.
814
+ * Using globalThis ensures all module instances share the same handlers,
815
+ * which is critical in monorepos where the same package can be loaded
816
+ * from different paths (e.g., pnpm store vs workspace symlink).
817
+ *
818
+ * @see https://github.com/happyvertical/smrt/issues/543
819
+ */
820
+ declare global {
821
+ var __smrtProfileRelationshipHandlers: Map<string, ReciprocalHandler> | undefined;
822
+ var __smrtProfileRelationshipHandlersInitialized: boolean | undefined;
823
+ }
package/dist/utils.js CHANGED
@@ -1,17 +1,17 @@
1
1
  //#region src/utils.ts
2
2
  async function getProfileMetadata(profileId, options = {}) {
3
- const { ProfileMetadataCollection } = await import("./chunks/ProfileMetadataCollection-DyVxb-Tn.js").then((n) => n.n);
3
+ const { ProfileMetadataCollection } = await import("./chunks/ProfileMetadataCollection-DxX_BJKV.js").then((n) => n.n);
4
4
  return await (await ProfileMetadataCollection.create(options)).getMetadataObject(profileId);
5
5
  }
6
6
  async function setProfileMetadata(profileId, metafieldSlug, value, options = {}) {
7
- const { ProfileCollection } = await import("./chunks/ProfileCollection-BAC5weFA.js").then((n) => n.r);
7
+ const { ProfileCollection } = await import("./chunks/ProfileCollection-BvhD2cfL.js").then((n) => n.r);
8
8
  const profile = await (await ProfileCollection.create(options)).get({ id: profileId });
9
9
  if (!profile) throw new Error(`Profile '${profileId}' not found`);
10
10
  await profile.addMetadata(metafieldSlug, value);
11
11
  }
12
12
  async function findProfilesByMeta(metafieldSlug, value, options = {}) {
13
- const { ProfileMetafieldCollection } = await import("./chunks/ProfileMetafieldCollection-KSYFXBxU.js").then((n) => n.n);
14
- const { ProfileMetadataCollection } = await import("./chunks/ProfileMetadataCollection-DyVxb-Tn.js").then((n) => n.n);
13
+ const { ProfileMetafieldCollection } = await import("./chunks/ProfileMetafieldCollection-CMKhVi2I.js").then((n) => n.n);
14
+ const { ProfileMetadataCollection } = await import("./chunks/ProfileMetadataCollection-DxX_BJKV.js").then((n) => n.n);
15
15
  const metafield = await (await ProfileMetafieldCollection.create(options)).getBySlug(metafieldSlug);
16
16
  if (!metafield) throw new Error(`Metafield '${metafieldSlug}' not found`);
17
17
  return await (await ProfileMetadataCollection.create(options)).findProfilesByMetadata(metafield.id, value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-profiles",
3
- "version": "0.51.13",
3
+ "version": "0.51.14",
4
4
  "description": "Profile management system with relationships, metadata, and reciprocal associations for SMRT framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "import": "./dist/utils.js"
21
21
  },
22
22
  "./internal/oidc-provisioning": {
23
- "types": "./dist/oidc-provisioning.d.ts",
23
+ "types": "./dist/internal/oidc-provisioning.d.ts",
24
24
  "import": "./dist/internal/oidc-provisioning.js"
25
25
  },
26
26
  "./manifest": "./dist/manifest.json",
@@ -30,19 +30,19 @@
30
30
  "@happyvertical/ai": "^0.89.12",
31
31
  "@happyvertical/files": "^0.89.12",
32
32
  "@happyvertical/logger": "^0.89.12",
33
- "@happyvertical/smrt-assets": "0.51.13",
34
- "@happyvertical/smrt-core": "0.51.13",
35
- "@happyvertical/smrt-prompts": "0.51.13",
36
- "@happyvertical/smrt-tenancy": "0.51.13",
33
+ "@happyvertical/smrt-assets": "0.51.14",
34
+ "@happyvertical/smrt-core": "0.51.14",
35
+ "@happyvertical/smrt-prompts": "0.51.14",
36
+ "@happyvertical/smrt-tenancy": "0.51.14",
37
37
  "@happyvertical/sql": "^0.89.12",
38
38
  "@happyvertical/utils": "^0.89.12",
39
- "@noble/curves": "^1.9.7",
39
+ "@noble/curves": "^2.4.0",
40
40
  "bech32": "^2.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@faker-js/faker": "^10.5.0",
44
- "@happyvertical/smrt-vitest": "0.51.13",
45
- "@types/node": "24.13.2",
43
+ "@faker-js/faker": "^10.6.0",
44
+ "@happyvertical/smrt-vitest": "0.51.14",
45
+ "@types/node": "24.13.6",
46
46
  "fast-glob": "3.3.3",
47
47
  "typescript": "5.9.3",
48
48
  "vite": "8.1.4",