@vritti/api-sdk 0.3.3 → 0.3.5
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/auth.cjs +942 -0
- package/dist/auth.cjs.map +1 -0
- package/dist/auth.d.cts +95 -0
- package/dist/auth.d.ts +95 -0
- package/dist/auth.js +884 -0
- package/dist/auth.js.map +1 -0
- package/dist/cache.cjs +182 -14
- package/dist/cache.cjs.map +1 -1
- package/dist/cache.d.cts +48 -4
- package/dist/cache.d.ts +48 -4
- package/dist/cache.js +177 -12
- package/dist/cache.js.map +1 -1
- package/dist/catalog-resolver.cjs +226 -51
- package/dist/catalog-resolver.cjs.map +1 -1
- package/dist/catalog-resolver.d.cts +41 -19
- package/dist/catalog-resolver.d.ts +41 -19
- package/dist/catalog-resolver.js +212 -46
- package/dist/catalog-resolver.js.map +1 -1
- package/dist/code-pattern-BP4zkNtT.d.cts +12 -0
- package/dist/code-pattern-BP4zkNtT.d.ts +12 -0
- package/dist/context.cjs +93 -0
- package/dist/context.cjs.map +1 -0
- package/dist/context.d.cts +19 -0
- package/dist/context.d.ts +19 -0
- package/dist/context.js +64 -0
- package/dist/context.js.map +1 -0
- package/dist/countries.cjs +1559 -0
- package/dist/countries.cjs.map +1 -0
- package/dist/countries.d.cts +13 -0
- package/dist/countries.d.ts +13 -0
- package/dist/countries.js +1532 -0
- package/dist/countries.js.map +1 -0
- package/dist/data-table.cjs +1280 -0
- package/dist/data-table.cjs.map +1 -0
- package/dist/data-table.d.cts +123 -0
- package/dist/data-table.d.ts +123 -0
- package/dist/data-table.js +1260 -0
- package/dist/data-table.js.map +1 -0
- package/dist/database.cjs +1510 -0
- package/dist/database.cjs.map +1 -0
- package/dist/database.d.cts +287 -0
- package/dist/database.d.ts +287 -0
- package/dist/database.js +1469 -0
- package/dist/database.js.map +1 -0
- package/dist/decimal.d.cts +0 -1
- package/dist/decimal.d.ts +0 -1
- package/dist/decorators.cjs +1817 -0
- package/dist/decorators.cjs.map +1 -0
- package/dist/decorators.d.cts +24 -0
- package/dist/decorators.d.ts +24 -0
- package/dist/decorators.js +1780 -0
- package/dist/decorators.js.map +1 -0
- package/dist/drizzle-pg-core.cjs +25 -0
- package/dist/drizzle-pg-core.cjs.map +1 -1
- package/dist/drizzle-pg-core.d.cts +7 -0
- package/dist/drizzle-pg-core.d.ts +7 -0
- package/dist/drizzle-pg-core.js +22 -0
- package/dist/drizzle-pg-core.js.map +1 -1
- package/dist/exceptions.cjs +301 -0
- package/dist/exceptions.cjs.map +1 -0
- package/dist/exceptions.d.cts +90 -0
- package/dist/exceptions.d.ts +90 -0
- package/dist/exceptions.js +257 -0
- package/dist/exceptions.js.map +1 -0
- package/dist/filter.types-PuARU9XD.d.cts +50 -0
- package/dist/filter.types-PuARU9XD.d.ts +50 -0
- package/dist/filters.cjs +407 -0
- package/dist/filters.cjs.map +1 -0
- package/dist/filters.d.cts +55 -0
- package/dist/filters.d.ts +55 -0
- package/dist/filters.js +377 -0
- package/dist/filters.js.map +1 -0
- package/dist/index.cjs +0 -5423
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +93 -854
- package/dist/index.d.ts +93 -854
- package/dist/index.js +0 -5301
- package/dist/index.js.map +1 -1
- package/dist/is-country.decorator-CcNwSSr5.d.cts +5 -0
- package/dist/is-country.decorator-CcNwSSr5.d.ts +5 -0
- package/dist/license.d.cts +1 -1
- package/dist/license.d.ts +1 -1
- package/dist/lodash.cjs.map +1 -1
- package/dist/lodash.js.map +1 -1
- package/dist/logger.cjs +862 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/logger.d.cts +118 -0
- package/dist/logger.d.ts +118 -0
- package/dist/logger.js +816 -0
- package/dist/logger.js.map +1 -0
- package/dist/migrate.cjs +2 -2
- package/dist/migrate.cjs.map +1 -1
- package/dist/migrate.d.cts +2 -0
- package/dist/migrate.d.ts +2 -0
- package/dist/migrate.js +2 -2
- package/dist/migrate.js.map +1 -1
- package/dist/money.cjs +18 -3
- package/dist/money.cjs.map +1 -1
- package/dist/money.d.cts +13 -13
- package/dist/money.d.ts +13 -13
- package/dist/money.js +18 -3
- package/dist/money.js.map +1 -1
- package/dist/nats.cjs +34 -35
- package/dist/nats.cjs.map +1 -1
- package/dist/nats.d.cts +14 -14
- package/dist/nats.d.ts +14 -14
- package/dist/nats.js +32 -33
- package/dist/nats.js.map +1 -1
- package/dist/root.cjs +225 -0
- package/dist/root.cjs.map +1 -0
- package/dist/root.d.cts +4 -0
- package/dist/root.d.ts +4 -0
- package/dist/root.js +200 -0
- package/dist/root.js.map +1 -0
- package/dist/{types-DQRwj5rr.d.cts → types-C9jPdQqH.d.cts} +32 -6
- package/dist/{types-DQRwj5rr.d.ts → types-C9jPdQqH.d.ts} +32 -6
- package/dist/types.cjs +19 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +17 -0
- package/dist/types.d.ts +17 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.cjs +273 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +8 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.js +245 -0
- package/dist/utils.js.map +1 -0
- package/package.json +122 -1
- package/dist/cache.service-_SuJIcNA.d.cts +0 -20
- package/dist/cache.service-_SuJIcNA.d.ts +0 -20
- package/dist/fastify-augmentation-CQPBNS5a.d.cts +0 -105
- package/dist/fastify-augmentation-CQPBNS5a.d.ts +0 -105
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const CODE_PATTERN_SOURCE = "^[a-z][a-z0-9-]*$";
|
|
2
|
+
declare const DOTTED_CODE_PATTERN_SOURCE = "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)*$";
|
|
3
|
+
declare const CODE_PATTERN: RegExp;
|
|
4
|
+
declare const DOTTED_CODE_PATTERN: RegExp;
|
|
5
|
+
interface CodeOptions {
|
|
6
|
+
dotted?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare function codePattern(options?: CodeOptions): RegExp;
|
|
9
|
+
declare function codePatternSource(options?: CodeOptions): string;
|
|
10
|
+
declare function codeMessage(property: string, options?: CodeOptions): string;
|
|
11
|
+
|
|
12
|
+
export { type CodeOptions as C, DOTTED_CODE_PATTERN as D, CODE_PATTERN as a, CODE_PATTERN_SOURCE as b, codeMessage as c, codePattern as d, codePatternSource as e, DOTTED_CODE_PATTERN_SOURCE as f };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const CODE_PATTERN_SOURCE = "^[a-z][a-z0-9-]*$";
|
|
2
|
+
declare const DOTTED_CODE_PATTERN_SOURCE = "^[a-z][a-z0-9-]*(\\.[a-z][a-z0-9-]*)*$";
|
|
3
|
+
declare const CODE_PATTERN: RegExp;
|
|
4
|
+
declare const DOTTED_CODE_PATTERN: RegExp;
|
|
5
|
+
interface CodeOptions {
|
|
6
|
+
dotted?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare function codePattern(options?: CodeOptions): RegExp;
|
|
9
|
+
declare function codePatternSource(options?: CodeOptions): string;
|
|
10
|
+
declare function codeMessage(property: string, options?: CodeOptions): string;
|
|
11
|
+
|
|
12
|
+
export { type CodeOptions as C, DOTTED_CODE_PATTERN as D, CODE_PATTERN as a, CODE_PATTERN_SOURCE as b, codeMessage as c, codePattern as d, codePatternSource as e, DOTTED_CODE_PATTERN_SOURCE as f };
|
package/dist/context.cjs
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/context/index.ts
|
|
22
|
+
var context_exports = {};
|
|
23
|
+
__export(context_exports, {
|
|
24
|
+
getRequestFromContext: () => getRequestFromContext,
|
|
25
|
+
getResponseFromContext: () => getResponseFromContext,
|
|
26
|
+
registerTransport: () => registerTransport,
|
|
27
|
+
resolveExtractor: () => resolveExtractor,
|
|
28
|
+
resolveInjectedRequest: () => resolveInjectedRequest
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(context_exports);
|
|
31
|
+
|
|
32
|
+
// src/context/extractors/graphql.extractor.ts
|
|
33
|
+
var graphqlExtractor = {
|
|
34
|
+
getRequest: /* @__PURE__ */ __name((host) => host.getArgByIndex(2).req, "getRequest"),
|
|
35
|
+
getResponse: /* @__PURE__ */ __name((host) => host.getArgByIndex(2).reply, "getResponse")
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/context/extractors/http.extractor.ts
|
|
39
|
+
var httpExtractor = {
|
|
40
|
+
getRequest: /* @__PURE__ */ __name((host) => host.switchToHttp().getRequest(), "getRequest"),
|
|
41
|
+
getResponse: /* @__PURE__ */ __name((host) => host.switchToHttp().getResponse(), "getResponse")
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// src/context/context.registry.ts
|
|
45
|
+
var registry = /* @__PURE__ */ new Map([
|
|
46
|
+
[
|
|
47
|
+
"http",
|
|
48
|
+
httpExtractor
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
"graphql",
|
|
52
|
+
graphqlExtractor
|
|
53
|
+
]
|
|
54
|
+
]);
|
|
55
|
+
function registerTransport(type, extractor) {
|
|
56
|
+
registry.set(type, extractor);
|
|
57
|
+
}
|
|
58
|
+
__name(registerTransport, "registerTransport");
|
|
59
|
+
function resolveExtractor(type) {
|
|
60
|
+
return registry.get(type) ?? httpExtractor;
|
|
61
|
+
}
|
|
62
|
+
__name(resolveExtractor, "resolveExtractor");
|
|
63
|
+
|
|
64
|
+
// src/context/get-request.ts
|
|
65
|
+
function getRequestFromContext(host) {
|
|
66
|
+
return resolveExtractor(host.getType()).getRequest(host);
|
|
67
|
+
}
|
|
68
|
+
__name(getRequestFromContext, "getRequestFromContext");
|
|
69
|
+
|
|
70
|
+
// src/context/get-response.ts
|
|
71
|
+
function getResponseFromContext(host) {
|
|
72
|
+
return resolveExtractor(host.getType()).getResponse(host);
|
|
73
|
+
}
|
|
74
|
+
__name(getResponseFromContext, "getResponseFromContext");
|
|
75
|
+
|
|
76
|
+
// src/context/resolve-request.ts
|
|
77
|
+
function resolveInjectedRequest(injected) {
|
|
78
|
+
const candidate = injected;
|
|
79
|
+
if (candidate && candidate.headers === void 0 && candidate.req) {
|
|
80
|
+
return candidate.req;
|
|
81
|
+
}
|
|
82
|
+
return injected;
|
|
83
|
+
}
|
|
84
|
+
__name(resolveInjectedRequest, "resolveInjectedRequest");
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
getRequestFromContext,
|
|
88
|
+
getResponseFromContext,
|
|
89
|
+
registerTransport,
|
|
90
|
+
resolveExtractor,
|
|
91
|
+
resolveInjectedRequest
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=context.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/context/index.ts","../src/context/extractors/graphql.extractor.ts","../src/context/extractors/http.extractor.ts","../src/context/context.registry.ts","../src/context/get-request.ts","../src/context/get-response.ts","../src/context/resolve-request.ts"],"sourcesContent":["// Transport-agnostic execution-context access — resolves the Fastify request/response per transport.\nexport { registerTransport, resolveExtractor } from './context.registry';\nexport type { RequestExtractor, TransportType } from './context.types';\nexport { getRequestFromContext } from './get-request';\nexport { getResponseFromContext } from './get-response';\nexport { resolveInjectedRequest } from './resolve-request';\n","import type { ArgumentsHost } from '@nestjs/common';\nimport type { FastifyReply, FastifyRequest } from 'fastify';\nimport type { RequestExtractor } from '../context.types';\n\ninterface GqlContext {\n req: FastifyRequest;\n reply?: FastifyReply;\n}\n\nexport const graphqlExtractor: RequestExtractor = {\n getRequest: (host: ArgumentsHost) => host.getArgByIndex<GqlContext>(2).req,\n getResponse: (host: ArgumentsHost) => host.getArgByIndex<GqlContext>(2).reply as FastifyReply,\n};\n","import type { FastifyReply, FastifyRequest } from 'fastify';\nimport type { RequestExtractor } from '../context.types';\n\n// Default transport: standard HTTP via the Fastify adapter.\nexport const httpExtractor: RequestExtractor = {\n getRequest: (host) => host.switchToHttp().getRequest<FastifyRequest>(),\n getResponse: (host) => host.switchToHttp().getResponse<FastifyReply>(),\n};\n","import type { RequestExtractor, TransportType } from './context.types';\nimport { graphqlExtractor } from './extractors/graphql.extractor';\nimport { httpExtractor } from './extractors/http.extractor';\n\nconst registry = new Map<TransportType, RequestExtractor>([\n ['http', httpExtractor],\n ['graphql', graphqlExtractor],\n]);\n\n// Registers (or overrides) the extractor for a transport type without modifying the SDK\nexport function registerTransport(type: TransportType, extractor: RequestExtractor): void {\n registry.set(type, extractor);\n}\n\n// Resolves the extractor for the host's reported transport, falling back to HTTP.\nexport function resolveExtractor(type: string): RequestExtractor {\n return registry.get(type as TransportType) ?? httpExtractor;\n}\n","import type { ArgumentsHost } from '@nestjs/common';\nimport type { FastifyRequest } from 'fastify';\nimport { resolveExtractor } from './context.registry';\n\n// Returns the underlying Fastify request for any registered transport, via the transport registry.\nexport function getRequestFromContext(host: ArgumentsHost): FastifyRequest {\n return resolveExtractor(host.getType()).getRequest(host);\n}\n","import type { ArgumentsHost } from '@nestjs/common';\nimport type { FastifyReply } from 'fastify';\nimport { resolveExtractor } from './context.registry';\n\n// Returns the underlying Fastify reply for any registered transport (HTTP, GraphQL, ...).\nexport function getResponseFromContext(host: ArgumentsHost): FastifyReply {\n return resolveExtractor(host.getType()).getResponse(host);\n}\n","import type { FastifyRequest } from 'fastify';\n\n// Unwraps the @Inject(REQUEST) value to the real Fastify request (GraphQL injects a { req, reply } context).\nexport function resolveInjectedRequest(injected: FastifyRequest): FastifyRequest {\n const candidate = injected as unknown as { headers?: unknown; req?: FastifyRequest };\n if (candidate && candidate.headers === undefined && candidate.req) {\n return candidate.req;\n }\n return injected;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;ACSO,IAAMA,mBAAqC;EAChDC,YAAY,wBAACC,SAAwBA,KAAKC,cAA0B,CAAA,EAAGC,KAA3D;EACZC,aAAa,wBAACH,SAAwBA,KAAKC,cAA0B,CAAA,EAAGG,OAA3D;AACf;;;ACRO,IAAMC,gBAAkC;EAC7CC,YAAY,wBAACC,SAASA,KAAKC,aAAY,EAAGF,WAAU,GAAxC;EACZG,aAAa,wBAACF,SAASA,KAAKC,aAAY,EAAGC,YAAW,GAAzC;AACf;;;ACHA,IAAMC,WAAW,oBAAIC,IAAqC;EACxD;IAAC;IAAQC;;EACT;IAAC;IAAWC;;CACb;AAGM,SAASC,kBAAkBC,MAAqBC,WAA2B;AAChFN,WAASO,IAAIF,MAAMC,SAAAA;AACrB;AAFgBF;AAKT,SAASI,iBAAiBH,MAAY;AAC3C,SAAOL,SAASS,IAAIJ,IAAAA,KAA0BH;AAChD;AAFgBM;;;ACVT,SAASE,sBAAsBC,MAAmB;AACvD,SAAOC,iBAAiBD,KAAKE,QAAO,CAAA,EAAIC,WAAWH,IAAAA;AACrD;AAFgBD;;;ACAT,SAASK,uBAAuBC,MAAmB;AACxD,SAAOC,iBAAiBD,KAAKE,QAAO,CAAA,EAAIC,YAAYH,IAAAA;AACtD;AAFgBD;;;ACFT,SAASK,uBAAuBC,UAAwB;AAC7D,QAAMC,YAAYD;AAClB,MAAIC,aAAaA,UAAUC,YAAYC,UAAaF,UAAUG,KAAK;AACjE,WAAOH,UAAUG;EACnB;AACA,SAAOJ;AACT;AANgBD;","names":["graphqlExtractor","getRequest","host","getArgByIndex","req","getResponse","reply","httpExtractor","getRequest","host","switchToHttp","getResponse","registry","Map","httpExtractor","graphqlExtractor","registerTransport","type","extractor","set","resolveExtractor","get","getRequestFromContext","host","resolveExtractor","getType","getRequest","getResponseFromContext","host","resolveExtractor","getType","getResponse","resolveInjectedRequest","injected","candidate","headers","undefined","req"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ArgumentsHost } from '@nestjs/common';
|
|
2
|
+
import { FastifyRequest, FastifyReply } from 'fastify';
|
|
3
|
+
|
|
4
|
+
type TransportType = 'http' | 'rpc' | 'ws' | 'graphql';
|
|
5
|
+
interface RequestExtractor {
|
|
6
|
+
getRequest(host: ArgumentsHost): FastifyRequest;
|
|
7
|
+
getResponse(host: ArgumentsHost): FastifyReply;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare function registerTransport(type: TransportType, extractor: RequestExtractor): void;
|
|
11
|
+
declare function resolveExtractor(type: string): RequestExtractor;
|
|
12
|
+
|
|
13
|
+
declare function getRequestFromContext(host: ArgumentsHost): FastifyRequest;
|
|
14
|
+
|
|
15
|
+
declare function getResponseFromContext(host: ArgumentsHost): FastifyReply;
|
|
16
|
+
|
|
17
|
+
declare function resolveInjectedRequest(injected: FastifyRequest): FastifyRequest;
|
|
18
|
+
|
|
19
|
+
export { type RequestExtractor, type TransportType, getRequestFromContext, getResponseFromContext, registerTransport, resolveExtractor, resolveInjectedRequest };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ArgumentsHost } from '@nestjs/common';
|
|
2
|
+
import { FastifyRequest, FastifyReply } from 'fastify';
|
|
3
|
+
|
|
4
|
+
type TransportType = 'http' | 'rpc' | 'ws' | 'graphql';
|
|
5
|
+
interface RequestExtractor {
|
|
6
|
+
getRequest(host: ArgumentsHost): FastifyRequest;
|
|
7
|
+
getResponse(host: ArgumentsHost): FastifyReply;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare function registerTransport(type: TransportType, extractor: RequestExtractor): void;
|
|
11
|
+
declare function resolveExtractor(type: string): RequestExtractor;
|
|
12
|
+
|
|
13
|
+
declare function getRequestFromContext(host: ArgumentsHost): FastifyRequest;
|
|
14
|
+
|
|
15
|
+
declare function getResponseFromContext(host: ArgumentsHost): FastifyReply;
|
|
16
|
+
|
|
17
|
+
declare function resolveInjectedRequest(injected: FastifyRequest): FastifyRequest;
|
|
18
|
+
|
|
19
|
+
export { type RequestExtractor, type TransportType, getRequestFromContext, getResponseFromContext, registerTransport, resolveExtractor, resolveInjectedRequest };
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/context/extractors/graphql.extractor.ts
|
|
5
|
+
var graphqlExtractor = {
|
|
6
|
+
getRequest: /* @__PURE__ */ __name((host) => host.getArgByIndex(2).req, "getRequest"),
|
|
7
|
+
getResponse: /* @__PURE__ */ __name((host) => host.getArgByIndex(2).reply, "getResponse")
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// src/context/extractors/http.extractor.ts
|
|
11
|
+
var httpExtractor = {
|
|
12
|
+
getRequest: /* @__PURE__ */ __name((host) => host.switchToHttp().getRequest(), "getRequest"),
|
|
13
|
+
getResponse: /* @__PURE__ */ __name((host) => host.switchToHttp().getResponse(), "getResponse")
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// src/context/context.registry.ts
|
|
17
|
+
var registry = /* @__PURE__ */ new Map([
|
|
18
|
+
[
|
|
19
|
+
"http",
|
|
20
|
+
httpExtractor
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
"graphql",
|
|
24
|
+
graphqlExtractor
|
|
25
|
+
]
|
|
26
|
+
]);
|
|
27
|
+
function registerTransport(type, extractor) {
|
|
28
|
+
registry.set(type, extractor);
|
|
29
|
+
}
|
|
30
|
+
__name(registerTransport, "registerTransport");
|
|
31
|
+
function resolveExtractor(type) {
|
|
32
|
+
return registry.get(type) ?? httpExtractor;
|
|
33
|
+
}
|
|
34
|
+
__name(resolveExtractor, "resolveExtractor");
|
|
35
|
+
|
|
36
|
+
// src/context/get-request.ts
|
|
37
|
+
function getRequestFromContext(host) {
|
|
38
|
+
return resolveExtractor(host.getType()).getRequest(host);
|
|
39
|
+
}
|
|
40
|
+
__name(getRequestFromContext, "getRequestFromContext");
|
|
41
|
+
|
|
42
|
+
// src/context/get-response.ts
|
|
43
|
+
function getResponseFromContext(host) {
|
|
44
|
+
return resolveExtractor(host.getType()).getResponse(host);
|
|
45
|
+
}
|
|
46
|
+
__name(getResponseFromContext, "getResponseFromContext");
|
|
47
|
+
|
|
48
|
+
// src/context/resolve-request.ts
|
|
49
|
+
function resolveInjectedRequest(injected) {
|
|
50
|
+
const candidate = injected;
|
|
51
|
+
if (candidate && candidate.headers === void 0 && candidate.req) {
|
|
52
|
+
return candidate.req;
|
|
53
|
+
}
|
|
54
|
+
return injected;
|
|
55
|
+
}
|
|
56
|
+
__name(resolveInjectedRequest, "resolveInjectedRequest");
|
|
57
|
+
export {
|
|
58
|
+
getRequestFromContext,
|
|
59
|
+
getResponseFromContext,
|
|
60
|
+
registerTransport,
|
|
61
|
+
resolveExtractor,
|
|
62
|
+
resolveInjectedRequest
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/context/extractors/graphql.extractor.ts","../src/context/extractors/http.extractor.ts","../src/context/context.registry.ts","../src/context/get-request.ts","../src/context/get-response.ts","../src/context/resolve-request.ts"],"sourcesContent":["import type { ArgumentsHost } from '@nestjs/common';\nimport type { FastifyReply, FastifyRequest } from 'fastify';\nimport type { RequestExtractor } from '../context.types';\n\ninterface GqlContext {\n req: FastifyRequest;\n reply?: FastifyReply;\n}\n\nexport const graphqlExtractor: RequestExtractor = {\n getRequest: (host: ArgumentsHost) => host.getArgByIndex<GqlContext>(2).req,\n getResponse: (host: ArgumentsHost) => host.getArgByIndex<GqlContext>(2).reply as FastifyReply,\n};\n","import type { FastifyReply, FastifyRequest } from 'fastify';\nimport type { RequestExtractor } from '../context.types';\n\n// Default transport: standard HTTP via the Fastify adapter.\nexport const httpExtractor: RequestExtractor = {\n getRequest: (host) => host.switchToHttp().getRequest<FastifyRequest>(),\n getResponse: (host) => host.switchToHttp().getResponse<FastifyReply>(),\n};\n","import type { RequestExtractor, TransportType } from './context.types';\nimport { graphqlExtractor } from './extractors/graphql.extractor';\nimport { httpExtractor } from './extractors/http.extractor';\n\nconst registry = new Map<TransportType, RequestExtractor>([\n ['http', httpExtractor],\n ['graphql', graphqlExtractor],\n]);\n\n// Registers (or overrides) the extractor for a transport type without modifying the SDK\nexport function registerTransport(type: TransportType, extractor: RequestExtractor): void {\n registry.set(type, extractor);\n}\n\n// Resolves the extractor for the host's reported transport, falling back to HTTP.\nexport function resolveExtractor(type: string): RequestExtractor {\n return registry.get(type as TransportType) ?? httpExtractor;\n}\n","import type { ArgumentsHost } from '@nestjs/common';\nimport type { FastifyRequest } from 'fastify';\nimport { resolveExtractor } from './context.registry';\n\n// Returns the underlying Fastify request for any registered transport, via the transport registry.\nexport function getRequestFromContext(host: ArgumentsHost): FastifyRequest {\n return resolveExtractor(host.getType()).getRequest(host);\n}\n","import type { ArgumentsHost } from '@nestjs/common';\nimport type { FastifyReply } from 'fastify';\nimport { resolveExtractor } from './context.registry';\n\n// Returns the underlying Fastify reply for any registered transport (HTTP, GraphQL, ...).\nexport function getResponseFromContext(host: ArgumentsHost): FastifyReply {\n return resolveExtractor(host.getType()).getResponse(host);\n}\n","import type { FastifyRequest } from 'fastify';\n\n// Unwraps the @Inject(REQUEST) value to the real Fastify request (GraphQL injects a { req, reply } context).\nexport function resolveInjectedRequest(injected: FastifyRequest): FastifyRequest {\n const candidate = injected as unknown as { headers?: unknown; req?: FastifyRequest };\n if (candidate && candidate.headers === undefined && candidate.req) {\n return candidate.req;\n }\n return injected;\n}\n"],"mappings":";;;;AASO,IAAMA,mBAAqC;EAChDC,YAAY,wBAACC,SAAwBA,KAAKC,cAA0B,CAAA,EAAGC,KAA3D;EACZC,aAAa,wBAACH,SAAwBA,KAAKC,cAA0B,CAAA,EAAGG,OAA3D;AACf;;;ACRO,IAAMC,gBAAkC;EAC7CC,YAAY,wBAACC,SAASA,KAAKC,aAAY,EAAGF,WAAU,GAAxC;EACZG,aAAa,wBAACF,SAASA,KAAKC,aAAY,EAAGC,YAAW,GAAzC;AACf;;;ACHA,IAAMC,WAAW,oBAAIC,IAAqC;EACxD;IAAC;IAAQC;;EACT;IAAC;IAAWC;;CACb;AAGM,SAASC,kBAAkBC,MAAqBC,WAA2B;AAChFN,WAASO,IAAIF,MAAMC,SAAAA;AACrB;AAFgBF;AAKT,SAASI,iBAAiBH,MAAY;AAC3C,SAAOL,SAASS,IAAIJ,IAAAA,KAA0BH;AAChD;AAFgBM;;;ACVT,SAASE,sBAAsBC,MAAmB;AACvD,SAAOC,iBAAiBD,KAAKE,QAAO,CAAA,EAAIC,WAAWH,IAAAA;AACrD;AAFgBD;;;ACAT,SAASK,uBAAuBC,MAAmB;AACxD,SAAOC,iBAAiBD,KAAKE,QAAO,CAAA,EAAIC,YAAYH,IAAAA;AACtD;AAFgBD;;;ACFT,SAASK,uBAAuBC,UAAwB;AAC7D,QAAMC,YAAYD;AAClB,MAAIC,aAAaA,UAAUC,YAAYC,UAAaF,UAAUG,KAAK;AACjE,WAAOH,UAAUG;EACnB;AACA,SAAOJ;AACT;AANgBD;","names":["graphqlExtractor","getRequest","host","getArgByIndex","req","getResponse","reply","httpExtractor","getRequest","host","switchToHttp","getResponse","registry","Map","httpExtractor","graphqlExtractor","registerTransport","type","extractor","set","resolveExtractor","get","getRequestFromContext","host","resolveExtractor","getType","getRequest","getResponseFromContext","host","resolveExtractor","getType","getResponse","resolveInjectedRequest","injected","candidate","headers","undefined","req"]}
|