@nxgt/shared-graphql 1.0.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/README.md +15 -0
- package/dist/directives/federation.d.ts +2 -0
- package/dist/directives/federation.d.ts.map +1 -0
- package/dist/directives/index.d.ts +2 -0
- package/dist/directives/index.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +907 -0
- package/dist/index.js.map +31 -0
- package/dist/integrations/hono.d.ts +13 -0
- package/dist/integrations/hono.d.ts.map +1 -0
- package/dist/integrations/index.d.ts +2 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/plugins/auth.d.ts +4 -0
- package/dist/plugins/auth.d.ts.map +1 -0
- package/dist/plugins/extract-jwt.d.ts +9 -0
- package/dist/plugins/extract-jwt.d.ts.map +1 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/ory-auth.d.ts +55 -0
- package/dist/plugins/ory-auth.d.ts.map +1 -0
- package/dist/scalars/any/any.scalars.d.ts +5 -0
- package/dist/scalars/any/any.scalars.d.ts.map +1 -0
- package/dist/scalars/any/index.d.ts +2 -0
- package/dist/scalars/any/index.d.ts.map +1 -0
- package/dist/scalars/custom/custom.scalars.d.ts +3 -0
- package/dist/scalars/custom/custom.scalars.d.ts.map +1 -0
- package/dist/scalars/custom/index.d.ts +2 -0
- package/dist/scalars/custom/index.d.ts.map +1 -0
- package/dist/scalars/custom/utils.d.ts +8 -0
- package/dist/scalars/custom/utils.d.ts.map +1 -0
- package/dist/scalars/index.d.ts +3 -0
- package/dist/scalars/index.d.ts.map +1 -0
- package/dist/scalars/upload/index.d.ts +2 -0
- package/dist/scalars/upload/index.d.ts.map +1 -0
- package/dist/scalars/upload/upload.scalar.d.ts +4 -0
- package/dist/scalars/upload/upload.scalar.d.ts.map +1 -0
- package/dist/security/index.d.ts +2 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +28 -0
- package/dist/security/index.js.map +11 -0
- package/dist/security/policies/evaluation.service.d.ts +9 -0
- package/dist/security/policies/evaluation.service.d.ts.map +1 -0
- package/dist/security/policies/exaluation.utils.d.ts +4 -0
- package/dist/security/policies/exaluation.utils.d.ts.map +1 -0
- package/dist/security/policies/index.d.ts +3 -0
- package/dist/security/policies/index.d.ts.map +1 -0
- package/dist/security/policies/policy.types.d.ts +3 -0
- package/dist/security/policies/policy.types.d.ts.map +1 -0
- package/dist/shared.d.ts +2 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/types/context.d.ts +14 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/graphql.d.ts +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/upload.d.ts +3 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/utils/change-resolvers.utils.d.ts +66 -0
- package/dist/utils/change-resolvers.utils.d.ts.map +1 -0
- package/dist/utils/codegen.utils.d.ts +68 -0
- package/dist/utils/codegen.utils.d.ts.map +1 -0
- package/dist/utils/data-loader.utils.d.ts +14 -0
- package/dist/utils/data-loader.utils.d.ts.map +1 -0
- package/dist/utils/errors.utils.d.ts +23 -0
- package/dist/utils/errors.utils.d.ts.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/publish.d.ts +8 -0
- package/dist/utils/publish.d.ts.map +1 -0
- package/dist/utils/sandbox.d.ts +9 -0
- package/dist/utils/sandbox.d.ts.map +1 -0
- package/dist/utils/schema.utils.d.ts +11 -0
- package/dist/utils/schema.utils.d.ts.map +1 -0
- package/dist/utils/websocket.d.ts +11 -0
- package/dist/utils/websocket.d.ts.map +1 -0
- package/dist/utils/ws-context.d.ts +24 -0
- package/dist/utils/ws-context.d.ts.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export declare const SCALARS_MAPPING: {
|
|
2
|
+
ID: string;
|
|
3
|
+
DateTime: string;
|
|
4
|
+
Date: string;
|
|
5
|
+
Any: string;
|
|
6
|
+
BigInt: string;
|
|
7
|
+
EmailAddress: string;
|
|
8
|
+
GeoJSON: string;
|
|
9
|
+
HSL: string;
|
|
10
|
+
HSLA: string;
|
|
11
|
+
HexColorCode: string;
|
|
12
|
+
Hexadecimal: string;
|
|
13
|
+
IBAN: string;
|
|
14
|
+
IP: string;
|
|
15
|
+
Time: string;
|
|
16
|
+
LocalTime: string;
|
|
17
|
+
UUID: string;
|
|
18
|
+
PositiveInt: string;
|
|
19
|
+
NegativeInt: string;
|
|
20
|
+
NonPositiveInt: string;
|
|
21
|
+
NonNegativeInt: string;
|
|
22
|
+
PositiveFloat: string;
|
|
23
|
+
NegativeFloat: string;
|
|
24
|
+
NonPositiveFloat: string;
|
|
25
|
+
NonNegativeFloat: string;
|
|
26
|
+
NonEmptyString: string;
|
|
27
|
+
PostalCode: string;
|
|
28
|
+
RGB: string;
|
|
29
|
+
RGBA: string;
|
|
30
|
+
SESSN: string;
|
|
31
|
+
Timestamp: string;
|
|
32
|
+
URL: string;
|
|
33
|
+
USCurrency: string;
|
|
34
|
+
UTCOffset: string;
|
|
35
|
+
Long: string;
|
|
36
|
+
Short: string;
|
|
37
|
+
Byte: string;
|
|
38
|
+
BigDecimal: string;
|
|
39
|
+
BigInteger: string;
|
|
40
|
+
Char: string;
|
|
41
|
+
Locale: string;
|
|
42
|
+
CountryCode: string;
|
|
43
|
+
CountryName: string;
|
|
44
|
+
AccountNumber: string;
|
|
45
|
+
CurrencyCode: string;
|
|
46
|
+
Duration: string;
|
|
47
|
+
Url: string;
|
|
48
|
+
JSONObject: string;
|
|
49
|
+
JSON: string;
|
|
50
|
+
Void: string;
|
|
51
|
+
ObjectID: string;
|
|
52
|
+
Upload: string;
|
|
53
|
+
Email: string;
|
|
54
|
+
Port: string;
|
|
55
|
+
IPv4: string;
|
|
56
|
+
IPv6: string;
|
|
57
|
+
MAC: string;
|
|
58
|
+
Password: string;
|
|
59
|
+
PhoneNumber: string;
|
|
60
|
+
ZIPCode: string;
|
|
61
|
+
SSN: string;
|
|
62
|
+
GUID: string;
|
|
63
|
+
ISBN: string;
|
|
64
|
+
Latitude: string;
|
|
65
|
+
Longitude: string;
|
|
66
|
+
JWT: string;
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=codegen.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codegen.utils.d.ts","sourceRoot":"","sources":["../../src/utils/codegen.utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkE3B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type HydratedDocument, type IConnection, type Model, type PaginationOptions, type SimplePaginationOptions } from '@nxgt/shared-mongo';
|
|
2
|
+
import DataLoader from 'dataloader';
|
|
3
|
+
export declare function createDataLoader<K, V>(batchLoadFn: DataLoader.BatchLoadFn<K, V>, options?: DataLoader.Options<K, V, K>): DataLoader<K, V, K>;
|
|
4
|
+
export declare function createConnectionListDataLoader<K, V>(path: keyof K, model: Model<V, any, any, any, any, any, any>, options: PaginationOptions): DataLoader<K, IConnection<HydratedDocument<V>>, K>;
|
|
5
|
+
export declare function createChildrenConnectionDataLoader<K, V>(path: keyof V, model: Model<V, any, any, any, any, any, any>, options: PaginationOptions): DataLoader<HydratedDocument<K>, IConnection<HydratedDocument<V>>, HydratedDocument<K>>;
|
|
6
|
+
export declare function createSimpleListDataLoader<K, V>(path: keyof K, model: Model<V, any, any, any, any, any, any>, options?: SimplePaginationOptions): DataLoader<K, HydratedDocument<V>[], K>;
|
|
7
|
+
export declare function createChildrenListDataLoader<K, V>(path: keyof V, model: Model<V, any, any, any, any, any, any>, options?: SimplePaginationOptions): DataLoader<HydratedDocument<K>, HydratedDocument<V>[], HydratedDocument<K>>;
|
|
8
|
+
export declare function createSingleChildDataLoader<K, V extends {
|
|
9
|
+
id: string;
|
|
10
|
+
}>(path: keyof K, model: Model<V, any, any, any, any, any, any>): DataLoader<K, HydratedDocument<V> | null, K>;
|
|
11
|
+
export declare function createEntitiesReferenceLoader<V extends {
|
|
12
|
+
id: string;
|
|
13
|
+
}>(model: Model<V, any, any, any, any, any, any>): DataLoader<string, HydratedDocument<V> | null>;
|
|
14
|
+
//# sourceMappingURL=data-loader.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-loader.utils.d.ts","sourceRoot":"","sources":["../../src/utils/data-loader.utils.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,KAAK,EAEV,KAAK,iBAAiB,EAGtB,KAAK,uBAAuB,EAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AAGpC,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,EACpC,WAAW,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EACzC,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,uBAGrC;AAED,wBAAgB,8BAA8B,CAAC,CAAC,EAAE,CAAC,EAClD,IAAI,EAAE,MAAM,CAAC,EACb,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC7C,OAAO,EAAE,iBAAiB,sDAiC1B;AAED,wBAAgB,kCAAkC,CAAC,CAAC,EAAE,CAAC,EACtD,IAAI,EAAE,MAAM,CAAC,EACb,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC7C,OAAO,EAAE,iBAAiB,0FAoB1B;AAED,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,CAAC,EAC9C,IAAI,EAAE,MAAM,CAAC,EACb,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC7C,OAAO,CAAC,EAAE,uBAAuB,2CA+BjC;AAED,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,CAAC,EAChD,IAAI,EAAE,MAAM,CAAC,EACb,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC7C,OAAO,CAAC,EAAE,uBAAuB,+EA6BjC;AAED,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACtE,IAAI,EAAE,MAAM,CAAC,EACb,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,gDAmB7C;AAED,wBAAgB,6BAA6B,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACrE,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAgBvC,UAAU,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CACpD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ApolloServerOptions } from '@apollo/server';
|
|
2
|
+
import { type LocaleKey, type TranslationContext } from '@nxgt/i18n';
|
|
3
|
+
import { GraphQLError, type GraphQLErrorOptions } from 'graphql';
|
|
4
|
+
import type { MaskError } from 'graphql-yoga';
|
|
5
|
+
import type { GraphQLBaseContext } from '../types';
|
|
6
|
+
export declare function createGraphQLError(message: string, options?: GraphQLErrorOptions): GraphQLError;
|
|
7
|
+
export declare function createFormatError<K extends LocaleKey, C extends GraphQLBaseContext = GraphQLBaseContext>(translate?: (message: K, context?: TranslationContext) => string, production?: boolean): ApolloServerOptions<C>['formatError'];
|
|
8
|
+
/**
|
|
9
|
+
* Yoga's `maskedErrors.maskError`, taught this repo's exceptions.
|
|
10
|
+
*
|
|
11
|
+
* Yoga masks anything that is not a `GraphQLError` as "Unexpected error." —
|
|
12
|
+
* and `CustomException` extends `Error`, so out of the box a service's
|
|
13
|
+
* `notFound()` or `forbidden()` reaches the client as an opaque 500. This
|
|
14
|
+
* turns one into a `GraphQLError` with the translated message, the
|
|
15
|
+
* exception's `code` in `extensions`, and a matching HTTP status; a Mongoose
|
|
16
|
+
* error goes through `castError` first, as `createFormatError` does for
|
|
17
|
+
* Apollo. `OryUnavailable` (stx-sdk/ory) becomes a 503 `SERVICE_UNAVAILABLE`,
|
|
18
|
+
* never a denial. Everything else is masked exactly as before.
|
|
19
|
+
*
|
|
20
|
+
* createYoga({ maskedErrors: { maskError: createMaskError(translate) } })
|
|
21
|
+
*/
|
|
22
|
+
export declare function createMaskError<K extends LocaleKey>(translate?: (message: K, context?: TranslationContext) => string): MaskError;
|
|
23
|
+
//# sourceMappingURL=errors.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.utils.d.ts","sourceRoot":"","sources":["../../src/utils/errors.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAK1D,OAAO,EACN,KAAK,SAAS,EACd,KAAK,kBAAkB,EAEvB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnD,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,mBAAmB,GAC3B,YAAY,CAEd;AAED,wBAAgB,iBAAiB,CAChC,CAAC,SAAS,SAAS,EACnB,CAAC,SAAS,kBAAkB,GAAG,kBAAkB,EAEjD,SAAS,GAAE,CACV,OAAO,EAAE,CAAC,EACV,OAAO,CAAC,EAAE,kBAAkB,KACxB,MAAsB,EAC3B,UAAU,CAAC,EAAE,OAAO,GAClB,mBAAmB,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAoDvC;AAYD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,SAAS,EAClD,SAAS,GAAE,CACV,OAAO,EAAE,CAAC,EACV,OAAO,CAAC,EAAE,kBAAkB,KACxB,MAAsB,GACzB,SAAS,CAkDX"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './change-resolvers.utils';
|
|
2
|
+
export * from './codegen.utils';
|
|
3
|
+
export * from './data-loader.utils';
|
|
4
|
+
export * from './errors.utils';
|
|
5
|
+
export * from './publish';
|
|
6
|
+
export * from './sandbox';
|
|
7
|
+
export * from './schema.utils';
|
|
8
|
+
export * from './websocket';
|
|
9
|
+
export * from './ws-context';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Redis } from 'ioredis';
|
|
2
|
+
export declare const createYogaPubSub: ({ publishClient, subscribeClient, }: {
|
|
3
|
+
publishClient: Redis;
|
|
4
|
+
subscribeClient: Redis;
|
|
5
|
+
}) => import("graphql-yoga").PubSub<{
|
|
6
|
+
[key: string]: [] | [any] | [string | number, any];
|
|
7
|
+
}>;
|
|
8
|
+
//# sourceMappingURL=publish.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/utils/publish.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,eAAO,MAAM,gBAAgB,GAAI,qCAG9B;IACF,aAAa,EAAE,KAAK,CAAC;IACrB,eAAe,EAAE,KAAK,CAAC;CACvB;;EAOA,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type RenderSandboxOptions = {
|
|
2
|
+
port?: number;
|
|
3
|
+
graphqlEndpoint?: string;
|
|
4
|
+
protocol?: string;
|
|
5
|
+
hostname?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const renderSandbox: ({ port, hostname, graphqlEndpoint, protocol, title, }: RenderSandboxOptions) => import("hono/utils/html").HtmlEscapedString | Promise<import("hono/utils/html").HtmlEscapedString>;
|
|
9
|
+
//# sourceMappingURL=sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/utils/sandbox.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,GAAG;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,uDAM3B,oBAAoB,uGAuBtB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { buildSubgraphSchema as buildSubgraphSchemaBase } from '@apollo/subgraph';
|
|
2
|
+
export declare const SHARED_SCHEMA_PATH: string;
|
|
3
|
+
export declare function loadTypeDefs(...paths: string[]): import("graphql").DocumentNode;
|
|
4
|
+
export declare function buildSubgraphSchema(modulesOrSdl: Parameters<typeof buildSubgraphSchemaBase>[0]): import("graphql").GraphQLSchema;
|
|
5
|
+
/**
|
|
6
|
+
* Utility function to generate a GraphQL schema file from the provided type definitions.
|
|
7
|
+
* @param output - The path where the generated schema file should be saved.
|
|
8
|
+
* @param paths - An array of glob patterns to locate the GraphQL type definition files.
|
|
9
|
+
*/
|
|
10
|
+
export declare function generateSchema(output: string, ...paths: string[]): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=schema.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.utils.d.ts","sourceRoot":"","sources":["../../src/utils/schema.utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,IAAI,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAMlF,eAAO,MAAM,kBAAkB,QAAqC,CAAC;AAErE,wBAAgB,YAAY,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,kCAU9C;AAED,wBAAgB,mBAAmB,CAClC,YAAY,EAAE,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC,CAAC,CAAC,mCAK3D;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,iBAKtE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ServerOptions } from 'graphql-ws';
|
|
2
|
+
import type { YogaServerInstance } from 'graphql-yoga';
|
|
3
|
+
export declare function setupYogaWebSocketServer<ServerContext extends {}, UserContext extends {}>({ yoga, context, }: {
|
|
4
|
+
yoga: YogaServerInstance<ServerContext, UserContext>;
|
|
5
|
+
context?: ServerOptions['context'];
|
|
6
|
+
}): {
|
|
7
|
+
yoga: YogaServerInstance<ServerContext, UserContext>;
|
|
8
|
+
httpServer: import("node:http").Server<typeof import("node:http").IncomingMessage, typeof import("node:http").ServerResponse>;
|
|
9
|
+
startServer: (port: number) => Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=websocket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../src/utils/websocket.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGvD,wBAAgB,wBAAwB,CACvC,aAAa,SAAS,EAAE,EACxB,WAAW,SAAS,EAAE,EACrB,EACD,IAAI,EACJ,OAAO,GACP,EAAE;IACF,IAAI,EAAE,kBAAkB,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;IACrD,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CACnC;;;wBA0C2B,MAAM;EAGjC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Principal } from '@nxgt/shared';
|
|
2
|
+
import type { Context } from 'graphql-ws';
|
|
3
|
+
import type { createAuthClient } from 'stx-sdk/auth';
|
|
4
|
+
type AuthClient = ReturnType<typeof createAuthClient>;
|
|
5
|
+
export interface ResolvedWsUser {
|
|
6
|
+
user: Principal | undefined;
|
|
7
|
+
token: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the authenticated Principal for a `graphql-ws` connection - the
|
|
11
|
+
* WS-transport equivalent of the HTTP-path `useAuth()`/`useGenericAuth()`
|
|
12
|
+
* plugins. There is no gateway hop for WS connections, so each app performs
|
|
13
|
+
* the OAuth introspection call itself using its own `auth` client.
|
|
14
|
+
*
|
|
15
|
+
* Reads the bearer token off `connectionParams.authorization` /
|
|
16
|
+
* `connectionParams.Authorization` (both casings are used by existing
|
|
17
|
+
* clients), strips the `Bearer ` prefix, and introspects it. Returns
|
|
18
|
+
* `user: undefined` for a missing, invalid, or inactive token - callers
|
|
19
|
+
* pass `user ?? null` into their own `services()` factory, exactly as the
|
|
20
|
+
* HTTP-path plugins already do.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveWsUser(connectionParams: Context['connectionParams'], authClient: AuthClient): Promise<ResolvedWsUser>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=ws-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws-context.d.ts","sourceRoot":"","sources":["../../src/utils/ws-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEtD,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,aAAa,CAClC,gBAAgB,EAAE,OAAO,CAAC,kBAAkB,CAAC,EAC7C,UAAU,EAAE,UAAU,GACpB,OAAO,CAAC,cAAc,CAAC,CAezB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nxgt/shared-graphql",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md",
|
|
11
|
+
"package.json"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./security": {
|
|
20
|
+
"types": "./dist/security/index.d.ts",
|
|
21
|
+
"import": "./dist/security/index.js",
|
|
22
|
+
"default": "./dist/security/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/softistx/nxgt-core.git",
|
|
29
|
+
"directory": "packages/shared-graphql"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"registry": "https://registry.npmjs.org",
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "bun run ../../build.ts",
|
|
37
|
+
"typecheck": "tsc --noEmit"
|
|
38
|
+
},
|
|
39
|
+
"nxgt": {
|
|
40
|
+
"entrypoints": [
|
|
41
|
+
"src/index.ts",
|
|
42
|
+
"src/security/index.ts"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@apollo/server": "^5.5.1",
|
|
47
|
+
"@apollo/subgraph": "^2.14.3",
|
|
48
|
+
"@envelop/extended-validation": "^7.1.1",
|
|
49
|
+
"@envelop/generic-auth": "^11.1.1",
|
|
50
|
+
"@graphql-hive/gateway": "^2.11.2",
|
|
51
|
+
"@graphql-tools/load-files": "^7.0.1",
|
|
52
|
+
"@graphql-tools/merge": "^9.2.3",
|
|
53
|
+
"@graphql-tools/utils": "^12.0.0",
|
|
54
|
+
"@graphql-yoga/redis-event-target": "^3.0.3",
|
|
55
|
+
"@hono/zod-validator": "^0.9.0",
|
|
56
|
+
"@nxgt/i18n": "1.0.0",
|
|
57
|
+
"@nxgt/security": "1.0.0",
|
|
58
|
+
"@nxgt/shared": "1.0.0",
|
|
59
|
+
"@nxgt/shared-exceptions": "1.0.0",
|
|
60
|
+
"@nxgt/shared-logging": "1.0.0",
|
|
61
|
+
"@nxgt/shared-mongo": "1.0.0",
|
|
62
|
+
"dataloader": "^2.2.3",
|
|
63
|
+
"graphql": "^16.4.2",
|
|
64
|
+
"graphql-scalars": "^1.26.0",
|
|
65
|
+
"graphql-subscriptions": "^3.0.0",
|
|
66
|
+
"graphql-upload": "^18.0.0",
|
|
67
|
+
"graphql-ws": "^6.2.1",
|
|
68
|
+
"graphql-yoga": "^5.21.3",
|
|
69
|
+
"hono": "^4.13.4",
|
|
70
|
+
"ioredis": "^6.0.0",
|
|
71
|
+
"lodash": "^4.18.1",
|
|
72
|
+
"ws": "^8.21.3",
|
|
73
|
+
"zod": "^4.4.3"
|
|
74
|
+
},
|
|
75
|
+
"devDependencies": {
|
|
76
|
+
"@types/bun": "^1.4.0",
|
|
77
|
+
"@types/graphql-upload": "^17.0.0",
|
|
78
|
+
"@types/lodash": "^4.17.25",
|
|
79
|
+
"@types/ws": "^8.18.1"
|
|
80
|
+
},
|
|
81
|
+
"peerDependencies": {
|
|
82
|
+
"stx-sdk": ">=1.0.0",
|
|
83
|
+
"typescript": "^6.0.3"
|
|
84
|
+
}
|
|
85
|
+
}
|