1
0
Эх сурвалжийг харах

chore(core): Export new symbols, add some documentation

Michael Bromley 5 жил өмнө
parent
commit
28c520f8af

+ 12 - 4
packages/admin-ui/src/lib/core/src/common/generated-types.ts

@@ -598,7 +598,7 @@ export type CreateZoneInput = {
 /**
  * @description
  * ISO 4217 currency code
- * 
+ *
  * @docsCategory common
  */
 export enum CurrencyCode {
@@ -1393,7 +1393,7 @@ export type JobSortParameter = {
 /**
  * @description
  * The state of a Job in the JobQueue
- * 
+ *
  * @docsCategory common
  */
 export enum JobState {
@@ -1411,7 +1411,7 @@ export enum JobState {
  * region or script modifier (e.g. de_AT). The selection available is based
  * on the [Unicode CLDR summary list](https://unicode-org.github.io/cldr-staging/charts/37/summary/root.html)
  * and includes the major spoken languages of the world and any widely-used variants.
- * 
+ *
  * @docsCategory common
  */
 export enum LanguageCode {
@@ -1778,6 +1778,7 @@ export type Mutation = {
   assignProductsToChannel: Array<Product>;
   /** Assign a Role to an Administrator */
   assignRoleToAdministrator: Administrator;
+  authenticate: LoginResult;
   cancelOrder: Order;
   /** Create a new Administrator */
   createAdministrator: Administrator;
@@ -1855,6 +1856,7 @@ export type Mutation = {
   deleteZone: DeletionResponse;
   fulfillOrder: Fulfillment;
   importProducts?: Maybe<ImportInfo>;
+  /** @deprecated Use `authenticate` mutation with the 'native' strategy instead. */
   login: LoginResult;
   logout: Scalars['Boolean'];
   /** Move a Collection to a different parent or index */
@@ -1966,6 +1968,12 @@ export type MutationAssignRoleToAdministratorArgs = {
 };
 
 
+export type MutationAuthenticateArgs = {
+  input: AuthenticationInput;
+  rememberMe?: Maybe<Scalars['Boolean']>;
+};
+
+
 export type MutationCancelOrderArgs = {
   input: CancelOrderInput;
 };
@@ -2597,7 +2605,7 @@ export type PaymentMethodSortParameter = {
  * @description
  * Permissions for administrators and customers. Used to control access to
  * GraphQL resolvers via the {@link Allow} decorator.
- * 
+ *
  * @docsCategory common
  */
 export enum Permission {

+ 7 - 0
packages/asset-server-plugin/e2e/graphql/generated-e2e-asset-server-plugin-types.ts

@@ -1771,7 +1771,9 @@ export type Mutation = {
     updateAsset: Asset;
     /** Delete an Asset */
     deleteAsset: DeletionResponse;
+    /** @deprecated Use `authenticate` mutation with the 'native' strategy instead. */
     login: LoginResult;
+    authenticate: LoginResult;
     logout: Scalars['Boolean'];
     /** Create a new Channel */
     createChannel: Channel;
@@ -1944,6 +1946,11 @@ export type MutationLoginArgs = {
     rememberMe?: Maybe<Scalars['Boolean']>;
 };
 
+export type MutationAuthenticateArgs = {
+    input: AuthenticationInput;
+    rememberMe?: Maybe<Scalars['Boolean']>;
+};
+
 export type MutationCreateChannelArgs = {
     input: CreateChannelInput;
 };

+ 12 - 4
packages/common/src/generated-types.ts

@@ -597,7 +597,7 @@ export type CreateZoneInput = {
 /**
  * @description
  * ISO 4217 currency code
- * 
+ *
  * @docsCategory common
  */
 export enum CurrencyCode {
@@ -1385,7 +1385,7 @@ export type JobSortParameter = {
 /**
  * @description
  * The state of a Job in the JobQueue
- * 
+ *
  * @docsCategory common
  */
 export enum JobState {
@@ -1403,7 +1403,7 @@ export enum JobState {
  * region or script modifier (e.g. de_AT). The selection available is based
  * on the [Unicode CLDR summary list](https://unicode-org.github.io/cldr-staging/charts/37/summary/root.html)
  * and includes the major spoken languages of the world and any widely-used variants.
- * 
+ *
  * @docsCategory common
  */
 export enum LanguageCode {
@@ -1770,7 +1770,9 @@ export type Mutation = {
   updateAsset: Asset;
   /** Delete an Asset */
   deleteAsset: DeletionResponse;
+  /** @deprecated Use `authenticate` mutation with the 'native' strategy instead. */
   login: LoginResult;
+  authenticate: LoginResult;
   logout: Scalars['Boolean'];
   /** Create a new Channel */
   createChannel: Channel;
@@ -1951,6 +1953,12 @@ export type MutationLoginArgs = {
 };
 
 
+export type MutationAuthenticateArgs = {
+  input: AuthenticationInput;
+  rememberMe?: Maybe<Scalars['Boolean']>;
+};
+
+
 export type MutationCreateChannelArgs = {
   input: CreateChannelInput;
 };
@@ -2557,7 +2565,7 @@ export type PaymentMethodSortParameter = {
  * @description
  * Permissions for administrators and customers. Used to control access to
  * GraphQL resolvers via the {@link Allow} decorator.
- * 
+ *
  * @docsCategory common
  */
 export enum Permission {

+ 14 - 2
packages/core/src/config/auth/authentication-strategy.ts

@@ -4,6 +4,13 @@ import { RequestContext } from '../../api/common/request-context';
 import { InjectableStrategy } from '../../common/types/injectable-strategy';
 import { User } from '../../entity/user/user.entity';
 
+/**
+ * @description
+ * An AuthenticationStrategy defines how a User (which can be a Customer in the Shop API or
+ * and Administrator in the Admin API) may be authenticated.
+ *
+ * @docsCategory auth
+ */
 export interface AuthenticationStrategy<Data = unknown> extends InjectableStrategy {
     /**
      * @description
@@ -16,7 +23,8 @@ export interface AuthenticationStrategy<Data = unknown> extends InjectableStrate
      * @description
      * Defines the type of the GraphQL Input object expected by the `authenticate`
      * mutation. The final input object will be a map, with the key being the name
-     * of the strategy.
+     * of the strategy. The shape of the input object should match the generic `Data`
+     * type argument.
      *
      * For example, given the following:
      * ```TypeScript
@@ -41,12 +49,16 @@ export interface AuthenticationStrategy<Data = unknown> extends InjectableStrate
      *   # ...
      * }
      * ```
+     *
+     * **Note:** if more than one graphql `input` type is being defined (as in a nested input type), then
+     * the _first_ input will be assumed to be the top-level input.
      */
     defineInputType(): DocumentNode;
 
     /**
      * @description
-     * Used to authenticate a user with the authentication provider.
+     * Used to authenticate a user with the authentication provider. This method
+     * will
      */
     authenticate(ctx: RequestContext, data: Data): Promise<User | false>;
 

+ 8 - 11
packages/core/src/config/auth/native-authentication-strategy.ts

@@ -1,6 +1,4 @@
-import { ExecutionContext } from '@nestjs/common';
 import { ID } from '@vendure/common/lib/shared-types';
-import { isObject } from '@vendure/common/lib/shared-utils';
 import { DocumentNode } from 'graphql';
 import gql from 'graphql-tag';
 import { Connection } from 'typeorm';
@@ -8,7 +6,6 @@ import { Connection } from 'typeorm';
 import { RequestContext } from '../../api/common/request-context';
 import { UnauthorizedError } from '../../common/error/errors';
 import { Injector } from '../../common/injector';
-import { AuthenticationMethod } from '../../entity/authentication-method/authentication-method.entity';
 import { NativeAuthenticationMethod } from '../../entity/authentication-method/native-authentication-method.entity';
 import { User } from '../../entity/user/user.entity';
 import { PasswordCiper } from '../../service/helpers/password-cipher/password-ciper';
@@ -22,6 +19,14 @@ export interface NativeAuthenticationData {
 
 export const NATIVE_AUTH_STRATEGY_NAME = 'native';
 
+/**
+ * @description
+ * This strategy implements a username/password credential-based authentication, with the credentials
+ * being stored in the Vendure database. This is the default method of authentication, and it is advised
+ * to keep it configured unless there is a specific reason not to.
+ *
+ * @docsCategory auth
+ */
 export class NativeAuthenticationStrategy implements AuthenticationStrategy<NativeAuthenticationData> {
     readonly name = NATIVE_AUTH_STRATEGY_NAME;
 
@@ -33,14 +38,6 @@ export class NativeAuthenticationStrategy implements AuthenticationStrategy<Nati
         this.passwordCipher = injector.get(PasswordCiper);
     }
 
-    /*validateData(data: unknown): data is NativeAuthenticationData {
-        return (
-            isObject(data) &&
-            typeof (data as any).username === 'string' &&
-            typeof (data as any).password === 'string'
-        );
-    }*/
-
     defineInputType(): DocumentNode {
         return gql`
             input NativeAuthInput {

+ 2 - 0
packages/core/src/config/index.ts

@@ -2,6 +2,8 @@ export * from './asset-naming-strategy/asset-naming-strategy';
 export * from './asset-naming-strategy/default-asset-naming-strategy';
 export * from './asset-preview-strategy/asset-preview-strategy';
 export * from './asset-storage-strategy/asset-storage-strategy';
+export * from './auth/authentication-strategy';
+export * from './auth/native-authentication-strategy';
 export * from './collection/collection-filter';
 export * from './collection/default-collection-filters';
 export * from './config.module';

+ 19 - 1
packages/core/src/config/vendure-config.ts

@@ -224,7 +224,19 @@ export interface AuthOptions {
      * Configures the credentials to be used to create a superadmin
      */
     superadminCredentials?: SuperadminCredentials;
+    /**
+     * @description
+     * Configures one or more AuthenticationStrategies which defines how authentication
+     * is handled in the Shop API.
+     * @default NativeAuthenticationStrategy
+     */
     shopAuthenticationStrategy?: AuthenticationStrategy[];
+    /**
+     * @description
+     * Configures one or more AuthenticationStrategy which defines how authentication
+     * is handled in the Admin API.
+     * @default NativeAuthenticationStrategy
+     */
     adminAuthenticationStrategy?: AuthenticationStrategy[];
 }
 
@@ -414,18 +426,24 @@ export interface ShippingOptions {
 }
 
 /**
- * @docsCategory superadmin
+ * @description
+ * These credentials will be used to create the Superadmin user & administrator
+ * when Vendure first bootstraps.
+ *
+ * @docsCategory auth
  */
 export interface SuperadminCredentials {
     /**
      * @description
      * The identifier to be used to create a superadmin account
+     * @default 'superadmin'
      */
     identifier: string;
 
     /**
      * @description
      * The password to be used to create a superadmin account
+     * @default 'superadmin'
      */
     password: string;
 }

+ 3 - 0
packages/core/src/entity/index.ts

@@ -1,6 +1,9 @@
 export * from './address/address.entity';
 export * from './administrator/administrator.entity';
 export * from './asset/asset.entity';
+export * from './authentication-method/authentication-method.entity';
+export * from './authentication-method/external-authentication-method.entity';
+export * from './authentication-method/native-authentication-method.entity';
 export * from './base/base.entity';
 export * from './channel/channel.entity';
 export * from './collection/collection.entity';

+ 7 - 0
packages/elasticsearch-plugin/e2e/graphql/generated-e2e-elasticsearch-plugin-types.ts

@@ -1771,7 +1771,9 @@ export type Mutation = {
     updateAsset: Asset;
     /** Delete an Asset */
     deleteAsset: DeletionResponse;
+    /** @deprecated Use `authenticate` mutation with the 'native' strategy instead. */
     login: LoginResult;
+    authenticate: LoginResult;
     logout: Scalars['Boolean'];
     /** Create a new Channel */
     createChannel: Channel;
@@ -1944,6 +1946,11 @@ export type MutationLoginArgs = {
     rememberMe?: Maybe<Scalars['Boolean']>;
 };
 
+export type MutationAuthenticateArgs = {
+    input: AuthenticationInput;
+    rememberMe?: Maybe<Scalars['Boolean']>;
+};
+
 export type MutationCreateChannelArgs = {
     input: CreateChannelInput;
 };

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
schema-admin.json


Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно