Skip to content

Commit

Permalink
chore: fix type issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninerian committed Jun 28, 2024
1 parent 8bdecac commit 5ad1354
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 65 deletions.
4 changes: 3 additions & 1 deletion samples/weather-forecast/dev/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
* limitations under the License.
*/

import { ExternalBlockDefinition } from "widget-sdk";
import { ExternalBlockDefinition } from "@staffbase/widget-sdk";
import { configurationSchema, uiSchema } from "../src/configuration-schema";
import React, { FC } from "react";
import Form from "@rjsf/material-ui";
import validator from "@rjsf/validator-ajv8";

const updateWidget = (data: Record<string, string>) => {
const el = document.querySelector("#preview > :first-child");
Expand Down Expand Up @@ -78,6 +79,7 @@ const Config: FC<Props> = ({ blockDefinition }) => {
<Form
schema={configurationSchema}
uiSchema={uiSchema}
validator={validator}
onSubmit={(e) => {
updateWidget(e.formData);
}}
Expand Down
3 changes: 3 additions & 0 deletions samples/weather-forecast/dev/widget-api-mock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import {
getUserInformationByExternalId,
} from "./user";

import getIntegration from "./integrations";

const apiMock: WidgetApi = {
getIntegration,
getLegacyAppTheme,
getUserInformation,
getUserList,
Expand Down
40 changes: 40 additions & 0 deletions samples/weather-forecast/dev/widget-api-mock/integrations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*!
* Copyright 2024, Staffbase GmbH and contributors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {
IntegrationInformation,
IntegrationStates,
IntegrationType,
} from "@staffbase/widget-sdk";

export default async (
_type: IntegrationType
): Promise<IntegrationInformation> => {
const date = new Date();
const expireDate = new Date();

expireDate.setDate(date.getDate() + 1);

return {
status: IntegrationStates.AVAILABLE,
enabledFeatures: ["foo"],
supportedFeatures: ["foo"],
token: {
accessToken: "fooToken",
accessTokenExpiresAt: expireDate,
},
signIn: () => {
console.log("Sign in");
},
};
};
3 changes: 2 additions & 1 deletion samples/weather-forecast/dev/widget-api-mock/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from "@staffbase/widget-sdk";

const user: SBUserProfile = {
id: "5c35e4feea2d15e6ffa8251d",
firstName: "Lucy",
lastName: "Liu",
};
Expand All @@ -33,7 +34,7 @@ export const getUserInformationByExternalId = async (
export const getUserList = async (
_query: UserListRequestQuery
): Promise<UserListResponse> => ({
data: [{ id: "5c35e4feea2d15e6ffa8251d", ...user }],
data: [{ ...user, id: "5c35e4feea2d15e6ffa8251d" }],
offset: 0,
limit: 1,
total: 1,
Expand Down
8 changes: 5 additions & 3 deletions samples/weather-forecast/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
"@babel/preset-typescript": "^7.24.7",
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@rjsf/core": "^3.0.0",
"@rjsf/material-ui": "^3.0.0",
"@rjsf/core": "5.18.4",
"@rjsf/utils": "5.18.4",
"@rjsf/material-ui": "5.18.4",
"@rjsf/validator-ajv8": "^5.18.4",
"@svgr/webpack": "6.5.1",
"@testing-library/dom": "8.2.0",
"@testing-library/jest-dom": "5.14.1",
Expand Down Expand Up @@ -71,7 +73,7 @@
"react-svg-loader": "^3.0.3",
"ts-loader": "^9.5.1",
"ts-node": "10.9.2",
"typescript": "4.4.2",
"typescript": "^4.4.2",
"url-loader": "^4.1.1",
"webpack": "^5.92.1",
"webpack-cli": "^4.8.0",
Expand Down
2 changes: 1 addition & 1 deletion samples/weather-forecast/src/configuration-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* limitations under the License.
*/

import { UiSchema } from "@rjsf/core";
import { UiSchema } from "@rjsf/utils";
import { JSONSchema7 } from "json-schema";

/**
Expand Down
2 changes: 1 addition & 1 deletion samples/weather-forecast/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
BlockDefinition,
ExternalBlockDefinition,
BaseBlock,
} from "widget-sdk";
} from "@staffbase/widget-sdk";
import { WeatherForecastProps, WeatherForecast } from "./weather-forecast";
import { configurationSchema, uiSchema } from "./configuration-schema";
import pkg from "../package.json";
Expand Down
2 changes: 1 addition & 1 deletion samples/weather-forecast/src/views/weatherView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import { isSameDay } from "date-fns";
import React, { FunctionComponent, useState } from "react";
import { BlockAttributes } from "widget-sdk";
import { BlockAttributes } from "@staffbase/widget-sdk";
import useCity from "../api/useCity";
import useWeather from "../api/useWeather";
import { ErrorBox } from "../components/ErrorBox";
Expand Down
2 changes: 1 addition & 1 deletion samples/weather-forecast/src/weather-forecast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import React, { ReactElement } from "react";
import { QueryClient, QueryClientProvider } from "react-query";
import { WeatherView } from "./views/weatherView";
import { BlockAttributes } from "widget-sdk";
import { BlockAttributes } from "@staffbase/widget-sdk";

const queryClient = new QueryClient({
defaultOptions: {
Expand Down
9 changes: 2 additions & 7 deletions samples/weather-forecast/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@
"resolveJsonModule": true,
"baseUrl": "src",
"rootDir": ".",
"paths": {
"widget-sdk": ["../node_modules/@staffbase/widget-sdk"]
},
"typeRoots": [
"./typings",
"node_modules/@types"
]
"paths": {},
"typeRoots": ["./typings", "node_modules/@types"]
},
"include": ["src/**/*", "src/custom.d.ts"],
"exclude": ["node_modules", "dist"]
Expand Down
91 changes: 42 additions & 49 deletions samples/weather-forecast/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1583,22 +1583,7 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@rjsf/core@^3.0.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@rjsf/core/-/core-3.1.0.tgz#7667364a4532e25c164abbc2adabe39157ffec4c"
integrity sha512-EwM2juiQxEdXzFy9rIIsDr6/e+FYeR1cKx0/no8ASEuXZ1p+/nf/CxKGobzD6UhpRip7JK9PhhuHFEFBIjHFJA==
dependencies:
"@types/json-schema" "^7.0.7"
ajv "^6.7.0"
core-js-pure "^3.6.5"
json-schema-merge-allof "^0.6.0"
jsonpointer "^4.0.1"
lodash "^4.17.15"
nanoid "^3.1.23"
prop-types "^15.7.2"
react-is "^16.9.0"

"@rjsf/core@^5.13.6":
"@rjsf/core@5.18.4", "@rjsf/core@^5.13.6":
version "5.18.4"
resolved "https://registry.yarnpkg.com/@rjsf/core/-/core-5.18.4.tgz#a0e5a77a54dd07bcd40dd287db7002b8973421f4"
integrity sha512-OUPC+l44X1geYT9sSsmQC2pakvFWCQB+5Iy/ITfLMJq3MIjJn0gakCwYHXMMBGUAKM1SSMIyKWyCazt3kY9fhg==
Expand All @@ -1609,12 +1594,12 @@
nanoid "^3.3.7"
prop-types "^15.8.1"

"@rjsf/material-ui@^3.0.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@rjsf/material-ui/-/material-ui-3.1.0.tgz#ed15fc75de1594f87cd8336b7f2ebc492a432d8b"
integrity sha512-kWz37spT5SOXkb8Axq4g4BzQjXRylQr6B7eFAg1NPhSK7KrJYwSMSsFJ9Ze2vEBxwEiR0Z0n/4puaamGuGFRBw==
"@rjsf/material-ui@5.18.4":
version "5.18.4"
resolved "https://registry.yarnpkg.com/@rjsf/material-ui/-/material-ui-5.18.4.tgz#9135ccd544b0e4cfb75c33a37f94d1c33863c85b"
integrity sha512-jShLQ7AGDGK+b5MDdMzSSu97YaIk4OTtWYfjlbKlVMOFIWW4AGO/exPZfLtcGW3ST4LYWWQE02g8O0SQpnLWaA==

"@rjsf/utils@^5.13.6":
"@rjsf/utils@5.18.4", "@rjsf/utils@^5.13.6":
version "5.18.4"
resolved "https://registry.yarnpkg.com/@rjsf/utils/-/utils-5.18.4.tgz#098c767f6bfbbf660f201d864bf8bba247453dfd"
integrity sha512-svLMk5aW6q3JQRYVTJradFc9tLeQ1vX5/k6fPwxf+08eweqPbINq7aokLBSStUNr8FfYgThTl8IfehLoVP2dvw==
Expand All @@ -1625,6 +1610,16 @@
lodash-es "^4.17.21"
react-is "^18.2.0"

"@rjsf/validator-ajv8@^5.18.4":
version "5.18.5"
resolved "https://registry.yarnpkg.com/@rjsf/validator-ajv8/-/validator-ajv8-5.18.5.tgz#0f02f39462b3cdc15641df9dd63263600556b374"
integrity sha512-R1kPl86NzhbVYyRQ7Sa3GLDEmZdum7Qcvi9wKBy0GmnONM9dX6wZGikzr5/7x8mVYCIjukAd3eL129uchIv95w==
dependencies:
ajv "^8.12.0"
ajv-formats "^2.1.1"
lodash "^4.17.21"
lodash-es "^4.17.21"

"@sinonjs/commons@^1.7.0":
version "1.8.3"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d"
Expand Down Expand Up @@ -2503,12 +2498,19 @@ aggregate-error@^3.0.0:
clean-stack "^2.0.0"
indent-string "^4.0.0"

ajv-formats@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ajv-formats/-/ajv-formats-2.1.1.tgz#6e669400659eb74973bbf2e33327180a0996b520"
integrity sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==
dependencies:
ajv "^8.0.0"

ajv-keywords@^3.5.2:
version "3.5.2"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d"
integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==

ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.4, ajv@^6.12.5, ajv@^6.7.0:
ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.4, ajv@^6.12.5:
version "6.12.6"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==
Expand All @@ -2518,6 +2520,16 @@ ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.4, ajv@^6.12.5, ajv@^6.7.0:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"

ajv@^8.0.0, ajv@^8.12.0:
version "8.16.0"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.16.0.tgz#22e2a92b94f005f7e0f9c9d39652ef0b8f6f0cb4"
integrity sha512-F0twR8U1ZU67JIEtekUcLkXkoO5mMMmgGD8sK/xUFzJ805jxHQl92hImFAqqXMyMYjSPOyUPAwHYhB72g5sTXw==
dependencies:
fast-deep-equal "^3.1.3"
json-schema-traverse "^1.0.0"
require-from-string "^2.0.2"
uri-js "^4.4.1"

ajv@^8.0.1:
version "8.6.2"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.6.2.tgz#2fb45e0e5fcbc0813326c1c3da535d1881bb0571"
Expand Down Expand Up @@ -3102,7 +3114,7 @@ compute-gcd@^1.2.1:
validate.io-function "^1.0.2"
validate.io-integer-array "^1.0.0"

compute-lcm@^1.1.0, compute-lcm@^1.1.2:
compute-lcm@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/compute-lcm/-/compute-lcm-1.1.2.tgz#9107c66b9dca28cefb22b4ab4545caac4034af23"
integrity sha512-OFNPdQAXnQhDSKioX8/XYT6sdUlXwpeMjfd6ApxMJfyZ4GxmLR1xvMERctlYhlHwIiz6CSpBc2+qYKjHGZw4TQ==
Expand Down Expand Up @@ -3176,7 +3188,7 @@ core-js-compat@^3.31.0, core-js-compat@^3.36.1:
dependencies:
browserslist "^4.23.0"

core-js-pure@^3.16.0, core-js-pure@^3.6.5:
core-js-pure@^3.16.0:
version "3.16.2"
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.16.2.tgz#0ef4b79cabafb251ea86eb7d139b42bd98c533e8"
integrity sha512-oxKe64UH049mJqrKkynWp6Vu0Rlm/BTXO/bJZuN2mmR3RtOFNepLlSWDd1eo16PzHpQAoNG97rLU1V/YxesJjw==
Expand Down Expand Up @@ -5246,15 +5258,6 @@ json-schema-compare@^0.2.2:
dependencies:
lodash "^4.17.4"

json-schema-merge-allof@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/json-schema-merge-allof/-/json-schema-merge-allof-0.6.0.tgz#64d48820fec26b228db837475ce3338936bf59a5"
integrity sha512-LEw4VMQVRceOPLuGRWcxW5orTTiR9ZAtqTAe4rQUjNADTeR81bezBVFa0MqIwp0YmHIM1KkhSjZM7o+IQhaPbQ==
dependencies:
compute-lcm "^1.1.0"
json-schema-compare "^0.2.2"
lodash "^4.17.4"

json-schema-merge-allof@^0.8.1:
version "0.8.1"
resolved "https://registry.yarnpkg.com/json-schema-merge-allof/-/json-schema-merge-allof-0.8.1.tgz#ed2828cdd958616ff74f932830a26291789eaaf2"
Expand Down Expand Up @@ -5291,11 +5294,6 @@ json5@^2.1.2, json5@^2.2.3:
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==

jsonpointer@^4.0.1:
version "4.1.0"
resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.1.0.tgz#501fb89986a2389765ba09e6053299ceb4f2c2cc"
integrity sha512-CXcRvMyTlnR53xMcKnuMzfCA5i/nfblTnnr74CZb6C4vG39eu6w51t7nKmU5MfLfbTgGItliNyjO/ciNPDqClg==

jsonpointer@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-5.0.1.tgz#2110e0af0900fd37467b5907ecd13a7884a1b559"
Expand Down Expand Up @@ -5696,11 +5694,6 @@ nano-time@1.0.0:
dependencies:
big-integer "^1.6.16"

nanoid@^3.1.23:
version "3.3.2"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.2.tgz#c89622fafb4381cd221421c69ec58547a1eec557"
integrity sha512-CuHBogktKwpm5g2sRgv83jEy2ijFzBwMoYA60orPDR7ynsLijJDqgsi4RDGj3OJpy3Ieb+LYwiRmIOGyytgITA==

nanoid@^3.3.7:
version "3.3.7"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8"
Expand Down Expand Up @@ -6232,7 +6225,7 @@ react-error-boundary@^3.1.0:
dependencies:
"@babel/runtime" "^7.12.5"

react-is@^16.13.1, react-is@^16.7.0, react-is@^16.9.0:
react-is@^16.13.1, react-is@^16.7.0:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
Expand Down Expand Up @@ -7110,10 +7103,10 @@ typedarray-to-buffer@^3.1.5:
dependencies:
is-typedarray "^1.0.0"

typescript@4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86"
integrity sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==
typescript@^4.4.2:
version "4.9.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==

unbox-primitive@^1.0.1:
version "1.0.1"
Expand Down Expand Up @@ -7179,7 +7172,7 @@ update-browserslist-db@^1.0.16:
escalade "^3.1.2"
picocolors "^1.0.1"

uri-js@^4.2.2:
uri-js@^4.2.2, uri-js@^4.4.1:
version "4.4.1"
resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e"
integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==
Expand Down

0 comments on commit 5ad1354

Please sign in to comment.