@meltingspot/core 0.1.0
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.
- package/LICENSE +28 -0
- package/README.md +42 -0
- package/api/meltingSpotApi.d.ts +57 -0
- package/index.d.ts +51 -0
- package/index.mjs +6134 -0
- package/index.umd.js +33 -0
- package/logger.d.ts +8 -0
- package/package.json +22 -0
- package/playbookEditor/index.d.ts +9 -0
- package/services/api/analytics/analytics.api.input.d.ts +6 -0
- package/services/api/analytics/analytics.api.service.d.ts +9 -0
- package/services/api/playbook/playbook.api.input.d.ts +68 -0
- package/services/api/playbook/playbook.api.output.d.ts +44 -0
- package/services/api/playbook/playbook.api.service.d.ts +22 -0
- package/services/api/spot/spot.api.output.d.ts +8 -0
- package/services/api/spot/spot.api.service.d.ts +11 -0
- package/services/api/spotMember/spotMember.api.output.d.ts +18 -0
- package/services/api/spotMember/spotMember.api.service.d.ts +12 -0
- package/services/api/spotMemberAuth/spotMemberAuth.api.output.d.ts +3 -0
- package/services/api/spotMemberAuth/spotMemberAuth.api.service.d.ts +11 -0
- package/services/auth.service.d.ts +49 -0
- package/services/configuration.service.d.ts +20 -0
- package/services/http.service.d.ts +33 -0
- package/services/routeChangeDetector.service.d.ts +29 -0
- package/services/sso.service.d.ts +8 -0
- package/services/storage.service.d.ts +11 -0
- package/types/authTokens.d.ts +4 -0
- package/types/conversation/conversation.d.ts +16 -0
- package/types/conversation/conversationMessage.d.ts +12 -0
- package/types/conversation/conversationSseEvent.d.ts +44 -0
- package/types/conversation/conversationStreamResponse.d.ts +9 -0
- package/types/conversation/createConversationResponse.d.ts +8 -0
- package/types/conversation/getConversationMessagesResponse.d.ts +25 -0
- package/types/conversation/index.d.ts +11 -0
- package/types/conversation/listConversationsResponse.d.ts +9 -0
- package/types/conversation/meltyWidgetAction.d.ts +12 -0
- package/types/conversation/proactiveCheckResponse.d.ts +12 -0
- package/types/conversation/renderableWidgetAction.d.ts +15 -0
- package/types/conversation/triggerType.d.ts +17 -0
- package/types/index.d.ts +12 -0
- package/types/injectable.d.ts +3 -0
- package/types/integrationSchema/beacon.d.ts +112 -0
- package/types/integrationSchema/index.d.ts +3 -0
- package/types/integrationSchema/integrationSchema.d.ts +19 -0
- package/types/integrationSchema/touchPoint.d.ts +89 -0
- package/types/learningPathContentType.d.ts +6 -0
- package/types/live/index.d.ts +2 -0
- package/types/live/liveBuiltInType.d.ts +4 -0
- package/types/live/liveStatus.d.ts +5 -0
- package/types/maybe.d.ts +2 -0
- package/types/meltyIntent/index.d.ts +3 -0
- package/types/meltyIntent/intentUserState.d.ts +7 -0
- package/types/meltyIntent/lastActionState.d.ts +5 -0
- package/types/meltyIntent/meltyIntentUserStateList.d.ts +11 -0
- package/types/nullable.d.ts +1 -0
- package/types/simplifiedRichText.d.ts +39 -0
- package/types/themeMode.d.ts +1 -0
- package/types/widget/index.d.ts +3 -0
- package/types/widget/metadata/abstractWidgetContentMetadata.d.ts +6 -0
- package/types/widget/metadata/channelWidgetContentMetadata.d.ts +11 -0
- package/types/widget/metadata/collectionWidgetContentMetadata.d.ts +12 -0
- package/types/widget/metadata/courseWidgetContentMetadata.d.ts +13 -0
- package/types/widget/metadata/documentLinkWidgetContentMetadata.d.ts +12 -0
- package/types/widget/metadata/documentPageWidgetContentMetadata.d.ts +12 -0
- package/types/widget/metadata/forumWidgetContentMetadata.d.ts +11 -0
- package/types/widget/metadata/index.d.ts +23 -0
- package/types/widget/metadata/learningPathWidgetContentMetadata.d.ts +16 -0
- package/types/widget/metadata/liveWidgetContentMetadata.d.ts +15 -0
- package/types/widget/metadata/richTextWidgetContentMetadata.d.ts +7 -0
- package/types/widget/metadata/topicWidgetContentMetadata.d.ts +14 -0
- package/types/widget/playbook/index.d.ts +8 -0
- package/types/widget/playbook/playbook.d.ts +8 -0
- package/types/widget/playbook/playbookHotspot.d.ts +12 -0
- package/types/widget/playbook/playbookHotspotLocation.d.ts +4 -0
- package/types/widget/playbook/playbookIntent.d.ts +12 -0
- package/types/widget/playbook/playbookIntentStatus.d.ts +5 -0
- package/types/widget/playbook/playbookIntentWidgetMode.d.ts +4 -0
- package/types/widget/playbook/playbookMatchingRules.d.ts +23 -0
- package/types/widget/playbook/playbookPage.d.ts +10 -0
- package/types/widget/spotWidgetContentType.d.ts +13 -0
- package/utils/date/date.d.ts +7 -0
- package/utils/date/formatDate.d.ts +16 -0
- package/utils/date/formatters/formatToDate.d.ts +2 -0
- package/utils/date/formatters/formatToDateTime.d.ts +2 -0
- package/utils/date/formatters/formatToExtraShortDate.d.ts +3 -0
- package/utils/date/formatters/formatToInlineExtraShortDate.d.ts +3 -0
- package/utils/date/formatters/formatToInlineShortDate.d.ts +3 -0
- package/utils/date/formatters/formatToLongDate.d.ts +3 -0
- package/utils/date/formatters/formatToLongDateTime.d.ts +3 -0
- package/utils/date/formatters/formatToShortDate.d.ts +2 -0
- package/utils/date/formatters/formatToShortTime.d.ts +3 -0
- package/utils/date/formatters/formatToSimpleDate.d.ts +2 -0
- package/utils/date/formatters/formatToSimpleDateTime.d.ts +2 -0
- package/utils/date/formatters/formatToTime.d.ts +2 -0
- package/utils/date/types.d.ts +3 -0
- package/utils/format.d.ts +6 -0
- package/utils/index.d.ts +16 -0
- package/utils/logger.d.ts +15 -0
- package/utils/playbook/testUrlMatching.d.ts +2 -0
- package/utils/playbookEditor/bridge.d.ts +22 -0
- package/utils/playbookEditor/lifecycle.d.ts +52 -0
- package/utils/string/sanitizeUrl.d.ts +1 -0
- package/utils/string/trim.d.ts +2 -0
- package/utils/ui/createDialog.d.ts +1 -0
- package/utils/ui/createIframe.d.ts +9 -0
- package/utils/ui/getHTMLElement.d.ts +5 -0
- package/utils/ui/isTouchDevice.d.ts +6 -0
- package/utm/flattenUtmParameters.d.ts +3 -0
- package/utm/index.d.ts +3 -0
- package/utm/parseUtmParameters.d.ts +2 -0
- package/utm/utmParameters.d.ts +7 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 MeltingSpot
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
16
|
+
may be used to endorse or promote products derived from this software
|
|
17
|
+
without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Core SDK
|
|
2
|
+
|
|
3
|
+
Foundation layer of the MeltingSpot SDKs. It exposes the shared services (configuration, authentication, SSO, HTTP/API access) and types consumed by the higher-level SDKs (`@meltingspot/embed`, `@meltingspot/widget`, `@meltingspot/coach`).
|
|
4
|
+
|
|
5
|
+
> You usually don't install this package directly — it comes as a dependency of the SDK you integrate. Install it explicitly only for advanced programmatic usage.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @meltingspot/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { ConfigurationService, AuthService } from '@meltingspot/core';
|
|
17
|
+
|
|
18
|
+
// Configure the SDK once for your spot.
|
|
19
|
+
ConfigurationService.setConfiguration({ spotId: 'YOUR_SPOT_ID' });
|
|
20
|
+
|
|
21
|
+
// Authenticate the current user with a MeltingSpot SSO token.
|
|
22
|
+
const result = await AuthService.loginWithSsoToken('CURRENT_USER_SSO_TOKEN');
|
|
23
|
+
if (result.isErr()) {
|
|
24
|
+
console.error('Authentication failed', result.error);
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## What's inside
|
|
29
|
+
|
|
30
|
+
| Export | Description |
|
|
31
|
+
| ---------------------- | ------------------------------------------------------ |
|
|
32
|
+
| `ConfigurationService` | Global SDK configuration (spot id, theme, API base...) |
|
|
33
|
+
| `AuthService` | Authentication & token lifecycle |
|
|
34
|
+
| `SsoService` | SSO token exchange |
|
|
35
|
+
| `MeltingSpotApi` | Typed HTTP client for the MeltingSpot API |
|
|
36
|
+
| `Logger` | Namespaced logger with debug toggle |
|
|
37
|
+
|
|
38
|
+
See the [MeltingSpot helpdesk](https://help.meltingspot.io) for integration guides.
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Result } from 'neverthrow';
|
|
2
|
+
import { HttpGetInput, HttpPatchInput, HttpPostInput, HttpError, HttpMethods } from '../services/http.service';
|
|
3
|
+
export declare enum MeltingSpotApiHeaders {
|
|
4
|
+
Authorization = "Authorization",
|
|
5
|
+
SpotId = "x-spotid"
|
|
6
|
+
}
|
|
7
|
+
interface CommonApiCallInput {
|
|
8
|
+
method: HttpMethods;
|
|
9
|
+
endpoint: string;
|
|
10
|
+
options?: Omit<HttpGetInput, 'url'> | Omit<HttpPostInput, 'url'>;
|
|
11
|
+
requiresAuth?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface GetApiCallInput extends CommonApiCallInput {
|
|
14
|
+
method: HttpMethods.GET;
|
|
15
|
+
options?: Omit<HttpGetInput, 'url'>;
|
|
16
|
+
}
|
|
17
|
+
interface PatchApiCallInput extends CommonApiCallInput {
|
|
18
|
+
method: HttpMethods.PATCH;
|
|
19
|
+
options: Omit<HttpPatchInput, 'url'>;
|
|
20
|
+
}
|
|
21
|
+
interface PostApiCallInput extends CommonApiCallInput {
|
|
22
|
+
method: HttpMethods.POST;
|
|
23
|
+
options: Omit<HttpPostInput, 'url'>;
|
|
24
|
+
}
|
|
25
|
+
type ApiCallInput = GetApiCallInput | PatchApiCallInput | PostApiCallInput;
|
|
26
|
+
export interface AuthenticatedRequest {
|
|
27
|
+
url: string;
|
|
28
|
+
headers: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
export declare class MeltingSpotApi {
|
|
31
|
+
private static instance;
|
|
32
|
+
static getInstance(): MeltingSpotApi;
|
|
33
|
+
/**
|
|
34
|
+
* Build an authenticated request (URL + headers) for direct fetch() calls.
|
|
35
|
+
* Does NOT go through the FIFO queue — intended for SSE endpoints.
|
|
36
|
+
*/
|
|
37
|
+
static buildAuthenticatedRequest(endpoint: string): Result<AuthenticatedRequest, Error>;
|
|
38
|
+
/**
|
|
39
|
+
* Perform an authenticated streaming fetch (SSE).
|
|
40
|
+
* Does NOT go through the FIFO queue — intended for SSE endpoints
|
|
41
|
+
* where the response is a ReadableStream consumed by the caller.
|
|
42
|
+
*/
|
|
43
|
+
static stream(endpoint: string, body?: unknown, signal?: AbortSignal): Promise<Result<ReadableStream<Uint8Array>, Error>>;
|
|
44
|
+
private readonly authService;
|
|
45
|
+
private readonly httpService;
|
|
46
|
+
private readonly queue;
|
|
47
|
+
private isProcessing;
|
|
48
|
+
private isPaused;
|
|
49
|
+
get pendingCount(): number;
|
|
50
|
+
constructor();
|
|
51
|
+
private enqueue;
|
|
52
|
+
private processQueue;
|
|
53
|
+
pauseQueue(): void;
|
|
54
|
+
resumeQueue(): void;
|
|
55
|
+
call<TResponse>(input: ApiCallInput): Promise<Result<TResponse, HttpError>>;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { PlaybookApiService } from './services/api/playbook/playbook.api.service';
|
|
2
|
+
import { SpotApiService } from './services/api/spot/spot.api.service';
|
|
3
|
+
import { SpotMemberApiService } from './services/api/spotMember/spotMember.api.service';
|
|
4
|
+
import { AuthService } from './services/auth.service';
|
|
5
|
+
import { ConfigurationService } from './services/configuration.service';
|
|
6
|
+
import { SsoService } from './services/sso.service';
|
|
7
|
+
export { AuthService, AuthServiceEvents, type AuthTokensUpdatedEventDetail, } from './services/auth.service';
|
|
8
|
+
export { SsoService } from './services/sso.service';
|
|
9
|
+
export { HttpService, HttpMethods } from './services/http.service';
|
|
10
|
+
export { RouteChangeDetector } from './services/routeChangeDetector.service';
|
|
11
|
+
export type { RouteChangeDetectorOptions } from './services/routeChangeDetector.service';
|
|
12
|
+
export type { MeltingSpotConfiguration } from './services/configuration.service';
|
|
13
|
+
export { ConfigurationService } from './services/configuration.service';
|
|
14
|
+
export { MeltingSpotApi, type AuthenticatedRequest, } from './api/meltingSpotApi';
|
|
15
|
+
export * from './services/api/playbook/playbook.api.input';
|
|
16
|
+
export * from './services/api/playbook/playbook.api.output';
|
|
17
|
+
export * from './services/api/spot/spot.api.output';
|
|
18
|
+
export * from './services/api/spotMember/spotMember.api.output';
|
|
19
|
+
export { AnalyticsApiService } from './services/api/analytics/analytics.api.service';
|
|
20
|
+
export { SpotMemberApiService } from './services/api/spotMember/spotMember.api.service';
|
|
21
|
+
export type { AppendAnalyticsEventInput } from './services/api/analytics/analytics.api.input';
|
|
22
|
+
export { setLoggerDebugMode } from './logger';
|
|
23
|
+
export * from './utils';
|
|
24
|
+
export * from './utm';
|
|
25
|
+
export * from './types';
|
|
26
|
+
export declare const Configuration: ConfigurationService;
|
|
27
|
+
export declare const Auth: AuthService;
|
|
28
|
+
export declare const Sso: SsoService;
|
|
29
|
+
export declare const Api: {
|
|
30
|
+
Playbook: PlaybookApiService;
|
|
31
|
+
Spot: SpotApiService;
|
|
32
|
+
SpotMember: SpotMemberApiService;
|
|
33
|
+
};
|
|
34
|
+
declare global {
|
|
35
|
+
interface MeltingSpotNamespace {
|
|
36
|
+
Configuration: ConfigurationService;
|
|
37
|
+
Auth: AuthService;
|
|
38
|
+
Sso: SsoService;
|
|
39
|
+
Api: {
|
|
40
|
+
Playbook: PlaybookApiService;
|
|
41
|
+
Spot: SpotApiService;
|
|
42
|
+
SpotMember: SpotMemberApiService;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
interface Window {
|
|
46
|
+
MeltingSpot: MeltingSpotNamespace;
|
|
47
|
+
}
|
|
48
|
+
interface ServiceWorkerGlobalScope {
|
|
49
|
+
MeltingSpot: MeltingSpotNamespace;
|
|
50
|
+
}
|
|
51
|
+
}
|