File tree Expand file tree Collapse file tree 8 files changed +58
-11
lines changed
Expand file tree Collapse file tree 8 files changed +58
-11
lines changed Original file line number Diff line number Diff line change 1+ default :
2+ make -j2 server delayed-open
3+
4+ server :
5+ cd ../.. && python -m http.server
6+
7+ delayed-open :
8+ sleep 1 && xdg-open http://localhost:8000/examples/browser/index.html
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html >
3+ < body >
4+ < h1 > Load SDK in browser</ h1 >
5+ < script type ="importmap ">
6+ {
7+ "imports" : {
8+ "@rails/actioncable" : "/node_modules/@rails/actioncable/app/assets/javascripts/actioncable.esm.js"
9+ }
10+ }
11+ </ script >
12+ < script type ="module ">
13+ import { createFrontendClient } from "/dist/browser/browser/index.js"
14+ const client = createFrontendClient ( )
15+ const p = document . createElement ( "p" )
16+ p . textContent = "sdk version: " + client . version
17+ document . body . appendChild ( p )
18+ </ script >
19+ </ body >
20+ </ html >
Original file line number Diff line number Diff line change 3535 "access" : " public"
3636 },
3737 "scripts" : {
38- "prepublish" : " rm -rf dist && pnpm run build" ,
39- "build" : " pnpm run build:node && pnpm run build:browser" ,
38+ "prepublish" : " pnpm run build" ,
39+ "prebuild" : " node scripts/updateVersion.mjs" ,
40+ "build" : " rm -rf dist && pnpm run prebuild && pnpm run build:node && pnpm run build:browser" ,
4041 "build:node" : " tsc -p tsconfig.node.json" ,
4142 "build:browser" : " tsc -p tsconfig.browser.json" ,
4243 "test" : " jest" ,
Original file line number Diff line number Diff line change 1+ import fs from "fs" ;
2+ import cp from "child_process" ;
3+
4+ if ( ! process . env . CI ) {
5+ // make sure people building locally automatically do not track changes to version file
6+ cp . execSync ( "git update-index --skip-worktree src/version.ts" ) ;
7+ }
8+
9+ const pkg = JSON . parse ( String ( fs . readFileSync ( "./package.json" , "utf8" ) ) )
10+ const versionTsPath = "./src/version.ts" ;
11+ const data = String ( fs . readFileSync ( versionTsPath , "utf8" ) ) ;
12+ const newData = data . replace ( / " ( .* ) " / , `"${ pkg . version } "` ) ;
13+ fs . writeFileSync ( versionTsPath , newData ) ;
Original file line number Diff line number Diff line change 1- import { AsyncResponseManager } from "../shared/async" ;
2- import type { AsyncResponseManagerOpts } from "../shared/async" ;
1+ import { AsyncResponseManager } from "../shared/async.js " ;
2+ import type { AsyncResponseManagerOpts } from "../shared/async.js " ;
33
44export type BrowserAsyncResponseManagerOpts = {
55 apiHost : string ;
Original file line number Diff line number Diff line change 44// operations, like connecting accounts via Pipedream Connect. See the server/
55// directory for the server client.
66
7- import { BrowserAsyncResponseManager } from "./async" ;
7+ import { BrowserAsyncResponseManager } from "./async.js " ;
88import {
99 AccountsRequestResponse ,
1010 BaseClient ,
1111 GetAccountOpts ,
1212 type ConnectTokenResponse ,
13- } from "../shared" ;
14- export type * from "../shared" ;
13+ } from "../shared/index.js " ;
14+ export type * from "../shared/index.js " ;
1515
1616/**
1717 * Options for creating a browser-side client. This is used to configure the
Original file line number Diff line number Diff line change 11// This code is meant to be shared between the browser and server.
2- import { AsyncResponseManager } from "./async" ;
2+ import { AsyncResponseManager } from "./async.js " ;
33import type {
44 AsyncResponse , AsyncErrorResponse ,
5- } from "./async" ;
6- import type { V1Component } from "./component" ;
7- export * from "./component" ;
5+ } from "./async.js" ;
6+ import type { V1Component } from "./component.js" ;
7+ export * from "./component.js" ;
8+ import { version as sdkVersion } from "../version.js" ;
89
910type RequestInit = globalThis . RequestInit ;
1011
@@ -290,6 +291,7 @@ export interface AsyncRequestOptions extends RequestOptions {
290291 * A client for interacting with the Pipedream Connect API on the server-side.
291292 */
292293export abstract class BaseClient {
294+ version = sdkVersion ;
293295 protected apiHost : string ;
294296 protected abstract asyncResponseManager : AsyncResponseManager ;
295297 protected readonly baseApiUrl : string ;
@@ -351,6 +353,7 @@ export abstract class BaseClient {
351353
352354 const headers : Record < string , string > = {
353355 ...customHeaders ,
356+ "X-PD-SDK-Version" : sdkVersion ,
354357 "X-PD-Environment" : this . environment ,
355358 } ;
356359
Original file line number Diff line number Diff line change 1+ // DO NOT EDIT, SET AT BUILD TIME
2+ export const version = "0.0.0"
You can’t perform that action at this time.
0 commit comments