Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 4 additions & 16 deletions .github/workflows/deno.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@ on:
branches: [main]

jobs:
backport:
runs-on: ubuntu-latest
steps:
- name: Setup repo
uses: actions/checkout@v4

- name: Install dependencies
run: npm install --ignore-scripts

- name: Run backporting
run: npm run backport

format-and-lint:
runs-on: ubuntu-latest
steps:
Expand All @@ -43,6 +31,9 @@ jobs:
- name: Lint
run: deno lint

- name: Check
run: deno check

test:
runs-on: ${{ matrix.os }} # runs a test on Ubuntu, Windows and macOS

Expand All @@ -58,8 +49,5 @@ jobs:
with:
deno-version: v2.x

- name: Cache Dependencies
run: deno task check

- name: Run Tests
run: deno task test
run: deno test
38 changes: 27 additions & 11 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
{
"name": "@grammyjs/stream",
"version": "2.0.0-beta.0",
"exports": "./src/mod.ts",
Comment on lines +2 to +4

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update the npm quickstart for JSR-only publishing

After replacing the npm package build with this JSR-only package definition, the command in README.md:10 still tells users to run npm i grammy @grammyjs/stream .... That installs the previously published npm package (the deleted manifest identifies it as v1.1.0 with a grammy ^1.39.0 peer) rather than this grammY 2-compatible release, potentially producing a peer conflict or silently giving users the old plugin. Update the quickstart to use the JSR installation workflow, or continue publishing a matching npm package.

Useful? React with 👍 / 👎.

"imports": {
"@grammyjs/grammy": "jsr:@grammyjs/grammy@^2.0.0-beta.7",
"@std/assert": "jsr:@std/assert@^1.0.16",
"@std/testing/bdd": "jsr:@std/testing@^1.0.16/bdd"
},
"license": "MIT",
"publish": {
"include": [
"LICENSE",
"README.md",
"src/**/*.ts"
]
},
"nodeModulesDir": "none",
"lock": false,
"minimumDependencyAge": {
"exclude": ["jsr:@grammyjs/grammy"]
},
"tasks": {
"check": "deno cache --allow-import --check=all src/mod.ts",
"build": "deno run --no-prompt --allow-import --allow-read=. --allow-write=. https://deno.land/x/deno2node@v1.16.0/src/cli.ts tsconfig.json",
"test": "deno test --allow-import test",
"ok": "deno fmt && deno lint && deno task test && deno task check",
"clean": "git clean -fX out"
"ok": "deno fmt --check && deno lint && deno check && deno test",
"publish:jsr": "deno publish",
"publish:jsr:dry-run": "deno publish --dry-run"
},
"exclude": [
"./node_modules/",
"./out/",
"./package-lock.json",
"./test/cov_profile"
],
"fmt": {
"indentWidth": 4,
"proseWrap": "preserve"
},
"lint": {
"rules": {
"include": ["no-top-level-await"]
}
}
}
48 changes: 0 additions & 48 deletions package.json

This file was deleted.

11 changes: 0 additions & 11 deletions src/deps.deno.ts

This file was deleted.

7 changes: 0 additions & 7 deletions src/deps.node.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/shim.node.ts

This file was deleted.

30 changes: 14 additions & 16 deletions src/stream.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import {
type ApiMethods,
type Context,
type InputRichMessage,
type Message,
type MessageEntity,
type MiddlewareFn,
type RawApi,
} from "./deps.deno.ts";
import type { Context, MiddlewareFn, RawApi } from "@grammyjs/grammy";
import type {
ApiMethods,
InputRichMessage,
Message,
MessageEntity,
} from "@grammyjs/grammy/types";

/**
* A draft piece is an object that describes a chunk of a message draft. It can
Expand Down Expand Up @@ -111,7 +109,7 @@ export interface StreamContextExtension {
"chat_id" | "text"
>,
signal?: AbortSignal,
): Promise<Message.TextMessage[]>;
): Promise<Message[]>;
/**
* Use this method to stream an iterator of rich markdown message pieces
* to a private chat. Returns a rich message object.
Expand Down Expand Up @@ -154,7 +152,7 @@ export interface StreamContextExtension {
>,
baseInputRichMessage?: Omit<InputRichMessage, "markdown" | "html">,
signal?: AbortSignal,
): Promise<Message.RichMessageMessage>;
): Promise<Message>;
/**
* Use this method to stream an iterator of rich HTML message pieces to
* a private chat. Returns a rich message object.
Expand Down Expand Up @@ -197,7 +195,7 @@ export interface StreamContextExtension {
>,
baseInputRichMessage?: Omit<InputRichMessage, "markdown" | "html">,
signal?: AbortSignal,
): Promise<Message.RichMessageMessage>;
): Promise<Message>;
};
/**
* Use this method to stream an iterator of message pieces to the current
Expand Down Expand Up @@ -275,7 +273,7 @@ export interface StreamContextExtension {
"chat_id" | "text"
>,
signal?: AbortSignal,
): Promise<Message.TextMessage[]>;
): Promise<Message[]>;
/**
* Use this method to stream an iterator of rich markdown message pieces to
* a private chat. Returns a rich message object.
Expand Down Expand Up @@ -319,7 +317,7 @@ export interface StreamContextExtension {
>,
baseInputRichMessage?: Omit<InputRichMessage, "markdown" | "html">,
signal?: AbortSignal,
): Promise<Message.RichMessageMessage>;
): Promise<Message>;
/**
* Use this method to stream an iterator of rich HTML message pieces to a
* private chat. Returns a rich message object.
Expand Down Expand Up @@ -363,7 +361,7 @@ export interface StreamContextExtension {
>,
baseInputRichMessage?: Omit<InputRichMessage, "markdown" | "html">,
signal?: AbortSignal,
): Promise<Message.RichMessageMessage>;
): Promise<Message>;
}

/** Collection of options for the stream plugin */
Expand Down Expand Up @@ -756,7 +754,7 @@ export function streamApi(
}
}

const messages: Message.TextMessage[] = [];
const messages: Message[] = [];
async function push() {
try {
while (!exhausted || complete.length > 0) {
Expand Down
2 changes: 0 additions & 2 deletions test/deps.test.ts

This file was deleted.

19 changes: 7 additions & 12 deletions test/stream.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import {
assert,
assertEquals,
assertMatch,
assertRejects,
describe,
it,
} from "./deps.test.ts";
import { Message, MessageEntity, RawApi } from "../src/deps.deno.ts";
import { MessageDraftPiece, streamApi } from "../src/stream.ts";
import { assert, assertEquals, assertMatch, assertRejects } from "@std/assert";
import { describe, it } from "@std/testing/bdd";
import type { RawApi } from "@grammyjs/grammy";
import type { Message, MessageEntity } from "@grammyjs/grammy/types";
import { type MessageDraftPiece, streamApi } from "../src/stream.ts";

interface RawApiStub {
drafts: Parameters<RawApi["sendMessageDraft"]>[0][];
Expand Down Expand Up @@ -91,7 +86,7 @@ function stubRawApi(options: {
if (blockMessage) await messageLock.promise;
const message_id = stub.messages.length;
stub.messages.push(record(params));
return { message_id } as Message.TextMessage;
return { message_id } as Message;
},
async sendRichMessageDraft(params) {
if (draftError) throw draftError;
Expand All @@ -104,7 +99,7 @@ function stubRawApi(options: {
if (blockMessage) await messageLock.promise;
const message_id = stub.richMessages.length;
stub.richMessages.push(record(params));
return { message_id } as Message.RichMessageMessage;
return { message_id } as Message;
},
} as RawApi,
};
Expand Down
23 changes: 0 additions & 23 deletions tsconfig.json

This file was deleted.

Loading