@govflanders/vl-widget-global-header-types 0.0.1

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.
@@ -0,0 +1,6 @@
1
+ export type AlertModifier = 'success' | 'warning' | 'error';
2
+ export interface AlertConfig {
3
+ enabled: boolean;
4
+ message: string;
5
+ modifier: AlertModifier;
6
+ }
@@ -0,0 +1,24 @@
1
+ import { I18n } from './i18n';
2
+ import { Image } from './image';
3
+ import { LinkWithTarget } from './link';
4
+ /** Only required for level < 4 */
5
+ export interface BrandingConfigUmbrella extends LinkWithTarget {
6
+ }
7
+ export interface BrandingConfigHost extends LinkWithTarget {
8
+ logo: Image | null;
9
+ }
10
+ /** Configure the branding colors, only for level < 1 */
11
+ export interface BrandingConfigColors {
12
+ primary: string;
13
+ functional: string;
14
+ }
15
+ /** Configure the branding level. */
16
+ export type BrandingConfigLevel = 1 | 2 | 3 | 4;
17
+ export interface BrandingConfig {
18
+ allowOverride?: boolean;
19
+ level?: BrandingConfigLevel;
20
+ colors?: Partial<BrandingConfigColors>;
21
+ umbrella?: Partial<BrandingConfigUmbrella>;
22
+ host?: Partial<BrandingConfigHost>;
23
+ i18n?: I18n;
24
+ }
@@ -0,0 +1,39 @@
1
+ import { Translatable } from './i18n';
2
+ import { IDPData } from './idp';
3
+ export type CapacityCode = 'BUR' | 'EA' | 'VER';
4
+ export interface ProfileConfig {
5
+ active: boolean;
6
+ loginUrl: string;
7
+ loginRedirectUrl: string;
8
+ logoutUrl: string;
9
+ switchCapacityUrl: string;
10
+ idpData: IDPData;
11
+ }
12
+ export interface Session {
13
+ application: {
14
+ sessionSupport: boolean;
15
+ };
16
+ }
17
+ export interface Application {
18
+ isMainCapacity: boolean;
19
+ mainCapacityCode: CapacityCode;
20
+ name: string;
21
+ }
22
+ export interface CitizenProfileConfig {
23
+ pluginTypeId: 'citizen_profile';
24
+ session: Session;
25
+ application: Application;
26
+ }
27
+ export interface MainLink {
28
+ title: string;
29
+ href: string;
30
+ isExternal?: boolean;
31
+ target?: '_blank' | '_self' | '_parent' | '_top';
32
+ }
33
+ export interface ApplicationLink {
34
+ title: string;
35
+ href: string;
36
+ target?: string;
37
+ icon?: 'e-desk' | 'e-desk-lock';
38
+ }
39
+ export type ApplicationMenuLink = ApplicationLink | Translatable<ApplicationLink>;
@@ -0,0 +1,101 @@
1
+ import { Translatable } from './i18n';
2
+ import { MainLink, ProfileConfig } from './citizen-profile';
3
+ import { EnrichedServicePoints, ServicePoints } from './contact';
4
+ import { Config } from './config';
5
+ import { ApplicationMenuLink } from './citizen-profile';
6
+ export type Handlers = {
7
+ /**
8
+ * Get the current configuration
9
+ * @returns A promise that resolves to the current configuration
10
+ */
11
+ getConfig: Handler<undefined, Config>;
12
+ /**
13
+ * Set the service points
14
+ * @param servicePoints The service points to set
15
+ * @returns A promise that resolves to the set service points
16
+ */
17
+ setServicePoints: Handler<Translatable<ServicePoints>, Translatable<ServicePoints>>;
18
+ /**
19
+ * Get the current service points
20
+ * @returns A promise that resolves to the current service points
21
+ */
22
+ getServicePoints: Handler<undefined, EnrichedServicePoints>;
23
+ /**
24
+ * Reset the service points to the initial values from the configuration.
25
+ *
26
+ * This method reverts the service points back to their original state
27
+ * as defined in the initial configuration, effectively overriding any
28
+ * previously set service points.
29
+ *
30
+ * @return {Promise<this>}
31
+ * A promise that resolves when the service points have been reset.
32
+ */
33
+ resetServicePoints: Handler<undefined, boolean>;
34
+ /**
35
+ * Set the profile configuration
36
+ * @param profileConfig The profile configuration to set
37
+ * @returns A promise that resolves to true if the profile configuration was set, false otherwise
38
+ */
39
+ setProfile: Handler<ProfileConfig, boolean>;
40
+ /**
41
+ * Set the main links
42
+ * @param mainLinks The main links to set
43
+ * @returns A promise that resolves to true if the main links were set, false otherwise
44
+ */
45
+ setMainLinks: Handler<MainLink[], boolean>;
46
+ /**
47
+ * Add an application menu link
48
+ * @param link The link to add
49
+ * @returns A promise that resolves to the updated application menu
50
+ */
51
+ addApplicationMenuLink: Handler<ApplicationMenuLink, ApplicationMenuLink[]>;
52
+ /**
53
+ * Add multiple application menu links
54
+ * @param links The links to add
55
+ * @returns A promise that resolves to the updated application menu
56
+ */
57
+ addApplicationMenuLinks: Handler<ApplicationMenuLink[], ApplicationMenuLink[]>;
58
+ /**
59
+ * Set the application menu links
60
+ * @param links The links to set
61
+ * @returns A promise that resolves to the updated application menu
62
+ */
63
+ setApplicationMenuLinks: Handler<ApplicationMenuLink[], ApplicationMenuLink[]>;
64
+ /**
65
+ * Mount an element
66
+ * @param element The element to mount
67
+ * @returns A promise that resolves to true if the element was mounted, false otherwise
68
+ */
69
+ mount: Handler<HTMLElement | void, boolean>;
70
+ };
71
+ type PromiseResolver<T> = (value: T | PromiseLike<T>) => void;
72
+ type PromiseRejecter = (reason?: any) => void;
73
+ export type Handler<Args, Return> = (args: Args, resolve: PromiseResolver<Return>, reject: PromiseRejecter) => void;
74
+ type ArgumentTypes = {
75
+ [HandlersKey in keyof Handlers]: Handlers[HandlersKey] extends Handler<infer Args, any> ? Args : never;
76
+ };
77
+ type ReturnTypes = {
78
+ [HandlersKey in keyof Handlers]: Handlers[HandlersKey] extends Handler<any, infer Return> ? Return : never;
79
+ };
80
+ export type GlobalHeaderClient = {
81
+ [K in keyof Handlers]: (args: ArgumentTypes[K]) => Promise<ReturnTypes[K]>;
82
+ };
83
+ export type QueueItem<Key extends keyof Handlers> = {
84
+ [K in keyof Handlers]: {
85
+ key: K;
86
+ args: ArgumentTypes[K];
87
+ resolve: PromiseResolver<ReturnTypes[K]>;
88
+ reject: PromiseRejecter;
89
+ };
90
+ }[Key];
91
+ export interface GlobalHeaderLinker {
92
+ queue: QueueItem<keyof Handlers>[];
93
+ update: () => void;
94
+ }
95
+ declare global {
96
+ interface Window {
97
+ globalHeaderClient: GlobalHeaderClient;
98
+ globalHeaderLinker: GlobalHeaderLinker;
99
+ }
100
+ }
101
+ export {};
@@ -0,0 +1,18 @@
1
+ import { I18n } from './i18n';
2
+ import { AlertConfig } from './alert';
3
+ import { BrandingConfig } from './branding';
4
+ export type PluginTypeId = 'contact' | 'citizen_profile';
5
+ export interface Config {
6
+ branding: BrandingConfig;
7
+ alert: AlertConfig;
8
+ i18n?: I18n;
9
+ extensions: {
10
+ pluginTypeId: PluginTypeId;
11
+ i18n?: I18n;
12
+ [key: string]: string | number | object | undefined;
13
+ }[];
14
+ }
15
+ export * from './alert';
16
+ export * from './branding';
17
+ export * from './contact';
18
+ export * from './citizen-profile';
@@ -0,0 +1,140 @@
1
+ export type CobrowseChannel = 'link-mobile' | 'chat';
2
+ export interface CobrowseConfig {
3
+ isEnabled: boolean;
4
+ licenseKey?: string;
5
+ channels: CobrowseChannel[];
6
+ consent: CobrowseConsentConfig;
7
+ }
8
+ export interface CobrowseConsentConfig {
9
+ title: string;
10
+ htmlContent: string;
11
+ }
12
+ export type ContactServiceEndpoints = Partial<{
13
+ channels: string;
14
+ chatCsat: string;
15
+ sendEmail: string;
16
+ chatSocket: string;
17
+ requestCallMe: string;
18
+ sendMailFormDataMessage: string;
19
+ }>;
20
+ export interface ContactConfig {
21
+ pluginTypeId: 'contact';
22
+ cobrowse: CobrowseConfig;
23
+ defaultContext: string;
24
+ serviceEndpoints: ContactServiceEndpoints;
25
+ }
26
+ type ContactOptionType = 'contactOption';
27
+ type LinkType = 'link';
28
+ interface BaseOption {
29
+ type: ContactOptionType | LinkType;
30
+ label?: string;
31
+ }
32
+ export interface ContactOptionRef extends BaseOption {
33
+ type: ContactOptionType;
34
+ contactGroupId: string;
35
+ }
36
+ interface Link extends BaseOption {
37
+ type: LinkType;
38
+ href: string;
39
+ name?: string;
40
+ }
41
+ type DisplayMode = 'grouped';
42
+ export type ServicePoint = ContactOption | ContactOptionRef | Link;
43
+ export type EnrichedServicePoint = ContactOption | Link;
44
+ export interface ServicePoints {
45
+ displayMode?: DisplayMode;
46
+ groupLabel?: string;
47
+ contextual?: ServicePoint[] | null;
48
+ defaults?: ServicePoint[] | null;
49
+ }
50
+ export interface EnrichedServicePoints extends ServicePoints {
51
+ contextual: EnrichedServicePoint[];
52
+ defaults: EnrichedServicePoint[];
53
+ }
54
+ export type ContactOptionSocialPlatform = 'facebook' | 'twitter' | 'instagram' | 'linkedin' | 'youtube' | 'x';
55
+ export interface ContactOption extends Record<string, unknown> {
56
+ label: string;
57
+ key: string;
58
+ name: string;
59
+ about?: string;
60
+ ouapi_id?: string;
61
+ configCategory?: 'CONTACTOPTIES';
62
+ createdAt?: string;
63
+ lastModifiedAt?: string;
64
+ channels?: Channel[];
65
+ social?: {
66
+ description?: string;
67
+ media?: {
68
+ icon: ContactOptionSocialPlatform;
69
+ text?: string;
70
+ description?: string;
71
+ url: string;
72
+ }[];
73
+ };
74
+ subject?: string;
75
+ requestedBy?: string;
76
+ privacy?: ContactPrivacy;
77
+ }
78
+ interface ContactPrivacy {
79
+ gdpr: string;
80
+ }
81
+ export type ChannelIcon = 'call' | 'mail' | 'chat' | 'screen' | 'location';
82
+ export type ChannelType = 'link-mobile' | 'form' | 'chat' | 'link' | 'location';
83
+ export interface Channel {
84
+ id?: string;
85
+ name: string;
86
+ icon?: ChannelIcon;
87
+ type: ChannelType;
88
+ url?: string;
89
+ information?: string;
90
+ ouapi_contactline_id?: string;
91
+ value?: null | {
92
+ name: string;
93
+ address: string;
94
+ campaign: string;
95
+ workgroup: string;
96
+ information: string;
97
+ formId: string;
98
+ fields: {
99
+ type: string;
100
+ label: string;
101
+ attrs: {
102
+ name: string;
103
+ maxlength: number;
104
+ type: string;
105
+ placeholder: string;
106
+ required: string;
107
+ };
108
+ }[];
109
+ };
110
+ availability?: {
111
+ openInformation?: string;
112
+ closedInformation?: string;
113
+ exceptionallyClosedInformation?: string;
114
+ hours?: ContactOptionTimeSlot[][];
115
+ exceptions?: ContactOptionAvailabilityException[];
116
+ remark: string;
117
+ };
118
+ opening_hours?: {
119
+ is_open: boolean;
120
+ };
121
+ }
122
+ declare enum ContactOptionTimeSlotRemark {
123
+ OPEN = "OPEN",
124
+ APPOINTMENT = "APPOINTMENT",
125
+ PHONE = "PHONE",
126
+ DIGITAL = "DIGITAL",
127
+ OTHER = "OTHER"
128
+ }
129
+ interface ContactOptionTimeSlot {
130
+ from: string;
131
+ to: string;
132
+ remark?: ContactOptionTimeSlotRemark;
133
+ customRemark?: string;
134
+ }
135
+ interface ContactOptionAvailabilityException {
136
+ date?: string;
137
+ information?: string;
138
+ hours?: ContactOptionTimeSlot[];
139
+ }
140
+ export {};
package/dist/i18n.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { PluginTypeId } from './config';
2
+ export type Language = 'nl' | 'fr' | 'de' | 'en';
3
+ type LanguageTranslationsMap = Partial<Record<Language, RecursiveRecord>>;
4
+ export interface Translations {
5
+ base: LanguageTranslationsMap;
6
+ extensions: Partial<Record<PluginTypeId, LanguageTranslationsMap>>;
7
+ }
8
+ export interface RecursiveRecord {
9
+ [key: string]: string | RecursiveRecord;
10
+ }
11
+ export interface ResolveOptions {
12
+ fallback?: string;
13
+ extension?: PluginTypeId;
14
+ }
15
+ export interface I18n {
16
+ default: Language;
17
+ translations: Partial<Record<Language, RecursiveRecord>>;
18
+ }
19
+ export type Translatable<T> = T | Record<Language, T>;
20
+ export {};
package/dist/idp.d.ts ADDED
@@ -0,0 +1,39 @@
1
+ interface BaseEntity {
2
+ code: 'BUR' | 'VER' | 'EA' | 'GID' | 'LB' | 'OV';
3
+ name: string;
4
+ identifier?: string;
5
+ }
6
+ interface GID extends BaseEntity {
7
+ code: 'GID';
8
+ /** identifier: ovoCode */
9
+ identifier: string;
10
+ }
11
+ interface VER extends BaseEntity {
12
+ code: 'VER';
13
+ vCode: string;
14
+ }
15
+ interface EA extends BaseEntity {
16
+ code: 'EA';
17
+ identifier: string;
18
+ }
19
+ interface BUR extends BaseEntity {
20
+ code: 'BUR';
21
+ name: string;
22
+ firstName: string;
23
+ }
24
+ interface User {
25
+ firstName: string;
26
+ name: string;
27
+ }
28
+ type Entity = BUR | GID | VER | EA;
29
+ interface Authorization {
30
+ user: User;
31
+ onBehalfOff?: Entity;
32
+ mandateGiver?: Entity;
33
+ loginHint: string;
34
+ }
35
+ export interface IDPData {
36
+ active: Authorization;
37
+ identities: Authorization[];
38
+ }
39
+ export {};
@@ -0,0 +1,5 @@
1
+ export interface Image {
2
+ readonly src?: string | null;
3
+ readonly srcSet?: string[] | null;
4
+ readonly alt: string;
5
+ }
@@ -0,0 +1,10 @@
1
+ export * from './alert';
2
+ export * from './branding';
3
+ export * from './citizen-profile';
4
+ export * from './client';
5
+ export * from './config';
6
+ export * from './contact';
7
+ export * from './i18n';
8
+ export * from './idp';
9
+ export * from './image';
10
+ export * from './link';
package/dist/link.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export interface Link {
2
+ readonly label: string;
3
+ readonly href: string;
4
+ }
5
+ export interface LinkWithTarget extends Link {
6
+ readonly target?: string | null;
7
+ }
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@govflanders/vl-widget-global-header-types",
3
+ "version": "0.0.1",
4
+ "description": "TypeScript definitions for GlobalHeaderClient",
5
+ "main": "",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "keywords": [
11
+ "typescript",
12
+ "types",
13
+ "global",
14
+ "header",
15
+ "client"
16
+ ],
17
+ "author": "Maarten Van Steenkiste",
18
+ "license": "MIT",
19
+ "publishConfig": {
20
+ "registry": "https://registry.npmjs.org/",
21
+ "access": "public"
22
+ },
23
+ "scripts": {
24
+ "build": "tsc -p tsconfig.json",
25
+ "publish": "npm_config_registry=https://registry.npmjs.org/ npm publish --access public"
26
+ }
27
+ }