@happyvertical/smrt-cli 0.51.24 → 0.51.25
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 -0
- package/README.md +1 -0
- package/dist/{ApiKey-BZmbOTnL-niFNV-7x.js → ApiKey-BZmbOTnL-BHFzurt7.js} +2 -2
- package/dist/ApiKeyCollection-Bfb_nw81-D8b3Nrg4.js +2 -0
- package/dist/AuditLogCollection-B1YonCAP-CpPE8zro.js +2 -0
- package/dist/{NostrIdentity-n70E0vck-C3qsu8zD.js → NostrIdentity-n70E0vck-Cga1lWU1.js} +3 -3
- package/dist/NostrIdentityCollection-Ca74dkaL-BKzq1O2N.js +2 -0
- package/dist/{OidcIdentity-K8V4u0CR-CwvImYYY.js → OidcIdentity-K8V4u0CR-buvSdd8D.js} +2 -2
- package/dist/OidcIdentityCollection-gnrLoF08-BsEJX0w8.js +2 -0
- package/dist/ProfileAssetCollection-CmbeSgDi-CcjX8UeG.js +2 -0
- package/dist/{ProfileCollection-DTT4KNpQ-BSl_c1i_.js → ProfileCollection-DTT4KNpQ-B2yHjF8e.js} +30 -653
- package/dist/ProfileMetadataCollection-DxX_BJKV-CqTZZ7O9.js +2 -0
- package/dist/{ProfileMetafieldCollection-CMKhVi2I-HKsCJDn7.js → ProfileMetafieldCollection-CMKhVi2I-BTguykyW.js} +1 -1
- package/dist/{ProfileRelationshipCollection-DUVgaIqf-DVwIEN1I.js → ProfileRelationshipCollection-DUVgaIqf-CdOJCU07.js} +1 -1
- package/dist/{ProfileRelationshipTermCollection-DtA9OM23-DhMqV5y2.js → ProfileRelationshipTermCollection-DtA9OM23-ug8uUFUp.js} +1 -1
- package/dist/{ProfileRelationshipType-BRiRka6t-CZxd9f0l.js → ProfileRelationshipType-BRiRka6t-B-lkyTB2.js} +1 -1
- package/dist/{ProfileRelationshipTypeCollection-BdXwd7Kf-DWDh61w6.js → ProfileRelationshipTypeCollection-BdXwd7Kf-BUuZ3P72.js} +1 -1
- package/dist/{commands-CclKGZRp.js → commands-BVFlmHkE.js} +61 -1
- package/dist/dist-4XD0OZmB.js +1235 -0
- package/dist/dist-C-AYkaoT.js +813 -0
- package/dist/{dist-BHR0tsIO.js → dist-CaxtTrhT.js} +3 -3
- package/dist/{dist-C-yxvpyT.js → dist-VEFJWHIY.js} +25 -25
- package/dist/index.js +9 -9
- package/dist/{oidcProvisioningPrimitives-0-3n3D6f-iCSXDIAZ.js → oidcProvisioningPrimitives-0-3n3D6f-DpuGh5Ac.js} +4 -4
- package/dist/resolveIdentity-BrJDCjYi-DrBA1wFo.js +2 -0
- package/package.json +9 -8
- package/dist/ApiKeyCollection-Bfb_nw81-CNPNkzCL.js +0 -2
- package/dist/AuditLogCollection-B1YonCAP-IB02mJPz.js +0 -2
- package/dist/NostrIdentityCollection-Ca74dkaL-CUV-1Hzs.js +0 -2
- package/dist/OidcIdentityCollection-gnrLoF08-WIx_hLet.js +0 -2
- package/dist/ProfileAssetCollection-CmbeSgDi-BQd2qiDK.js +0 -2
- package/dist/ProfileMetadataCollection-DxX_BJKV-kpa3rgiI.js +0 -2
- package/dist/dist-0QjiSFH4.js +0 -190
- package/dist/resolveIdentity-BrJDCjYi-BtP8skcX.js +0 -2
package/dist/index.js
CHANGED
|
@@ -49,63 +49,63 @@ var _playgroundCommands = null;
|
|
|
49
49
|
var _workbenchCommands = null;
|
|
50
50
|
async function getGnodeCommands() {
|
|
51
51
|
if (!_gnodeCommands) {
|
|
52
|
-
const { gnodeCommands } = await import("./commands-
|
|
52
|
+
const { gnodeCommands } = await import("./commands-BVFlmHkE.js");
|
|
53
53
|
_gnodeCommands = gnodeCommands;
|
|
54
54
|
}
|
|
55
55
|
return _gnodeCommands;
|
|
56
56
|
}
|
|
57
57
|
async function getGitCommands() {
|
|
58
58
|
if (!_gitCommands) {
|
|
59
|
-
const { gitCommands } = await import("./commands-
|
|
59
|
+
const { gitCommands } = await import("./commands-BVFlmHkE.js");
|
|
60
60
|
_gitCommands = gitCommands;
|
|
61
61
|
}
|
|
62
62
|
return _gitCommands;
|
|
63
63
|
}
|
|
64
64
|
async function getGenerateCommands() {
|
|
65
65
|
if (!_generateCommands) {
|
|
66
|
-
const { generateCommands } = await import("./commands-
|
|
66
|
+
const { generateCommands } = await import("./commands-BVFlmHkE.js");
|
|
67
67
|
_generateCommands = generateCommands;
|
|
68
68
|
}
|
|
69
69
|
return _generateCommands;
|
|
70
70
|
}
|
|
71
71
|
async function getInitCommands() {
|
|
72
72
|
if (!_initCommands) {
|
|
73
|
-
const { initCommands } = await import("./commands-
|
|
73
|
+
const { initCommands } = await import("./commands-BVFlmHkE.js");
|
|
74
74
|
_initCommands = initCommands;
|
|
75
75
|
}
|
|
76
76
|
return _initCommands;
|
|
77
77
|
}
|
|
78
78
|
async function getUtilityCommands() {
|
|
79
79
|
if (!_utilityCommands) {
|
|
80
|
-
const { utilityCommands } = await import("./commands-
|
|
80
|
+
const { utilityCommands } = await import("./commands-BVFlmHkE.js");
|
|
81
81
|
_utilityCommands = utilityCommands;
|
|
82
82
|
}
|
|
83
83
|
return _utilityCommands;
|
|
84
84
|
}
|
|
85
85
|
async function getDispatchCommands() {
|
|
86
86
|
if (!_dispatchCommands) {
|
|
87
|
-
const { dispatchCommands } = await import("./commands-
|
|
87
|
+
const { dispatchCommands } = await import("./commands-BVFlmHkE.js");
|
|
88
88
|
_dispatchCommands = dispatchCommands;
|
|
89
89
|
}
|
|
90
90
|
return _dispatchCommands;
|
|
91
91
|
}
|
|
92
92
|
async function getDocsCommands() {
|
|
93
93
|
if (!_docsCommands) {
|
|
94
|
-
const { docsCommands } = await import("./commands-
|
|
94
|
+
const { docsCommands } = await import("./commands-BVFlmHkE.js");
|
|
95
95
|
_docsCommands = docsCommands;
|
|
96
96
|
}
|
|
97
97
|
return _docsCommands;
|
|
98
98
|
}
|
|
99
99
|
async function getPlaygroundCommands() {
|
|
100
100
|
if (!_playgroundCommands) {
|
|
101
|
-
const { playgroundCommands } = await import("./commands-
|
|
101
|
+
const { playgroundCommands } = await import("./commands-BVFlmHkE.js");
|
|
102
102
|
_playgroundCommands = playgroundCommands;
|
|
103
103
|
}
|
|
104
104
|
return _playgroundCommands;
|
|
105
105
|
}
|
|
106
106
|
async function getWorkbenchCommands() {
|
|
107
107
|
if (!_workbenchCommands) {
|
|
108
|
-
const { workbenchCommands } = await import("./commands-
|
|
108
|
+
const { workbenchCommands } = await import("./commands-BVFlmHkE.js");
|
|
109
109
|
_workbenchCommands = workbenchCommands;
|
|
110
110
|
}
|
|
111
111
|
return _workbenchCommands;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as OidcIdentity } from "./OidcIdentity-K8V4u0CR-
|
|
5
|
-
import { c as saveOidcRaceArbiter, i as ProfileType, n as ProfileCollection, t as Profile } from "./ProfileCollection-DTT4KNpQ-
|
|
2
|
+
import { s as isSystemContext } from "./dist-C-AYkaoT.js";
|
|
3
|
+
import { n as __exportAll$1 } from "./NostrIdentity-n70E0vck-Cga1lWU1.js";
|
|
4
|
+
import { t as OidcIdentity } from "./OidcIdentity-K8V4u0CR-buvSdd8D.js";
|
|
5
|
+
import { c as saveOidcRaceArbiter, i as ProfileType, n as ProfileCollection, t as Profile } from "./ProfileCollection-DTT4KNpQ-B2yHjF8e.js";
|
|
6
6
|
import { SmrtCollection, smrt } from "@happyvertical/smrt-core";
|
|
7
7
|
//#region ../profiles/dist/chunks/oidcProvisioningPrimitives-0-3n3D6f.js
|
|
8
8
|
var oidcProvisioningPrimitives_0_3n3D6f_exports = /* @__PURE__ */ __exportAll({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-cli",
|
|
3
|
-
"version": "0.51.
|
|
3
|
+
"version": "0.51.25",
|
|
4
4
|
"description": "Developer CLI for SMRT framework - introspection, testing, and project management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,13 +28,14 @@
|
|
|
28
28
|
"@happyvertical/ai": "^0.90.0",
|
|
29
29
|
"@happyvertical/files": "^0.90.0",
|
|
30
30
|
"@happyvertical/logger": "^0.90.0",
|
|
31
|
-
"@happyvertical/smrt-agents": "0.51.
|
|
32
|
-
"@happyvertical/smrt-config": "0.51.
|
|
33
|
-
"@happyvertical/smrt-core": "0.51.
|
|
34
|
-
"@happyvertical/smrt-dev-mcp": "0.51.
|
|
35
|
-
"@happyvertical/smrt-
|
|
36
|
-
"@happyvertical/smrt-
|
|
37
|
-
"@happyvertical/smrt-
|
|
31
|
+
"@happyvertical/smrt-agents": "0.51.25",
|
|
32
|
+
"@happyvertical/smrt-config": "0.51.25",
|
|
33
|
+
"@happyvertical/smrt-core": "0.51.25",
|
|
34
|
+
"@happyvertical/smrt-dev-mcp": "0.51.25",
|
|
35
|
+
"@happyvertical/smrt-ledgers": "0.51.25",
|
|
36
|
+
"@happyvertical/smrt-playground": "0.51.25",
|
|
37
|
+
"@happyvertical/smrt-types": "0.51.25",
|
|
38
|
+
"@happyvertical/smrt-users": "0.51.25",
|
|
38
39
|
"@happyvertical/sql": "^0.90.0",
|
|
39
40
|
"@happyvertical/utils": "^0.90.0",
|
|
40
41
|
"acorn": "^8.18.0",
|
package/dist/dist-0QjiSFH4.js
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { ObjectRegistry, SmrtObject, applyPendingDecoratorRegistrations, crossPackageRef, field, registerCompatibleFieldDecorator, smrt } from "@happyvertical/smrt-core";
|
|
2
|
-
import { createLogger } from "@happyvertical/logger";
|
|
3
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
|
-
//#region ../tenancy/dist/chunks/context-CwbLwyIV.js
|
|
5
|
-
var SYSTEM_CONTEXT_MARKER = /* @__PURE__ */ Symbol.for("smrt:system-context");
|
|
6
|
-
var TENANT_STORAGE_KEY = /* @__PURE__ */ Symbol.for("smrt:tenant-context-storage");
|
|
7
|
-
function resolveTenantStorage() {
|
|
8
|
-
const root = globalThis;
|
|
9
|
-
root[TENANT_STORAGE_KEY] ??= new AsyncLocalStorage();
|
|
10
|
-
return root[TENANT_STORAGE_KEY];
|
|
11
|
-
}
|
|
12
|
-
var tenantStorage = resolveTenantStorage();
|
|
13
|
-
function getCurrentTenant() {
|
|
14
|
-
const store = tenantStorage.getStore();
|
|
15
|
-
if (store === SYSTEM_CONTEXT_MARKER) return;
|
|
16
|
-
return store;
|
|
17
|
-
}
|
|
18
|
-
function getTenantId() {
|
|
19
|
-
const store = tenantStorage.getStore();
|
|
20
|
-
if (store === SYSTEM_CONTEXT_MARKER) return;
|
|
21
|
-
return store?.tenantId;
|
|
22
|
-
}
|
|
23
|
-
function isSystemContext() {
|
|
24
|
-
return tenantStorage.getStore() === SYSTEM_CONTEXT_MARKER;
|
|
25
|
-
}
|
|
26
|
-
function isSuperAdminBypass() {
|
|
27
|
-
const store = tenantStorage.getStore();
|
|
28
|
-
if (store === SYSTEM_CONTEXT_MARKER) return false;
|
|
29
|
-
return store?.superAdminBypass === true;
|
|
30
|
-
}
|
|
31
|
-
async function withSystemContext(fn) {
|
|
32
|
-
return tenantStorage.run(SYSTEM_CONTEXT_MARKER, fn);
|
|
33
|
-
}
|
|
34
|
-
var TenantIsolationError = class extends Error {
|
|
35
|
-
/** Stable error code; always `'TENANT_ISOLATION_VIOLATION'`. */
|
|
36
|
-
code = "TENANT_ISOLATION_VIOLATION";
|
|
37
|
-
/** The tenant ID that is active in the current context. */
|
|
38
|
-
tenantId;
|
|
39
|
-
/** The tenant ID that was attempted (and rejected). */
|
|
40
|
-
attemptedTenantId;
|
|
41
|
-
constructor(message, details) {
|
|
42
|
-
super(message);
|
|
43
|
-
this.name = "TenantIsolationError";
|
|
44
|
-
this.tenantId = details?.tenantId;
|
|
45
|
-
this.attemptedTenantId = details?.attemptedTenantId;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region ../tenancy/dist/chunks/testing-s12-pjzJ.js
|
|
50
|
-
var DEFAULT_CONFIG = {
|
|
51
|
-
mode: "required",
|
|
52
|
-
field: "tenantId",
|
|
53
|
-
autoFilter: true,
|
|
54
|
-
autoPopulate: true,
|
|
55
|
-
allowSuperAdminBypass: false
|
|
56
|
-
};
|
|
57
|
-
var tenantScopedClasses = /* @__PURE__ */ new Map();
|
|
58
|
-
var unregisteredDecoratorRegistrations = /* @__PURE__ */ new Map();
|
|
59
|
-
function registerTenantScopedConstructor(target, config = {}) {
|
|
60
|
-
const resolved = {
|
|
61
|
-
...DEFAULT_CONFIG,
|
|
62
|
-
...config
|
|
63
|
-
};
|
|
64
|
-
unregisteredDecoratorRegistrations.set(target.name, resolved);
|
|
65
|
-
tenantScopedClasses.set(target.name, resolved);
|
|
66
|
-
}
|
|
67
|
-
var KEY = /* @__PURE__ */ Symbol.for("smrt:tenant-global-read-scope");
|
|
68
|
-
var root = globalThis;
|
|
69
|
-
root[KEY] ??= new AsyncLocalStorage();
|
|
70
|
-
root[KEY];
|
|
71
|
-
function assertTenantReadAllowed(tenantId, label) {
|
|
72
|
-
const tenantContext = getCurrentTenant();
|
|
73
|
-
if (tenantContext && !isSuperAdminBypass() && tenantContext.tenantId !== tenantId) throw new TenantIsolationError(`Tenant isolation violation in ${label}: context tenant is '${tenantContext.tenantId}' but query requested '${tenantId}'`, {
|
|
74
|
-
tenantId: tenantContext.tenantId,
|
|
75
|
-
attemptedTenantId: tenantId
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
async function queryGlobal(collection) {
|
|
79
|
-
const metaType = collection.getStiChildMetaType();
|
|
80
|
-
const where = metaType ? "WHERE _meta_type = ? AND tenant_id IS NULL" : "WHERE tenant_id IS NULL";
|
|
81
|
-
const params = metaType ? [metaType] : [];
|
|
82
|
-
return await collection.query(`SELECT * FROM ${collection.tableName} ${where}`, params, { allowRawOnTenantScoped: true });
|
|
83
|
-
}
|
|
84
|
-
async function queryWithGlobals(collection, tenantId, label) {
|
|
85
|
-
assertTenantReadAllowed(tenantId, label);
|
|
86
|
-
const metaType = collection.getStiChildMetaType();
|
|
87
|
-
const where = metaType ? "WHERE _meta_type = ? AND (tenant_id = ? OR tenant_id IS NULL)" : "WHERE tenant_id = ? OR tenant_id IS NULL";
|
|
88
|
-
const params = metaType ? [metaType, tenantId] : [tenantId];
|
|
89
|
-
return await collection.query(`SELECT * FROM ${collection.tableName} ${where}`, params, { allowRawOnTenantScoped: true });
|
|
90
|
-
}
|
|
91
|
-
createLogger({ level: "info" });
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region ../tenancy/dist/index.js
|
|
94
|
-
ObjectRegistry.registerPackageManifest(JSON.parse("{\"version\":\"1.0.0\",\"timestamp\":0,\"packageName\":\"@happyvertical/smrt-tenancy\",\"packageVersion\":\"0.51.24\",\"objects\":{\"@happyvertical/smrt-tenancy:BillingRelationship\":{\"name\":\"billingrelationship\",\"className\":\"BillingRelationship\",\"qualifiedName\":\"@happyvertical/smrt-tenancy:BillingRelationship\",\"collection\":\"billingrelationships\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/tenancy/src/billing-relationship.ts\",\"packageName\":\"@happyvertical/smrt-tenancy\",\"fields\":{\"childTenantId\":{\"type\":\"crossPackageRef\",\"required\":true,\"related\":\"@happyvertical/smrt-users:Tenant\",\"_meta\":{\"required\":true}},\"resellerTenantId\":{\"type\":\"crossPackageRef\",\"required\":true,\"related\":\"@happyvertical/smrt-users:Tenant\",\"_meta\":{\"required\":true}},\"billingOwnerMode\":{\"type\":\"text\",\"required\":false,\"default\":\"self\"}},\"methods\":{},\"decoratorConfig\":{\"tableName\":\"_smrt_billing_relationships\",\"conflictColumns\":[\"child_tenant_id\"],\"api\":false,\"cli\":false,\"mcp\":false},\"extends\":\"SmrtObject\",\"exportName\":\"BillingRelationship\",\"collectionExportName\":\"BillingRelationshipCollection\",\"validationRules\":[{\"field\":\"childTenantId\",\"rule\":\"required\",\"fieldType\":\"crossPackageRef\"},{\"field\":\"resellerTenantId\",\"rule\":\"required\",\"fieldType\":\"crossPackageRef\"}],\"schema\":{\"tableName\":\"_smrt_billing_relationships\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_billing_relationships\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"child_tenant_id\\\" UUID NOT NULL,\\n \\\"reseller_tenant_id\\\" UUID NOT NULL,\\n \\\"billing_owner_mode\\\" TEXT DEFAULT 'self'\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"child_tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"reseller_tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"billing_owner_mode\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"self\"}},\"indexes\":[{\"name\":\"_smrt_billing_relationships_child_tenant_id_idx\",\"columns\":[\"child_tenant_id\"],\"unique\":true},{\"name\":\"_smrt_billing_relationships_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"_smrt_billing_relationships_created_at_idx\",\"columns\":[\"created_at\"]},{\"name\":\"_smrt_billing_relationships_reseller_tenant_id_idx\",\"columns\":[\"reseller_tenant_id\"]}],\"version\":\"4d7f410a\"},\"importPath\":\"@happyvertical/smrt-tenancy\"},\"@happyvertical/smrt-tenancy:BillingRelationshipCollection\":{\"name\":\"billingrelationshipcollection\",\"className\":\"BillingRelationshipCollection\",\"qualifiedName\":\"@happyvertical/smrt-tenancy:BillingRelationshipCollection\",\"collection\":\"billingrelationships\",\"filePath\":\"/home/runner/work/smrt/smrt/packages/tenancy/src/billing-relationship.ts\",\"packageName\":\"@happyvertical/smrt-tenancy\",\"fields\":{},\"methods\":{},\"decoratorConfig\":{\"tableName\":\"_smrt_billing_relationships\",\"api\":false,\"mcp\":false,\"cli\":false},\"extends\":\"SmrtCollection\",\"extendsTypeArg\":\"BillingRelationship\",\"exportName\":\"BillingRelationshipCollection\",\"collectionExportName\":\"BillingRelationshipCollectionCollection\",\"schema\":{\"tableName\":\"_smrt_billing_relationships\",\"ddl\":\"CREATE TABLE IF NOT EXISTS \\\"_smrt_billing_relationships\\\" (\\n \\\"id\\\" UUID PRIMARY KEY NOT NULL,\\n \\\"slug\\\" TEXT NOT NULL,\\n \\\"context\\\" TEXT NOT NULL DEFAULT '',\\n \\\"created_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"updated_at\\\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\\n \\\"child_tenant_id\\\" UUID NOT NULL,\\n \\\"reseller_tenant_id\\\" UUID NOT NULL,\\n \\\"billing_owner_mode\\\" TEXT DEFAULT 'self'\\n);\",\"columns\":{\"id\":{\"type\":\"UUID\",\"primaryKey\":true,\"referenceKind\":\"id\",\"notNull\":true},\"slug\":{\"type\":\"TEXT\",\"notNull\":true},\"context\":{\"type\":\"TEXT\",\"notNull\":true,\"default\":\"\"},\"created_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"updated_at\":{\"type\":\"TIMESTAMP\",\"notNull\":true,\"default\":\"current_timestamp\"},\"child_tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"reseller_tenant_id\":{\"type\":\"UUID\",\"referenceKind\":\"crossPackageRef\",\"notNull\":true,\"unique\":false},\"billing_owner_mode\":{\"type\":\"TEXT\",\"notNull\":false,\"unique\":false,\"default\":\"self\"}},\"indexes\":[{\"name\":\"_smrt_billing_relationships_child_tenant_id_idx\",\"columns\":[\"child_tenant_id\"],\"unique\":true},{\"name\":\"_smrt_billing_relationships_slug_context_idx\",\"columns\":[\"slug\",\"context\"]},{\"name\":\"_smrt_billing_relationships_created_at_idx\",\"columns\":[\"created_at\"]},{\"name\":\"_smrt_billing_relationships_reseller_tenant_id_idx\",\"columns\":[\"reseller_tenant_id\"]}],\"version\":\"4d7f410a\"},\"importPath\":\"@happyvertical/smrt-tenancy\"}},\"moduleType\":\"smrt\",\"smrtDependencies\":[\"@happyvertical/smrt-core\"]}"));
|
|
95
|
-
var __defProp = Object.defineProperty;
|
|
96
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
97
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
98
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
99
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--) if (decorator = decorators[i]) result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
100
|
-
if (kind && result) __defProp(target, key, result);
|
|
101
|
-
return result;
|
|
102
|
-
};
|
|
103
|
-
var BillingRelationshipError = class extends Error {
|
|
104
|
-
constructor(message, code) {
|
|
105
|
-
super(message);
|
|
106
|
-
this.code = code;
|
|
107
|
-
this.name = "BillingRelationshipError";
|
|
108
|
-
}
|
|
109
|
-
code;
|
|
110
|
-
};
|
|
111
|
-
var BillingRelationship = class extends SmrtObject {
|
|
112
|
-
childTenantId = "";
|
|
113
|
-
resellerTenantId = "";
|
|
114
|
-
billingOwnerMode = "self";
|
|
115
|
-
async validateBeforeSave() {
|
|
116
|
-
await super.validateBeforeSave();
|
|
117
|
-
this.childTenantId = canonicalTenantId(this.childTenantId);
|
|
118
|
-
this.resellerTenantId = canonicalTenantId(this.resellerTenantId);
|
|
119
|
-
assertMode(this.billingOwnerMode);
|
|
120
|
-
if (this.childTenantId === this.resellerTenantId) throw new BillingRelationshipError("A tenant cannot resell to itself.", "CIRCULAR_RELATIONSHIP");
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
__decorateClass([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({ required: true })], BillingRelationship.prototype, "childTenantId", 2);
|
|
124
|
-
__decorateClass([crossPackageRef("@happyvertical/smrt-users:Tenant"), field({ required: true })], BillingRelationship.prototype, "resellerTenantId", 2);
|
|
125
|
-
BillingRelationship = __decorateClass([smrt({
|
|
126
|
-
tableName: "_smrt_billing_relationships",
|
|
127
|
-
conflictColumns: ["child_tenant_id"],
|
|
128
|
-
api: false,
|
|
129
|
-
cli: false,
|
|
130
|
-
mcp: false
|
|
131
|
-
})], BillingRelationship);
|
|
132
|
-
var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
133
|
-
function assertTenantId(id) {
|
|
134
|
-
if (typeof id !== "string" || !UUID_PATTERN.test(id)) throw new BillingRelationshipError("Tenant IDs must be UUIDs.", "INVALID_TENANT");
|
|
135
|
-
}
|
|
136
|
-
function canonicalTenantId(id) {
|
|
137
|
-
assertTenantId(id);
|
|
138
|
-
return id.toLowerCase();
|
|
139
|
-
}
|
|
140
|
-
function assertMode(mode) {
|
|
141
|
-
if (mode !== "self" && mode !== "reseller") throw new BillingRelationshipError("Billing owner mode must be self or reseller.", "INVALID_OWNER_MODE");
|
|
142
|
-
}
|
|
143
|
-
function TenantScoped(options = {}) {
|
|
144
|
-
return (target, decoratorContext) => {
|
|
145
|
-
applyPendingDecoratorRegistrations(target, decoratorContext);
|
|
146
|
-
const config = {
|
|
147
|
-
mode: options.mode ?? "required",
|
|
148
|
-
field: options.field ?? "tenantId",
|
|
149
|
-
autoFilter: options.autoFilter ?? true,
|
|
150
|
-
autoPopulate: options.autoPopulate ?? true,
|
|
151
|
-
allowSuperAdminBypass: options.allowSuperAdminBypass ?? false
|
|
152
|
-
};
|
|
153
|
-
registerTenantScopedConstructor(target, config);
|
|
154
|
-
ObjectRegistry.reconcileTenantScopedConfig(target, {
|
|
155
|
-
mode: config.mode ?? "required",
|
|
156
|
-
field: config.field ?? "tenantId",
|
|
157
|
-
autoFilter: config.autoFilter ?? true,
|
|
158
|
-
autoPopulate: config.autoPopulate ?? true,
|
|
159
|
-
allowSuperAdminBypass: config.allowSuperAdminBypass ?? false
|
|
160
|
-
});
|
|
161
|
-
return target;
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
function tenantId(options = {}) {
|
|
165
|
-
const opts = {
|
|
166
|
-
autoFilter: true,
|
|
167
|
-
required: true,
|
|
168
|
-
autoPopulate: true,
|
|
169
|
-
nullable: false,
|
|
170
|
-
...options
|
|
171
|
-
};
|
|
172
|
-
return ((targetOrValue, propertyKeyOrContext) => {
|
|
173
|
-
registerCompatibleFieldDecorator(targetOrValue, propertyKeyOrContext, (className, propertyKey, ctor) => {
|
|
174
|
-
const fieldOptions = {
|
|
175
|
-
type: "foreignKey",
|
|
176
|
-
related: "Tenant",
|
|
177
|
-
sqlType: "UUID",
|
|
178
|
-
required: opts.required,
|
|
179
|
-
nullable: opts.nullable,
|
|
180
|
-
__tenancy: {
|
|
181
|
-
...opts,
|
|
182
|
-
isTenantIdField: true
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
ObjectRegistry.registerFieldDecorator(className, propertyKey, fieldOptions, ctor);
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
//#endregion
|
|
190
|
-
export { getTenantId as a, queryWithGlobals as i, tenantId as n, isSystemContext as o, queryGlobal as r, withSystemContext as s, TenantScoped as t };
|