@happyvertical/smrt-users 0.57.14 → 0.57.15
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/README.md +27 -0
- package/dist/chunks/{TerminalAuthService-DlNv0fkn.js → TerminalAuthService-DUdmRz4P.js} +2 -2
- package/dist/chunks/{TerminalAuthService-DlNv0fkn.js.map → TerminalAuthService-DUdmRz4P.js.map} +1 -1
- package/dist/index.js +3 -3
- package/dist/manifest.json +1 -1
- package/dist/smrt-knowledge.json +3 -3
- package/dist/sveltekit/resource-list-handler.d.ts.map +1 -1
- package/dist/sveltekit.js +53 -19
- package/dist/sveltekit.js.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { $ as PermissionCatalogService, A as InvalidCredentialsError, At as Session, B as backfillUserEmailKeys, C as DEFAULT_LOGIN_ATTEMPT_WINDOW_SECONDS, Ct as SessionCollection, D as DEFAULT_LOGIN_MAX_ATTEMPTS, E as DEFAULT_LOGIN_LOCKOUT_MAX_SECONDS, Et as normalizeEmail, F as withoutListBounds, G as MAX_TENANT_HIERARCHY_DEPTH, H as TenantPermissionOverride, I as OidcProvisioningError, J as assertTenantTableName, K as TenantHierarchyError, L as UserCollection, M as LoginRateLimitError, Mt as Role, Nt as Permission, O as DEFAULT_SOURCE_LOCKOUT_AUDIT_SECONDS, Ot as DEFAULT_SESSION_TTL, Pt as Membership, Q as RolePermissionCollection, S as normalizeAncestorReadPolicy, St as UsersLoginAttempt, T as DEFAULT_LOGIN_LOCKOUT_FACTOR, Tt as isValidEmail, U as TenantCollection, V as TenantPermissionOverrideCollection, W as Tenant, X as recordTenantHierarchyChanges, Y as planTenantHierarchy, Z as DEFAULT_ROLE_PERMISSION_PATTERNS, _ as PermissionResolver, _t as GroupCollection, a as DEFAULT_PASSWORD_RECOVERY_MAX_AGE_SECONDS, at as RolePermission, b as getConfiguredAncestorReadPolicy, bt as UsersLoginAuditEvent, c as PASSWORD_PERMISSION_DEFINITIONS, ct as UsersPasswordCredentialCollection, d as PasswordCredentialForbiddenError, dt as MembershipOverride, et as deriveOperationPermissionCollectionName, f as PasswordCredentialService, ft as MembershipCollection, g as SessionService, gt as GroupMember, h as outOfBandProofSessionData, ht as GroupMemberCollection, i as DEFAULT_PASSWORD_MIN_LENGTH, it as syncPermissionCatalog, j as LoginAttemptLimiter, jt as generateSessionId, k as DurableLoginAuditSink, kt as SESSION_DATA_KEYS, l as PASSWORD_RECOVERY_MAX_AGE_CEILING_SECONDS, lt as UsersPasswordCredential, m as ensurePasswordPermissionsRegistered, mt as GroupRole, n as DEFAULT_PASSWORD_MANAGE_PERMISSION, nt as normalizeOperationPermissionAction, o as PASSWORD_LOGIN_KIND, ot as RoleCollection, p as PasswordPolicyError, pt as GroupRoleCollection, q as applyTenantHierarchyUpdates, r as DEFAULT_PASSWORD_MAX_LENGTH, rt as registerPermissionDefinitions, s as PASSWORD_MAX_LENGTH_CEILING, st as PermissionCollection, t as DEFAULT_PASSWORD_DENYLIST, tt as deriveOperationPermissionSlug, u as PasswordCredentialError, ut as MembershipOverrideCollection, v as ANCESTOR_READ_ACTION, vt as Group, w as DEFAULT_LOGIN_LOCKOUT_BASE_SECONDS, wt as User, x as isAncestorReadableSlug, xt as UsersLoginAttemptCollection, y as DEFAULT_ANCESTOR_READ_MAX_DEPTH, yt as UsersLoginAuditEventCollection, z as UserEmailKeyBackfillError } from "./chunks/PasswordCredentialService-CyB9FmYp.js";
|
|
2
|
-
import { A as DeviceCredentialForbiddenError, B as UsersCliAuthRequest, C as encodeOidcTransaction, D as DEFAULT_DEVICE_PERSON_IDLE_SECONDS, F as PinVerifier, I as ensurePinPermissionsRegistered, L as UsersPinCredentialCollection, M as DeviceCredentialService, N as PIN_LOGIN_KIND, O as DEFAULT_PIN_MANAGE_PERMISSION, P as PIN_PERMISSION_DEFINITIONS, R as UsersPinCredential, S as decodeOidcTransaction, T as resolveOidcProviderConfig, _ as MobileAuthService, a as TerminalAuthError, b as OidcLoginError, c as OperationPermissionError, d as hasOperationPermission, f as getCurrentSessionPermissionContext, g as MobileAuthError, h as withSessionPermissionContext, i as TERMINAL_APPROVE_LOGIN_KIND, j as DeviceCredentialPolicyError, k as DeviceCredentialError, l as assertOperationPermission, m as withPrincipalPermissionContext, n as DEFAULT_CLI_AUTH_REQUEST_TTL_SECONDS, o as TerminalAuthRateLimitError, p as getRequestScopedDatabase, r as DEFAULT_CLI_SESSION_TTL_SECONDS, s as TerminalAuthService, t as DEFAULT_CLI_AUTH_POLL_INTERVAL_SECONDS, u as checkOperationPermission, v as readMobileBearerToken, w as getUsersOidcConfig, x as OidcLoginService, y as validateMobileRedirectUri, z as UsersCliAuthRequestCollection } from "./chunks/TerminalAuthService-
|
|
2
|
+
import { A as DeviceCredentialForbiddenError, B as UsersCliAuthRequest, C as encodeOidcTransaction, D as DEFAULT_DEVICE_PERSON_IDLE_SECONDS, F as PinVerifier, I as ensurePinPermissionsRegistered, L as UsersPinCredentialCollection, M as DeviceCredentialService, N as PIN_LOGIN_KIND, O as DEFAULT_PIN_MANAGE_PERMISSION, P as PIN_PERMISSION_DEFINITIONS, R as UsersPinCredential, S as decodeOidcTransaction, T as resolveOidcProviderConfig, _ as MobileAuthService, a as TerminalAuthError, b as OidcLoginError, c as OperationPermissionError, d as hasOperationPermission, f as getCurrentSessionPermissionContext, g as MobileAuthError, h as withSessionPermissionContext, i as TERMINAL_APPROVE_LOGIN_KIND, j as DeviceCredentialPolicyError, k as DeviceCredentialError, l as assertOperationPermission, m as withPrincipalPermissionContext, n as DEFAULT_CLI_AUTH_REQUEST_TTL_SECONDS, o as TerminalAuthRateLimitError, p as getRequestScopedDatabase, r as DEFAULT_CLI_SESSION_TTL_SECONDS, s as TerminalAuthService, t as DEFAULT_CLI_AUTH_POLL_INTERVAL_SECONDS, u as checkOperationPermission, v as readMobileBearerToken, w as getUsersOidcConfig, x as OidcLoginService, y as validateMobileRedirectUri, z as UsersCliAuthRequestCollection } from "./chunks/TerminalAuthService-DUdmRz4P.js";
|
|
3
3
|
import { a as MembershipStatus, c as TenantPermissionEffect, i as DEFAULT_TENANT_POLICY, l as TenantStatus, n as DEFAULT_ROLES, o as OverrideEffect, r as DEFAULT_ROLE_SLUGS, s as SessionStatus, t as AccessRequestStatus, u as UserStatus } from "./chunks/types-DFqeph0R.js";
|
|
4
4
|
import { ObjectRegistry, SmrtCollection, SmrtObject, SmrtRecipe, bumpChangeFeed, crossPackageRef, ensureChangeFeedTable, field, findManifestEntryByQualifiedName, foreignKey, isEmbeddedDatabase, isUniqueViolationError, registerRetentionTask, smrt, unregisterRetentionTask, withEmbeddedWriteTransaction } from "@happyvertical/smrt-core";
|
|
5
5
|
import { TenantScoped, getTenantId, tenantId, withSystemContext, withTenant, withTenantGlobalRead } from "@happyvertical/smrt-tenancy";
|
|
@@ -2627,7 +2627,7 @@ var MagicLinkService = class MagicLinkService {
|
|
|
2627
2627
|
* The caller is responsible for emailing the token to the user.
|
|
2628
2628
|
*/
|
|
2629
2629
|
async generate(email) {
|
|
2630
|
-
const { SignJWT } = await import("./chunks/TerminalAuthService-
|
|
2630
|
+
const { SignJWT } = await import("./chunks/TerminalAuthService-DUdmRz4P.js").then((n) => n.E);
|
|
2631
2631
|
const key = await this.getSigningKey();
|
|
2632
2632
|
const nonce = crypto.randomUUID();
|
|
2633
2633
|
const normalizedEmail = normalizeEmail(email);
|
|
@@ -2656,7 +2656,7 @@ var MagicLinkService = class MagicLinkService {
|
|
|
2656
2656
|
* @throws {MagicLinkError} If the token is invalid, expired, or already used
|
|
2657
2657
|
*/
|
|
2658
2658
|
async verify(token) {
|
|
2659
|
-
const { jwtVerify, errors } = await import("./chunks/TerminalAuthService-
|
|
2659
|
+
const { jwtVerify, errors } = await import("./chunks/TerminalAuthService-DUdmRz4P.js").then((n) => n.E);
|
|
2660
2660
|
const key = await this.getSigningKey();
|
|
2661
2661
|
let payload;
|
|
2662
2662
|
try {
|
package/dist/manifest.json
CHANGED
package/dist/smrt-knowledge.json
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
"sensitiveFieldsExcluded": true,
|
|
4
4
|
"generatedAt": "1970-01-01T00:00:00.000Z",
|
|
5
5
|
"packageName": "@happyvertical/smrt-users",
|
|
6
|
-
"packageVersion": "0.57.
|
|
6
|
+
"packageVersion": "0.57.15",
|
|
7
7
|
"sourceManifestPath": "dist/manifest.json",
|
|
8
8
|
"agentDocPath": "AGENTS.md",
|
|
9
9
|
"sourceHashes": {
|
|
10
|
-
"manifest": "
|
|
11
|
-
"packageJson": "
|
|
10
|
+
"manifest": "71193c92b367d31f98c45a5f24745c6e5aefa6c04cb0b5d5333f4e686480b16a",
|
|
11
|
+
"packageJson": "eebc1ac8ed27fd5c4a7fc200f5b95c5e28acb06beebd03c69465729ab4436b97",
|
|
12
12
|
"agents": "eac1496479196208c81a434fdc0d861a8d57ea2246a70e2606dea8d07e424903",
|
|
13
13
|
"moduleDoc:agents/permissions.md": "02b2f03f0e057721369d9c693a624a6fdb3df4935401531a4373ff18229a64be",
|
|
14
14
|
"moduleDoc:agents/oidc-provisioning.md": "b73f3fdaf61136720132a614c7e14237b7bd35f7bf5d43eabb29f565485803b9",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-list-handler.d.ts","sourceRoot":"","sources":["../../src/sveltekit/resource-list-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAIH,OAAO,yBAAyB,CAAC;AAEjC,OAAO,EAKL,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EACL,KAAK,mBAAmB,EAExB,KAAK,4BAA4B,EAElC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAErF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"resource-list-handler.d.ts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,OAAO,CAAC,OAAO,CAAC,CAAC;IAE1E;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,KAAK,MAAM,CAAC;IAEb;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,KAAK,cAAc,GAAG;IACpB,OAAO,EAAE;QAAE,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,GAAG,CAAC;CACV,CAAC;AAMF,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,gCAAgC,GACxC,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,QAAQ,CAAC,CAkR9C;AA+jBD;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,SAAqC;CAIzD"}
|
package/dist/sveltekit.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { M as LoginRateLimitError, d as PasswordCredentialForbiddenError, f as PasswordCredentialService, g as SessionService, p as PasswordPolicyError, u as PasswordCredentialError } from "./chunks/PasswordCredentialService-CyB9FmYp.js";
|
|
2
|
-
import { A as DeviceCredentialForbiddenError, C as encodeOidcTransaction, M as DeviceCredentialService, S as decodeOidcTransaction, T as resolveOidcProviderConfig, _ as MobileAuthService, a as TerminalAuthError, b as OidcLoginError, c as OperationPermissionError, g as MobileAuthError, h as withSessionPermissionContext, j as DeviceCredentialPolicyError, k as DeviceCredentialError, o as TerminalAuthRateLimitError, s as TerminalAuthService, v as readMobileBearerToken, w as getUsersOidcConfig, x as OidcLoginService, y as validateMobileRedirectUri } from "./chunks/TerminalAuthService-
|
|
2
|
+
import { A as DeviceCredentialForbiddenError, C as encodeOidcTransaction, M as DeviceCredentialService, S as decodeOidcTransaction, T as resolveOidcProviderConfig, _ as MobileAuthService, a as TerminalAuthError, b as OidcLoginError, c as OperationPermissionError, g as MobileAuthError, h as withSessionPermissionContext, j as DeviceCredentialPolicyError, k as DeviceCredentialError, o as TerminalAuthRateLimitError, s as TerminalAuthService, v as readMobileBearerToken, w as getUsersOidcConfig, x as OidcLoginService, y as validateMobileRedirectUri } from "./chunks/TerminalAuthService-DUdmRz4P.js";
|
|
3
3
|
import { DiscoveryArtifactValidationError, SMRT_APP_RESULT_CONTRACT, SMRT_APP_RESULT_SCHEMA, SMRT_APP_RESULT_VERSION, SMRT_DISCOVERY_CONFORMANCE_ARTIFACT_SCHEMA, SMRT_DISCOVERY_CONFORMANCE_SCHEMA, SMRT_DISCOVERY_CONFORMANCE_VERSION, SMRT_MCP_RESULT_METADATA_KEY, canonicalizeDiscoveryArtifact, createDiscoveryConformanceArtifact, deriveCommandRequirements, validateDiscoveryConformanceArtifact } from "./app-contract.js";
|
|
4
4
|
import { ObjectRegistry, createClassNamePredicate, resolveCustomActionMetadata, resolveEffectiveActionMetadata } from "@happyvertical/smrt-core";
|
|
5
5
|
import { createLogger } from "@happyvertical/logger";
|
|
@@ -553,9 +553,8 @@ function createResourceListHandler(options) {
|
|
|
553
553
|
if (error instanceof InvalidBearerError) return jsonResponse$1({ error: error.message }, 401);
|
|
554
554
|
throw error;
|
|
555
555
|
}
|
|
556
|
-
const resources = [];
|
|
557
556
|
const skipWarnings = [];
|
|
558
|
-
const
|
|
557
|
+
const resourceGroups = /* @__PURE__ */ new Map();
|
|
559
558
|
const registeredClasses = [...ObjectRegistry.getAllClasses()];
|
|
560
559
|
const isModelClassName = createClassNamePredicate(registeredClasses.flatMap(([name, registered]) => {
|
|
561
560
|
const definition = registered;
|
|
@@ -570,9 +569,14 @@ function createResourceListHandler(options) {
|
|
|
570
569
|
const cliConfig = def.decoratorConfig.cli;
|
|
571
570
|
if (!cliConfig) continue;
|
|
572
571
|
if (!isHttpCliConfig(cliConfig)) continue;
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
572
|
+
const collectionClass = isCollectionClass(def);
|
|
573
|
+
const collectionIncludes = typeof cliConfig === "object" && Array.isArray(cliConfig.include) ? cliConfig.include : [];
|
|
574
|
+
if (collectionClass && collectionIncludes.length === 0) continue;
|
|
575
|
+
if (!collectionClass && sharesAncestorCollection(def, registeredClasses)) continue;
|
|
576
|
+
const includedMethods = resolveCliIncludedMethods(cliConfig, resolveApiActionSet({
|
|
577
|
+
...def,
|
|
578
|
+
...collectionClass ? { extends: "SmrtCollection" } : {}
|
|
579
|
+
}, void 0, { isModelClassName })).filter((name) => !collectionClass || collectionIncludes.includes(name) && !STANDARD_API_ACTIONS.includes(name));
|
|
576
580
|
if (includedMethods.length === 0) continue;
|
|
577
581
|
const slug = resourceSlug({
|
|
578
582
|
className: def.className,
|
|
@@ -580,13 +584,6 @@ function createResourceListHandler(options) {
|
|
|
580
584
|
qualifiedName: def.qualifiedName,
|
|
581
585
|
packageName: def.packageName
|
|
582
586
|
});
|
|
583
|
-
const previous = slugSeen.get(slug);
|
|
584
|
-
if (previous && previous !== def.qualifiedName) return jsonResponse$1({
|
|
585
|
-
error: "resource-slug-collision",
|
|
586
|
-
slug,
|
|
587
|
-
classes: [previous, def.qualifiedName ?? def.className].filter(Boolean)
|
|
588
|
-
}, 500);
|
|
589
|
-
slugSeen.set(slug, def.qualifiedName ?? def.className);
|
|
590
587
|
const resourceShell = {
|
|
591
588
|
slug,
|
|
592
589
|
className: def.className,
|
|
@@ -595,6 +592,12 @@ function createResourceListHandler(options) {
|
|
|
595
592
|
label: humanLabel(def.className),
|
|
596
593
|
apiPath: resolveApiPath(def)
|
|
597
594
|
};
|
|
595
|
+
const group = resourceGroups.get(slug) ?? [];
|
|
596
|
+
if (group.length > 0 && (group.length !== 1 || !isInheritedItemActionPair(group[0].def, def) || group[0].shell.apiPath !== resourceShell.apiPath)) return jsonResponse$1({
|
|
597
|
+
error: "resource-slug-collision",
|
|
598
|
+
slug,
|
|
599
|
+
classes: [group[0].def.qualifiedName ?? group[0].def.className, def.qualifiedName ?? def.className]
|
|
600
|
+
}, 500);
|
|
598
601
|
const classMeta = {
|
|
599
602
|
name: def.className,
|
|
600
603
|
qualifiedName: def.qualifiedName,
|
|
@@ -629,6 +632,11 @@ function createResourceListHandler(options) {
|
|
|
629
632
|
commandNameSeen.add(result.command.commandName);
|
|
630
633
|
candidates.push(result.command);
|
|
631
634
|
}
|
|
635
|
+
for (const candidate of candidates) if (group.some((member) => member.candidates.some((previous) => previous.commandName === candidate.commandName || commandRouteKey(previous) === commandRouteKey(candidate)))) return jsonResponse$1({
|
|
636
|
+
error: "command-name-collision",
|
|
637
|
+
slug,
|
|
638
|
+
commandName: candidate.commandName
|
|
639
|
+
}, 500);
|
|
632
640
|
const policyResults = await Promise.all(candidates.map((candidate) => commandPolicy({
|
|
633
641
|
resource: resourceShell,
|
|
634
642
|
command: candidate,
|
|
@@ -636,10 +644,21 @@ function createResourceListHandler(options) {
|
|
|
636
644
|
classMeta
|
|
637
645
|
})));
|
|
638
646
|
const allowed = candidates.filter((_, i) => policyResults[i]);
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
647
|
+
group.push({
|
|
648
|
+
def,
|
|
649
|
+
shell: resourceShell,
|
|
650
|
+
candidates,
|
|
651
|
+
allowed
|
|
652
|
+
});
|
|
653
|
+
resourceGroups.set(slug, group);
|
|
654
|
+
}
|
|
655
|
+
const resources = [];
|
|
656
|
+
for (const members of resourceGroups.values()) {
|
|
657
|
+
const ordered = [...members].sort((left, right) => Number(isCollectionClass(left.def)) - Number(isCollectionClass(right.def)));
|
|
658
|
+
const commands = ordered.flatMap((member) => member.allowed);
|
|
659
|
+
if (commands.length > 0) resources.push({
|
|
660
|
+
...ordered[0].shell,
|
|
661
|
+
commands
|
|
643
662
|
});
|
|
644
663
|
}
|
|
645
664
|
const warnResults = await Promise.all(skipWarnings.map((w) => commandPolicy({
|
|
@@ -664,6 +683,19 @@ function createResourceListHandler(options) {
|
|
|
664
683
|
}, 200, { "cache-control": "private, no-store" });
|
|
665
684
|
};
|
|
666
685
|
}
|
|
686
|
+
function commandRouteKey(command) {
|
|
687
|
+
return JSON.stringify([command.httpMethod, command.scope === "item" ? [":id", ...command.pathSegments] : command.pathSegments]);
|
|
688
|
+
}
|
|
689
|
+
function isInheritedItemActionPair(first, second) {
|
|
690
|
+
const firstCollection = isCollectionClass(first);
|
|
691
|
+
if (firstCollection === isCollectionClass(second)) return false;
|
|
692
|
+
const collection = firstCollection ? first : second;
|
|
693
|
+
const model = firstCollection ? second : first;
|
|
694
|
+
if (collection.decoratorConfig.collection !== void 0 || collection.collection !== model.collection || typeof collection.collectionConstructor !== "function" || collection.collectionConstructor !== model.collectionConstructor || typeof model.constructor !== "function") return false;
|
|
695
|
+
const itemClass = collection.collectionConstructor._itemClass;
|
|
696
|
+
if (typeof itemClass !== "function") return false;
|
|
697
|
+
return ObjectRegistry.getClassByConstructor(itemClass)?.constructor === model.constructor;
|
|
698
|
+
}
|
|
667
699
|
function synthesizeDefinition(_registeredName, registered) {
|
|
668
700
|
const methods = {};
|
|
669
701
|
for (const [name, value] of registered.methods.entries()) methods[name] = value;
|
|
@@ -679,7 +711,8 @@ function synthesizeDefinition(_registeredName, registered) {
|
|
|
679
711
|
tools: registered.tools,
|
|
680
712
|
extends: registered.extends,
|
|
681
713
|
extendsTypeArg: registered.extendsTypeArg,
|
|
682
|
-
constructor: registered.constructor
|
|
714
|
+
constructor: registered.constructor,
|
|
715
|
+
collectionConstructor: registered.collectionConstructor
|
|
683
716
|
};
|
|
684
717
|
}
|
|
685
718
|
function sharesAncestorCollection(def, registeredClasses) {
|
|
@@ -704,6 +737,7 @@ function sharesAncestorCollection(def, registeredClasses) {
|
|
|
704
737
|
return false;
|
|
705
738
|
}
|
|
706
739
|
function isCollectionClass(def) {
|
|
740
|
+
if (ObjectRegistry.isCollectionClass(def.qualifiedName ?? def.className)) return true;
|
|
707
741
|
if (def.extends === "SmrtCollection") return true;
|
|
708
742
|
if (def.extendsTypeArg) return true;
|
|
709
743
|
return ctorChainContains(def.constructor, "SmrtCollection");
|
|
@@ -799,7 +833,7 @@ function buildCustomCommand(def, methodName, methodDef, kebabRoutes) {
|
|
|
799
833
|
...methodDef ? { method: methodDef } : {},
|
|
800
834
|
apiConfig: apiConfigObj
|
|
801
835
|
});
|
|
802
|
-
const defaultScope = methodDef?.isStatic ? "collection" : "item";
|
|
836
|
+
const defaultScope = isCollectionClass(def) || methodDef?.isStatic ? "collection" : "item";
|
|
803
837
|
let scope = defaultScope;
|
|
804
838
|
try {
|
|
805
839
|
scope = resolveCustomActionMetadata({
|