@happyvertical/smrt-cli 0.55.1 → 0.55.3
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 +1 -1
- package/agents/db-migrate-concurrency.md +55 -0
- package/dist/{AuditLogCollection-WDHL-_AF-G2UOSM3H.js → AuditLogCollection-WDHL-_AF-Bgyxf5sF.js} +1 -1
- package/dist/{OidcIdentity-BjRu3n1g-CzvSN6Wz.js → OidcIdentity-BUblgQLs-B4mzosmT.js} +3 -3
- package/dist/{OidcIdentityCollection-B4jYh36_-6UWtXCwi.js → OidcIdentityCollection-ClOyaHeF-DqB9Ex4b.js} +4 -4
- package/dist/{ProfileAssetCollection-HeMtjBc0-Cz4MOeSB.js → ProfileAssetCollection-CRMcjLJ--CIoZ9Fd2.js} +6 -6
- package/dist/{ProfileCollection-Bt6IJK49-CFyOiVFz.js → ProfileCollection-C4INKh7Y-DU6dPYSG.js} +24 -19
- package/dist/{ProfileLinkCollection-u1hhzKTm-CAfIjZ4f.js → ProfileLinkCollection-DFfZRsgv-qtgfWKFC.js} +5 -5
- package/dist/{ProfileMetadataCollection-BIYKy4Y3-CqcaAHAJ.js → ProfileMetadataCollection-BIYKy4Y3-BS9BY4vO.js} +1 -1
- package/dist/{ProfileMetafieldCollection-Buz7gzag-BNRo6e4x.js → ProfileMetafieldCollection-Buz7gzag-DyUWqbh9.js} +1 -1
- package/dist/{ProfileRelationshipCollection-C4g_QLI4-DeJzJ_hF.js → ProfileRelationshipCollection-C4g_QLI4-Ci7IHfeW.js} +1 -1
- package/dist/ProfileTypeCollection-B7kwi1mU-6KYMumQp.js +103 -0
- package/dist/commands/utilities.d.ts.map +1 -1
- package/dist/{commands-CboMy2vr.js → commands-KDgVSMM3.js} +46 -27
- package/dist/{config-hqNo4lzH.js → config-CdJRSMRi.js} +2 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/{dist-F98s-wG1.js → dist-C8iSkjym.js} +4 -4
- package/dist/{dist-m9bKxs6w.js → dist-CTMZBIem.js} +16 -15
- package/dist/dist-CoCIu5cW.js +21 -0
- package/dist/{dist-N7UoPf_4.js → dist-DQg_1csT.js} +3 -3
- package/dist/{dist-wrk3GKo3.js → dist-DRSQUACn.js} +26 -6
- package/dist/index.js +14 -14
- package/dist/{json-validator-BiAdsE1O.js → json-validator-CF2oQNDw.js} +1 -1
- package/dist/oidcProvisioningPrimitives-DNP9EZlU-CUDQKgU2.js +93 -0
- package/dist/{resolveIdentity-CvGDegU6-BePPF1Iv.js → resolveIdentity-CkyqvctR-DFVUhcM1.js} +17 -17
- package/package.json +16 -16
- package/dist/dist-CkONQFUR.js +0 -20
- package/dist/oidcProvisioningPrimitives-CYood-2M-DKUWB1oI.js +0 -171
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import { c as isSystemContext } from "./dist-wrk3GKo3.js";
|
|
3
|
-
import { n as __exportAll$1 } from "./NostrIdentity-AC8fAdxe-DKxKyu_a.js";
|
|
4
|
-
import { t as OidcIdentity } from "./OidcIdentity-BjRu3n1g-CzvSN6Wz.js";
|
|
5
|
-
import { a as ProfileCollection, f as saveOidcRaceArbiter, i as Profile, s as ProfileType } from "./ProfileCollection-Bt6IJK49-CFyOiVFz.js";
|
|
6
|
-
import { SmrtCollection, smrt } from "@happyvertical/smrt-core";
|
|
7
|
-
//#region ../profiles/dist/chunks/oidcProvisioningPrimitives-CYood-2M.js
|
|
8
|
-
var oidcProvisioningPrimitives_CYood_2M_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
-
a: () => Person,
|
|
10
|
-
c: () => ProfileTypeCollection_exports,
|
|
11
|
-
i: () => Organization,
|
|
12
|
-
n: () => insertOidcProvisioningIdentity,
|
|
13
|
-
o: () => ProfileTypes_exports,
|
|
14
|
-
r: () => Bot,
|
|
15
|
-
s: () => ProfileTypeCollection,
|
|
16
|
-
t: () => createOidcProvisioningPerson
|
|
17
|
-
});
|
|
18
|
-
var ProfileTypeCollection_exports = /* @__PURE__ */ __exportAll$1({ ProfileTypeCollection: () => ProfileTypeCollection });
|
|
19
|
-
function isPostgresUrl(url) {
|
|
20
|
-
return /^postgres(?:ql)?:/iu.test(url ?? "");
|
|
21
|
-
}
|
|
22
|
-
var ProfileTypeCollection = class extends SmrtCollection {
|
|
23
|
-
static _itemClass = ProfileType;
|
|
24
|
-
/**
|
|
25
|
-
* Get profile type by slug
|
|
26
|
-
*
|
|
27
|
-
* @param slug - The slug to search for
|
|
28
|
-
* @returns ProfileType instance or null
|
|
29
|
-
*/
|
|
30
|
-
async getBySlug(slug) {
|
|
31
|
-
return await this.get({ slug });
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Get or create a profile type by slug
|
|
35
|
-
*
|
|
36
|
-
* @param slug - The slug to search for
|
|
37
|
-
* @param defaults - Default values if creating
|
|
38
|
-
* @returns ProfileType instance
|
|
39
|
-
*/
|
|
40
|
-
async getOrCreateBySlug(slug, defaults) {
|
|
41
|
-
const existing = await this.getBySlug(slug);
|
|
42
|
-
if (existing) return existing;
|
|
43
|
-
const profileType = await this.create({
|
|
44
|
-
slug,
|
|
45
|
-
...defaults
|
|
46
|
-
});
|
|
47
|
-
await profileType.save();
|
|
48
|
-
return profileType;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Atomically create or load a global ProfileType from trusted system code.
|
|
52
|
-
*
|
|
53
|
-
* This intentionally bypasses tenant auto-population and therefore refuses
|
|
54
|
-
* to run outside an explicit `withSystemContext()` boundary.
|
|
55
|
-
*/
|
|
56
|
-
async getOrCreateGlobalBySlug(slug, defaults) {
|
|
57
|
-
if (!isSystemContext()) throw new Error("Global ProfileType creation requires an explicit system context.");
|
|
58
|
-
const existing = await this.loadGlobalBySlug(slug);
|
|
59
|
-
if (existing) return existing;
|
|
60
|
-
const insertIfAbsent = async (db) => {
|
|
61
|
-
if (isPostgresUrl(db.url)) await db.query("SELECT pg_advisory_xact_lock(hashtext(?), hashtext(?))", "@happyvertical/smrt-profiles:profile_types:global", slug);
|
|
62
|
-
await db.query(`INSERT INTO profile_types
|
|
63
|
-
(id, slug, context, _meta_type, tenant_id, name, description)
|
|
64
|
-
SELECT ?, ?, '', '@happyvertical/smrt-profiles:ProfileType', NULL, ?, ?
|
|
65
|
-
WHERE NOT EXISTS (
|
|
66
|
-
SELECT 1 FROM profile_types
|
|
67
|
-
WHERE slug = ?
|
|
68
|
-
AND context = ''
|
|
69
|
-
AND _meta_type = '@happyvertical/smrt-profiles:ProfileType'
|
|
70
|
-
AND tenant_id IS NULL
|
|
71
|
-
)`, crypto.randomUUID(), slug, defaults.name, defaults.description ?? null, slug);
|
|
72
|
-
};
|
|
73
|
-
const isTransactionBound = typeof this.db.commit === "function";
|
|
74
|
-
if (isPostgresUrl(this.db.url) && !isTransactionBound && typeof this.db.transaction === "function") await this.db.transaction((tx) => insertIfAbsent(tx));
|
|
75
|
-
else await insertIfAbsent(this.db);
|
|
76
|
-
const profileType = await this.loadGlobalBySlug(slug);
|
|
77
|
-
if (!profileType) throw new Error(`Global ProfileType '${slug}' could not be created or loaded.`);
|
|
78
|
-
return profileType;
|
|
79
|
-
}
|
|
80
|
-
async loadGlobalBySlug(slug) {
|
|
81
|
-
const id = (await this.db.query(`SELECT CAST(id AS VARCHAR) AS id
|
|
82
|
-
FROM profile_types
|
|
83
|
-
WHERE slug = ?
|
|
84
|
-
AND context = ''
|
|
85
|
-
AND _meta_type = '@happyvertical/smrt-profiles:ProfileType'
|
|
86
|
-
AND tenant_id IS NULL
|
|
87
|
-
LIMIT 1`, slug)).rows[0]?.id;
|
|
88
|
-
if (typeof id !== "string") return null;
|
|
89
|
-
const profileType = await this.get({ id });
|
|
90
|
-
if (profileType) profileType.id = id;
|
|
91
|
-
return profileType;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
var ProfileTypes_exports = /* @__PURE__ */ __exportAll$1({
|
|
95
|
-
Bot: () => Bot,
|
|
96
|
-
Organization: () => Organization,
|
|
97
|
-
Person: () => Person
|
|
98
|
-
});
|
|
99
|
-
var __defProp = Object.defineProperty;
|
|
100
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
101
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
102
|
-
enumerable: true,
|
|
103
|
-
configurable: true,
|
|
104
|
-
writable: true,
|
|
105
|
-
value
|
|
106
|
-
}) : obj[key] = value;
|
|
107
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
108
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
109
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
110
|
-
if (kind && result) __defProp(target, key, result);
|
|
111
|
-
return result;
|
|
112
|
-
};
|
|
113
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
114
|
-
var Person = class extends Profile {
|
|
115
|
-
constructor(options = {}) {
|
|
116
|
-
super(options);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
__publicField(Person, "__smrtPackage__", "@happyvertical/smrt-profiles");
|
|
120
|
-
Person = __decorateClass([smrt({ tableStrategy: "sti" })], Person);
|
|
121
|
-
var Organization = class extends Profile {
|
|
122
|
-
constructor(options = {}) {
|
|
123
|
-
super(options);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
__publicField(Organization, "__smrtPackage__", "@happyvertical/smrt-profiles");
|
|
127
|
-
Organization = __decorateClass([smrt({ tableStrategy: "sti" })], Organization);
|
|
128
|
-
var Bot = class extends Profile {
|
|
129
|
-
constructor(options = {}) {
|
|
130
|
-
super(options);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
__publicField(Bot, "__smrtPackage__", "@happyvertical/smrt-profiles");
|
|
134
|
-
Bot = __decorateClass([smrt({ tableStrategy: "sti" })], Bot);
|
|
135
|
-
async function createOidcProvisioningPerson(db, input) {
|
|
136
|
-
const typeId = requireProvisioningId((await (await ProfileTypeCollection.create({ db })).getOrCreateGlobalBySlug("person", {
|
|
137
|
-
name: "Person",
|
|
138
|
-
description: "Individual person profile"
|
|
139
|
-
})).id, "Person ProfileType");
|
|
140
|
-
let profile = new Person({
|
|
141
|
-
db,
|
|
142
|
-
slug: `oidc-${crypto.randomUUID()}`,
|
|
143
|
-
tenantId: null,
|
|
144
|
-
typeId,
|
|
145
|
-
email: input.email ?? "",
|
|
146
|
-
name: input.name || input.preferredUsername || input.subject
|
|
147
|
-
});
|
|
148
|
-
await profile.initialize();
|
|
149
|
-
await saveOidcRaceArbiter(() => profile.save());
|
|
150
|
-
if (input.email) profile = await (await ProfileCollection.create({ db })).reserveCanonicalIdentityEmail(requireProvisioningId(profile.id, "Created Profile"), input.email);
|
|
151
|
-
return profile;
|
|
152
|
-
}
|
|
153
|
-
async function insertOidcProvisioningIdentity(db, input) {
|
|
154
|
-
const identity = new OidcIdentity({
|
|
155
|
-
db,
|
|
156
|
-
email: input.email ?? "",
|
|
157
|
-
issuer: input.issuer,
|
|
158
|
-
profileId: input.profileId,
|
|
159
|
-
provider: input.provider,
|
|
160
|
-
subject: input.subject
|
|
161
|
-
});
|
|
162
|
-
await identity.initialize();
|
|
163
|
-
await saveOidcRaceArbiter(() => identity.save());
|
|
164
|
-
return identity;
|
|
165
|
-
}
|
|
166
|
-
function requireProvisioningId(value, label) {
|
|
167
|
-
if (typeof value !== "string" || !value) throw new Error(`${label} did not produce an id.`);
|
|
168
|
-
return value;
|
|
169
|
-
}
|
|
170
|
-
//#endregion
|
|
171
|
-
export { createOidcProvisioningPerson as a, ProfileTypeCollection as i, Organization as n, insertOidcProvisioningIdentity as o, Person as r, oidcProvisioningPrimitives_CYood_2M_exports as s, Bot as t };
|