-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript support? #11
Comments
Hi @webriq - this is something the team is working on with the next major version, but no precise ETA yet |
Hey there, just bumping this with the same question– any ETA now that its been a few weeks? |
This should work as a workaround: // types/swell-node.d.ts
import EventEmitter from "node:events"
declare module 'swell-node' {
type Callback<D, T> = (error: unknown, data?: D, response?: T) => void | Promise<void>
interface SwellNodeClientParams {
clientId?: string,
clientKey?: string,
host?: string,
port?: string,
verifyCert?: boolean,
version?: string,
session?: any,
route?: any,
timeout?: number,
routeClientId?: string,
cache?: boolean,
debug?: boolean,
}
interface SwellNodeClient extends EventEmitter {
params: any
server: any
cache: any
authed: boolean
new (clientId: string, clientKey: string, options?: SwellNodeClientParams, callback?: (arg: this) => void | Promise<void>): SwellNodeClient
static create (clientId: string, clientKey: string, options?: SwellNodeClientParams, callback?: (arg: this) => void | Promise<void>): SwellNodeClient
init(clientId: string, clientKey: string, options?: SwellNodeClientParams): SwellNodeClient
connect(callback: (arg: this) => void | Promise<void>): void
request<T = any>(method: string, url: string, data?: any): Promise<T>
get<T = any>(url: string, data?: any): Promise<T>
post<T = any>(url: string, data?: any): Promise<T>
put<T = any>(url: string, data?: any): Promise<T>
delete<T = any>(url: string, data?: any): Promise<T>
}
export function createClient(
clientId: string,
clientKey: string,
options?: SwellNodeClientParams,
callback?: (arg: this) => void
): SwellNodeClient
} usage: import { createClient } from 'swell-node'
const swell = createClient() |
For anyone getting an error similar to I had to move the // types/index.d.ts
declare module "swell-node" {
import EventEmitter from "node:events";
type Callback<D, T> = (
error: unknown,
data?: D,
response?: T
) => void | Promise<void>;
interface SwellNodeClientParams {
clientId?: string;
clientKey?: string;
host?: string;
port?: string;
verifyCert?: boolean;
version?: string;
session?: any;
route?: any;
timeout?: number;
routeClientId?: string;
cache?: boolean;
debug?: boolean;
}
interface SwellNodeClient extends EventEmitter {
params: any;
server: any;
cache: any;
authed: boolean;
new (
clientId: string,
clientKey: string,
options?: SwellNodeClientParams,
callback?: (arg: this) => void | Promise<void>
): SwellNodeClient;
create(
clientId: string,
clientKey: string,
options?: SwellNodeClientParams,
callback?: (arg: this) => void | Promise<void>
): SwellNodeClient;
init(
clientId: string,
clientKey: string,
options?: SwellNodeClientParams
): SwellNodeClient;
connect(callback: (arg: this) => void | Promise<void>): void;
request<T = any>(method: string, url: string, data?: any): Promise<T>;
get<T = any>(url: string, data?: any): Promise<T>;
post<T = any>(url: string, data?: any): Promise<T>;
put<T = any>(url: string, data?: any): Promise<T>;
delete<T = any>(url: string, data?: any): Promise<T>;
}
export function createClient(
clientId: string,
clientKey: string,
options?: SwellNodeClientParams,
callback?: (arg: this) => void
): SwellNodeClient;
} |
What's up with swell? Are they doing ok? Every time I find a thread with Swell saying they are working on something, there is no follow up several months later. Is typescript support really an "enhancement" in almost 2023? |
A lot of competing priorities, but this one is now being worked on actively! |
To implement the above while using the // ...
export function init(
clientId: string,
clientKey: string,
options?: SwellNodeClientParams
): SwellNodeClient;
// ... |
Anything happening here? It's been months... |
Its been a few more months now... Pleaseeeeee give us TS support |
We started developing a new version of Swell.js with typescript late last year, but had to shift priorities. There were a bunch of improvements in the process however including full TS support using GraphQL. No ETA as of right now |
Thats a shame! We're looking for a tool to outsource or cart experience, but not having TS is a deal breaker. |
It has really caused a lot of headaches not having typescript support. Especially since the data models vary between front end and back end. I understand swell has been working on other features like an app marketplace but for those of us trying to run a business on swell, the core infrastructure should really be a priority. Including API reliability, speed, typescript support etc. |
I was considering to guard the api calls with Zod, but it's just too much of a hassle, unfortunately. The backend API doesn't support GQL neither, right? |
Is there any progress at all - and an ETA - on typescript support for swell-node ? It really is a basic requirement. Thanks |
It’s not a focus internally right now as the SDKs need to be refactored generally |
And there's nothing internally you use that could be released, even with a warning that it's not complete etc? Even just as a base to work from? Thanks Eric. |
Is this library dead or something? Last comment on this issue was around a year ago and apparently Typescript support is not a major priority in an age where TS support is almost mandatory for the NextJS/Vercel metagame. "Not a focus internally" is a bad business move because poor DX means I find another library/service that gives me the safety I want without a workaround. |
This is not in wide use currently as most developers have preferred to build their own HTTP handlers. We even started using a different repo for internal services: https://github.com/swellstores/swell-node-http I do think we'll eventually get back to building a first-class backend node library, but it's not critical right now since there are many other ways to work with the Swell API. |
Just a single data point, but FWIW It's the reason why we dropped swell altogether. |
You do know the trend right now is to fetch on the server then pass to client right? I don't know what could be more critical for increasing usage of your platform other than to work on a client using preferred way of fetching data with javascript right now. I'll be dropping this too as it will hard to debug later if the platform API changes due to a lack of type safety. |
Providing a working typescript library and improving the API speed would
make swell pretty great. The team seems to be focused on building out an
app ecosystem but the core product needs a lot of work. I’m not going to
pretend I understand the incentives they are dealing with as a startup, but
as a user I really wish they would spend six months with the whole team
focused on improving the core product.
…On Wed, Oct 2, 2024 at 5:27 AM vaneworks ***@***.***> wrote:
You do know the trend right now is to fetch on the server then pass to
client right? I don't know what could be more critical for increasing usage
of your platform other than to work on a client using preferred way of
fetching data with javascript right now.
I'll be dropping this too as it will hard to debug later if the platform
API changes due to a lack of type safety.
—
Reply to this email directly, view it on GitHub
<#11 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAYFFLH5JYINFGOVMJX7FS3ZZPDCRAVCNFSM6AAAAABPGUYYMGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBYGMYDSNBXGQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@MoSattler @vaneworks @vettloffah We just now updated the implementation of this library to use HTTP instead of our TCP wire protocol (essentially swapped with https://github.com/swellstores/swell-node-http). The library itself now uses Typescript, but if you're looking for TS types on API results (models) then it's not quite there yet. The issue is that each store can have its own models so we need to implement a type generation step, which is tricky and wouldn't be internally prioritized for some time. |
Hey @ericingram, thanks for the update! Unfortunately, we had to move away from Swell due to the lack of TypeScript support, which was a key requirement for us. |
Thanks for the update. That’s definitely an improvement.
Ideally swell would offer a typescript definition generator via a CLI
command that grabs the model definition JSON from the store then uses it to
generate the ts definition file for it. This is how the typescript support
works for prismic, and I believe other platforms as well.
Then if the user updates the model, they just run the CLI command to
re-generate the type file.
…On Thu, Oct 24, 2024 at 7:14 AM Mo Sattler ***@***.***> wrote:
Hey @ericingram <https://github.com/ericingram>, thanks for the update!
Unfortunately, we had to move away from Swell due to the lack of
TypeScript support, which was a key requirement for us.
—
Reply to this email directly, view it on GitHub
<#11 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAYFFLG5TT5UXU4HWEP23O3Z5DQCXAVCNFSM6AAAAABPGUYYMGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMZVGEZDENJWGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@vettloffah makes sense, that's what we'll do. We actually had a working version of TS typegen internally a while ago but it never got released. I'll look to see if it's something we could add soon. |
No description provided.
The text was updated successfully, but these errors were encountered: