diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b7384362d..d9ea4d87c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -26,11 +26,11 @@ jobs: path: | /home/runner/.deno /home/runner/.cache/deno/deps/https/deno.land - - uses: denoland/setup-deno@v1 + - uses: denoland/setup-deno@v2 with: - deno-version: v1.x + deno-version: v2.x - name: Bundle Apps - run: deno run -A --lock=deno.lock --lock-write --reload scripts/start.ts + run: deno run -A --lock=deno.lock --frozen=false --reload scripts/start.ts - name: Check run: deno task check @@ -47,8 +47,8 @@ jobs: - name: Test continue-on-error: true - run: deno test --lock=deno.lock --lock-write -A . + run: deno test --lock=deno.lock --frozen=false -A . - name: Benchmark continue-on-error: true - run: deno bench --lock=deno.lock --lock-write -A . \ No newline at end of file + run: deno bench --lock=deno.lock --frozen=false -A . diff --git a/.github/workflows/issues.yaml b/.github/workflows/issues.yaml index 9504b5705..d5f99f015 100644 --- a/.github/workflows/issues.yaml +++ b/.github/workflows/issues.yaml @@ -15,4 +15,4 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_REPO: ${{ github.repository }} NUMBER: ${{ github.event.issue.number }} - LABELS: triage \ No newline at end of file + LABELS: triage diff --git a/.github/workflows/releaser.yaml b/.github/workflows/releaser.yaml index 5584f177e..f4fb8d2a0 100644 --- a/.github/workflows/releaser.yaml +++ b/.github/workflows/releaser.yaml @@ -9,9 +9,9 @@ on: - main permissions: - contents: write # Necessary for accessing and modifying repository content - pull-requests: write # Necessary for interacting with pull requests - actions: write # Necessary for triggering other workflows + contents: write # Necessary for accessing and modifying repository content + pull-requests: write # Necessary for interacting with pull requests + actions: write # Necessary for triggering other workflows jobs: tag-discussion: @@ -21,9 +21,9 @@ jobs: - name: Checkout Code uses: actions/checkout@v3 with: - ref: ${{ github.event.pull_request.base.ref }} # Checkout the base branch (target repository) - repository: ${{ github.event.pull_request.base.repo.full_name }} # Checkout from the target repo - + ref: ${{ github.event.pull_request.base.ref }} # Checkout the base branch (target repository) + repository: ${{ github.event.pull_request.base.repo.full_name }} # Checkout from the target repo + - name: Calculate new versions id: calculate_versions run: | @@ -162,11 +162,11 @@ jobs: run: | git tag ${{ steps.determine_version.outputs.new_version }} git push origin ${{ steps.determine_version.outputs.new_version }} - + - name: Trigger Release Workflow run: | curl -X POST \ -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ -H "Accept: application/vnd.github.everest-preview+json" \ https://api.github.com/repos/${{ github.repository }}/actions/workflows/release.yaml/dispatches \ - -d '{"ref":"main", "inputs":{"tag_name":"${{ steps.determine_version.outputs.new_version }}"}}' \ No newline at end of file + -d '{"ref":"main", "inputs":{"tag_name":"${{ steps.determine_version.outputs.new_version }}"}}' diff --git a/ai-assistants/actions/describeImage.ts b/ai-assistants/actions/describeImage.ts index 22296dc35..c5661f712 100644 --- a/ai-assistants/actions/describeImage.ts +++ b/ai-assistants/actions/describeImage.ts @@ -2,6 +2,7 @@ import { AssistantIds } from "../types.ts"; import { AppContext } from "../mod.ts"; import { logger, meter, ValueType } from "@deco/deco/o11y"; import { shortcircuit } from "@deco/deco"; + const stats = { promptTokens: meter.createHistogram("assistant_image_prompt_tokens", { description: "Tokens used in Sales Assistant Describe Image Input - OpenAI", @@ -78,13 +79,18 @@ export default async function describeImage( }); return response; } catch (error) { + const errorObj = error as { + error: { message: string }; + status: number; + headers: Headers; + }; stats.describeImageError.add(1, { assistantId, }); shortcircuit( - new Response(JSON.stringify({ error: error.error.message }), { - status: error.status, - headers: error.headers, + new Response(JSON.stringify({ error: errorObj.error.message }), { + status: errorObj.status, + headers: errorObj.headers, }), ); } diff --git a/ai-assistants/mod.ts b/ai-assistants/mod.ts index ae3b64a21..d9db17ecd 100644 --- a/ai-assistants/mod.ts +++ b/ai-assistants/mod.ts @@ -1,4 +1,4 @@ -import AWS from "https://esm.sh/aws-sdk@2.1585.0"; +import AWS from "npm:aws-sdk@2.1585.0"; import { deferred } from "std/async/deferred.ts"; import openai, { Props as OpenAIProps, diff --git a/deno.json b/deno.json index 6070a233e..5be76c40b 100644 --- a/deno.json +++ b/deno.json @@ -38,7 +38,7 @@ }, "lock": false, "tasks": { - "check": "deno fmt && deno lint && deno check **/mod.ts", + "check": "deno fmt && deno lint && deno check --allow-import **/mod.ts", "release": "deno eval 'import \"deco/scripts/release.ts\"'", "start": "deno run -A ./scripts/start.ts", "bundle": "deno run -A jsr:@deco/deco/scripts/bundle", @@ -62,5 +62,5 @@ "jsx": "react-jsx", "jsxImportSource": "preact" }, - "version": "0.62.8" + "version": "0.62.9" } diff --git a/konfidency/loaders/productDetailsPage.ts b/konfidency/loaders/productDetailsPage.ts index 1fa179177..7dce10635 100644 --- a/konfidency/loaders/productDetailsPage.ts +++ b/konfidency/loaders/productDetailsPage.ts @@ -40,8 +40,9 @@ export default function productDetailsPage( }, }; } catch (error) { - logger.error(`{ errorName: ${error.name}, - errorMessage: ${error.message} }`); + const errorObj = error as { name: string; message: string }; + logger.error(`{ errorName: ${errorObj.name}, + errorMessage: ${errorObj.message} }`); return productDetailsPage; } }; diff --git a/posthog/components/PostHog.tsx b/posthog/components/PostHog.tsx index 85178ace4..b19b9fab7 100644 --- a/posthog/components/PostHog.tsx +++ b/posthog/components/PostHog.tsx @@ -29,7 +29,7 @@ const snippet = () => { const trackPageview = () => globalThis.window.posthog?.capture("$pageview", { ...props, - "$current_url": window.location.href, + "$current_url": globalThis.location.href, }); // Attach pushState and popState listeners const originalPushState = history.pushState; diff --git a/records/deps.ts b/records/deps.ts index 461cf0294..71c2d8aac 100644 --- a/records/deps.ts +++ b/records/deps.ts @@ -1,5 +1,5 @@ import { context } from "@deco/deco"; -export * from "https://esm.sh/drizzle-orm@0.30.10/libsql"; +export * from "npm:drizzle-orm@0.30.10/libsql"; export * from "npm:@libsql/client@0.7.0"; export const createLocalClient = !context.isDeploy && (await import("npm:@libsql/client@0.7.0/node")).createClient; diff --git a/smarthint/components/Click.tsx b/smarthint/components/Click.tsx index 07d1a8d61..899a3efba 100644 --- a/smarthint/components/Click.tsx +++ b/smarthint/components/Click.tsx @@ -21,7 +21,7 @@ export const SmarthintSendEventOnClick = ({ } elem.addEventListener("click", () => { - window.smarthint.click(event); + globalThis.smarthint.click(event); }); }, id, diff --git a/smarthint/sections/Analytics/SmarthintTracking.tsx b/smarthint/sections/Analytics/SmarthintTracking.tsx index b1abb65e3..d90c46995 100644 --- a/smarthint/sections/Analytics/SmarthintTracking.tsx +++ b/smarthint/sections/Analytics/SmarthintTracking.tsx @@ -16,7 +16,7 @@ const listener = ( ReturnType, ) => { const prodURL = new URL(publicUrl); - const url = new URL(window.location.href); + const url = new URL(globalThis.location.href); url.host = prodURL.host; url.port = ""; const pageType = diff --git a/utils/pool.ts b/utils/pool.ts index bfd4f8417..6845e5cbe 100644 --- a/utils/pool.ts +++ b/utils/pool.ts @@ -17,6 +17,8 @@ export const createPool = (resources: T[]) => { const index = free.values().next().value; + if (index === undefined) return; + taken.add(index); free.delete(index); diff --git a/vtex/sections/Analytics/Vtex.tsx b/vtex/sections/Analytics/Vtex.tsx index 53d75cf11..ba91361bd 100644 --- a/vtex/sections/Analytics/Vtex.tsx +++ b/vtex/sections/Analytics/Vtex.tsx @@ -15,7 +15,7 @@ interface ISCookies { session: any; } const snippet = (account: string, agent: string, cookies: ISCookies | null) => { - const url = new URL(window.location.href); + const url = new URL(globalThis.location.href); const isSearch = url.searchParams.get("q"); const apiUrl = `https://sp.vtex.com/event-api/v1/${account}/event`; const eventFetch = (props: SPEvent) => { diff --git a/wake/hooks/context.ts b/wake/hooks/context.ts index 4d3f6b1c4..0afc46a4a 100644 --- a/wake/hooks/context.ts +++ b/wake/hooks/context.ts @@ -83,7 +83,7 @@ const enqueue2 = ( return; } - const isLocalhost = window.location.hostname === "localhost"; + const isLocalhost = globalThis.location.hostname === "localhost"; if (!isLocalhost) { const url = new URL("/api/carrinho", shop.checkoutUrl); diff --git a/website/components/Clickhouse.tsx b/website/components/Clickhouse.tsx index 2e2007b2b..3e4e1d350 100644 --- a/website/components/Clickhouse.tsx +++ b/website/components/Clickhouse.tsx @@ -218,7 +218,7 @@ const snippet = ({ siteId, siteName, serviceEndpoint, userId, sessionId }: { return match ? match[1].replace("_", ".") : "Unknown"; } function getUrlParam(param: string) { - const urlParams = new URLSearchParams(window.location.search); + const urlParams = new URLSearchParams(globalThis.location.search); return urlParams.get(param); } function getReferrerSource(referrer: string) { @@ -245,7 +245,7 @@ const snippet = ({ siteId, siteName, serviceEndpoint, userId, sessionId }: { start_time: new Date().toISOString(), timestamp: undefined, // get server side pathname: globalThis.window.location.pathname + - (window.location.hash ?? ""), + (globalThis.location.hash ?? ""), navigation_from: globalThis.window.navigation.activation.from, entry_meta: { key: Object.keys(values), @@ -266,7 +266,7 @@ const snippet = ({ siteId, siteName, serviceEndpoint, userId, sessionId }: { ip_timezone: undefined, // get server side ip_lat: undefined, // get server side ip_long: undefined, // get server side - screen_size: `${window.screen.width}x${window.screen.height}`, + screen_size: `${globalThis.screen.width}x${globalThis.screen.height}`, device: getDeviceType(), operating_system: getOperatingSystem(), operating_system_version: getOSVersion(), diff --git a/website/handlers/fresh.ts b/website/handlers/fresh.ts index 55035d722..626c68e1d 100644 --- a/website/handlers/fresh.ts +++ b/website/handlers/fresh.ts @@ -12,6 +12,8 @@ import { isDeferred, RequestContext, } from "@deco/deco"; +import type { Exception } from "npm:@opentelemetry/api@1.9.0"; + type ConnInfo = Deno.ServeHandlerInfo; /** * @title Fresh Config @@ -120,7 +122,7 @@ export default function Fresh( try { return await getPage(); } catch (e) { - span.recordException(e); + span.recordException(e as Exception); throw e; } finally { span.end(); @@ -163,7 +165,7 @@ export default function Fresh( } return response; } catch (err) { - span.recordException(err); + span.recordException(err as Exception); throw err; } finally { span.end(); diff --git a/website/loaders/image.ts b/website/loaders/image.ts index 748aa51ee..3f3bf28c2 100644 --- a/website/loaders/image.ts +++ b/website/loaders/image.ts @@ -68,10 +68,11 @@ const handler = async ( return response; } catch (error) { + const errorObj = error as { message?: string; status: number }; console.error(error); - return new Response(error.message ?? Deno.inspect(error), { - status: error instanceof HttpError ? error.status : 500, + return new Response(errorObj.message ?? Deno.inspect(error), { + status: error instanceof HttpError ? errorObj.status : 500, headers: { "cache-control": "no-cache, no-store", "vary": "Accept", diff --git a/website/pages/Page.tsx b/website/pages/Page.tsx index 02d0a5c8a..315d4284e 100644 --- a/website/pages/Page.tsx +++ b/website/pages/Page.tsx @@ -61,9 +61,9 @@ class ErrorBoundary extends Component<{ // deno-lint-ignore no-explicit-any fallback: ComponentFunc; }> { - state = { error: null as Error | null }; + override state = { error: null as Error | null }; // deno-lint-ignore no-explicit-any - static getDerivedStateFromError(error: any) { + static override getDerivedStateFromError(error: any) { return { error }; } render() { diff --git a/website/utils/image/engines/cloudflare/engine.ts b/website/utils/image/engines/cloudflare/engine.ts index 85c620471..7fb7140af 100644 --- a/website/utils/image/engines/cloudflare/engine.ts +++ b/website/utils/image/engines/cloudflare/engine.ts @@ -8,15 +8,21 @@ export const engine: Engine = { const format = prefferedMediaType?.replace("image/", ""); - return fetch(src, { - // @ts-expect-error Only available when deployed into cloudflare workers - cf: { - image: { format, fit, width, height, quality }, - cacheKey: `${format}-${src}`, - cacheEverything: true, - cacheTtlByStatus: { "200-299": 15552000, "400-499": 10, "500-599": 0 }, - }, - }); + return fetch( + src, + { + cf: { + image: { format, fit, width, height, quality }, + cacheKey: `${format}-${src}`, + cacheEverything: true, + cacheTtlByStatus: { + "200-299": 15552000, + "400-499": 10, + "500-599": 0, + }, + }, + } as RequestInit & { cf: unknown }, + ); }, // is Cloudflare worker