2.0.0 • Published 4 months ago

@impartner/angular-sdk v2.0.0

Weekly downloads
-
License
BSD-3-Clause
Repository
-
Last release
4 months ago

@impartner/angular-sdk

This package contains Angular services and typings to facilitate development and integration of Angular web components written for Impartner host applications.

Getting Started

  1. Add the @impartner/angular-sdk dependency from npm.
  2. Update the application project's environment.ts and environment.prod.ts files to include the impartnerEndpointUrl property.
    • In environment.ts, set this property value to "/api", or some other unique path segment that will be used in the same project's local-serve proxy configuration to proxy requests to the Impartner PRM.
    • In environment.prod.ts, set this property value to an empty string, as it will not be used in production builds.
  3. Import ImpartnerSdkModule to the application's root NgModule using the ImpartnerSdkModule.forRoot(...) static function, passing the project's environment constant as the only argument.

    import { ImpartnerSdkModule } from '@impartner/angular-sdk';
    
    @NgModule({
      ...
      imports: [
        ...
        ImpartnerSdkModule.forRoot(environment),
        ...
      ],
      ...
    })
    export class AppModule { ... }

Available Services

This package provides several discrete services to enable integration with Impartner's front-end client applications, and does so through normal Angular dependency injection.

ImpartnerConfigService

Service TypeDI TokenProvided In
ImpartnerConfigServiceImpartnerConfigServiceroot

A simple service for synchronously fetching current configuration and context information that may be pertinent to client widget or micro front-end.

Methods

Name
getConfiggetConfig() => IImpartnerConfigReturns current configuration and context for the client application, including rendered locale, available locales, available features, and tenant ID.

ImpartnerEventBusService

Service TypeDI TokenProvided In
ImpartnerEventBusServiceImpartnerEventBusServiceroot

A service for emitting and listening to events available to the Impartner client application and any other widgets or micro front-ends in scope.

Methods

Name
emitemit<T>(eventName: string, event: T) => voidSynchronously emits a new bus event for eventName with the provided payload event of generic type T.
event$event$<T>(eventName: string) => Observable<T>Returns a hot Observable for bus events with name eventName.

ImpartnerMetadataService

Service TypeDI TokenProvided In
ImpartnerMetadataServiceImpartnerMetadataServiceroot

A service for fetching metadata about Impartner PRM objects and/or their fields from the host.

Methods

Name
describeAllObjectsdescribeAllObjects(profile?: DescribeProfile, context?: DescribeContextTypes) => Observable<IPrmObjectDefinition[]> Asynchronously fetches object metadata for all Impartner PRM objects visible to the user type specified by profile, or for the current user if unspecified. The context parameter determines how much information is provided, All and Sync options return basic information (eg. display name, API name, CRUD capabilities), Extended returns in-depth object metadata in the form of the ExtendedObjectProperties interface.
describeObjectdescribeObject(prmObjectName: string, profile?: DescribeProfile) => Observable<IPrmObjectDefinition \| null> Asynchronously fetches basic object metadata for Impartner PRM object prmObjectName for user type specified by profile, or for the current user if unspecified. Result may be null if the named Impartner PRM object does not exist or if it is inaccessible to the user type.
describeFieldsdescribeFields(prmObjectName: string, profile?: DescribeProfile, context?: DescribeContextTypes, depth?: number) => Observable<IPrmFieldDefinition[]> Asynchronously fetches field metadata for all fields of Impartner PRM object prmObjectName for user type specified by profile, or for the current user if unspecified. The context parameter determines how much information is provided, All and Sync options return basic information, Extended returns in-depth field metadata in the form of the ExtendedFieldProperties interface. The depth parameter will recursively populate the foreignFieldDefinitions array for fields with a fieldType of fk.
describeFielddescribeField(prmObjectName: string, fieldName: string, profile?: DescribeProfile, context?: DescribeContextTypes, depth?: number) => Observable<IPrmFieldDefinition \| null> Asynchronously fetches field metadata for named field fieldName of Impartner PRM object prmObjectName for user type specified by profile, or for the current user if unspecified. The context parameter determines how much information is provided, All and Sync options return basic information, Extended returns in-depth field metadata in the form of the ExtendedFieldProperties interface. The depth parameter will recursively populate the foreignFieldDefinitions array for fields with a fieldType of fk.
describeFilterEvaluatorsdescribeFilterEvaluators() => Observable<IFilterCriteriaTypeDefinitions> Asynchronously fetches the collection of different Impartner PRM object field data types and the filter operator types available for them.

ImpartnerObjectService

Service typeDI TokenProvided In
ImpartnerObjectServiceImpartnerObjectServiceroot

A service for performing CRUD operations with Impartner PRM object records.

Methods

Name
getget<T>(objectName: string, id: number \| string, fields?: string[]) => Observable<IPrmApiResult<T>> Asynchronously retrieves a record with the provided id of the specified Impartner PRM object type objectName, including any fields named in the fields array.
getManygetMany<T>(objectName: string, options?: ISearchOptions) => Observable<IPrmApiResult<IEntitySearchResult<T>>> Asynchronously retrieves many records of the specified Impartner PRM object type objectName. Providing an options value allows for specifying additional aspects of the request, including returned record fields, filter criteria, sort order, and skip/take values for pagination.
getManyByCriteriagetManyByCriteria<T>(objectName: string, options: ICriteriaSearchOptions) => Observable<IPrmApiResult<IEntitySearchResult<T>>> Asynchronously retrieves many records of the specified Impartner PRM object type objectName. Providing an options value allows for specifying additional aspects of the request, including returned record fields, filter criteria, sort order, and skip/take values for pagination. While similar in nature to getMany, the expanded typing of the options argument allows for alternative filtering logic and behavior, including integration with custom logic.
updateupdate<TBody, TResult extends TBody = TBody>(objectName: string, id: number \| string, body: TBody, returnFields?: (string \| keyof TResult)[]) => Observable<IPrmApiResult<TResult> Asynchronously updates a single record with the provided id of the specified Impartner PRM object type objectName, updating its fields according to the provided values in body. The returned results will include the same fields as those present on body, as well as any additional fields specified by the fields array.
updateManyupdateMany<TResult = unknown>(objectName: string, body: unknown[], returnFields?: (string \| keyof TResult)[]) => Observable<IPrmPatchManyResult<TResult>> Asynchronously updates multiple records of the specified Impartner PRM object type objectName, updating their fields according to the partial record values in body. Every record in body must have an id property present. The returned results will include the same fields as those present on their records in body, as well as any additional fields specified by the fields array.
deletedelete(objectName: string, id: number \| string) => Observable<IPrmApiResult<{ id: number \| string }>> Asynchronously deletes a record with the provided id of the specified Impartner PRM object type objectName. The result will be a plain object with the ID of the deleted record.
exportexport(objectName: string, criteria: IExportOptions) => Observable<ExportResult> Asynchronously retrieves a file export of records of the specified Impartner PRM object type objectName according to the file type, headers, filter criteria, and sort order in criteria. Result is an ExportResult instance that can trigger file download in the browser by invoking the ExportResult's startDownload() method.

ImpartnerUserService

Service TypeDI TokenProvided In
ImpartnerUserServiceImpartnerUserServiceroot

A service for accessing basic information about the current user.

Methods

Name
getUsergetUser() => IProfile Retrieves the current user's profile, including (but not limited to) id, user type, name, and email address.
getUserSegmentsgetUserSegments() => Observable<IUserSegmentationValues> Asynchronously retrieves segmentation information about the current user.

IImpartnerHttpClient

Service TypeDI TokenProvided In
IImpartnerHttpClientIMPARTNER_HTTP_CLIENT_TOKENImpartnerSdkModule.forRoot(...)

A service for making HTTP calls to the Impartner PRM host. This service ensures that any additional required information (eg. HTTP headers) are present for calls to Impartner. This service should always be used when attempting to make HTTP-based API calls to the Impartner host.

Methods

Name
getget<T, U extends IApiResultBase = IApiResult<T>>(url: string, options?: IHttpClientOptions) => Promise<U> Asynchronously makes an HTTP GET call to the Impartner PRM resource path specified by url.
postpost<T, U extends IApiResultBase = IApiResult<T>>(url: string, body: unknown, options?: IHttpClientOptions) => Promise<U> Asynchronously makes an HTTP POST call to the Impartner PRM resource path specified by url, with the body value as its payload.
putput<T, U extends IApiResultBase = IApiResult<T>>(url: string, body: unknown, options?: IHttpClientOptions) => Promise<U> Asynchronously makes an HTTP PUT call to the Impartner PRM resource path specified by url, with the body value as its payload.
patchpatch<T, U extends IApiResultBase = IApiResult<T>>(url: string, body: unknown, options?: IHttpClientOptions) => Promise<U> Asynchronously makes an HTTP PATCH call to the Impartner PRM resource path specified by url, with the body value as its payload.
deletedelete<T, U extends IApiResultBase = IApiResult<T>>(url: string, body: unknown, options?: IHttpClientOptions) => Promise<U> Asynchronously makes an HTTP DELETE call to the Impartner PRM resource path specified by url.

IImpartnerRouter

Service TypeDI TokenProvided In
IImpartnerRouterIMPARTNER_ROUTER_TOKENImpartnerSdkModule.forRoot(...)

A service for accessing and modifying navigation state within the host Impartner front-end application.

Methods

Name
navigatenavigate(path: string, navigationParams?: INavigationParams, navigationOptions?: INavigationOptions) => Promise<void> Triggers navigation to the specified path within the Impartner client application.
getStategetState() => IRouterState Returns current route state within the Impartner client application, including page title, path, and present query string parameters.
getContentPageMetadatagetContentPageMetadata() Asynchronously retrieves a list of available page routes for navigation. Only applicable within Impartner Portal host applications.

IImpartnerLogger

Service TypeDI TokenProvided In
IImpartnerLoggerIMPARTNER_LOGGER_TOKENImpartnerSdkModule.forRoot(...)

A service for simple logging behavior.

Methods

All below methods accept one message argument and an open-ended number of additional objects to be logged - the only difference between them is the message severity, which is denoted by the method name itself.

Name
tracetrace(message: string, ...argument: unknown[]) => void
infoinfo(message: string, ...argument: unknown[]) => void
loglog(message: string, ...argument: unknown[]) => void
debugdebug(message: string, ...argument: unknown[]) => void
warnwarn(message: string, ...argument: unknown[]) => void
errorerror(message: string, ...argument: unknown[]) => void

Local Development

All of the above documented services will also work in local development, provided the environment object passed to ImpartnerSdkModule.forRoot(environment) includes the property value production: false. However, there are some notable differences when running locally.

  • IImpartnerHttpClient
    • HTTP calls made through IImpartnerHttpClient (including those by ImpartnerMetadataService and ImpartnerObjectService) will go to localhost with a root path matching the impartnerEndpointUrl property of the environment object. In order for these requests to adequately resolve, the Angular application's local development build must be configured to proxy calls on that path to an Impartner environment. For instructions on how to configure the proxy for local development, consult the Angular documentation.
  • IImpartnerRouter
    • The navigate method will not trigger any actual navigation, but instead will log the provided arguments to the console and trigger a browser alert notifying that navigation was triggered.
    • The getState method will log a trace message to the console and return an object with the current query string parameters and the below name and path properties:
      {
        name: 'Local Development',
        path: '/'
      }
    • The getContentPageMetadata method will log a trace message to the console and return a resolved Promise with an array of predefined, for-testing-only routes.
1.4.0

4 months ago

2.0.0

4 months ago

1.3.0

5 months ago

1.2.0

10 months ago

1.1.0

11 months ago

1.2.1

8 months ago

1.0.0

1 year ago