@newhomestar/sdk 0.8.12 → 0.8.13
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/dist/index.js +18 -1
- package/dist/integration.d.ts +20 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -906,12 +906,29 @@ export function runHttpServer(def, opts = {}) {
|
|
|
906
906
|
// Resolve credentials (same flow as action handlers)
|
|
907
907
|
const credCtx = buildCredentialCtx(def.name, authToken);
|
|
908
908
|
const credentials = await credCtx.resolveCredentials();
|
|
909
|
-
//
|
|
909
|
+
// Extract and normalize the scope identifiers from the request body.
|
|
910
|
+
// The UI posts `{ config, remoteId, remoteType }`. Both may be null
|
|
911
|
+
// for legacy / unscoped lookups. We keep them typed so handlers
|
|
912
|
+
// using `ctx.remoteId` get proper autocomplete.
|
|
913
|
+
const rawRemoteId = req.body?.remoteId;
|
|
914
|
+
const rawRemoteType = req.body?.remoteType;
|
|
915
|
+
const remoteId = typeof rawRemoteId === 'string' && rawRemoteId.trim() !== ''
|
|
916
|
+
? rawRemoteId
|
|
917
|
+
: null;
|
|
918
|
+
const remoteType = rawRemoteType === 'account' || rawRemoteType === 'company'
|
|
919
|
+
? rawRemoteType
|
|
920
|
+
: null;
|
|
921
|
+
// Build OptionsContext for the handler. `remoteId`/`remoteType`
|
|
922
|
+
// let the handler scope its lookup to the currently-selected
|
|
923
|
+
// ticketing account / HRIS company (e.g. list only Jira
|
|
924
|
+
// projects tied to *this* account's connection).
|
|
910
925
|
const optionsCtx = {
|
|
911
926
|
fetch: credCtx.fetch,
|
|
912
927
|
config: req.body?.config ?? {},
|
|
913
928
|
credentials,
|
|
914
929
|
tenantId: req.auth?.sub ?? 'unknown',
|
|
930
|
+
remoteId,
|
|
931
|
+
remoteType,
|
|
915
932
|
};
|
|
916
933
|
// Run the optionsFetcher handler
|
|
917
934
|
console.log(`[nova] 🔧 Running optionsFetcher for config field "${field.key}"`);
|
package/dist/integration.d.ts
CHANGED
|
@@ -144,6 +144,26 @@ export interface OptionsContext {
|
|
|
144
144
|
credentials: ResolvedCredentials;
|
|
145
145
|
/** Tenant ID for calling internal Nova platform services */
|
|
146
146
|
tenantId: string;
|
|
147
|
+
/**
|
|
148
|
+
* Scope UUID this options lookup belongs to. For ticketing integrations
|
|
149
|
+
* this is the `TicketingAccount.id`; for HRIS integrations it's the
|
|
150
|
+
* `HrisCompany.id`. May be null/undefined when the caller hasn't
|
|
151
|
+
* selected a scope yet (legacy / unscoped lookups).
|
|
152
|
+
*
|
|
153
|
+
* Use this to filter the options query when the same user administers
|
|
154
|
+
* multiple accounts — e.g. only list Jira projects linked to this
|
|
155
|
+
* specific ticketing account's connection, not all of the user's
|
|
156
|
+
* accessible projects.
|
|
157
|
+
*/
|
|
158
|
+
remoteId?: string | null;
|
|
159
|
+
/**
|
|
160
|
+
* Scope type discriminator so the handler knows which domain the
|
|
161
|
+
* `remoteId` came from without having to infer it from the integration
|
|
162
|
+
* category.
|
|
163
|
+
* • "account" → ticketing (TicketingAccount.id)
|
|
164
|
+
* • "company" → HRIS (HrisCompany.id)
|
|
165
|
+
*/
|
|
166
|
+
remoteType?: 'account' | 'company' | null;
|
|
147
167
|
}
|
|
148
168
|
/**
|
|
149
169
|
* A handler function that fetches select options dynamically.
|
package/package.json
CHANGED