@xemahq/xema-service-nest 0.2.6 → 0.2.7
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xema-service-module.d.ts","sourceRoot":"","sources":["../../src/lib/xema-service-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"xema-service-module.d.ts","sourceRoot":"","sources":["../../src/lib/xema-service-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAqBrF,OAAO,EACL,aAAa,EAEb,UAAU,EAEV,KAAK,4BAA4B,EAClC,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,4BAA4B,CAAC;AAQpC,MAAM,WAAW,wBAAwB;IAMvC,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAE7B,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC;IAKnC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAWpC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAUxC,QAAQ,CAAC,2BAA2B,CAAC,EAAE,CACrC,GAAG,IAAI,EAAE,KAAK,EAAE,KACb,4BAA4B,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAM1E,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;IAK5C,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;CAC9C;AAsCD,qBAAa,iBAAiB;WACd,QAAQ,CACpB,UAAU,EAAE,sBAAsB,EAClC,OAAO,GAAE,wBAA6B,GACrC,aAAa;CAejB"}
|
|
@@ -36,19 +36,11 @@ function buildServiceRegistryModule(descriptor, consumes) {
|
|
|
36
36
|
profile: (0, service_registry_nest_1.parseKernelStateProfile)(config.get('XEMA_KERNEL_STATE_PROFILE')),
|
|
37
37
|
}),
|
|
38
38
|
consumes,
|
|
39
|
-
tokenProvider: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const token = await bootstrap.getAccessToken();
|
|
45
|
-
if (typeof token !== 'string' || token.length === 0) {
|
|
46
|
-
throw new Error('[xema-service-nest] IdentityBootstrapService.getAccessToken() ' +
|
|
47
|
-
'returned no service token; cannot authenticate the typed-client call.');
|
|
48
|
-
}
|
|
49
|
-
return token;
|
|
50
|
-
},
|
|
51
|
-
},
|
|
39
|
+
tokenProvider: new service_registry_nest_1.IdentityBackedServiceTokenProvider({
|
|
40
|
+
getAccessToken: () => moduleRef
|
|
41
|
+
.get(identity_client_1.IdentityBootstrapService, { strict: false })
|
|
42
|
+
.getAccessToken(),
|
|
43
|
+
}),
|
|
52
44
|
descriptor: {
|
|
53
45
|
name: descriptor.name,
|
|
54
46
|
semver: descriptor.semver,
|
|
@@ -112,20 +104,28 @@ function buildRuntimeModule(descriptor, options) {
|
|
|
112
104
|
const discovery = options.discovery ?? xema_decorators_1.DiscoveryMode.Decorators;
|
|
113
105
|
const policy = options.policy ?? xema_decorators_1.PolicyMode.FailClosed;
|
|
114
106
|
if (options.registerCapabilities) {
|
|
107
|
+
const usesDefaultClient = options.useCapabilityRegistryClient === undefined;
|
|
108
|
+
const useCapabilityRegistryClient = usesDefaultClient
|
|
109
|
+
? (config, identityBootstrap) => new xema_decorators_1.IdentityBoundCapabilityRegistryClient(config.getOrThrow('CAPABILITY_REGISTRY_API_URL'), identityBootstrap)
|
|
110
|
+
: options.useCapabilityRegistryClient;
|
|
111
|
+
const inject = usesDefaultClient
|
|
112
|
+
? [config_1.ConfigService, identity_client_1.IdentityBootstrapService]
|
|
113
|
+
: options.inject;
|
|
114
|
+
const imports = usesDefaultClient
|
|
115
|
+
? [config_1.ConfigModule, ...(options.imports ?? [])]
|
|
116
|
+
: options.imports;
|
|
115
117
|
return xema_decorators_1.XemaRuntimeModule.forServiceAsync({
|
|
116
118
|
serviceName: descriptor.name,
|
|
117
119
|
serviceKind: descriptor.serviceKind,
|
|
118
120
|
discovery,
|
|
119
121
|
policy,
|
|
120
122
|
registerCapabilities: true,
|
|
123
|
+
useCapabilityRegistryClient: useCapabilityRegistryClient,
|
|
121
124
|
...(options.manifestOutputDir !== undefined && {
|
|
122
125
|
manifestOutputDir: options.manifestOutputDir,
|
|
123
126
|
}),
|
|
124
|
-
...(
|
|
125
|
-
|
|
126
|
-
}),
|
|
127
|
-
...(options.inject !== undefined && { inject: options.inject }),
|
|
128
|
-
...(options.imports !== undefined && { imports: options.imports }),
|
|
127
|
+
...(inject !== undefined && { inject }),
|
|
128
|
+
...(imports !== undefined && { imports }),
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
return xema_decorators_1.XemaRuntimeModule.forService({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xema-service-module.js","sourceRoot":"","sources":["../../src/lib/xema-service-module.ts"],"names":[],"mappings":";;;AACA,uCAAyC;AACzC,2CAA6D;AAC7D,6DAGiC;AACjC,gFAGmD;AACnD,uEAAiE;AACjE,6DAAqD;AACrD,
|
|
1
|
+
{"version":3,"file":"xema-service-module.js","sourceRoot":"","sources":["../../src/lib/xema-service-module.ts"],"names":[],"mappings":";;;AACA,uCAAyC;AACzC,2CAA6D;AAC7D,6DAGiC;AACjC,gFAGmD;AACnD,uEAAiE;AACjE,6DAAqD;AACrD,yEAOuC;AACvC,6DAMiC;AAEjC,yEAGoC;AA8FpC,MAAa,iBAAiB;IACrB,MAAM,CAAC,QAAQ,CACpB,UAAkC,EAClC,UAAoC,EAAE;QAEtC,IAAA,yDAA8B,EAAC,UAAU,CAAC,CAAC;QAE3C,MAAM,QAAQ,GAAG,CAAC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AO,mCAAiB,CAAC,eAAe,CAAC;YACvC,WAAW,EAAE,UAAU,CAAC,IAAI;YAC5B,WAAW,EAAE,UAAU,CAAC,WAAW;YACnC,SAAS;YACT,MAAM;YACN,oBAAoB,EAAE,IAAI;YAC1B,2BAA2B,EACzB,2BAA0E;YAC5E,GAAG,CAAC,OAAO,CAAC,iBAAiB,KAAK,SAAS,IAAI;gBAC7C,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;aAC7C,CAAC;YACF,GAAG,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC;YACvC,GAAG,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,OAAO,EAAE,CAAC;SAC1C,CAAC,CAAC;IACL,CAAC;IAED,OAAO,mCAAiB,CAAC,UAAU,CAAC;QAClC,WAAW,EAAE,UAAU,CAAC,IAAI;QAC5B,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,SAAS;QACT,MAAM;QACN,GAAG,CAAC,OAAO,CAAC,iBAAiB,KAAK,SAAS,IAAI;YAC7C,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;SAC7C,CAAC;KACH,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xemahq/xema-service-nest",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Xema platform service-bootstrap SDK. `XemaServiceModule.forBiome(descriptor)` composes the full platform service stack — Service Registry, Identity bootstrap, Auth (JWT verification + request context), and the Xema runtime route/capability scanner — behind a single call, so a biome API is auth-correct in ~5 lines and never re-wires authentication.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xema",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"@xemahq/identity-client": "^0.3.5",
|
|
67
67
|
"@xemahq/kernel-state-runtime": "^0.1.5",
|
|
68
68
|
"@xemahq/platform-common": "^0.2.4",
|
|
69
|
-
"@xemahq/service-registry-nest": "^0.1.
|
|
70
|
-
"@xemahq/xema-decorators": "^0.2.
|
|
69
|
+
"@xemahq/service-registry-nest": "^0.1.10",
|
|
70
|
+
"@xemahq/xema-decorators": "^0.2.1"
|
|
71
71
|
},
|
|
72
72
|
"exports": {
|
|
73
73
|
".": {
|
|
@@ -13,6 +13,7 @@ import { createKernelState } from '@xemahq/kernel-state-runtime';
|
|
|
13
13
|
import { AuthModule } from '@xemahq/platform-common';
|
|
14
14
|
import {
|
|
15
15
|
buildSelfHttpEndpointUrl,
|
|
16
|
+
IdentityBackedServiceTokenProvider,
|
|
16
17
|
parseKernelStateProfile,
|
|
17
18
|
resolveServiceInstanceId,
|
|
18
19
|
ServiceRegistryAdapterKind,
|
|
@@ -20,6 +21,7 @@ import {
|
|
|
20
21
|
} from '@xemahq/service-registry-nest';
|
|
21
22
|
import {
|
|
22
23
|
DiscoveryMode,
|
|
24
|
+
IdentityBoundCapabilityRegistryClient,
|
|
23
25
|
PolicyMode,
|
|
24
26
|
XemaRuntimeModule,
|
|
25
27
|
type XemaCapabilityRegistryClient,
|
|
@@ -52,17 +54,37 @@ export interface XemaServiceModuleOptions {
|
|
|
52
54
|
readonly manifestOutputDir?: string;
|
|
53
55
|
/**
|
|
54
56
|
* Opt into the boot-time capability auto-register path (Phase H#2). When
|
|
55
|
-
* `true
|
|
56
|
-
*
|
|
57
|
+
* `true` and no {@link useCapabilityRegistryClient} is supplied, `forBiome`
|
|
58
|
+
* auto-wires the default {@link IdentityBoundCapabilityRegistryClient} —
|
|
59
|
+
* resolving the capability-registry-api base URL from the
|
|
60
|
+
* `CAPABILITY_REGISTRY_API_URL` env var (fail-fast if unset) and minting
|
|
61
|
+
* the service bearer through the IdentityBootstrapService this module
|
|
62
|
+
* already wires. A service therefore no longer writes its own
|
|
63
|
+
* `capability-registry.client.ts` adapter or factory.
|
|
57
64
|
*/
|
|
58
65
|
readonly registerCapabilities?: boolean;
|
|
59
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* Explicit override: a factory producing a custom capability-registry
|
|
68
|
+
* client (DI-resolved). Only needed when the default
|
|
69
|
+
* {@link IdentityBoundCapabilityRegistryClient} does not fit (e.g. a
|
|
70
|
+
* non-Keycloak bearer source or a non-standard base-URL resolution). When
|
|
71
|
+
* supplied, the caller also owns {@link inject} / {@link imports} for the
|
|
72
|
+
* factory. When omitted (the common case), the default client is wired
|
|
73
|
+
* internally.
|
|
74
|
+
*/
|
|
60
75
|
readonly useCapabilityRegistryClient?: (
|
|
61
76
|
...args: never[]
|
|
62
77
|
) => XemaCapabilityRegistryClient | Promise<XemaCapabilityRegistryClient>;
|
|
63
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* DI tokens for a custom {@link useCapabilityRegistryClient}. Ignored when
|
|
80
|
+
* the default client is used (this module injects ConfigService +
|
|
81
|
+
* IdentityBootstrapService itself).
|
|
82
|
+
*/
|
|
64
83
|
readonly inject?: FactoryProvider['inject'];
|
|
65
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* Extra modules a custom capability-client factory needs. Merged ahead of
|
|
86
|
+
* the internally-required `ConfigModule` when the default client is used.
|
|
87
|
+
*/
|
|
66
88
|
readonly imports?: ModuleMetadata['imports'];
|
|
67
89
|
}
|
|
68
90
|
|
|
@@ -147,24 +169,17 @@ function buildServiceRegistryModule(
|
|
|
147
169
|
// SDK's EnvServiceTokenProvider (env XEMA_SERVICE_TOKEN), which is unset in
|
|
148
170
|
// production → every typed-client call fails to mint a bearer.
|
|
149
171
|
//
|
|
150
|
-
//
|
|
151
|
-
//
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
'[xema-service-nest] IdentityBootstrapService.getAccessToken() ' +
|
|
162
|
-
'returned no service token; cannot authenticate the typed-client call.',
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
return token;
|
|
166
|
-
},
|
|
167
|
-
},
|
|
172
|
+
// The IdentityBootstrapService is resolved LAZILY via ModuleRef so there
|
|
173
|
+
// is no module-init ordering/cycle: getAccessToken runs at request time
|
|
174
|
+
// (an outbound typed-client call), long after bootstrap, and itself
|
|
175
|
+
// waits-for-ready + refreshes the JWT. The provider fail-fasts on an empty
|
|
176
|
+
// token (see IdentityBackedServiceTokenProvider).
|
|
177
|
+
tokenProvider: new IdentityBackedServiceTokenProvider({
|
|
178
|
+
getAccessToken: (): Promise<string> =>
|
|
179
|
+
moduleRef
|
|
180
|
+
.get(IdentityBootstrapService, { strict: false })
|
|
181
|
+
.getAccessToken(),
|
|
182
|
+
}),
|
|
168
183
|
descriptor: {
|
|
169
184
|
name: descriptor.name,
|
|
170
185
|
semver: descriptor.semver,
|
|
@@ -248,20 +263,52 @@ function buildRuntimeModule(
|
|
|
248
263
|
const policy = options.policy ?? PolicyMode.FailClosed;
|
|
249
264
|
|
|
250
265
|
if (options.registerCapabilities) {
|
|
266
|
+
// The auto-register path needs a capability-registry client. A service
|
|
267
|
+
// MAY supply its own factory (`useCapabilityRegistryClient`) for a custom
|
|
268
|
+
// client; when it does not, `forBiome` wires the default
|
|
269
|
+
// IdentityBoundCapabilityRegistryClient internally — resolving the
|
|
270
|
+
// capability-registry-api base URL from `CAPABILITY_REGISTRY_API_URL`
|
|
271
|
+
// (fail-fast via getOrThrow) and minting the bearer through the
|
|
272
|
+
// IdentityBootstrapService this module already wires. This is what lets
|
|
273
|
+
// the ~12 hand-rolled `capability-registry.client.ts` adapters + their
|
|
274
|
+
// factories be deleted.
|
|
275
|
+
const usesDefaultClient =
|
|
276
|
+
options.useCapabilityRegistryClient === undefined;
|
|
277
|
+
|
|
278
|
+
const useCapabilityRegistryClient = usesDefaultClient
|
|
279
|
+
? (
|
|
280
|
+
config: ConfigService,
|
|
281
|
+
identityBootstrap: IdentityBootstrapService,
|
|
282
|
+
): XemaCapabilityRegistryClient =>
|
|
283
|
+
new IdentityBoundCapabilityRegistryClient(
|
|
284
|
+
config.getOrThrow<string>('CAPABILITY_REGISTRY_API_URL'),
|
|
285
|
+
identityBootstrap,
|
|
286
|
+
)
|
|
287
|
+
: options.useCapabilityRegistryClient;
|
|
288
|
+
|
|
289
|
+
// When the default client is used, this module owns the factory's DI:
|
|
290
|
+
// ConfigService + IdentityBootstrapService, with ConfigModule imported.
|
|
291
|
+
// When the caller overrides the factory, its `inject`/`imports` win.
|
|
292
|
+
const inject = usesDefaultClient
|
|
293
|
+
? [ConfigService, IdentityBootstrapService]
|
|
294
|
+
: options.inject;
|
|
295
|
+
const imports = usesDefaultClient
|
|
296
|
+
? [ConfigModule, ...(options.imports ?? [])]
|
|
297
|
+
: options.imports;
|
|
298
|
+
|
|
251
299
|
return XemaRuntimeModule.forServiceAsync({
|
|
252
300
|
serviceName: descriptor.name,
|
|
253
301
|
serviceKind: descriptor.serviceKind,
|
|
254
302
|
discovery,
|
|
255
303
|
policy,
|
|
256
304
|
registerCapabilities: true,
|
|
305
|
+
useCapabilityRegistryClient:
|
|
306
|
+
useCapabilityRegistryClient as XemaRuntimeServiceAsyncOptionsClientFactory,
|
|
257
307
|
...(options.manifestOutputDir !== undefined && {
|
|
258
308
|
manifestOutputDir: options.manifestOutputDir,
|
|
259
309
|
}),
|
|
260
|
-
...(
|
|
261
|
-
|
|
262
|
-
}),
|
|
263
|
-
...(options.inject !== undefined && { inject: options.inject }),
|
|
264
|
-
...(options.imports !== undefined && { imports: options.imports }),
|
|
310
|
+
...(inject !== undefined && { inject }),
|
|
311
|
+
...(imports !== undefined && { imports }),
|
|
265
312
|
});
|
|
266
313
|
}
|
|
267
314
|
|
|
@@ -275,3 +322,14 @@ function buildRuntimeModule(
|
|
|
275
322
|
}),
|
|
276
323
|
});
|
|
277
324
|
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* The factory shape `XemaRuntimeModule.forServiceAsync` accepts for
|
|
328
|
+
* `useCapabilityRegistryClient`. Mirrors its `(...args: never[]) => ...`
|
|
329
|
+
* signature so the default-client factory (which takes concrete DI args)
|
|
330
|
+
* type-checks against it — the runtime module invokes it with the
|
|
331
|
+
* DI-resolved `inject` tuple.
|
|
332
|
+
*/
|
|
333
|
+
type XemaRuntimeServiceAsyncOptionsClientFactory = (
|
|
334
|
+
...args: never[]
|
|
335
|
+
) => XemaCapabilityRegistryClient | Promise<XemaCapabilityRegistryClient>;
|