This document details the cdp.partner‑net library. This library is part of the Zastrozzi CDP suite and provides functionality for managing partner data, subscriptions, types, assets, and subgroup assignments. It leverages NgRx for state management (with actions, effects, reducers, selectors, and facades), exposes API routes and configuration tokens, and offers a set of reusable UI components and abstracted API service implementations (both live and mock). Detailed facades give you a high‑level API to interact with partner data, while API services (using Angular’s HttpClient) target live REST endpoints.
The cdp.partner‑net library provides partner‑related features including creation, retrieval, update, deletion, and subscription management. Key features include:
PartnerNetPartnerFacade, PartnerNetPartnerTypeFacade, and PartnerNetPartnerEnduserSubscriptionFacade expose methods like create, update, list, select, and delete.CDPPartnerNetModule), configuration, and environment providers.A high-level directory structure for the library (located in /packages/cdp/partner-net) is as follows:
.eslintrc.json
jest.config.ts
ng-package.json
package.json
project.json
README.md
tsconfig.json
tsconfig.lib.json
tsconfig.lib.prod.json
tsconfig.spec.json
src/
index.ts
test-setup.ts
lib/
cdp.partner-net.module.ts
cdp.partner-net.ts
+state/
identifiers.ts
index.ts
state.ts
actions/
// e.g. partner.actions.ts, partner-type.actions.ts, partner-enduser-subscription.actions.ts, etc.
effects/
// e.g. partner.effects.ts, partner-type.effects.ts, partner-enduser-subscription.effects.ts, partner-type-assignment.effects.ts, etc.
reducers/
// Reducers for partner, partner-type, subscriptions, etc.
selectors/
// Selectors for filtering and state retrieval.
facades/
// Detailed facades like PartnerNetPartnerFacade, PartnerNetPartnerTypeFacade, PartnerNetPartnerEnduserSubscriptionFacade, etc.
api-routes/
api-routes.ts
asset.routes.ts
enduser.routes.ts
partner.routes.ts
partner-type.routes.ts
// Other route files...
components/
// UI components for partner lists, paginated tables, etc.
config/
cdp.partner-net.api-config.ts
// Other configuration files.
model/
// Models, filters, requests, responses, and enums.
routes/
// Angular routing definitions if available.
services/
// Live and mock API service implementations.
cdp.partner-net.module.ts, it imports common Angular modules along with ZWPCommonModule, ZWPLayoutModule, ZWPAuthModule, and CDPUsersModule. It declares all internal components (exported via INTERNAL_COMPONENTS) and provides all state facades (exported from the +state/facades folder).forRoot() method accepts a configuration object of type CDPPartnerNetAPIConfig and registers providers for API tokens (e.g. CDP_PARTNER_NET_API_CONFIG and CDP_PARTNER_NET_API_BASE_URL).Identifiers:
Defined in identifiers.ts, these include:
CDP_COMMON_ACTION_IDENTIFIER (often used as a prefix)PARTNER_STATE_FEATURE_KEYPARTNER_TYPE_STATE_FEATURE_KEYPARTNER_ENDUSER_SUBSCRIPTION_STATE_FEATURE_KEYState Assembly:
The state is assembled by combining reducers (exported via state.ts) to create a single state slice. This central state is then accessed through selectors.
The partner‑net library defines actions for every domain. Here is a complete breakdown:
request: CreatePartnerRequest – Object containing new partner data.createPartner({ request: { name: 'New Partner', status: 'active', ... } })
partnerId: stringgetPartner({ partnerId: 'partner123' })
parentId?: stringparentType?: 'partnerType' | 'asset' | 'enduser' | 'none'pagination?: Partial<PaginatedQueryParams<PartnerResponse>>listPartners({ parentId: 'parent123', pagination: { page: 1, pageSize: 20 } })
partnerId: stringupdate: UpdatePartnerRequestupdatePartner({ partnerId: 'partner123', update: { status: 'inactive' } })
force flag to bypass validations.partnerId: stringforce?: booleandeletePartner({ partnerId: 'partner123', force: true })
request: CreatePartnerTypeRequestcreatePartnerType({ request: { typeName: 'Preferred' } })
partnerTypeId: stringgetPartnerType({ partnerTypeId: 'type123' })
parentId?: stringparentType?: 'partner' | 'none'pagination?: Partial<PaginatedQueryParams<PartnerTypeResponse>>listPartnerTypes({ parentType: 'none', pagination: { page: 1, pageSize: 10 } })
partnerTypeId: stringupdate: UpdatePartnerTypeRequestupdatePartnerType({ partnerTypeId: 'type123', update: { typeName: 'Updated Type' } })
partnerTypeId: stringdeletePartnerType({ partnerTypeId: 'type123' })
request: CreateSubscriptionRequestcreatePartnerEnduserSubscription({ request: { partnerId: 'partner123', enduserId: 'user456', plan: 'premium' } })
subscriptionId: stringgetPartnerEnduserSubscription({ subscriptionId: 'subs789' })
listPartnerEnduserSubscriptions({ partnerId: 'partner123', pagination: { page: 1, pageSize: 15 } })
updatePartnerEnduserSubscription({ subscriptionId: 'subs789', update: { plan: 'standard' } })
Each action follows standard NgRx conventions (using createAction) and is organized under remote and local action groups.
Effects listen for remote and local actions and trigger asynchronous API calls. They typically use:
@zwp/platform.common to simplify remote API calls.switchMap, map, catchError, debounceTime, and withLatestFrom.Examples include:
partner.effects.ts, effects such as createPartner$, getPartner$, listPartners$, updatePartner$, and deletePartner$ call corresponding API services from PartnerLiveAPIService.partner-type.effects.ts, manage creation, retrieval, listing, and updating of partner types.Reducers update state slices in response to dispatched actions. Common features:
createReducer and on to modify state immutably.Selectors provide memoized access to state slices. They include:
Facades abstract NgRx interactions and provide a simple API to components. They encapsulate dispatching actions and exposing selectors via observables.
partners$: Emits an array of all partner records.paginatedFilteredPartners$: Emits partners after applying filters and pagination.partnerFilters$: Emits current filter criteria.partnerRemotePagination$: Emits remote pagination metadata.partnerRemoteState$: Emits the state of the remote API call (loading, error, success, etc.).partnerTypes$: Emits all partner types.paginatedFilteredPartnerTypes$: Emits filtered and paginated lists of partner types.partnerTypeFilters$: Exposes the current filter settings for partner types.selectedPartnerType$: Emits the currently selected partner type.partnerSubscriptions$: Emits a list of enduser subscription records.partnerSubscriptionFilters$: Emits the current subscription filters.partnerSubscriptionRemotePagination$: Emits pagination details for subscriptions.partnerSubscriptionRemoteState$: Emits the API call state for subscription actions.The library centralizes route definitions in the api-routes/ folder.
createPartner()listPartners()getPartner(partnerId: string)updatePartner(partnerId: string)deletePartner(partnerId: string)assetRoutesForPartner() and enduserRoutesForPartner()).cdp.partner-net.api-config.ts:
CDP_PARTNER_NET_API_CONFIG: The configuration object with remoteBaseUrl and localBaseUrl.CDP_PARTNER_NET_API_BASE_URL: Selected based on the global API location.Models and types are organized under the /model folder and include:
CreatePartnerRequest, UpdatePartnerRequest, CreatePartnerTypeRequest, UpdatePartnerTypeRequest, etc.PartnerResponse, PartnerTypeResponse, PartnerTypeAssignmentResponse, etc./model/enums.The cdp.partner‑net library provides abstract API service definitions and live implementations to interact with live REST endpoints. These services are used by NgRx effects and facades to perform CRUD operations for partners, partner types, and partner enduser subscriptions. In addition, services for subgroup management (such as subgroup and subgroup-enduser subscriptions) are also provided. Below is a detailed description of each live API service.
createPartner(request: Model.CreatePartnerRequest): Observable<Model.PartnerResponse>getPartner(partnerId: string): Observable<Model.PartnerResponse>partnerId.listPartners(parentId: Nullable<string>, parentType: 'partnerType' | 'none', pagination: Nullable<Partial<PaginatedQueryParams<Model.PartnerResponse>>>, filters: Nullable<Partial<Model.PartnerFilters>>): Observable<PaginatedResponse<Model.PartnerResponse>>updatePartner(partnerId: string, request: Model.UpdatePartnerRequest): Observable<Model.PartnerResponse>deletePartner(partnerId: string, force: boolean): Observable<void>force is true, additional query parameters are added to override validations.createPartnerType(request: Model.CreatePartnerTypeRequest): Observable<Model.PartnerTypeResponse>getPartnerType(partnerTypeId: string): Observable<Model.PartnerTypeResponse>listPartnerTypes(parentId: Nullable<string>, parentType: 'partner' | 'none', pagination: Nullable<Partial<PaginatedQueryParams<Model.PartnerTypeResponse>>>, filters: Nullable<Partial<Model.PartnerTypeFilters>>): Observable<PaginatedResponse<Model.PartnerTypeResponse>>updatePartnerType(partnerTypeId: string, update: Model.UpdatePartnerTypeRequest): Observable<Model.PartnerTypeResponse>deletePartnerType(partnerTypeId: string): Observable<void>addPartner(partnerId: string, partnerTypeId: string): Observable<Model.PartnerTypeAssignmentResponse>removePartner(partnerId: string, partnerTypeId: string): Observable<void>createPartnerEnduserSubscription(request: Model.CreateSubscriptionRequest): Observable<Model.SubscriptionResponse>getPartnerEnduserSubscription(subscriptionId: string): Observable<Model.SubscriptionResponse>listPartnerEnduserSubscriptions(filter: { partnerId?: string; enduserId?: string }, pagination?: Partial<PaginatedQueryParams<Model.SubscriptionResponse>>): Observable<PaginatedResponse<Model.SubscriptionResponse>>updatePartnerEnduserSubscription(subscriptionId: string, update: Model.UpdateSubscriptionRequest): Observable<Model.SubscriptionResponse>deletePartnerEnduserSubscription(subscriptionId: string, force: boolean): Observable<void>force flag bypasses certain validations when needed.In addition to partner-related services, the library may include services for managing subgroup data and subgroup enduser subscriptions. These are structured similarly to the above services.
deleteSubgroup(subgroupId: string, force: boolean): Observable<void>upsertHTTPParam) and sends an HTTP DELETE request to remove the subgroup.createSubgroupEnduserSubscription(request: Model.CreateSubgroupSubscriptionRequest): Observable<Model.SubgroupSubscriptionResponse>getSubgroupEnduserSubscription(subscriptionId: string): Observable<Model.SubgroupSubscriptionResponse>listSubgroupEnduserSubscriptions(filter: { subgroupId?: string; enduserId?: string }, pagination?: Partial<PaginatedQueryParams<Model.SubgroupSubscriptionResponse>>): Observable<PaginatedResponse<Model.SubgroupSubscriptionResponse>>updateSubgroupEnduserSubscription(subscriptionId: string, update: Model.UpdateSubgroupSubscriptionRequest): Observable<Model.SubgroupSubscriptionResponse>deleteSubgroupEnduserSubscription(subscriptionId: string, force: boolean): Observable<void>All live services implement abstract API service interfaces defined in the /services/abstract folder. Injection tokens (e.g., PARTNER_API_SERVICE, PARTNER_TYPE_API_SERVICE, etc.) allow the module’s configuration (via the forRoot() method in CDPPartnerNetModule) to determine whether to use live implementations or mock alternatives.
PartnerAPIService defines the API surface for partner operations.PartnerTypeAPIService defines the partner type operations.PartnerEnduserSubscriptionAPIService defines the subscription operations.PARTNER_API_SERVICE are provided by the module’s providers in the services configuration. Based on the configuration, the appropriate live or mock service is injected.These services work in conjunction with NgRx effects, which invoke them to drive state changes.
The library provides UI components grouped by domain:
PartnerPaginatedListComponent:asset and subgroup (see the index file in /components). These components integrate with their respective facades. nx build cdp.partner-net
nx test cdp.partner-net
import { CDPPartnerNetModule } from '@zwp/cdp.partner-net';
@NgModule({
imports: [
CDPPartnerNetModule.forRoot({
remoteBaseUrl: 'https://api.remote.example.com',
localBaseUrl: 'http://localhost:3000'
}),
// other imports...
]
})
export class AppModule {}
import { Component } from '@angular/core';
import { PartnerNetPartnerFacade } from '@zwp/cdp.partner-net';
@Component({
selector: 'app-partner-demo',
template: `
<button (click)="createPartner()">Create Partner</button>
<cdp-partnernet-partner-paginated-list></cdp-partnernet-partner-paginated-list>
`
})
export class PartnerDemoComponent {
constructor(private partnerFacade: PartnerNetPartnerFacade) {}
createPartner() {
const request = { /* populate request with partner data */ };
this.partnerFacade.createPartner(request);
}
}
The cdp.partner‑net library provides a detailed and scalable solution for partner data management within the Zastrozzi CDP ecosystem. With comprehensive NgRx state management (actions, effects, reducers, selectors, and facades), robust live API service integrations, and a suite of reusable UI components, this library enables seamless partner interactions, subscriptions, type assignments, and related workflows.
This documentation is intended as a complete guide for understanding, configuring, and extending the partner‑net functionality. Feel free to update or expand on this documentation as our project requirements evolve.