workwonders-sdk 0.0.1 → 0.0.3

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/dist/index.d.ts CHANGED
@@ -4,4 +4,5 @@ declare global {
4
4
  workwondersSdk: WorkWondersSdk;
5
5
  }
6
6
  }
7
+ export { WorkWondersSdk } from "./workwonders-sdk";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,cAAc,EAAE,cAAc,CAAC;KAChC;CACF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,cAAc,EAAE,cAAc,CAAC;KAChC;CACF;AA0ED,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -46,4 +46,5 @@ document.addEventListener("click", async (event) => {
46
46
  window.workwondersSdk = new WorkWondersSdk();
47
47
  console.log("Work Wonders SDK loaded");
48
48
  })();
49
+ export { WorkWondersSdk } from "./workwonders-sdk";
49
50
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQnD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;IAC7C,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,yBAAyB,EAAE,CAAC;QACpD,MAAM,CAAC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,uBAAuB,EAAE,CAAC;QAChD,OAAO;IACT,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,CAAC,GAAG,EAAE;IACJ,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAClD,UAAU,CAAC,GAAG,GAAG,YAAY,CAAC;IAE9B,UAAU,CAAC,IAAI,GAAG,uCAAuC,CAAC;IAE1D,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAEtC,MAAM,CAAC,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;IAE7C,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AACzC,CAAC,CAAC,EAAE,CAAC;AAEL,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,14 +1,12 @@
1
1
  {
2
2
  "name": "workwonders-sdk",
3
3
  "author": "Work Wonders",
4
- "version": "0.0.1",
4
+ "version": "0.0.3",
5
5
  "description": "",
6
6
  "main": "dist/index.js",
7
- "scripts": {
8
- "dev": "vite",
9
- "build": "tsc && vite build",
10
- "preview": "vite preview"
11
- },
7
+ "files": [
8
+ "dist"
9
+ ],
12
10
  "devDependencies": {
13
11
  "@types/node": "^22.13.0",
14
12
  "typescript": "~5.6.2",
@@ -16,5 +14,10 @@
16
14
  },
17
15
  "dependencies": {
18
16
  "ky": "^1.11.0"
17
+ },
18
+ "scripts": {
19
+ "dev": "vite",
20
+ "build": "tsc && vite build",
21
+ "preview": "vite preview"
19
22
  }
20
- }
23
+ }
package/.dockerignore DELETED
@@ -1 +0,0 @@
1
- dist
package/.env.example DELETED
@@ -1,2 +0,0 @@
1
- VITE_WORKWONDERS_URL=
2
- VITE_WORKWONDERS_API_URL=
package/Dockerfile DELETED
@@ -1,17 +0,0 @@
1
- FROM node:22-alpine AS build
2
-
3
- RUN corepack enable
4
-
5
- WORKDIR /app
6
-
7
- COPY package.json pnpm-lock.yaml ./
8
-
9
- RUN pnpm install --frozen-lockfile --ignore-scripts
10
-
11
- COPY . .
12
-
13
- RUN pnpm build
14
-
15
- FROM nginx:alpine
16
-
17
- COPY --from=build /app/dist-html /usr/share/nginx/html
@@ -1,15 +0,0 @@
1
- services:
2
- app:
3
- build:
4
- context: .
5
- dockerfile: Dockerfile
6
- ports:
7
- - 3012:80
8
- develop:
9
- watch:
10
- - action: rebuild
11
- path: ./src
12
- - action: rebuild
13
- path: ./public
14
- - action: rebuild
15
- path: package.json
package/index.html DELETED
@@ -1,51 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/ww.png" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Work Wonders SDK Example</title>
8
- </head>
9
- <body>
10
- <input type="text" placeholder="Organization slug" id="slug" name="slug" />
11
- <input type="text" placeholder="Locale" id="locale" name="locale" />
12
- <button type="button" onclick="initSdk()">Init SDK</button>
13
-
14
- <div id="buttons-container"></div>
15
-
16
- <button type="button" onclick="clearLocalStorage()">
17
- Clear local storage
18
- </button>
19
- <script type="module" src="/src/index.ts"></script>
20
- <script>
21
- function initSdk() {
22
- const $buttonsContainer = document.getElementById("buttons-container");
23
-
24
- $buttonsContainer.innerHTML = ``;
25
-
26
- window.workwondersSdk
27
- .init({
28
- organization: document.getElementById("slug").value,
29
- token: "",
30
- locale: document.getElementById("locale").value,
31
- })
32
- .then(() => {
33
- window.workwondersSdk.initFeedbackWidget();
34
- window.workwondersSdk.initChangelogWidget();
35
- window.workwondersSdk.initChangelogWidgetMini();
36
-
37
- $buttonsContainer.innerHTML = `
38
- <button type="button" data-open-workwonders-feedback>Open feedback</button>
39
- <button type="button" data-open-workwonders-changelog>Open changelog</button>
40
- <button type="button" data-open-workwonders-changelog-mini>Open mini</button>
41
- `;
42
- });
43
- }
44
-
45
- function clearLocalStorage() {
46
- localStorage.clear();
47
- }
48
- </script>
49
- </body>
50
- </html>
51
-
package/public/_headers DELETED
@@ -1,4 +0,0 @@
1
- /*
2
- Access-Control-Allow-Origin: *
3
- Access-Control-Allow-Methods: GET, OPTIONS
4
- Access-Control-Allow-Headers: Content-Type
package/public/style.css DELETED
@@ -1,78 +0,0 @@
1
- .workwonders-widget-container {
2
- position: fixed;
3
- top: 0;
4
- left: 0;
5
- z-index: 9999;
6
- /* add blur to background */
7
- backdrop-filter: blur(2px);
8
- width: 100%;
9
- height: 100%;
10
- transition: opacity 0.3s ease-in-out;
11
- opacity: 1;
12
- display: flex;
13
- justify-content: center;
14
- align-items: center;
15
- }
16
-
17
- .workwonders-widget-container--hidden {
18
- opacity: 0;
19
- display: none;
20
- }
21
-
22
- .workwonders-widget-iframe {
23
- width: 400px;
24
- height: 500px;
25
- border: none;
26
- border-radius: 16px;
27
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
28
- }
29
-
30
- .workwonders-changelog-iframe {
31
- width: 642px;
32
- height: 672px;
33
- }
34
-
35
- .workwonders-feedback-iframe {
36
- width: 500px;
37
- height: 470px;
38
- }
39
-
40
- .workwonders-changelog-mini-container {
41
- backdrop-filter: none;
42
- right: 0;
43
- bottom: 0;
44
- width: inherit;
45
- height: inherit;
46
- top: inherit;
47
- left: inherit;
48
- justify-content: end;
49
- align-items: end;
50
- }
51
-
52
- .workwonders-feedback-button {
53
- position: absolute;
54
- right: 0;
55
- top: 75%;
56
- transform: translateY(-50%) translateX(40%) rotate(90deg);
57
- transform-origin: center;
58
- z-index: 9999;
59
- cursor: pointer;
60
- background-color: #1a1a1a;
61
- color: #fff;
62
- font-size: 16px;
63
- padding: 16px 16px 8px 16px;
64
- border-radius: 8px;
65
- display: flex;
66
- justify-content: center;
67
- align-items: center;
68
- font-weight: bold;
69
- border: none;
70
- outline: none;
71
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
72
- transition: all 0.3s ease-in-out;
73
- &:hover {
74
- background-color: #333;
75
- transform: translateY(-50%) translateX(38%) rotate(90deg) scale(1.1);
76
- }
77
- }
78
-
package/public/ww.png DELETED
Binary file
package/src/index.ts DELETED
@@ -1,80 +0,0 @@
1
- import { WorkWondersSdk } from "./workwonders-sdk";
2
-
3
- declare global {
4
- interface Window {
5
- workwondersSdk: WorkWondersSdk;
6
- }
7
- }
8
-
9
- window.addEventListener("message", (message) => {
10
- if (message.data.type === "changelog_widget_closed") {
11
- window.workwondersSdk.closeChangelogWidget();
12
- }
13
-
14
- if (message.data.type === "changelog_mini_widget_closed") {
15
- window.workwondersSdk.closeChangelogMiniWidget();
16
- }
17
-
18
- if (message.data.type === "changelog_mini_widget_item_clicked") {
19
- window.workwondersSdk.openChangelogWidget(message.data.id);
20
- window.workwondersSdk.closeChangelogMiniWidget();
21
- }
22
-
23
- if (message.data.type === "feedback_widget_closed") {
24
- window.workwondersSdk.closeFeedbackWidget();
25
- }
26
- });
27
-
28
- document.addEventListener("click", async (event) => {
29
- const $triggerFeedbackTarget = (event.target as HTMLElement).closest(
30
- "[data-open-workwonders-feedback]"
31
- );
32
-
33
- const $triggerChangelogTarget = (event.target as HTMLElement).closest(
34
- "[data-open-workwonders-changelog]"
35
- );
36
-
37
- const $triggerChangelogMiniTarget = (event.target as HTMLElement).closest(
38
- "[data-open-workwonders-changelog-mini]"
39
- );
40
-
41
- const $changelogMiniContainerTarget = (event.target as HTMLElement).closest(
42
- "#workwonders-changelog-mini-container"
43
- );
44
-
45
- if (!$changelogMiniContainerTarget) {
46
- window.workwondersSdk.closeChangelogMiniWidget();
47
- }
48
-
49
- if ($triggerFeedbackTarget) {
50
- console.log("Opening feedback");
51
- window.workwondersSdk.openFeedbackWidget();
52
- return;
53
- }
54
-
55
- if ($triggerChangelogTarget) {
56
- console.log("Opening changelog");
57
- window.workwondersSdk.openChangelogWidget();
58
- return;
59
- }
60
-
61
- if ($triggerChangelogMiniTarget) {
62
- console.log("Opening changelog mini");
63
- window.workwondersSdk.openChangelogMiniWidget();
64
- return;
65
- }
66
- });
67
-
68
- (() => {
69
- const $styleLink = document.createElement("link");
70
- $styleLink.rel = "stylesheet";
71
-
72
- $styleLink.href = "https://sdk.workwonders.app/style.css";
73
-
74
- document.head.appendChild($styleLink);
75
-
76
- window.workwondersSdk = new WorkWondersSdk();
77
-
78
- console.log("Work Wonders SDK loaded");
79
- })();
80
-
@@ -1,16 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.2 🍺
3
- * Do not edit manually.
4
- * Work Wonders API
5
- * OpenAPI spec version: 1.0
6
- */
7
- import type { ChangelogContextConditionsDtoAND } from './changelogContextConditionsDtoAND';
8
- import type { ChangelogContextConditionsDtoORItem } from './changelogContextConditionsDtoORItem';
9
- import type { ChangelogContextConditionsDtoNOT } from './changelogContextConditionsDtoNOT';
10
-
11
- export interface ChangelogContextConditionsDto {
12
- AND?: ChangelogContextConditionsDtoAND;
13
- OR?: ChangelogContextConditionsDtoORItem[];
14
- NOT?: ChangelogContextConditionsDtoNOT;
15
- urlPathContains?: string;
16
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.2 🍺
3
- * Do not edit manually.
4
- * Work Wonders API
5
- * OpenAPI spec version: 1.0
6
- */
7
-
8
- export type ChangelogContextConditionsDtoAND = { [key: string]: unknown };
@@ -1,8 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.2 🍺
3
- * Do not edit manually.
4
- * Work Wonders API
5
- * OpenAPI spec version: 1.0
6
- */
7
-
8
- export type ChangelogContextConditionsDtoNOT = { [key: string]: unknown };
@@ -1,8 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.2 🍺
3
- * Do not edit manually.
4
- * Work Wonders API
5
- * OpenAPI spec version: 1.0
6
- */
7
-
8
- export type ChangelogContextConditionsDtoORItem = { [key: string]: unknown };
@@ -1,24 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.2 🍺
3
- * Do not edit manually.
4
- * Work Wonders API
5
- * OpenAPI spec version: 1.0
6
- */
7
- import type { ChangelogSummaryDtoShowMode } from "./changelogSummaryDtoShowMode";
8
- import type { ChangelogContextConditionsDto } from "./changelogContextConditionsDto";
9
-
10
- export interface ChangelogSummaryDto {
11
- showMode: ChangelogSummaryDtoShowMode;
12
- /** The ID of the changelog */
13
- id: number;
14
- /** The date and time the changelog was created */
15
- createdAt: string;
16
- /** The date and time the changelog was updated */
17
- updatedAt: string;
18
- /** The changelog translations */
19
- availableLanguages: string[];
20
- /** @nullable */
21
- publishedAt: string | null;
22
- contextConditions: ChangelogContextConditionsDto;
23
- }
24
-
@@ -1,15 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.2 🍺
3
- * Do not edit manually.
4
- * Work Wonders API
5
- * OpenAPI spec version: 1.0
6
- */
7
-
8
- export type ChangelogSummaryDtoShowMode =
9
- (typeof ChangelogSummaryDtoShowMode)[keyof typeof ChangelogSummaryDtoShowMode];
10
-
11
- // eslint-disable-next-line @typescript-eslint/no-redeclare
12
- export const ChangelogSummaryDtoShowMode = {
13
- Regular: 'Regular',
14
- ContextBased: 'ContextBased',
15
- } as const;
@@ -1,12 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.2 🍺
3
- * Do not edit manually.
4
- * Work Wonders API
5
- * OpenAPI spec version: 1.0
6
- */
7
-
8
- export interface OrganizationChangelogConfigDto {
9
- disableCollaboration: boolean;
10
- showLatestChangelogOnFirstVisit: boolean;
11
- }
12
-
@@ -1,56 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.2 🍺
3
- * Do not edit manually.
4
- * Work Wonders API
5
- * OpenAPI spec version: 1.0
6
- */
7
- import type { OrganizationDtoAccessLevel } from "./organizationDtoAccessLevel";
8
- import type { OrganizationDtoRole } from "./organizationDtoRole";
9
- import type { OrganizationDtoTheme } from "./organizationDtoTheme";
10
- import type { OrganizationDtoEnabledModulesItem } from "./organizationDtoEnabledModulesItem";
11
- import type { OrganizationChangelogConfigDto } from "./organizationChangelogConfigDto";
12
- import type { OrganizationFeedbackPostConfigDto } from "./organizationFeedbackPostConfigDto";
13
- import type { OrganizationFeaturesDto } from "./organizationFeaturesDto";
14
-
15
- export interface OrganizationDto {
16
- /** Whether organization is public or private */
17
- accessLevel: OrganizationDtoAccessLevel;
18
- /** @nullable */
19
- role: OrganizationDtoRole;
20
- /** The theme of the organization */
21
- theme: OrganizationDtoTheme;
22
- /** Array of enabled module types */
23
- enabledModules: OrganizationDtoEnabledModulesItem[];
24
- /** The organization id */
25
- id: number;
26
- /** The organization name */
27
- name: string;
28
- /**
29
- * The organization website url
30
- * @nullable
31
- */
32
- websiteUrl: string | null;
33
- /**
34
- * Company SSO URL
35
- * @nullable
36
- */
37
- ssoUrl: string | null;
38
- /** The organization slug */
39
- slug: string;
40
- /** The languages of the organization */
41
- languages: string[];
42
- /** The default language of the organization */
43
- defaultLanguage: string;
44
- /**
45
- * The logo URL of the organization
46
- * @nullable
47
- */
48
- logoUrl: string | null;
49
- primaryColor: string;
50
- backgroundColor: string;
51
- changelogConfig: OrganizationChangelogConfigDto;
52
- feedbackPostConfig: OrganizationFeedbackPostConfigDto;
53
- features: OrganizationFeaturesDto;
54
- removeWorkWondersBranding: boolean;
55
- }
56
-
@@ -1,18 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.2 🍺
3
- * Do not edit manually.
4
- * Work Wonders API
5
- * OpenAPI spec version: 1.0
6
- */
7
-
8
- /**
9
- * Whether organization is public or private
10
- */
11
- export type OrganizationDtoAccessLevel =
12
- (typeof OrganizationDtoAccessLevel)[keyof typeof OrganizationDtoAccessLevel];
13
-
14
- // eslint-disable-next-line @typescript-eslint/no-redeclare
15
- export const OrganizationDtoAccessLevel = {
16
- Public: 'Public',
17
- Private: 'Private',
18
- } as const;
@@ -1,17 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.2 🍺
3
- * Do not edit manually.
4
- * Work Wonders API
5
- * OpenAPI spec version: 1.0
6
- */
7
-
8
- export type OrganizationDtoEnabledModulesItem =
9
- (typeof OrganizationDtoEnabledModulesItem)[keyof typeof OrganizationDtoEnabledModulesItem];
10
-
11
- // eslint-disable-next-line @typescript-eslint/no-redeclare
12
- export const OrganizationDtoEnabledModulesItem = {
13
- FEEDBACK: 'FEEDBACK',
14
- HELP_CENTER: 'HELP_CENTER',
15
- SUPPORT: 'SUPPORT',
16
- CHANGELOG: 'CHANGELOG',
17
- } as const;
@@ -1,21 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.2 🍺
3
- * Do not edit manually.
4
- * Work Wonders API
5
- * OpenAPI spec version: 1.0
6
- */
7
-
8
- /**
9
- * @nullable
10
- */
11
- export type OrganizationDtoRole =
12
- | (typeof OrganizationDtoRole)[keyof typeof OrganizationDtoRole]
13
- | null;
14
-
15
- // eslint-disable-next-line @typescript-eslint/no-redeclare
16
- export const OrganizationDtoRole = {
17
- Admin: "Admin",
18
- Manager: "Manager",
19
- User: "User",
20
- } as const;
21
-
@@ -1,18 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.2 🍺
3
- * Do not edit manually.
4
- * Work Wonders API
5
- * OpenAPI spec version: 1.0
6
- */
7
-
8
- /**
9
- * The theme of the organization
10
- */
11
- export type OrganizationDtoTheme =
12
- (typeof OrganizationDtoTheme)[keyof typeof OrganizationDtoTheme];
13
-
14
- // eslint-disable-next-line @typescript-eslint/no-redeclare
15
- export const OrganizationDtoTheme = {
16
- Light: 'Light',
17
- Dark: 'Dark',
18
- } as const;
@@ -1,18 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.2 🍺
3
- * Do not edit manually.
4
- * Work Wonders API
5
- * OpenAPI spec version: 1.0
6
- */
7
-
8
- export interface OrganizationFeaturesDto {
9
- maxSeats: number;
10
- roleBeasedPermissions: boolean;
11
- aiAssistant: boolean;
12
- helpCenterCustomDomain: boolean;
13
- changelogCustomDomain: boolean;
14
- removeWorkWondersBranding: boolean;
15
- widgets: boolean;
16
- customChangelogCategories: boolean;
17
- customFeedbackPostCategories: boolean;
18
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.2 🍺
3
- * Do not edit manually.
4
- * Work Wonders API
5
- * OpenAPI spec version: 1.0
6
- */
7
- import type { OrganizationFeedbackPostConfigDtoCopywriting } from './organizationFeedbackPostConfigDtoCopywriting';
8
-
9
- export interface OrganizationFeedbackPostConfigDto {
10
- copywriting: OrganizationFeedbackPostConfigDtoCopywriting;
11
- allowDownvoting: boolean;
12
- hideVoteCountUntilVote: boolean;
13
- allowAnonymousVoting: boolean;
14
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.2 🍺
3
- * Do not edit manually.
4
- * Work Wonders API
5
- * OpenAPI spec version: 1.0
6
- */
7
- import type { OrganizationFeedbackPostCopywritingDto } from './organizationFeedbackPostCopywritingDto';
8
-
9
- export type OrganizationFeedbackPostConfigDtoCopywriting = {
10
- [key: string]: OrganizationFeedbackPostCopywritingDto;
11
- };
@@ -1,13 +0,0 @@
1
- /**
2
- * Generated by orval v7.11.2 🍺
3
- * Do not edit manually.
4
- * Work Wonders API
5
- * OpenAPI spec version: 1.0
6
- */
7
-
8
- export interface OrganizationFeedbackPostCopywritingDto {
9
- title: string;
10
- buttonText: string;
11
- message: string;
12
- widgetButtonText: string;
13
- }
package/src/vite-env.d.ts DELETED
@@ -1,11 +0,0 @@
1
- /// <reference types="vite/client" />
2
-
3
- interface ImportMetaEnv {
4
- readonly VITE_WORKWONDERS_URL: string;
5
- readonly VITE_WORKWONDERS_API_URL: string;
6
- }
7
-
8
- interface ImportMeta {
9
- readonly env: ImportMetaEnv;
10
- }
11
-
@@ -1,417 +0,0 @@
1
- import ky from "ky";
2
- import { type OrganizationDto } from "./types/organizationDto";
3
- import { ChangelogSummaryDto } from "./types/changelogSummaryDto";
4
-
5
- interface InitArgs {
6
- organization: string;
7
- token?: string;
8
- locale?: string;
9
- }
10
-
11
- export class WorkWondersSdk {
12
- private ky = ky.create({
13
- prefixUrl: import.meta.env.VITE_WORKWONDERS_API_URL,
14
- });
15
-
16
- private $feedbackContainer: HTMLDivElement | null = null;
17
- private $changelogContainer: HTMLDivElement | null = null;
18
- private $changelogIframe: HTMLIFrameElement | null = null;
19
- private $changelogMiniContainer: HTMLDivElement | null = null;
20
- private $feedbackButton: HTMLButtonElement | null = null;
21
-
22
- private widgetBaseUrl = "";
23
- private args: InitArgs | null = null;
24
- private organizationData: OrganizationDto | null = null;
25
-
26
- private contextBasedChangelogs: ChangelogSummaryDto[] = [];
27
-
28
- init = async (args: InitArgs) => {
29
- this.args = args;
30
-
31
- console.log(this.contextBasedChangelogs);
32
-
33
- if (this.$changelogContainer) {
34
- this.$changelogContainer.remove();
35
- this.$changelogContainer = null;
36
- }
37
-
38
- if (this.$feedbackContainer) {
39
- this.$feedbackContainer.remove();
40
- this.$feedbackContainer = null;
41
- }
42
-
43
- if (this.$changelogMiniContainer) {
44
- this.$changelogMiniContainer.remove();
45
- this.$changelogMiniContainer = null;
46
- }
47
-
48
- if (this.$feedbackButton) {
49
- this.$feedbackButton.remove();
50
- this.$feedbackButton = null;
51
- }
52
-
53
- if (!args.organization) {
54
- console.error("Cannot init Work Wonders SDK. Organization is required.");
55
- return;
56
- }
57
-
58
- const organizationData = await this.ky
59
- .get<OrganizationDto>(`organizations/${args.organization}`)
60
- .then((res) => res.json());
61
-
62
- if (organizationData.accessLevel === "Private" && !args.token) {
63
- console.error(
64
- "Cannot init Work Wonders SDK. This organization is private, a token is required."
65
- );
66
- return;
67
- }
68
-
69
- if (!organizationData.features.widgets) {
70
- console.error(
71
- "Cannot init Work Wonders SDK. This organization does not have widgets feature enabled."
72
- );
73
- return;
74
- }
75
-
76
- this.organizationData = organizationData;
77
-
78
- const language =
79
- organizationData.languages.find((lang) => lang === args.locale) ??
80
- organizationData.defaultLanguage;
81
-
82
- args.locale = language;
83
-
84
- const workwondersUrl = new URL(import.meta.env.VITE_WORKWONDERS_URL);
85
-
86
- this.widgetBaseUrl = `https://${args.organization}.${workwondersUrl.host}/widget/`;
87
-
88
- console.log("Work Wonders SDK initialized");
89
- };
90
-
91
- initFeedbackWidget = () => {
92
- if (this.$feedbackContainer) {
93
- return;
94
- }
95
-
96
- const args = this.args;
97
- const organizationData = this.organizationData;
98
-
99
- if (!args) {
100
- return;
101
- }
102
-
103
- if (!organizationData) {
104
- return;
105
- }
106
-
107
- if (!organizationData.enabledModules.includes("FEEDBACK")) {
108
- console.warn("Feedback module is not enabled for this organization.");
109
- return;
110
- }
111
-
112
- const $feedbackContainer = document.createElement("div");
113
- this.$feedbackContainer = $feedbackContainer;
114
-
115
- $feedbackContainer.id = "workwonders-feedback-container";
116
- $feedbackContainer.classList.add("workwonders-widget-container");
117
- $feedbackContainer.classList.add("workwonders-widget-container--hidden");
118
-
119
- const $feedbackIframe = document.createElement("iframe");
120
- $feedbackIframe.id = "workwonders-feedback-iframe";
121
- $feedbackIframe.classList.add("workwonders-widget-iframe");
122
- $feedbackIframe.classList.add("workwonders-feedback-iframe");
123
-
124
- const widgetUrl = new URL("feedback", `${this.widgetBaseUrl}`);
125
- widgetUrl.searchParams.append("jwt", args.token || "");
126
- widgetUrl.searchParams.append("lang", args.locale || "");
127
- $feedbackIframe.src = widgetUrl.toString();
128
-
129
- $feedbackContainer.onclick = () => {
130
- this.closeFeedbackWidget();
131
- };
132
-
133
- $feedbackContainer.appendChild($feedbackIframe);
134
-
135
- document.body.appendChild($feedbackContainer);
136
-
137
- this.initFeedbackButton();
138
- };
139
-
140
- private initFeedbackButton() {
141
- if (this.$feedbackButton) {
142
- return;
143
- }
144
-
145
- const args = this.args;
146
- const organizationData = this.organizationData;
147
-
148
- if (!args?.locale || !organizationData) {
149
- return;
150
- }
151
-
152
- const $feedbackButton = document.createElement("button");
153
- this.$feedbackButton = $feedbackButton;
154
-
155
- const buttonText =
156
- organizationData.feedbackPostConfig.copywriting[args.locale]
157
- ?.widgetButtonText ??
158
- organizationData.feedbackPostConfig.copywriting[
159
- organizationData.defaultLanguage
160
- ].widgetButtonText ??
161
- "Feedback";
162
-
163
- $feedbackButton.id = "workwonders-feedback-button";
164
- $feedbackButton.textContent = buttonText;
165
- $feedbackButton.classList.add("workwonders-feedback-button");
166
- $feedbackButton.style.backgroundColor = organizationData.primaryColor;
167
-
168
- $feedbackButton.onclick = () => {
169
- this.openFeedbackWidget();
170
- };
171
-
172
- document.body.appendChild($feedbackButton);
173
- }
174
-
175
- initChangelogWidget = async () => {
176
- if (this.$changelogContainer) {
177
- return;
178
- }
179
-
180
- const args = this.args;
181
- const organizationData = this.organizationData;
182
-
183
- if (!args?.locale || !organizationData) {
184
- return;
185
- }
186
-
187
- if (!organizationData.enabledModules.includes("CHANGELOG")) {
188
- console.warn("Changelog module is not enabled for this organization.");
189
- return;
190
- }
191
-
192
- const $changelogContainer = document.createElement("div");
193
- this.$changelogContainer = $changelogContainer;
194
-
195
- const existingsChangelogs = await this.ky
196
- .get<ChangelogSummaryDto[]>(
197
- `organizations/${args.organization}/changelogs/summary?language=${args.locale}`
198
- )
199
- .then((res) => res.json())
200
- .then((changelogs) =>
201
- changelogs.sort(
202
- (a: ChangelogSummaryDto, b: ChangelogSummaryDto) =>
203
- new Date(b.publishedAt ?? 0).getTime() -
204
- new Date(a.publishedAt ?? 0).getTime()
205
- )
206
- );
207
-
208
- const regularChangelogs = existingsChangelogs.filter(
209
- (changelog: ChangelogSummaryDto) => changelog.showMode === "Regular"
210
- );
211
-
212
- this.contextBasedChangelogs = existingsChangelogs.filter(
213
- (changelog: ChangelogSummaryDto) => changelog.showMode === "ContextBased"
214
- );
215
-
216
- $changelogContainer.id = "workwonders-changelog-container";
217
- $changelogContainer.classList.add(
218
- "workwonders-widget-container",
219
- "workwonders-widget-container--hidden"
220
- );
221
-
222
- const $changelogIframe = document.createElement("iframe");
223
- $changelogIframe.id = "workwonders-changelog-iframe";
224
- $changelogIframe.classList.add(
225
- "workwonders-widget-iframe",
226
- "workwonders-changelog-iframe"
227
- );
228
-
229
- const seenChangelogs = localStorage.getItem(
230
- `workwonders-seen-changelogs-${args.organization}`
231
- );
232
- const seenChangelogsArray = seenChangelogs
233
- ? JSON.parse(seenChangelogs)
234
- : [];
235
-
236
- const unseenChangelogs = regularChangelogs.filter(
237
- (changelog: { id: number }) => !seenChangelogsArray.includes(changelog.id)
238
- );
239
-
240
- const shouldShowChangelogOnStart =
241
- unseenChangelogs.length > 0 &&
242
- (seenChangelogsArray.length > 0 ||
243
- organizationData.changelogConfig.showLatestChangelogOnFirstVisit);
244
-
245
- if (shouldShowChangelogOnStart) {
246
- const changelogIdsToShow =
247
- seenChangelogsArray.length === 0
248
- ? [unseenChangelogs[0].id]
249
- : unseenChangelogs.map((c: { id: number }) => c.id);
250
-
251
- this.showChangelogs(changelogIdsToShow, args.locale);
252
- }
253
-
254
- $changelogContainer.onclick = () => {
255
- this.closeChangelogWidget();
256
- };
257
-
258
- document.body.appendChild($changelogContainer);
259
- };
260
-
261
- showChangelogs = (changelogIdsToShow: number[], language: string) => {
262
- const widgetUrl = new URL("changelog", `${this.widgetBaseUrl}`);
263
- widgetUrl.searchParams.append("jwt", this.args?.token || "");
264
- widgetUrl.searchParams.append("lang", language);
265
- widgetUrl.searchParams.append("changelogIds", changelogIdsToShow.join(","));
266
-
267
- const $changelogIframe = this.$changelogIframe;
268
- const $changelogContainer = this.$changelogContainer;
269
-
270
- if (!$changelogIframe || !$changelogContainer) {
271
- return;
272
- }
273
-
274
- $changelogIframe.src = widgetUrl.toString();
275
-
276
- $changelogContainer.appendChild($changelogIframe);
277
-
278
- $changelogIframe.onload = () => {
279
- const currentSeenChangelogs = localStorage.getItem(
280
- `workwonders-seen-changelogs-${this.args?.organization}`
281
- );
282
- const currentSeenChangelogsArray = currentSeenChangelogs
283
- ? JSON.parse(currentSeenChangelogs)
284
- : [];
285
-
286
- const newSeenChangelogs = [
287
- ...currentSeenChangelogsArray,
288
- ...changelogIdsToShow,
289
- ];
290
-
291
- localStorage.setItem(
292
- `workwonders-seen-changelogs-${this.args?.organization}`,
293
- JSON.stringify(newSeenChangelogs)
294
- );
295
-
296
- $changelogContainer.classList.remove(
297
- "workwonders-widget-container--hidden"
298
- );
299
- };
300
- };
301
-
302
- initChangelogWidgetMini = () => {
303
- if (this.$changelogMiniContainer) {
304
- return;
305
- }
306
-
307
- const args = this.args;
308
- const organizationData = this.organizationData;
309
-
310
- if (!args) {
311
- return;
312
- }
313
-
314
- if (!organizationData) {
315
- return;
316
- }
317
-
318
- if (!organizationData.enabledModules.includes("CHANGELOG")) {
319
- console.warn("Changelog module is not enabled for this organization.");
320
- return;
321
- }
322
-
323
- const $changelogMiniContainer = document.createElement("div");
324
- this.$changelogMiniContainer = $changelogMiniContainer;
325
-
326
- $changelogMiniContainer.id = "workwonders-changelog-mini-container";
327
- $changelogMiniContainer.classList.add("workwonders-widget-container");
328
- $changelogMiniContainer.classList.add(
329
- "workwonders-changelog-mini-container"
330
- );
331
- $changelogMiniContainer.classList.add(
332
- "workwonders-widget-container--hidden"
333
- );
334
-
335
- const $changelogMiniIframe = document.createElement("iframe");
336
- $changelogMiniIframe.id = "workwonders-changelog-mini-iframe";
337
- $changelogMiniIframe.classList.add("workwonders-widget-iframe");
338
- $changelogMiniIframe.classList.add("workwonders-changelog-mini-iframe");
339
-
340
- const widgetUrl = new URL("changelog/mini", `${this.widgetBaseUrl}`);
341
- widgetUrl.searchParams.append("jwt", args.token || "");
342
- widgetUrl.searchParams.append("lang", args.locale || "");
343
-
344
- $changelogMiniIframe.src = widgetUrl.toString();
345
-
346
- $changelogMiniContainer.appendChild($changelogMiniIframe);
347
-
348
- $changelogMiniContainer.onclick = () => {
349
- this.closeChangelogMiniWidget();
350
- };
351
-
352
- document.body.appendChild($changelogMiniContainer);
353
- };
354
-
355
- openFeedbackWidget = () => {
356
- if (this.$feedbackContainer) {
357
- this.$feedbackContainer.classList.remove(
358
- "workwonders-widget-container--hidden"
359
- );
360
- }
361
- };
362
-
363
- openChangelogWidget = (id?: string) => {
364
- if (this.$changelogContainer) {
365
- if (id) {
366
- const $iframe = document.getElementById(
367
- "workwonders-changelog-iframe"
368
- ) as HTMLIFrameElement;
369
-
370
- const widgetUrl = new URL("changelog", `${this.widgetBaseUrl}`);
371
- widgetUrl.searchParams.append("jwt", this.args?.token || "");
372
- widgetUrl.searchParams.append("lang", this.args?.locale || "");
373
- widgetUrl.searchParams.append("changelogIds", id);
374
- $iframe.src = widgetUrl.toString();
375
- }
376
-
377
- this.$changelogContainer.classList.remove(
378
- "workwonders-widget-container--hidden"
379
- );
380
- }
381
- };
382
-
383
- openChangelogMiniWidget = () => {
384
- if (this.$changelogMiniContainer) {
385
- console.log("Opening changelog mini");
386
- this.$changelogMiniContainer.classList.remove(
387
- "workwonders-widget-container--hidden"
388
- );
389
- }
390
- };
391
-
392
- closeChangelogWidget = () => {
393
- if (this.$changelogContainer) {
394
- this.$changelogContainer.classList.add(
395
- "workwonders-widget-container--hidden"
396
- );
397
- }
398
- };
399
-
400
- closeFeedbackWidget = () => {
401
- if (this.$feedbackContainer) {
402
- this.$feedbackContainer.classList.add(
403
- "workwonders-widget-container--hidden"
404
- );
405
- }
406
- };
407
-
408
- closeChangelogMiniWidget = () => {
409
- if (this.$changelogMiniContainer) {
410
- console.log("Closing changelog mini");
411
- this.$changelogMiniContainer.classList.add(
412
- "workwonders-widget-container--hidden"
413
- );
414
- }
415
- };
416
- }
417
-
package/tsconfig.json DELETED
@@ -1,29 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "rootDir": "./src",
4
- "outDir": "./dist",
5
- "useDefineForClassFields": true,
6
- "module": "ESNext",
7
- "target": "esnext",
8
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
9
- "skipLibCheck": true,
10
-
11
- /* Bundler mode */
12
- "moduleResolution": "bundler",
13
- "isolatedModules": true,
14
- "moduleDetection": "force",
15
-
16
- // Other Outputs
17
- "sourceMap": true,
18
- "declaration": true,
19
- "declarationMap": true,
20
-
21
- /* Linting */
22
- "strict": true,
23
- "noUnusedLocals": true,
24
- "noUnusedParameters": true,
25
- "noFallthroughCasesInSwitch": true,
26
- "noUncheckedSideEffectImports": true
27
- },
28
- "include": ["src"]
29
- }
package/vite.config.ts DELETED
@@ -1,14 +0,0 @@
1
- import type { UserConfig } from "vite";
2
-
3
- export default {
4
- build: {
5
- outDir: "dist-html",
6
- minify: false,
7
- rollupOptions: {
8
- output: {
9
- entryFileNames: "sdk.js",
10
- },
11
- },
12
- },
13
- } satisfies UserConfig;
14
-