Skip to content

Commit

Permalink
Migrate to use deco from JSR (#770)
Browse files Browse the repository at this point in the history
* Migrate to use deco from JSR

Signed-off-by: Marcos Candeia <[email protected]>

Include usePartialSection on hooks and totally remove deco denopkg dep

Signed-off-by: Marcos Candeia <[email protected]>

Use deco from jsr on missing runtime.ts

Signed-off-by: Marcos Candeia <[email protected]>

Simplify deno.json

Signed-off-by: Marcos Candeia <[email protected]>

Use jsr

Signed-off-by: Marcos Candeia <[email protected]>

Add missing std/async

Signed-off-by: Marcos Candeia <[email protected]>

Migrating to jsr

Signed-off-by: Marcos Candeia <[email protected]>

run linter and formatter

Signed-off-by: Marcos Candeia <[email protected]>

Fix linter

Signed-off-by: Marcos Candeia <[email protected]>

Run linter and use deco from jsr

Signed-off-by: Marcos Candeia <[email protected]>

* Remove publish workflow

Signed-off-by: Marcos Candeia <[email protected]>

* Use imports from fresh

Signed-off-by: Marcos Candeia <[email protected]>

* Rebase with main

Signed-off-by: Marcos Candeia <[email protected]>

* Use deco web

Signed-off-by: Marcos Candeia <[email protected]>

* Update deco to alpha version

Signed-off-by: Marcos Candeia <[email protected]>

* Update to deco 1.97.0

Signed-off-by: Marcos Candeia <[email protected]>

---------

Signed-off-by: Marcos Candeia <[email protected]>
  • Loading branch information
mcandeia authored Sep 10, 2024
1 parent b1ca60b commit 6aa83a0
Show file tree
Hide file tree
Showing 299 changed files with 674 additions and 730 deletions.
48 changes: 0 additions & 48 deletions admin/types.ts

This file was deleted.

8 changes: 3 additions & 5 deletions ai-assistants/actions/awsUploadImage.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { logger } from "deco/observability/otel/config.ts";
import { meter } from "deco/observability/otel/metrics.ts";
import base64ToBlob from "../utils/blobConversion.ts";
import { AssistantIds } from "../types.ts";
import { ValueType } from "deco/deps.ts";
import { logger, meter, ValueType } from "@deco/deco/o11y";
import { AppContext } from "../mod.ts";
import { AssistantIds } from "../types.ts";
import base64ToBlob from "../utils/blobConversion.ts";

const stats = {
awsUploadImageError: meter.createCounter("assistant_aws_upload_error", {
Expand Down
2 changes: 1 addition & 1 deletion ai-assistants/actions/chat.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AppContext } from "../mod.ts";

import { badRequest, notFound } from "deco/mod.ts";
import { badRequest, notFound } from "@deco/deco";
import { messageProcessorFor } from "../chat/messages.ts";
import { Notify, Queue } from "../deps.ts";

Expand Down
8 changes: 3 additions & 5 deletions ai-assistants/actions/describeImage.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { logger } from "deco/observability/otel/config.ts";
import { meter } from "deco/observability/otel/metrics.ts";
import { AssistantIds } from "../types.ts";
import { ValueType } from "deco/deps.ts";
import { shortcircuit } from "@deco/deco";
import { logger, meter, ValueType } from "@deco/deco/o11y";
import { AppContext } from "../mod.ts";
import { shortcircuit } from "deco/engine/errors.ts";
import { AssistantIds } from "../types.ts";

const stats = {
promptTokens: meter.createHistogram("assistant_image_prompt_tokens", {
Expand Down
8 changes: 3 additions & 5 deletions ai-assistants/actions/transcribeAudio.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { logger } from "deco/observability/otel/config.ts";
import base64ToBlob from "../utils/blobConversion.ts";
import { meter } from "deco/observability/otel/metrics.ts";
import { AssistantIds } from "../types.ts";
import { ValueType } from "deco/deps.ts";
import { logger, meter, ValueType } from "@deco/deco/o11y";
import { AppContext } from "../mod.ts";
import { AssistantIds } from "../types.ts";
import base64ToBlob from "../utils/blobConversion.ts";

const stats = {
audioSize: meter.createHistogram("assistant_transcribe_audio_size", {
Expand Down
8 changes: 4 additions & 4 deletions ai-assistants/chat/messages.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { weakcache } from "../../utils/weakcache.ts";
import {
AssistantCreateParams,
RequiredActionFunctionToolCall,
Thread,
} from "../deps.ts";
import { threadMessageToReply, Tokens } from "../loaders/messages.ts";
import { JSONSchema7, ValueType, weakcache } from "deco/deps.ts";
import { lazySchemaFor } from "deco/engine/schema/lazy.ts";
import { Context } from "deco/live.ts";
import { meter } from "deco/observability/otel/metrics.ts";

import { Context, JSONSchema7, lazySchemaFor } from "@deco/deco";
import { meter, ValueType } from "@deco/deco/o11y";
import {
ChatMessage,
FunctionCallReply,
Expand Down
19 changes: 11 additions & 8 deletions ai-assistants/mod.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import type { App, AppContext as AC } from "@deco/deco";
import {
AppManifest,
asResolved,
AvailableActions,
AvailableLoaders,
isDeferred,
} from "@deco/deco";
import { isAwaitable } from "@deco/deco/utils";
import AWS from "https://esm.sh/[email protected]";
import { asResolved, isDeferred } from "deco/engine/core/resolver.ts";
import { isAwaitable } from "deco/engine/core/utils.ts";
import type { App, AppContext as AC } from "deco/mod.ts";
import { AvailableActions, AvailableLoaders } from "deco/utils/invoke.types.ts";
import { AppManifest } from "deco/types.ts";
import { deferred } from "std/async/deferred.ts";
import openai, {
Props as OpenAIProps,
State as OpenAIState,
} from "../openai/mod.ts";
import { Secret } from "../website/loaders/secret.ts";
import { Assistant } from "./deps.ts";
import manifest, { Manifest } from "./manifest.gen.ts";
import { Secret } from "../website/loaders/secret.ts";
import { PreviewContainer } from "../utils/preview.tsx";

export type GPTModel =
Expand Down Expand Up @@ -157,7 +160,7 @@ export default function App(
...openAIApp.state,
assistants: (state.assistants ?? []).filter(Boolean).reduce(
(acc, assistant) => {
const assistantDeferred = deferred<AIAssistant>();
const assistantDeferred = Promise.withResolvers<AIAssistant>();
if (isDeferred<AIAssistant>(assistant)) {
const aiAssistant = assistant();
if (isAwaitable(aiAssistant)) {
Expand Down
2 changes: 1 addition & 1 deletion ai-assistants/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { proxy } from "deco/clients/withManifest.ts";
import { proxy } from "@deco/deco/web";
import { Manifest } from "./manifest.gen.ts";

export const invoke = proxy<Manifest>();
2 changes: 1 addition & 1 deletion ai-assistants/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JSONSchema7 } from "deco/deps.ts";
import { JSONSchema7 } from "@deco/deco";

const isJSONSchema = (
v: unknown | JSONSchema7,
Expand Down
2 changes: 1 addition & 1 deletion ai-assistants/utils/blobConversion.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { logger } from "deco/observability/otel/config.ts";
import { logger } from "@deco/deco/o11y";
import { AssistantIds } from "../types.ts";

export default function base64ToBlob(
Expand Down
2 changes: 1 addition & 1 deletion algolia/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { App, AppContext as AC } from "deco/mod.ts";
import type { App, AppContext as AC } from "@deco/deco";
import algolia from "https://esm.sh/[email protected]";
import { createFetchRequester } from "npm:@algolia/[email protected]";
import { Markdown } from "../decohub/components/Markdown.tsx";
Expand Down
4 changes: 2 additions & 2 deletions algolia/sections/Analytics/Algolia.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SectionProps } from "deco/blocks/section.ts";
import { useScriptAsDataURI } from "deco/hooks/useScript.ts";
import { SectionProps } from "@deco/deco";
import { useScriptAsDataURI } from "@deco/deco/hooks";
import insights from "npm:[email protected]";
import {
AddToCartEvent,
Expand Down
3 changes: 2 additions & 1 deletion algolia/workflows/index/product.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { WorkflowContext, WorkflowGen } from "deco/mod.ts";
import { WorkflowGen } from "@deco/deco";
import { WorkflowContext } from "@deco/deco/blocks";
import { Product } from "../../../commerce/types.ts";
import type { Manifest } from "../../manifest.gen.ts";

Expand Down
2 changes: 1 addition & 1 deletion analytics/components/DecoAnalytics.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Head } from "$fresh/runtime.ts";
import { useScriptAsDataURI } from "deco/hooks/useScript.ts";
import { useScriptAsDataURI } from "@deco/deco/hooks";

export interface Props {
/**
Expand Down
4 changes: 2 additions & 2 deletions analytics/loaders/DecoAnalyticsScript.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useScriptAsDataURI } from "deco/hooks/useScript.ts";
import { Flag } from "deco/types.ts";
import { Flag } from "@deco/deco";
import { useScriptAsDataURI } from "@deco/deco/hooks";
import { Script } from "../../website/types.ts";
import { AppContext } from "../mod.ts";

Expand Down
2 changes: 1 addition & 1 deletion analytics/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { App, AppContext as AC } from "deco/mod.ts";
import type { App, AppContext as AC } from "@deco/deco";
import manifest, { Manifest } from "./manifest.gen.ts";
import { PreviewContainer } from "../utils/preview.tsx";

Expand Down
4 changes: 2 additions & 2 deletions anthropic/actions/code.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { shortcircuit } from "deco/engine/errors.ts";
import { AppContext } from "../mod.ts";
import { shortcircuit } from "@deco/deco";
import { Anthropic } from "../deps.ts";
import { AppContext } from "../mod.ts";
export interface Props {
/**
* @description The system prompt to be used for the AI Assistant.
Expand Down
7 changes: 2 additions & 5 deletions anthropic/actions/stream.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { JSONSchema7 } from "deco/deps.ts";
import { shortcircuit } from "deco/engine/errors.ts";
import { lazySchemaFor } from "deco/engine/schema/lazy.ts";
import { Context } from "deco/live.ts";
import { readFromStream } from "deco/utils/http.ts";
import { Context, JSONSchema7, lazySchemaFor, shortcircuit } from "@deco/deco";
import { readFromStream } from "@deco/deco/utils";
import { dereferenceJsonSchema } from "../../ai-assistants/schema.ts";
import { Anthropic } from "../deps.ts";
import { AppContext } from "../mod.ts";
Expand Down
2 changes: 1 addition & 1 deletion anthropic/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { App, AppContext as AC } from "deco/mod.ts";
import type { App, AppContext as AC } from "@deco/deco";
import { Secret } from "../website/loaders/secret.ts";
import { Anthropic } from "./deps.ts";
import manifest, { Manifest } from "./manifest.gen.ts";
Expand Down
2 changes: 1 addition & 1 deletion blog/loaders/Author.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Author } from "../types.ts";
import type { Author } from "../types.ts";

/**
* @title Author
Expand Down
4 changes: 2 additions & 2 deletions blog/loaders/BlogPostItem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppContext } from "../mod.ts";
import { BlogPost } from "../types.ts";
import type { AppContext } from "../mod.ts";
import type { BlogPost } from "../types.ts";
import { getRecordsByPath } from "../utils/records.ts";
import type { RequestURLParam } from "../../website/functions/requestToParam.ts";

Expand Down
4 changes: 2 additions & 2 deletions blog/loaders/BlogPostPage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppContext } from "../mod.ts";
import { BlogPost, BlogPostPage } from "../types.ts";
import type { AppContext } from "../mod.ts";
import type { BlogPost, BlogPostPage } from "../types.ts";
import { getRecordsByPath } from "../utils/records.ts";
import type { RequestURLParam } from "../../website/functions/requestToParam.ts";

Expand Down
2 changes: 1 addition & 1 deletion blog/loaders/Blogpost.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BlogPost } from "../types.ts";
import type { BlogPost } from "../types.ts";

/**
* @title Blogpost
Expand Down
6 changes: 3 additions & 3 deletions blog/loaders/BlogpostList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* @param ctx - The application context.
* @returns A promise that resolves to an array of blog posts.
*/
import { RequestURLParam } from "../../website/functions/requestToParam.ts";
import { AppContext } from "../mod.ts";
import { BlogPost, SortBy } from "../types.ts";
import type { AppContext } from "../mod.ts";
import type { RequestURLParam } from "../../website/functions/requestToParam.ts";
import type { BlogPost, SortBy } from "../types.ts";
import handlePosts, { slicePosts } from "../utils/handlePosts.ts";
import { getRecordsByPath } from "../utils/records.ts";

Expand Down
8 changes: 4 additions & 4 deletions blog/loaders/BlogpostListing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* @param ctx - The application context.
* @returns A promise that resolves to an array of blog posts.
*/
import { PageInfo } from "../../commerce/types.ts";
import { RequestURLParam } from "../../website/functions/requestToParam.ts";
import { AppContext } from "../mod.ts";
import { BlogPost, BlogPostListingPage, SortBy } from "../types.ts";
import type { PageInfo } from "../../commerce/types.ts";
import type { RequestURLParam } from "../../website/functions/requestToParam.ts";
import type { AppContext } from "../mod.ts";
import type { BlogPost, BlogPostListingPage, SortBy } from "../types.ts";
import handlePosts, { slicePosts } from "../utils/handlePosts.ts";
import { getRecordsByPath } from "../utils/records.ts";

Expand Down
2 changes: 1 addition & 1 deletion blog/loaders/Category.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Category } from "../types.ts";
import type { Category } from "../types.ts";

/**
* @title Category
Expand Down
6 changes: 3 additions & 3 deletions blog/loaders/GetCategories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* @param ctx - The application context.
* @returns A promise that resolves to an array of blog posts.
*/
import { RequestURLParam } from "../../website/functions/requestToParam.ts";
import { AppContext } from "../mod.ts";
import { Category } from "../types.ts";
import type { RequestURLParam } from "../../website/functions/requestToParam.ts";
import type { AppContext } from "../mod.ts";
import type { Category } from "../types.ts";
import { getRecordsByPath } from "../utils/records.ts";

const COLLECTION_PATH = "collections/blog/categories";
Expand Down
4 changes: 2 additions & 2 deletions blog/mod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { App, FnContext } from "deco/mod.ts";
import manifest, { Manifest } from "./manifest.gen.ts";
import type { App, FnContext } from "@deco/deco";
import manifest, { type Manifest } from "./manifest.gen.ts";
import { PreviewContainer } from "../utils/preview.tsx";

// deno-lint-ignore no-explicit-any
Expand Down
6 changes: 3 additions & 3 deletions blog/sections/Seo/SeoBlogPost.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Seo from "../../../website/components/Seo.tsx";
import {
renderTemplateString,
SEOSection,
type SEOSection,
} from "../../../website/components/Seo.tsx";
import { BlogPostPage } from "../../types.ts";
import { AppContext } from "../../mod.ts";
import type { BlogPostPage } from "../../types.ts";
import type { AppContext } from "../../mod.ts";

export interface Props {
/** @title Data Source */
Expand Down
6 changes: 3 additions & 3 deletions blog/sections/Seo/SeoBlogPostListing.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Seo from "../../../website/components/Seo.tsx";
import {
renderTemplateString,
SEOSection,
type SEOSection,
} from "../../../website/components/Seo.tsx";
import { BlogPostListingPage } from "../../types.ts";
import { AppContext } from "../../mod.ts";
import type { BlogPostListingPage } from "../../types.ts";
import type { AppContext } from "../../mod.ts";

export interface Props {
/** @title Data Source */
Expand Down
2 changes: 1 addition & 1 deletion blog/sections/Template.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BlogPost } from "../types.ts";
import type { BlogPost } from "../types.ts";
import { CSS } from "../static/css.ts";

export interface Props {
Expand Down
4 changes: 2 additions & 2 deletions blog/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ImageWidget } from "../admin/widgets.ts";
import { PageInfo } from "../commerce/types.ts";
import type { ImageWidget } from "../admin/widgets.ts";
import type { PageInfo } from "../commerce/types.ts";

/**
* @titleBy name
Expand Down
2 changes: 1 addition & 1 deletion blog/utils/handlePosts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BlogPost, SortBy } from "../types.ts";
import type { BlogPost, SortBy } from "../types.ts";
import { VALID_SORT_ORDERS } from "./constants.ts";

/**
Expand Down
4 changes: 2 additions & 2 deletions blog/utils/records.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppContext } from "../mod.ts";
import { Resolvable } from "deco/engine/core/resolver.ts";
import type { Resolvable } from "@deco/deco";
import type { AppContext } from "../mod.ts";

export async function getRecordsByPath<T>(
ctx: AppContext,
Expand Down
8 changes: 4 additions & 4 deletions brand-assistant/loaders/assistant.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// deno-lint-ignore-file ban-unused-ignore no-explicit-any
import type { ManifestOf } from "deco/mod.ts";
import { logger } from "deco/observability/otel/config.ts";
import type { ManifestOf } from "@deco/deco/blocks";
import { logger } from "@deco/deco/o11y";
import { Tokens } from "../../ai-assistants/loaders/messages.ts";
import type { AIAssistant, Log, Prompt } from "../../ai-assistants/mod.ts";
import type { AssistantPersonalization } from "../../ai-assistants/types.ts";
import type { Category, Product, Suggestion } from "../../commerce/types.ts";
import type { Manifest as OpenAIManifest } from "../../openai/manifest.gen.ts";
import type vtex from "../../vtex/mod.ts";
import { Tokens } from "../../ai-assistants/loaders/messages.ts";
import type { AssistantPersonalization } from "../../ai-assistants/types.ts";
export interface Props {
name: string;
productsSample?: Product[] | null;
Expand Down
2 changes: 1 addition & 1 deletion brand-assistant/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { App, AppContext as AC } from "deco/mod.ts";
import type { App, AppContext as AC } from "@deco/deco";
import manifest, { Manifest } from "./manifest.gen.ts";
import { PreviewContainer } from "../utils/preview.tsx";

Expand Down
Loading

0 comments on commit 6aa83a0

Please sign in to comment.