KMsgBuilder
Defined in: packages/messaging/src/k-msg.ts:1415
Fluent builder for creating KMsg instances.
Provides a chainable API for configuring providers, routing, defaults, and hooks.
Call build() to create the final KMsg instance.
Example
섹션 제목: “Example”const kmsg = KMsg.builder() .addProvider(new SolapiProvider({ apiKey: '...', apiSecret: '...' })) .addProvider(new IWINVProvider({ apiKey: '...' })) .withRouting({ defaultProviderId: 'solapi', byType: { ALIMTALK: 'iwinv' } }) .withDefaults({ sms: { autoLmsBytes: 90 } }) .withHooks({ onSuccess: (ctx, result) => console.log('Sent:', result.messageId) }) .build();Constructors
섹션 제목: “Constructors”Constructor
섹션 제목: “Constructor”new KMsgBuilder():
KMsgBuilder
Returns
섹션 제목: “Returns”KMsgBuilder
Methods
섹션 제목: “Methods”addProvider()
섹션 제목: “addProvider()”addProvider(
provider):this
Defined in: packages/messaging/src/k-msg.ts:1430
Adds a single provider to the builder.
Parameters
섹션 제목: “Parameters”provider
섹션 제목: “provider”The provider instance to add
Returns
섹션 제목: “Returns”this
this builder for method chaining
Example
섹션 제목: “Example”builder.addProvider(new SolapiProvider({ apiKey: '...', apiSecret: '...' }))addProviders()
섹션 제목: “addProviders()”addProviders(…
providers):this
Defined in: packages/messaging/src/k-msg.ts:1449
Adds multiple providers to the builder.
Parameters
섹션 제목: “Parameters”providers
섹션 제목: “providers”…Provider[]
The provider instances to add
Returns
섹션 제목: “Returns”this
this builder for method chaining
Example
섹션 제목: “Example”builder.addProviders( new SolapiProvider({ apiKey: '...', apiSecret: '...' }), new IWINVProvider({ apiKey: '...' }))build()
섹션 제목: “build()”build():
KMsg
Defined in: packages/messaging/src/k-msg.ts:1536
Builds and returns a new KMsg instance with the configured settings.
Returns
섹션 제목: “Returns”A new KMsg instance
Throws
섹션 제목: “Throws”Error if no providers have been added
Example
섹션 제목: “Example”const kmsg = KMsg.builder() .addProvider(new SolapiProvider({ apiKey: '...' })) .build();withDefaults()
섹션 제목: “withDefaults()”withDefaults(
defaults):this
Defined in: packages/messaging/src/k-msg.ts:1488
Sets the defaults configuration.
Parameters
섹션 제목: “Parameters”defaults
섹션 제목: “defaults”KMsgDefaultsConfig
Default values applied to outgoing messages
Returns
섹션 제목: “Returns”this
this builder for method chaining
Example
섹션 제목: “Example”builder.withDefaults({ sms: { autoLmsBytes: 90 }, kakao: { profileId: 'my-profile' }})withHooks()
섹션 제목: “withHooks()”withHooks(
hooks):this
Defined in: packages/messaging/src/k-msg.ts:1507
Sets the lifecycle hooks.
Parameters
섹션 제목: “Parameters”hooks
섹션 제목: “hooks”Hook functions for send lifecycle events
Returns
섹션 제목: “Returns”this
this builder for method chaining
Example
섹션 제목: “Example”builder.withHooks({ onSuccess: (ctx, result) => console.log('Sent:', result.messageId), onError: (ctx, error) => console.error('Failed:', error.message)})withPersistence()
섹션 제목: “withPersistence()”withPersistence(
persistence):this
Defined in: packages/messaging/src/k-msg.ts:1518
Sets the persistence configuration.
Parameters
섹션 제목: “Parameters”persistence
섹션 제목: “persistence”Persistence strategy and repository
{ repo: MessageRepository; strategy: PersistenceStrategy; } | undefined
Returns
섹션 제목: “Returns”this
this builder for method chaining
withRouting()
섹션 제목: “withRouting()”withRouting(
routing):this
Defined in: packages/messaging/src/k-msg.ts:1469
Sets the routing configuration.
Parameters
섹션 제목: “Parameters”routing
섹션 제목: “routing”KMsgRoutingConfig
Routing configuration for provider selection
Returns
섹션 제목: “Returns”this
this builder for method chaining
Example
섹션 제목: “Example”builder.withRouting({ defaultProviderId: 'solapi', byType: { ALIMTALK: 'iwinv' }, strategy: 'round_robin'})