@omen.foundation/node-microservice-runtime 0.1.0
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/.env +13 -0
- package/dist/auth.cjs +97 -0
- package/dist/auth.d.ts +14 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +93 -0
- package/dist/auth.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +588 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/decorators.cjs +181 -0
- package/dist/decorators.d.ts +23 -0
- package/dist/decorators.d.ts.map +1 -0
- package/dist/decorators.js +155 -0
- package/dist/decorators.js.map +1 -0
- package/dist/dependency.cjs +165 -0
- package/dist/dependency.d.ts +56 -0
- package/dist/dependency.d.ts.map +1 -0
- package/dist/dependency.js +162 -0
- package/dist/dependency.js.map +1 -0
- package/dist/dev.cjs +34 -0
- package/dist/dev.d.ts +9 -0
- package/dist/dev.d.ts.map +1 -0
- package/dist/dev.js +32 -0
- package/dist/dev.js.map +1 -0
- package/dist/discovery.cjs +79 -0
- package/dist/discovery.d.ts +20 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +75 -0
- package/dist/discovery.js.map +1 -0
- package/dist/docs.cjs +206 -0
- package/dist/docs.d.ts +30 -0
- package/dist/docs.d.ts.map +1 -0
- package/dist/docs.js +209 -0
- package/dist/docs.js.map +1 -0
- package/dist/env.cjs +106 -0
- package/dist/env.d.ts +4 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +108 -0
- package/dist/env.js.map +1 -0
- package/dist/errors.cjs +58 -0
- package/dist/errors.d.ts +26 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +48 -0
- package/dist/errors.js.map +1 -0
- package/dist/federation.cjs +356 -0
- package/dist/federation.d.ts +108 -0
- package/dist/federation.d.ts.map +1 -0
- package/dist/federation.js +341 -0
- package/dist/federation.js.map +1 -0
- package/dist/index.cjs +42 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/inventory.cjs +361 -0
- package/dist/inventory.d.ts +116 -0
- package/dist/inventory.d.ts.map +1 -0
- package/dist/inventory.js +351 -0
- package/dist/inventory.js.map +1 -0
- package/dist/logger.cjs +62 -0
- package/dist/logger.d.ts +9 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +29 -0
- package/dist/logger.js.map +1 -0
- package/dist/message.cjs +19 -0
- package/dist/message.d.ts +5 -0
- package/dist/message.d.ts.map +1 -0
- package/dist/message.js +15 -0
- package/dist/message.js.map +1 -0
- package/dist/requester.cjs +100 -0
- package/dist/requester.d.ts +20 -0
- package/dist/requester.d.ts.map +1 -0
- package/dist/requester.js +99 -0
- package/dist/requester.js.map +1 -0
- package/dist/routing.cjs +39 -0
- package/dist/routing.d.ts +2 -0
- package/dist/routing.d.ts.map +1 -0
- package/dist/routing.js +36 -0
- package/dist/routing.js.map +1 -0
- package/dist/runtime.cjs +735 -0
- package/dist/runtime.d.ts +40 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +825 -0
- package/dist/runtime.js.map +1 -0
- package/dist/services.cjs +346 -0
- package/dist/services.d.ts +46 -0
- package/dist/services.d.ts.map +1 -0
- package/dist/services.js +343 -0
- package/dist/services.js.map +1 -0
- package/dist/storage.cjs +147 -0
- package/dist/storage.d.ts +46 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +144 -0
- package/dist/storage.js.map +1 -0
- package/dist/types.cjs +2 -0
- package/dist/types.d.ts +108 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/urls.cjs +55 -0
- package/dist/utils/urls.d.ts +5 -0
- package/dist/utils/urls.d.ts.map +1 -0
- package/dist/utils/urls.js +50 -0
- package/dist/utils/urls.js.map +1 -0
- package/dist/websocket.cjs +142 -0
- package/dist/websocket.d.ts +33 -0
- package/dist/websocket.d.ts.map +1 -0
- package/dist/websocket.js +139 -0
- package/dist/websocket.js.map +1 -0
- package/env.sample +13 -0
- package/package.json +49 -0
- package/scripts/generate-openapi.mjs +114 -0
- package/scripts/lib/cli-utils.mjs +58 -0
- package/scripts/prepare-cjs.mjs +44 -0
- package/scripts/publish-service.mjs +1126 -0
- package/scripts/validate-service.mjs +103 -0
- package/scripts/ws-test.mjs +25 -0
- package/src/auth.ts +117 -0
- package/src/cli/index.ts +699 -0
- package/src/decorators.ts +207 -0
- package/src/dependency.ts +211 -0
- package/src/dev.ts +17 -0
- package/src/discovery.ts +88 -0
- package/src/docs.ts +262 -0
- package/src/env.ts +125 -0
- package/src/errors.ts +55 -0
- package/src/federation.ts +559 -0
- package/src/index.ts +51 -0
- package/src/inventory.ts +491 -0
- package/src/logger.ts +38 -0
- package/src/message.ts +19 -0
- package/src/requester.ts +126 -0
- package/src/routing.ts +42 -0
- package/src/runtime.ts +967 -0
- package/src/services.ts +459 -0
- package/src/storage.ts +206 -0
- package/src/types/beamable-sdk-api.d.ts +5 -0
- package/src/types.ts +117 -0
- package/src/utils/urls.ts +53 -0
- package/src/websocket.ts +170 -0
- package/tsconfig.base.json +31 -0
- package/tsconfig.build.json +10 -0
- package/tsconfig.cjs.json +16 -0
- package/tsconfig.dev.json +14 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { Logger } from 'pino';
|
|
2
|
+
import type { RequestContext } from './types.js';
|
|
3
|
+
export interface FederationComponentDescriptor {
|
|
4
|
+
federationType: string;
|
|
5
|
+
federationNamespace: string;
|
|
6
|
+
localSettings?: unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface FederationMetadata {
|
|
9
|
+
typeName: string;
|
|
10
|
+
identity: string;
|
|
11
|
+
localSettings?: unknown;
|
|
12
|
+
}
|
|
13
|
+
export interface FederationIdentity {
|
|
14
|
+
getUniqueName(): string;
|
|
15
|
+
}
|
|
16
|
+
export type FederationIdentityConstructor<T extends FederationIdentity = FederationIdentity> = new () => T;
|
|
17
|
+
export interface FederatedAuthenticationRequest {
|
|
18
|
+
token?: string;
|
|
19
|
+
challenge?: string;
|
|
20
|
+
solution?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface FederatedAuthenticationResponse {
|
|
23
|
+
user_id?: string;
|
|
24
|
+
challenge?: string;
|
|
25
|
+
challenge_ttl?: number;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
export interface FederatedItemProperty {
|
|
29
|
+
name: string;
|
|
30
|
+
value: string;
|
|
31
|
+
}
|
|
32
|
+
export interface FederatedItemProxy {
|
|
33
|
+
proxyId: string;
|
|
34
|
+
properties?: FederatedItemProperty[];
|
|
35
|
+
}
|
|
36
|
+
export interface FederatedInventoryProxyState {
|
|
37
|
+
currencies?: Record<string, number>;
|
|
38
|
+
items?: Record<string, FederatedItemProxy[]>;
|
|
39
|
+
}
|
|
40
|
+
export interface FederatedItemCreateRequest {
|
|
41
|
+
contentId: string;
|
|
42
|
+
properties?: Record<string, string>;
|
|
43
|
+
requestId?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface FederatedItemDeleteRequest {
|
|
46
|
+
contentId: string;
|
|
47
|
+
proxyId: string;
|
|
48
|
+
}
|
|
49
|
+
export interface FederatedItemUpdateRequest {
|
|
50
|
+
contentId: string;
|
|
51
|
+
proxyId: string;
|
|
52
|
+
properties?: Record<string, string>;
|
|
53
|
+
}
|
|
54
|
+
export interface FederatedInventoryStateRequest {
|
|
55
|
+
id: string;
|
|
56
|
+
}
|
|
57
|
+
export interface FederatedInventoryTransactionRequest {
|
|
58
|
+
id: string;
|
|
59
|
+
transaction: string;
|
|
60
|
+
currencies?: Record<string, number>;
|
|
61
|
+
newItems?: FederatedItemCreateRequest[];
|
|
62
|
+
deleteItems?: FederatedItemDeleteRequest[];
|
|
63
|
+
updateItems?: FederatedItemUpdateRequest[];
|
|
64
|
+
}
|
|
65
|
+
export interface FederatedInventoryOptions<T extends FederationIdentity> {
|
|
66
|
+
identity: FederationIdentityConstructor<T>;
|
|
67
|
+
authenticate?: string;
|
|
68
|
+
getInventoryState?: string;
|
|
69
|
+
startInventoryTransaction?: string;
|
|
70
|
+
}
|
|
71
|
+
interface FederatedInventoryMetadata {
|
|
72
|
+
identityCtor: FederationIdentityConstructor;
|
|
73
|
+
identityName: string;
|
|
74
|
+
methods: {
|
|
75
|
+
authenticate: string;
|
|
76
|
+
getInventoryState: string;
|
|
77
|
+
startInventoryTransaction: string;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
interface FederationRouteHandler {
|
|
81
|
+
identityName: string;
|
|
82
|
+
type: 'authenticate' | 'inventory-state' | 'inventory-transaction';
|
|
83
|
+
invoke(ctx: FederatedRequestContext): Promise<unknown>;
|
|
84
|
+
}
|
|
85
|
+
export interface FederatedRequestContext extends RequestContext {
|
|
86
|
+
federation: {
|
|
87
|
+
identity: string;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export declare function FederationComponent(descriptor: FederationComponentDescriptor): ClassDecorator;
|
|
91
|
+
export declare function getFederationComponents(target: Function): FederationComponentDescriptor[];
|
|
92
|
+
export declare function FederatedInventory<T extends FederationIdentity>(options: FederatedInventoryOptions<T>): ClassDecorator;
|
|
93
|
+
export declare function getFederatedInventoryMetadata(target: Function): FederatedInventoryMetadata[];
|
|
94
|
+
export declare class FederationRegistry {
|
|
95
|
+
private readonly logger;
|
|
96
|
+
private readonly manualComponents;
|
|
97
|
+
private readonly autoComponents;
|
|
98
|
+
private readonly routeHandlers;
|
|
99
|
+
constructor(logger: Logger);
|
|
100
|
+
register(component: FederationComponentDescriptor): void;
|
|
101
|
+
registerInventoryHandlers(service: object, metadata: FederatedInventoryMetadata[]): void;
|
|
102
|
+
list(): FederationComponentDescriptor[];
|
|
103
|
+
resolve(path: string): FederationRouteHandler | undefined;
|
|
104
|
+
private addAutoComponent;
|
|
105
|
+
private createInventoryHandler;
|
|
106
|
+
}
|
|
107
|
+
export {};
|
|
108
|
+
//# sourceMappingURL=federation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federation.d.ts","sourceRoot":"","sources":["../src/federation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,WAAW,6BAA6B;IAC5C,cAAc,EAAE,MAAM,CAAC;IACvB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,aAAa,IAAI,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,6BAA6B,CAAC,CAAC,SAAS,kBAAkB,GAAG,kBAAkB,IAAI,UAAU,CAAC,CAAC;AAE3G,MAAM,WAAW,8BAA8B;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,+BAA+B;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,qBAAqB,EAAE,CAAC;CACtC;AAED,MAAM,WAAW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OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,sBAAsB;CAqD/B"}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
const FEDERATION_COMPONENTS = new Map();
|
|
2
|
+
const FEDERATED_INVENTORY_MAP = new Map();
|
|
3
|
+
export function FederationComponent(descriptor) {
|
|
4
|
+
validateDescriptor(descriptor);
|
|
5
|
+
return (target) => {
|
|
6
|
+
const existing = FEDERATION_COMPONENTS.get(target) ?? [];
|
|
7
|
+
existing.push({
|
|
8
|
+
federationNamespace: descriptor.federationNamespace,
|
|
9
|
+
federationType: descriptor.federationType,
|
|
10
|
+
localSettings: descriptor.localSettings,
|
|
11
|
+
});
|
|
12
|
+
FEDERATION_COMPONENTS.set(target, existing);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function getFederationComponents(target) {
|
|
16
|
+
return FEDERATION_COMPONENTS.get(target) ?? [];
|
|
17
|
+
}
|
|
18
|
+
export function FederatedInventory(options) {
|
|
19
|
+
const authenticate = options.authenticate ?? 'Authenticate';
|
|
20
|
+
const getInventoryState = options.getInventoryState ?? 'GetInventoryState';
|
|
21
|
+
const startInventoryTransaction = options.startInventoryTransaction ?? 'StartInventoryTransaction';
|
|
22
|
+
return (target) => {
|
|
23
|
+
const identityInstance = new options.identity();
|
|
24
|
+
if (!identityInstance || typeof identityInstance.getUniqueName !== 'function') {
|
|
25
|
+
throw new Error('@FederatedInventory identity must implement getUniqueName().');
|
|
26
|
+
}
|
|
27
|
+
const identityName = identityInstance.getUniqueName();
|
|
28
|
+
if (!identityName || !identityName.trim()) {
|
|
29
|
+
throw new Error('@FederatedInventory identity must provide a non-empty unique name.');
|
|
30
|
+
}
|
|
31
|
+
const existing = FEDERATED_INVENTORY_MAP.get(target) ?? [];
|
|
32
|
+
existing.push({
|
|
33
|
+
identityCtor: options.identity,
|
|
34
|
+
identityName: identityName.trim(),
|
|
35
|
+
methods: {
|
|
36
|
+
authenticate,
|
|
37
|
+
getInventoryState,
|
|
38
|
+
startInventoryTransaction,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
FEDERATED_INVENTORY_MAP.set(target, existing);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export function getFederatedInventoryMetadata(target) {
|
|
45
|
+
return FEDERATED_INVENTORY_MAP.get(target) ?? [];
|
|
46
|
+
}
|
|
47
|
+
function validateDescriptor(descriptor) {
|
|
48
|
+
if (!descriptor.federationNamespace || !descriptor.federationNamespace.trim()) {
|
|
49
|
+
throw new Error('@FederationComponent requires a non-empty federationNamespace.');
|
|
50
|
+
}
|
|
51
|
+
if (!descriptor.federationType || !descriptor.federationType.trim()) {
|
|
52
|
+
throw new Error('@FederationComponent requires a non-empty federationType.');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export class FederationRegistry {
|
|
56
|
+
logger;
|
|
57
|
+
manualComponents = new Map();
|
|
58
|
+
autoComponents = new Map();
|
|
59
|
+
routeHandlers = new Map();
|
|
60
|
+
constructor(logger) {
|
|
61
|
+
this.logger = logger.child({ component: 'FederationRegistry' });
|
|
62
|
+
}
|
|
63
|
+
register(component) {
|
|
64
|
+
validateDescriptor(component);
|
|
65
|
+
const namespace = component.federationNamespace.trim();
|
|
66
|
+
const type = component.federationType.trim();
|
|
67
|
+
const existing = this.manualComponents.get(namespace) ?? new Set();
|
|
68
|
+
existing.add(type);
|
|
69
|
+
this.manualComponents.set(namespace, existing);
|
|
70
|
+
this.logger.debug({ component }, 'Registered federation component.');
|
|
71
|
+
}
|
|
72
|
+
registerInventoryHandlers(service, metadata) {
|
|
73
|
+
for (const entry of metadata) {
|
|
74
|
+
const identity = entry.identityName;
|
|
75
|
+
this.addAutoComponent(identity, 'IFederatedInventory');
|
|
76
|
+
this.addAutoComponent(identity, 'IFederatedLogin');
|
|
77
|
+
const authenticateHandler = this.createInventoryHandler(service, entry.methods.authenticate, identity, 'authenticate');
|
|
78
|
+
const stateHandler = this.createInventoryHandler(service, entry.methods.getInventoryState, identity, 'inventory-state');
|
|
79
|
+
const transactionHandler = this.createInventoryHandler(service, entry.methods.startInventoryTransaction, identity, 'inventory-transaction');
|
|
80
|
+
this.routeHandlers.set(`${identity.toLowerCase()}/authenticate`, authenticateHandler);
|
|
81
|
+
this.routeHandlers.set(`${identity.toLowerCase()}/inventory/state`, stateHandler);
|
|
82
|
+
this.routeHandlers.set(`${identity.toLowerCase()}/inventory/put`, transactionHandler);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
list() {
|
|
86
|
+
const components = [];
|
|
87
|
+
for (const [namespace, types] of this.manualComponents.entries()) {
|
|
88
|
+
for (const type of types) {
|
|
89
|
+
components.push({ federationNamespace: namespace, federationType: type });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
for (const [namespace, types] of this.autoComponents.entries()) {
|
|
93
|
+
for (const type of types) {
|
|
94
|
+
components.push({ federationNamespace: namespace, federationType: type });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return components;
|
|
98
|
+
}
|
|
99
|
+
resolve(path) {
|
|
100
|
+
return this.routeHandlers.get(path.toLowerCase());
|
|
101
|
+
}
|
|
102
|
+
addAutoComponent(namespace, type) {
|
|
103
|
+
const existing = this.autoComponents.get(namespace) ?? new Set();
|
|
104
|
+
existing.add(type);
|
|
105
|
+
this.autoComponents.set(namespace, existing);
|
|
106
|
+
}
|
|
107
|
+
createInventoryHandler(service, methodName, identity, type) {
|
|
108
|
+
const method = service[methodName];
|
|
109
|
+
if (typeof method !== 'function') {
|
|
110
|
+
throw new Error(`Federated inventory method "${methodName}" is not defined on service "${service.constructor.name}".`);
|
|
111
|
+
}
|
|
112
|
+
const paramTypes = getMethodParameterTypes(service, methodName);
|
|
113
|
+
return {
|
|
114
|
+
identityName: identity,
|
|
115
|
+
type,
|
|
116
|
+
invoke: async (ctx) => {
|
|
117
|
+
const federatedCtx = {
|
|
118
|
+
...ctx,
|
|
119
|
+
federation: { identity },
|
|
120
|
+
};
|
|
121
|
+
switch (type) {
|
|
122
|
+
case 'authenticate':
|
|
123
|
+
return invokeFederatedAuthenticate(method, service, federatedCtx, normalizeAuthenticationRequest(ctx.body), paramTypes);
|
|
124
|
+
case 'inventory-state':
|
|
125
|
+
return invokeFederatedGetInventoryState(method, service, federatedCtx, normalizeInventoryStateRequest(ctx.body), paramTypes);
|
|
126
|
+
case 'inventory-transaction':
|
|
127
|
+
return invokeFederatedStartInventoryTransaction(method, service, federatedCtx, normalizeInventoryTransactionRequest(ctx.body), paramTypes);
|
|
128
|
+
default:
|
|
129
|
+
throw new Error(`Unsupported federated handler type: ${type}`);
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function normalizeAuthenticationRequest(payload) {
|
|
136
|
+
if (!payload || typeof payload !== 'object') {
|
|
137
|
+
return {};
|
|
138
|
+
}
|
|
139
|
+
const body = payload;
|
|
140
|
+
return {
|
|
141
|
+
token: typeof body.token === 'string' ? body.token : undefined,
|
|
142
|
+
challenge: typeof body.challenge === 'string' ? body.challenge : undefined,
|
|
143
|
+
solution: typeof body.solution === 'string' ? body.solution : undefined,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function normalizeInventoryStateRequest(payload) {
|
|
147
|
+
if (!payload || typeof payload !== 'object' || typeof payload.id !== 'string') {
|
|
148
|
+
throw new Error('Federated inventory state requests must include an "id" property.');
|
|
149
|
+
}
|
|
150
|
+
const body = payload;
|
|
151
|
+
return { id: String(body.id) };
|
|
152
|
+
}
|
|
153
|
+
function normalizeInventoryTransactionRequest(payload) {
|
|
154
|
+
if (!payload || typeof payload !== 'object') {
|
|
155
|
+
throw new Error('Federated inventory transaction requests require a JSON body.');
|
|
156
|
+
}
|
|
157
|
+
const body = payload;
|
|
158
|
+
if (typeof body.id !== 'string') {
|
|
159
|
+
throw new Error('Federated inventory transaction requests must include an "id" property.');
|
|
160
|
+
}
|
|
161
|
+
if (typeof body.transaction !== 'string') {
|
|
162
|
+
throw new Error('Federated inventory transaction requests must include a "transaction" property.');
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
id: body.id,
|
|
166
|
+
transaction: body.transaction,
|
|
167
|
+
currencies: normalizeRecordOfNumbers(body.currencies),
|
|
168
|
+
newItems: normalizeFederatedCreateRequests(body.newItems),
|
|
169
|
+
deleteItems: normalizeFederatedDeleteRequests(body.deleteItems),
|
|
170
|
+
updateItems: normalizeFederatedUpdateRequests(body.updateItems),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function normalizeRecordOfNumbers(value) {
|
|
174
|
+
if (!value || typeof value !== 'object') {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
const record = {};
|
|
178
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
179
|
+
const numeric = Number(raw);
|
|
180
|
+
if (Number.isFinite(numeric)) {
|
|
181
|
+
record[key] = numeric;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return Object.keys(record).length > 0 ? record : undefined;
|
|
185
|
+
}
|
|
186
|
+
function normalizeFederatedCreateRequests(value) {
|
|
187
|
+
if (!Array.isArray(value)) {
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
const normalized = [];
|
|
191
|
+
for (const item of value) {
|
|
192
|
+
if (!item || typeof item !== 'object') {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
const record = item;
|
|
196
|
+
if (typeof record.contentId !== 'string') {
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
const properties = record.properties && typeof record.properties === 'object'
|
|
200
|
+
? Object.fromEntries(Object.entries(record.properties).map(([propKey, propVal]) => [
|
|
201
|
+
propKey,
|
|
202
|
+
String(propVal),
|
|
203
|
+
]))
|
|
204
|
+
: undefined;
|
|
205
|
+
normalized.push({
|
|
206
|
+
contentId: record.contentId,
|
|
207
|
+
requestId: typeof record.requestId === 'string' ? record.requestId : undefined,
|
|
208
|
+
properties,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
212
|
+
}
|
|
213
|
+
function normalizeFederatedDeleteRequests(value) {
|
|
214
|
+
if (!Array.isArray(value)) {
|
|
215
|
+
return undefined;
|
|
216
|
+
}
|
|
217
|
+
const normalized = [];
|
|
218
|
+
for (const item of value) {
|
|
219
|
+
if (!item || typeof item !== 'object') {
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
const record = item;
|
|
223
|
+
if (typeof record.contentId !== 'string' || typeof record.proxyId !== 'string') {
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
normalized.push({
|
|
227
|
+
contentId: record.contentId,
|
|
228
|
+
proxyId: record.proxyId,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
232
|
+
}
|
|
233
|
+
function normalizeFederatedUpdateRequests(value) {
|
|
234
|
+
if (!Array.isArray(value)) {
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
const normalized = [];
|
|
238
|
+
for (const item of value) {
|
|
239
|
+
if (!item || typeof item !== 'object') {
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
const record = item;
|
|
243
|
+
if (typeof record.contentId !== 'string' || typeof record.proxyId !== 'string') {
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
const properties = record.properties && typeof record.properties === 'object'
|
|
247
|
+
? Object.fromEntries(Object.entries(record.properties).map(([propKey, propVal]) => [
|
|
248
|
+
propKey,
|
|
249
|
+
String(propVal),
|
|
250
|
+
]))
|
|
251
|
+
: undefined;
|
|
252
|
+
normalized.push({
|
|
253
|
+
contentId: record.contentId,
|
|
254
|
+
proxyId: record.proxyId,
|
|
255
|
+
properties,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
259
|
+
}
|
|
260
|
+
function getMethodParameterTypes(service, methodName) {
|
|
261
|
+
const prototype = Object.getPrototypeOf(service);
|
|
262
|
+
if (!prototype || typeof Reflect.getMetadata !== 'function') {
|
|
263
|
+
return [];
|
|
264
|
+
}
|
|
265
|
+
return Reflect.getMetadata('design:paramtypes', prototype, methodName) ?? [];
|
|
266
|
+
}
|
|
267
|
+
function isStringType(type) {
|
|
268
|
+
return type === String;
|
|
269
|
+
}
|
|
270
|
+
function invokeFederatedAuthenticate(method, service, ctx, request, paramTypes) {
|
|
271
|
+
const argsWithoutContext = [request.token, request.challenge, request.solution];
|
|
272
|
+
if (method.length === argsWithoutContext.length) {
|
|
273
|
+
return method.call(service, ...argsWithoutContext);
|
|
274
|
+
}
|
|
275
|
+
if (method.length === argsWithoutContext.length + 1) {
|
|
276
|
+
return method.call(service, ctx, ...argsWithoutContext);
|
|
277
|
+
}
|
|
278
|
+
if (method.length === 1) {
|
|
279
|
+
const firstType = paramTypes[0];
|
|
280
|
+
if (isStringType(firstType)) {
|
|
281
|
+
return method.call(service, ...argsWithoutContext);
|
|
282
|
+
}
|
|
283
|
+
return method.call(service, request);
|
|
284
|
+
}
|
|
285
|
+
if (method.length === 2) {
|
|
286
|
+
const secondType = paramTypes[1];
|
|
287
|
+
if (isStringType(secondType)) {
|
|
288
|
+
return method.call(service, ctx, ...argsWithoutContext);
|
|
289
|
+
}
|
|
290
|
+
return method.call(service, ctx, request);
|
|
291
|
+
}
|
|
292
|
+
return method.call(service, ctx, request);
|
|
293
|
+
}
|
|
294
|
+
function invokeFederatedGetInventoryState(method, service, ctx, request, paramTypes) {
|
|
295
|
+
const argsWithoutContext = [request.id];
|
|
296
|
+
if (method.length === argsWithoutContext.length) {
|
|
297
|
+
const firstType = paramTypes[0];
|
|
298
|
+
if (isStringType(firstType)) {
|
|
299
|
+
return method.call(service, ...argsWithoutContext);
|
|
300
|
+
}
|
|
301
|
+
return method.call(service, request);
|
|
302
|
+
}
|
|
303
|
+
if (method.length === argsWithoutContext.length + 1) {
|
|
304
|
+
const secondType = paramTypes[1];
|
|
305
|
+
if (isStringType(secondType)) {
|
|
306
|
+
return method.call(service, ctx, ...argsWithoutContext);
|
|
307
|
+
}
|
|
308
|
+
return method.call(service, ctx, request);
|
|
309
|
+
}
|
|
310
|
+
if (method.length === 1) {
|
|
311
|
+
return method.call(service, request);
|
|
312
|
+
}
|
|
313
|
+
if (method.length === 2) {
|
|
314
|
+
return method.call(service, ctx, request);
|
|
315
|
+
}
|
|
316
|
+
return method.call(service, ctx, request);
|
|
317
|
+
}
|
|
318
|
+
function invokeFederatedStartInventoryTransaction(method, service, ctx, request, _paramTypes) {
|
|
319
|
+
const argsWithoutContext = [
|
|
320
|
+
request.id,
|
|
321
|
+
request.transaction,
|
|
322
|
+
request.currencies ?? {},
|
|
323
|
+
request.newItems ?? [],
|
|
324
|
+
request.deleteItems ?? [],
|
|
325
|
+
request.updateItems ?? [],
|
|
326
|
+
];
|
|
327
|
+
if (method.length === argsWithoutContext.length) {
|
|
328
|
+
return method.call(service, ...argsWithoutContext);
|
|
329
|
+
}
|
|
330
|
+
if (method.length === argsWithoutContext.length + 1) {
|
|
331
|
+
return method.call(service, ctx, ...argsWithoutContext);
|
|
332
|
+
}
|
|
333
|
+
if (method.length === 1) {
|
|
334
|
+
return method.call(service, request);
|
|
335
|
+
}
|
|
336
|
+
if (method.length === 2) {
|
|
337
|
+
return method.call(service, ctx, request);
|
|
338
|
+
}
|
|
339
|
+
return method.call(service, ctx, request);
|
|
340
|
+
}
|
|
341
|
+
//# sourceMappingURL=federation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federation.js","sourceRoot":"","sources":["../src/federation.ts"],"names":[],"mappings":"AA4GA,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAA6C,CAAC;AACnF,MAAM,uBAAuB,GAAG,IAAI,GAAG,EAA0C,CAAC;AAElF,MAAM,UAAU,mBAAmB,CAAC,UAAyC;IAC3E,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAE/B,OAAO,CAAC,MAAM,E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,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import type { Logger } from 'pino';\r\nimport type { RequestContext } from './types.js';\r\n\r\nexport interface FederationComponentDescriptor {\r\n federationType: string;\r\n federationNamespace: string;\r\n localSettings?: unknown;\r\n}\r\n\r\nexport interface FederationMetadata {\r\n typeName: string;\r\n identity: string;\r\n localSettings?: unknown;\r\n}\r\n\r\nexport interface FederationIdentity {\r\n getUniqueName(): string;\r\n}\r\n\r\nexport type FederationIdentityConstructor<T extends FederationIdentity = FederationIdentity> = new () => T;\r\n\r\nexport interface FederatedAuthenticationRequest {\r\n token?: string;\r\n challenge?: string;\r\n solution?: string;\r\n}\r\n\r\nexport interface FederatedAuthenticationResponse {\r\n user_id?: string;\r\n challenge?: string;\r\n challenge_ttl?: number;\r\n [key: string]: unknown;\r\n}\r\n\r\nexport interface FederatedItemProperty {\r\n name: string;\r\n value: string;\r\n}\r\n\r\nexport interface FederatedItemProxy {\r\n proxyId: string;\r\n properties?: FederatedItemProperty[];\r\n}\r\n\r\nexport interface FederatedInventoryProxyState {\r\n currencies?: Record<string, number>;\r\n items?: Record<string, FederatedItemProxy[]>;\r\n}\r\n\r\nexport interface FederatedItemCreateRequest {\r\n contentId: string;\r\n properties?: Record<string, string>;\r\n requestId?: string;\r\n}\r\n\r\nexport interface FederatedItemDeleteRequest {\r\n contentId: string;\r\n proxyId: string;\r\n}\r\n\r\nexport interface FederatedItemUpdateRequest {\r\n contentId: string;\r\n proxyId: string;\r\n properties?: Record<string, string>;\r\n}\r\n\r\nexport interface FederatedInventoryStateRequest {\r\n id: string;\r\n}\r\n\r\nexport interface FederatedInventoryTransactionRequest {\r\n id: string;\r\n transaction: string;\r\n currencies?: Record<string, number>;\r\n newItems?: FederatedItemCreateRequest[];\r\n deleteItems?: FederatedItemDeleteRequest[];\r\n updateItems?: FederatedItemUpdateRequest[];\r\n}\r\n\r\nexport interface FederatedInventoryOptions<T extends FederationIdentity> {\r\n identity: FederationIdentityConstructor<T>;\r\n authenticate?: string;\r\n getInventoryState?: string;\r\n startInventoryTransaction?: string;\r\n}\r\n\r\ninterface FederatedInventoryMetadata {\r\n identityCtor: FederationIdentityConstructor;\r\n identityName: string;\r\n methods: {\r\n authenticate: string;\r\n getInventoryState: string;\r\n startInventoryTransaction: string;\r\n };\r\n}\r\n\r\ninterface FederationRouteHandler {\r\n identityName: string;\r\n type: 'authenticate' | 'inventory-state' | 'inventory-transaction';\r\n invoke(ctx: FederatedRequestContext): Promise<unknown>;\r\n}\r\n\r\nexport interface FederatedRequestContext extends RequestContext {\r\n federation: {\r\n identity: string;\r\n };\r\n}\r\n\r\nconst FEDERATION_COMPONENTS = new Map<Function, FederationComponentDescriptor[]>();\r\nconst FEDERATED_INVENTORY_MAP = new Map<Function, FederatedInventoryMetadata[]>();\r\n\r\nexport function FederationComponent(descriptor: FederationComponentDescriptor): ClassDecorator {\r\n validateDescriptor(descriptor);\r\n\r\n return (target) => {\r\n const existing = FEDERATION_COMPONENTS.get(target) ?? [];\r\n existing.push({\r\n federationNamespace: descriptor.federationNamespace,\r\n federationType: descriptor.federationType,\r\n localSettings: descriptor.localSettings,\r\n });\r\n FEDERATION_COMPONENTS.set(target, existing);\r\n };\r\n}\r\n\r\nexport function getFederationComponents(target: Function): FederationComponentDescriptor[] {\r\n return FEDERATION_COMPONENTS.get(target) ?? [];\r\n}\r\n\r\nexport function FederatedInventory<T extends FederationIdentity>(\r\n options: FederatedInventoryOptions<T>,\r\n): ClassDecorator {\r\n const authenticate = options.authenticate ?? 'Authenticate';\r\n const getInventoryState = options.getInventoryState ?? 'GetInventoryState';\r\n const startInventoryTransaction = options.startInventoryTransaction ?? 'StartInventoryTransaction';\r\n\r\n return (target) => {\r\n const identityInstance = new options.identity();\r\n if (!identityInstance || typeof identityInstance.getUniqueName !== 'function') {\r\n throw new Error('@FederatedInventory identity must implement getUniqueName().');\r\n }\r\n const identityName = identityInstance.getUniqueName();\r\n if (!identityName || !identityName.trim()) {\r\n throw new Error('@FederatedInventory identity must provide a non-empty unique name.');\r\n }\r\n\r\n const existing = FEDERATED_INVENTORY_MAP.get(target) ?? [];\r\n existing.push({\r\n identityCtor: options.identity,\r\n identityName: identityName.trim(),\r\n methods: {\r\n authenticate,\r\n getInventoryState,\r\n startInventoryTransaction,\r\n },\r\n });\r\n FEDERATED_INVENTORY_MAP.set(target, existing);\r\n };\r\n}\r\n\r\nexport function getFederatedInventoryMetadata(target: Function): FederatedInventoryMetadata[] {\r\n return FEDERATED_INVENTORY_MAP.get(target) ?? [];\r\n}\r\n\r\nfunction validateDescriptor(descriptor: FederationComponentDescriptor): void {\r\n if (!descriptor.federationNamespace || !descriptor.federationNamespace.trim()) {\r\n throw new Error('@FederationComponent requires a non-empty federationNamespace.');\r\n }\r\n if (!descriptor.federationType || !descriptor.federationType.trim()) {\r\n throw new Error('@FederationComponent requires a non-empty federationType.');\r\n }\r\n}\r\n\r\nexport class FederationRegistry {\r\n private readonly logger: Logger;\r\n private readonly manualComponents = new Map<string, Set<string>>();\r\n private readonly autoComponents = new Map<string, Set<string>>();\r\n private readonly routeHandlers = new Map<string, FederationRouteHandler>();\r\n\r\n constructor(logger: Logger) {\r\n this.logger = logger.child({ component: 'FederationRegistry' });\r\n }\r\n\r\n register(component: FederationComponentDescriptor): void {\r\n validateDescriptor(component);\r\n const namespace = component.federationNamespace.trim();\r\n const type = component.federationType.trim();\r\n const existing = this.manualComponents.get(namespace) ?? new Set<string>();\r\n existing.add(type);\r\n this.manualComponents.set(namespace, existing);\r\n this.logger.debug({ component }, 'Registered federation component.');\r\n }\r\n\r\n registerInventoryHandlers(service: object, metadata: FederatedInventoryMetadata[]): void {\r\n for (const entry of metadata) {\r\n const identity = entry.identityName;\r\n this.addAutoComponent(identity, 'IFederatedInventory');\r\n this.addAutoComponent(identity, 'IFederatedLogin');\r\n\r\n const authenticateHandler = this.createInventoryHandler(\r\n service,\r\n entry.methods.authenticate,\r\n identity,\r\n 'authenticate',\r\n );\r\n const stateHandler = this.createInventoryHandler(\r\n service,\r\n entry.methods.getInventoryState,\r\n identity,\r\n 'inventory-state',\r\n );\r\n const transactionHandler = this.createInventoryHandler(\r\n service,\r\n entry.methods.startInventoryTransaction,\r\n identity,\r\n 'inventory-transaction',\r\n );\r\n\r\n this.routeHandlers.set(`${identity.toLowerCase()}/authenticate`, authenticateHandler);\r\n this.routeHandlers.set(`${identity.toLowerCase()}/inventory/state`, stateHandler);\r\n this.routeHandlers.set(`${identity.toLowerCase()}/inventory/put`, transactionHandler);\r\n }\r\n }\r\n\r\n list(): FederationComponentDescriptor[] {\r\n const components: FederationComponentDescriptor[] = [];\r\n for (const [namespace, types] of this.manualComponents.entries()) {\r\n for (const type of types) {\r\n components.push({ federationNamespace: namespace, federationType: type });\r\n }\r\n }\r\n for (const [namespace, types] of this.autoComponents.entries()) {\r\n for (const type of types) {\r\n components.push({ federationNamespace: namespace, federationType: type });\r\n }\r\n }\r\n return components;\r\n }\r\n\r\n resolve(path: string): FederationRouteHandler | undefined {\r\n return this.routeHandlers.get(path.toLowerCase());\r\n }\r\n\r\n private addAutoComponent(namespace: string, type: string): void {\r\n const existing = this.autoComponents.get(namespace) ?? new Set<string>();\r\n existing.add(type);\r\n this.autoComponents.set(namespace, existing);\r\n }\r\n\r\n private createInventoryHandler(\r\n service: object,\r\n methodName: string,\r\n identity: string,\r\n type: FederationRouteHandler['type'],\r\n ): FederationRouteHandler {\r\n const method = (service as Record<string, unknown>)[methodName];\r\n if (typeof method !== 'function') {\r\n throw new Error(\r\n `Federated inventory method \"${methodName}\" is not defined on service \"${service.constructor.name}\".`,\r\n );\r\n }\r\n const paramTypes = getMethodParameterTypes(service, methodName);\r\n\r\n return {\r\n identityName: identity,\r\n type,\r\n invoke: async (ctx: FederatedRequestContext) => {\r\n const federatedCtx: FederatedRequestContext = {\r\n ...ctx,\r\n federation: { identity },\r\n };\r\n switch (type) {\r\n case 'authenticate':\r\n return invokeFederatedAuthenticate(\r\n method as (...args: unknown[]) => unknown,\r\n service,\r\n federatedCtx,\r\n normalizeAuthenticationRequest(ctx.body),\r\n paramTypes,\r\n );\r\n case 'inventory-state':\r\n return invokeFederatedGetInventoryState(\r\n method as (...args: unknown[]) => unknown,\r\n service,\r\n federatedCtx,\r\n normalizeInventoryStateRequest(ctx.body),\r\n paramTypes,\r\n );\r\n case 'inventory-transaction':\r\n return invokeFederatedStartInventoryTransaction(\r\n method as (...args: unknown[]) => unknown,\r\n service,\r\n federatedCtx,\r\n normalizeInventoryTransactionRequest(ctx.body),\r\n paramTypes,\r\n );\r\n default:\r\n throw new Error(`Unsupported federated handler type: ${type as string}`);\r\n }\r\n },\r\n };\r\n }\r\n}\r\n\r\nfunction normalizeAuthenticationRequest(payload: unknown): FederatedAuthenticationRequest {\r\n if (!payload || typeof payload !== 'object') {\r\n return {};\r\n }\r\n const body = payload as Record<string, unknown>;\r\n return {\r\n token: typeof body.token === 'string' ? body.token : undefined,\r\n challenge: typeof body.challenge === 'string' ? body.challenge : undefined,\r\n solution: typeof body.solution === 'string' ? body.solution : undefined,\r\n };\r\n}\r\n\r\nfunction normalizeInventoryStateRequest(payload: unknown): FederatedInventoryStateRequest {\r\n if (!payload || typeof payload !== 'object' || typeof (payload as Record<string, unknown>).id !== 'string') {\r\n throw new Error('Federated inventory state requests must include an \"id\" property.');\r\n }\r\n const body = payload as Record<string, unknown>;\r\n return { id: String(body.id) };\r\n}\r\n\r\nfunction normalizeInventoryTransactionRequest(payload: unknown): FederatedInventoryTransactionRequest {\r\n if (!payload || typeof payload !== 'object') {\r\n throw new Error('Federated inventory transaction requests require a JSON body.');\r\n }\r\n const body = payload as Record<string, unknown>;\r\n if (typeof body.id !== 'string') {\r\n throw new Error('Federated inventory transaction requests must include an \"id\" property.');\r\n }\r\n if (typeof body.transaction !== 'string') {\r\n throw new Error('Federated inventory transaction requests must include a \"transaction\" property.');\r\n }\r\n\r\n return {\r\n id: body.id,\r\n transaction: body.transaction,\r\n currencies: normalizeRecordOfNumbers(body.currencies),\r\n newItems: normalizeFederatedCreateRequests(body.newItems),\r\n deleteItems: normalizeFederatedDeleteRequests(body.deleteItems),\r\n updateItems: normalizeFederatedUpdateRequests(body.updateItems),\r\n };\r\n}\r\n\r\nfunction normalizeRecordOfNumbers(value: unknown): Record<string, number> | undefined {\r\n if (!value || typeof value !== 'object') {\r\n return undefined;\r\n }\r\n const record: Record<string, number> = {};\r\n for (const [key, raw] of Object.entries(value as Record<string, unknown>)) {\r\n const numeric = Number(raw);\r\n if (Number.isFinite(numeric)) {\r\n record[key] = numeric;\r\n }\r\n }\r\n return Object.keys(record).length > 0 ? record : undefined;\r\n}\r\n\r\nfunction normalizeFederatedCreateRequests(value: unknown): FederatedItemCreateRequest[] | undefined {\r\n if (!Array.isArray(value)) {\r\n return undefined;\r\n }\r\n const normalized: FederatedItemCreateRequest[] = [];\r\n for (const item of value) {\r\n if (!item || typeof item !== 'object') {\r\n continue;\r\n }\r\n const record = item as Record<string, unknown>;\r\n if (typeof record.contentId !== 'string') {\r\n continue;\r\n }\r\n const properties = record.properties && typeof record.properties === 'object'\r\n ? Object.fromEntries(\r\n Object.entries(record.properties as Record<string, unknown>).map(([propKey, propVal]) => [\r\n propKey,\r\n String(propVal),\r\n ]),\r\n )\r\n : undefined;\r\n normalized.push({\r\n contentId: record.contentId,\r\n requestId: typeof record.requestId === 'string' ? record.requestId : undefined,\r\n properties,\r\n });\r\n }\r\n return normalized.length > 0 ? normalized : undefined;\r\n}\r\n\r\nfunction normalizeFederatedDeleteRequests(value: unknown): FederatedItemDeleteRequest[] | undefined {\r\n if (!Array.isArray(value)) {\r\n return undefined;\r\n }\r\n const normalized: FederatedItemDeleteRequest[] = [];\r\n for (const item of value) {\r\n if (!item || typeof item !== 'object') {\r\n continue;\r\n }\r\n const record = item as Record<string, unknown>;\r\n if (typeof record.contentId !== 'string' || typeof record.proxyId !== 'string') {\r\n continue;\r\n }\r\n normalized.push({\r\n contentId: record.contentId,\r\n proxyId: record.proxyId,\r\n });\r\n }\r\n return normalized.length > 0 ? normalized : undefined;\r\n}\r\n\r\nfunction normalizeFederatedUpdateRequests(value: unknown): FederatedItemUpdateRequest[] | undefined {\r\n if (!Array.isArray(value)) {\r\n return undefined;\r\n }\r\n const normalized: FederatedItemUpdateRequest[] = [];\r\n for (const item of value) {\r\n if (!item || typeof item !== 'object') {\r\n continue;\r\n }\r\n const record = item as Record<string, unknown>;\r\n if (typeof record.contentId !== 'string' || typeof record.proxyId !== 'string') {\r\n continue;\r\n }\r\n const properties = record.properties && typeof record.properties === 'object'\r\n ? Object.fromEntries(\r\n Object.entries(record.properties as Record<string, unknown>).map(([propKey, propVal]) => [\r\n propKey,\r\n String(propVal),\r\n ]),\r\n )\r\n : undefined;\r\n normalized.push({\r\n contentId: record.contentId,\r\n proxyId: record.proxyId,\r\n properties,\r\n });\r\n }\r\n return normalized.length > 0 ? normalized : undefined;\r\n}\r\n\r\nfunction getMethodParameterTypes(service: object, methodName: string): unknown[] {\r\n const prototype = Object.getPrototypeOf(service);\r\n if (!prototype || typeof Reflect.getMetadata !== 'function') {\r\n return [];\r\n }\r\n return (Reflect.getMetadata('design:paramtypes', prototype, methodName) as unknown[]) ?? [];\r\n}\r\n\r\nfunction isStringType(type: unknown): boolean {\r\n return type === String;\r\n}\r\n\r\nfunction invokeFederatedAuthenticate(\r\n method: (...args: unknown[]) => unknown,\r\n service: object,\r\n ctx: FederatedRequestContext,\r\n request: FederatedAuthenticationRequest,\r\n paramTypes: unknown[],\r\n): unknown {\r\n const argsWithoutContext = [request.token, request.challenge, request.solution];\r\n\r\n if (method.length === argsWithoutContext.length) {\r\n return method.call(service, ...argsWithoutContext);\r\n }\r\n\r\n if (method.length === argsWithoutContext.length + 1) {\r\n return method.call(service, ctx, ...argsWithoutContext);\r\n }\r\n\r\n if (method.length === 1) {\r\n const firstType = paramTypes[0];\r\n if (isStringType(firstType)) {\r\n return method.call(service, ...argsWithoutContext);\r\n }\r\n return method.call(service, request);\r\n }\r\n\r\n if (method.length === 2) {\r\n const secondType = paramTypes[1];\r\n if (isStringType(secondType)) {\r\n return method.call(service, ctx, ...argsWithoutContext);\r\n }\r\n return method.call(service, ctx, request);\r\n }\r\n\r\n return method.call(service, ctx, request);\r\n}\r\n\r\nfunction invokeFederatedGetInventoryState(\r\n method: (...args: unknown[]) => unknown,\r\n service: object,\r\n ctx: FederatedRequestContext,\r\n request: FederatedInventoryStateRequest,\r\n paramTypes: unknown[],\r\n): unknown {\r\n const argsWithoutContext = [request.id];\r\n\r\n if (method.length === argsWithoutContext.length) {\r\n const firstType = paramTypes[0];\r\n if (isStringType(firstType)) {\r\n return method.call(service, ...argsWithoutContext);\r\n }\r\n return method.call(service, request);\r\n }\r\n\r\n if (method.length === argsWithoutContext.length + 1) {\r\n const secondType = paramTypes[1];\r\n if (isStringType(secondType)) {\r\n return method.call(service, ctx, ...argsWithoutContext);\r\n }\r\n return method.call(service, ctx, request);\r\n }\r\n\r\n if (method.length === 1) {\r\n return method.call(service, request);\r\n }\r\n\r\n if (method.length === 2) {\r\n return method.call(service, ctx, request);\r\n }\r\n\r\n return method.call(service, ctx, request);\r\n}\r\n\r\nfunction invokeFederatedStartInventoryTransaction(\r\n method: (...args: unknown[]) => unknown,\r\n service: object,\r\n ctx: FederatedRequestContext,\r\n request: FederatedInventoryTransactionRequest,\r\n _paramTypes: unknown[],\r\n): unknown {\r\n const argsWithoutContext = [\r\n request.id,\r\n request.transaction,\r\n request.currencies ?? {},\r\n request.newItems ?? [],\r\n request.deleteItems ?? [],\r\n request.updateItems ?? [],\r\n ];\r\n\r\n if (method.length === argsWithoutContext.length) {\r\n return method.call(service, ...argsWithoutContext);\r\n }\r\n\r\n if (method.length === argsWithoutContext.length + 1) {\r\n return method.call(service, ctx, ...argsWithoutContext);\r\n }\r\n\r\n if (method.length === 1) {\r\n return method.call(service, request);\r\n }\r\n\r\n if (method.length === 2) {\r\n return method.call(service, ctx, request);\r\n }\r\n\r\n return method.call(service, ctx, request);\r\n}\r\n"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FederatedInventory = exports.getFederationComponents = exports.FederationRegistry = exports.FederationComponent = exports.listRegisteredStorageObjects = exports.getStorageMetadata = exports.StorageObject = exports.StorageService = exports.createInventoryService = exports.InventoryUpdateBuilder = exports.runMicroservice = exports.MicroserviceRuntime = exports.BeamableRuntimeError = exports.loadEnvironmentConfig = exports.BEAMABLE_SERVICES_TOKEN = exports.REQUEST_CONTEXT_TOKEN = exports.ENVIRONMENT_CONFIG_TOKEN = exports.LOGGER_TOKEN = exports.ServiceLifetime = exports.DependencyBuilder = exports.BeamableServiceManager = exports.InitializeServices = exports.ConfigureServices = exports.SwaggerTags = exports.SwaggerCategory = exports.AdminCallable = exports.ServerCallable = exports.ClientCallable = exports.Callable = exports.Microservice = void 0;
|
|
4
|
+
var decorators_js_1 = require("./decorators.js");
|
|
5
|
+
Object.defineProperty(exports, "Microservice", { enumerable: true, get: function () { return decorators_js_1.Microservice; } });
|
|
6
|
+
Object.defineProperty(exports, "Callable", { enumerable: true, get: function () { return decorators_js_1.Callable; } });
|
|
7
|
+
Object.defineProperty(exports, "ClientCallable", { enumerable: true, get: function () { return decorators_js_1.ClientCallable; } });
|
|
8
|
+
Object.defineProperty(exports, "ServerCallable", { enumerable: true, get: function () { return decorators_js_1.ServerCallable; } });
|
|
9
|
+
Object.defineProperty(exports, "AdminCallable", { enumerable: true, get: function () { return decorators_js_1.AdminCallable; } });
|
|
10
|
+
Object.defineProperty(exports, "SwaggerCategory", { enumerable: true, get: function () { return decorators_js_1.SwaggerCategory; } });
|
|
11
|
+
Object.defineProperty(exports, "SwaggerTags", { enumerable: true, get: function () { return decorators_js_1.SwaggerTags; } });
|
|
12
|
+
Object.defineProperty(exports, "ConfigureServices", { enumerable: true, get: function () { return decorators_js_1.ConfigureServices; } });
|
|
13
|
+
Object.defineProperty(exports, "InitializeServices", { enumerable: true, get: function () { return decorators_js_1.InitializeServices; } });
|
|
14
|
+
var services_js_1 = require("./services.js");
|
|
15
|
+
Object.defineProperty(exports, "BeamableServiceManager", { enumerable: true, get: function () { return services_js_1.BeamableServiceManager; } });
|
|
16
|
+
var dependency_js_1 = require("./dependency.js");
|
|
17
|
+
Object.defineProperty(exports, "DependencyBuilder", { enumerable: true, get: function () { return dependency_js_1.DependencyBuilder; } });
|
|
18
|
+
Object.defineProperty(exports, "ServiceLifetime", { enumerable: true, get: function () { return dependency_js_1.ServiceLifetime; } });
|
|
19
|
+
Object.defineProperty(exports, "LOGGER_TOKEN", { enumerable: true, get: function () { return dependency_js_1.LOGGER_TOKEN; } });
|
|
20
|
+
Object.defineProperty(exports, "ENVIRONMENT_CONFIG_TOKEN", { enumerable: true, get: function () { return dependency_js_1.ENVIRONMENT_CONFIG_TOKEN; } });
|
|
21
|
+
Object.defineProperty(exports, "REQUEST_CONTEXT_TOKEN", { enumerable: true, get: function () { return dependency_js_1.REQUEST_CONTEXT_TOKEN; } });
|
|
22
|
+
Object.defineProperty(exports, "BEAMABLE_SERVICES_TOKEN", { enumerable: true, get: function () { return dependency_js_1.BEAMABLE_SERVICES_TOKEN; } });
|
|
23
|
+
var env_js_1 = require("./env.js");
|
|
24
|
+
Object.defineProperty(exports, "loadEnvironmentConfig", { enumerable: true, get: function () { return env_js_1.loadEnvironmentConfig; } });
|
|
25
|
+
var errors_js_1 = require("./errors.js");
|
|
26
|
+
Object.defineProperty(exports, "BeamableRuntimeError", { enumerable: true, get: function () { return errors_js_1.BeamableRuntimeError; } });
|
|
27
|
+
var runtime_js_1 = require("./runtime.js");
|
|
28
|
+
Object.defineProperty(exports, "MicroserviceRuntime", { enumerable: true, get: function () { return runtime_js_1.MicroserviceRuntime; } });
|
|
29
|
+
Object.defineProperty(exports, "runMicroservice", { enumerable: true, get: function () { return runtime_js_1.runMicroservice; } });
|
|
30
|
+
var inventory_js_1 = require("./inventory.js");
|
|
31
|
+
Object.defineProperty(exports, "InventoryUpdateBuilder", { enumerable: true, get: function () { return inventory_js_1.InventoryUpdateBuilder; } });
|
|
32
|
+
Object.defineProperty(exports, "createInventoryService", { enumerable: true, get: function () { return inventory_js_1.createInventoryService; } });
|
|
33
|
+
var storage_js_1 = require("./storage.js");
|
|
34
|
+
Object.defineProperty(exports, "StorageService", { enumerable: true, get: function () { return storage_js_1.StorageService; } });
|
|
35
|
+
Object.defineProperty(exports, "StorageObject", { enumerable: true, get: function () { return storage_js_1.StorageObject; } });
|
|
36
|
+
Object.defineProperty(exports, "getStorageMetadata", { enumerable: true, get: function () { return storage_js_1.getStorageMetadata; } });
|
|
37
|
+
Object.defineProperty(exports, "listRegisteredStorageObjects", { enumerable: true, get: function () { return storage_js_1.listRegisteredStorageObjects; } });
|
|
38
|
+
var federation_js_1 = require("./federation.js");
|
|
39
|
+
Object.defineProperty(exports, "FederationComponent", { enumerable: true, get: function () { return federation_js_1.FederationComponent; } });
|
|
40
|
+
Object.defineProperty(exports, "FederationRegistry", { enumerable: true, get: function () { return federation_js_1.FederationRegistry; } });
|
|
41
|
+
Object.defineProperty(exports, "getFederationComponents", { enumerable: true, get: function () { return federation_js_1.getFederationComponents; } });
|
|
42
|
+
Object.defineProperty(exports, "FederatedInventory", { enumerable: true, get: function () { return federation_js_1.FederatedInventory; } });
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { Microservice, Callable, ClientCallable, ServerCallable, AdminCallable, SwaggerCategory, SwaggerTags, ConfigureServices, InitializeServices, } from './decorators.js';
|
|
2
|
+
export type { MicroserviceOptions, CallableOptions, ServiceAccess } from './types.js';
|
|
3
|
+
export type { EnvironmentConfig, RequestContext, ServiceDefinition } from './types.js';
|
|
4
|
+
export type { BeamableMicroserviceServices, BoundBeamApi } from './services.js';
|
|
5
|
+
export { BeamableServiceManager } from './services.js';
|
|
6
|
+
export { DependencyBuilder, type DependencyScope, ServiceLifetime, LOGGER_TOKEN, ENVIRONMENT_CONFIG_TOKEN, REQUEST_CONTEXT_TOKEN, BEAMABLE_SERVICES_TOKEN, } from './dependency.js';
|
|
7
|
+
export { loadEnvironmentConfig } from './env.js';
|
|
8
|
+
export { BeamableRuntimeError } from './errors.js';
|
|
9
|
+
export { MicroserviceRuntime, runMicroservice } from './runtime.js';
|
|
10
|
+
export { InventoryUpdateBuilder, createInventoryService, type InventoryUpdatePayload, type InventoryBuilderOptions, } from './inventory.js';
|
|
11
|
+
export { StorageService, StorageObject, getStorageMetadata, listRegisteredStorageObjects } from './storage.js';
|
|
12
|
+
export { FederationComponent, FederationRegistry, getFederationComponents, FederatedInventory, type FederationIdentity, type FederatedAuthenticationRequest, type FederatedAuthenticationResponse, type FederatedInventoryProxyState, type FederatedInventoryStateRequest, type FederatedInventoryTransactionRequest, type FederatedItemCreateRequest, type FederatedItemDeleteRequest, type FederatedItemUpdateRequest, type FederatedItemProperty, type FederatedItemProxy, } from './federation.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,cAAc,EACd,aAAa,EACb,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACtF,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACvF,YAAY,EAAE,4BAA4B,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EACL,iBAAiB,EACjB,KAAK,eAAe,EACpB,eAAe,EACf,YAAY,EACZ,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAC/G,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,kBAAkB,EACvB,KAAK,8BAA8B,EACnC,KAAK,+BAA+B,EACpC,KAAK,4BAA4B,EACjC,KAAK,8BAA8B,EACnC,KAAK,oCAAoC,EACzC,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { Microservice, Callable, ClientCallable, ServerCallable, AdminCallable, SwaggerCategory, SwaggerTags, ConfigureServices, InitializeServices, } from './decorators.js';
|
|
2
|
+
export { BeamableServiceManager } from './services.js';
|
|
3
|
+
export { DependencyBuilder, ServiceLifetime, LOGGER_TOKEN, ENVIRONMENT_CONFIG_TOKEN, REQUEST_CONTEXT_TOKEN, BEAMABLE_SERVICES_TOKEN, } from './dependency.js';
|
|
4
|
+
export { loadEnvironmentConfig } from './env.js';
|
|
5
|
+
export { BeamableRuntimeError } from './errors.js';
|
|
6
|
+
export { MicroserviceRuntime, runMicroservice } from './runtime.js';
|
|
7
|
+
export { InventoryUpdateBuilder, createInventoryService, } from './inventory.js';
|
|
8
|
+
export { StorageService, StorageObject, getStorageMetadata, listRegisteredStorageObjects } from './storage.js';
|
|
9
|
+
export { FederationComponent, FederationRegistry, getFederationComponents, FederatedInventory, } from './federation.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,cAAc,EACd,aAAa,EACb,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EACL,iBAAiB,EAEjB,eAAe,EACf,YAAY,EACZ,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EACL,sBAAsB,EACtB,sBAAsB,GAGvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAC/G,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,GAYnB,MAAM,iBAAiB,CAAC","sourcesContent":["export {\r\n Microservice,\r\n Callable,\r\n ClientCallable,\r\n ServerCallable,\r\n AdminCallable,\r\n SwaggerCategory,\r\n SwaggerTags,\r\n ConfigureServices,\r\n InitializeServices,\r\n} from './decorators.js';\r\nexport type { MicroserviceOptions, CallableOptions, ServiceAccess } from './types.js';\r\nexport type { EnvironmentConfig, RequestContext, ServiceDefinition } from './types.js';\r\nexport type { BeamableMicroserviceServices, BoundBeamApi } from './services.js';\r\nexport { BeamableServiceManager } from './services.js';\r\nexport {\r\n DependencyBuilder,\r\n type DependencyScope,\r\n ServiceLifetime,\r\n LOGGER_TOKEN,\r\n ENVIRONMENT_CONFIG_TOKEN,\r\n REQUEST_CONTEXT_TOKEN,\r\n BEAMABLE_SERVICES_TOKEN,\r\n} from './dependency.js';\r\nexport { loadEnvironmentConfig } from './env.js';\r\nexport { BeamableRuntimeError } from './errors.js';\r\nexport { MicroserviceRuntime, runMicroservice } from './runtime.js';\r\nexport {\r\n InventoryUpdateBuilder,\r\n createInventoryService,\r\n type InventoryUpdatePayload,\r\n type InventoryBuilderOptions,\r\n} from './inventory.js';\r\nexport { StorageService, StorageObject, getStorageMetadata, listRegisteredStorageObjects } from './storage.js';\r\nexport {\r\n FederationComponent,\r\n FederationRegistry,\r\n getFederationComponents,\r\n FederatedInventory,\r\n type FederationIdentity,\r\n type FederatedAuthenticationRequest,\r\n type FederatedAuthenticationResponse,\r\n type FederatedInventoryProxyState,\r\n type FederatedInventoryStateRequest,\r\n type FederatedInventoryTransactionRequest,\r\n type FederatedItemCreateRequest,\r\n type FederatedItemDeleteRequest,\r\n type FederatedItemUpdateRequest,\r\n type FederatedItemProperty,\r\n type FederatedItemProxy,\r\n} from './federation.js';\r\n"]}
|