Skip to content

Commit

Permalink
Merge pull request #90 from ajthinking/quick-wins
Browse files Browse the repository at this point in the history
Cleanups
  • Loading branch information
ajthinking authored Dec 20, 2023
2 parents a04efa8 + 8150394 commit 8b344eb
Show file tree
Hide file tree
Showing 38 changed files with 273 additions and 40 deletions.
7 changes: 5 additions & 2 deletions packages/docs/pages/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@
"getting-started": "Getting Started",
"customize": "Customize",
"contributing": "Contributing",
"nodes": {
"title": "Nodes"
"core-nodes": {
"title": "Core Nodes"
},
"nodejs-nodes": {
"title": "NodeJS Nodes"
},

"playground": {
Expand Down
1 change: 1 addition & 0 deletions packages/docs/pages/contributing.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Contributing 🙏
### Packages summary
* core - the computation part 🧠
* nodejs - NodeJS specifics 🛠️
* ui - the react component 📦
* docs - this website 📚

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
48 changes: 17 additions & 31 deletions packages/docs/pages/getting-started.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Installation
### Installation
```bash copy
yarn add @data-story/ui
```

## Usage

### With NodeJS server
### Basic Usage

```js copy
import { DataStory } from '@data-story/ui'
Expand All @@ -20,37 +18,25 @@ export default function Home() {
}
```

Next, start a server:
> With this basic usage, you will get all available nodes in `@data-story/core` and an inline JS server.
### Usage with NodeJS
First, also install:
```bash
npx @data-story/core server
yarn add @data-story/nodejs
```

That's it!

> With this installation, you will use all available nodes in `@data-story/core`.
### With JS server
First, create an app and provider:
```ts
const app = new Application();

const provider = {
register(app) {
app.addComputers([
Signal,
ConsoleLog
])
},
boot(app) {},
}

app.register(provider);

app.boot();
```
Pass this app into the `server` parameter along with a `JS` type:
Then, when using the component, instruct it to listen on a websocket:
```tsx
<DataStory
server={{ type: 'JS', app }}
server={{ type: 'SOCKET', url: 'ws://localhost:3100' }}
/>
```

Finally, start a server:
```bash
npx @data-story/nodejs server
```



6 changes: 6 additions & 0 deletions packages/docs/pages/nodejs-nodes/Placeholder.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

# Placeholder

import NodeDemo from '../../components/demos/NodeDemo'

<NodeDemo nodeName={'Comment'} />
53 changes: 53 additions & 0 deletions packages/hubspot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local
.env*.local
.env

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# datastory
.datastory/cache
.datastory/data
.datastory/executions
.datastory/local*.*

notes
notes.json
notes.js
notes.md

src/tinker.ts

dist
45 changes: 45 additions & 0 deletions packages/hubspot/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@data-story/hubspot",
"version": "0.0.71",
"main": "dist/index.js",
"type": "commonjs",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"watch:tsc": "tsc --watch",
"tinker": "npx ts-node ./src/tinker.ts",
"test": "yarn run -T vitest",
"build": "tsc",
"release": "yarn run -T release-it"
},
"release-it": {
"git": false,
"npm": {
"publish": false,
"skipChecks": true,
"versionArgs": [
"--workspaces-update=false"
]
}
},
"dependencies": {
"@data-story/core": "workspace:*",
"@types/node": "18.14.2",
"axios": "^1.3.4",
"dotenv": "^16.0.3",
"openai": "^3.2.1",
"ws": "^8.12.1"
},
"devDependencies": {
"@types/glob": "^8.1.0",
"@types/ws": "^8.5.4",
"nodemon": "^2.0.21",
"ts-node": "^10.9.1",
"typescript": "4.9.5",
"webpack": "^5.88.1",
"webpack-cli": "^5.1.4",
"webpack-shebang-plugin": "^1.1.8"
}
}
Empty file.
Empty file.
58 changes: 58 additions & 0 deletions packages/hubspot/src/computers/crm/entity/basicApi/getById.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { ComputerConfig } from '@data-story/core';
import { Configuration, OpenAIApi } from 'openai';

export const getById: ComputerConfig = {
name: 'getById',
inputs: ['input'],
outputs: ['entity'],
params: [
{
name: 'id',
label: 'Id',
help: 'The ID of the entity to retrieve.',
inputMode: {
type: 'Stringable',
multiline: true,
canInterpolate: true,
interpolate: true,
evaluations: [],
casts: [],
value: '',
},
alternativeInputModes: [],
},
],

category: 'API',

async *run({ input, output }) {

if(!process.env.OPEN_AI_SECRET) throw Error('OPEN_AI_SECRET env not set')

const openai = new OpenAIApi(
new Configuration({
apiKey: process.env.OPEN_AI_SECRET,
})
);

while(true) {
const [ incoming ] = input.pull(1)

const prompt = incoming.params.prompt as string

const completion = await openai.createCompletion({
model: 'text-davinci-003',
prompt,
temperature: 0,
max_tokens: 500,
top_p: 1,
frequency_penalty: 0.0,
presence_penalty: 0.0,
});

output.pushTo('completions', completion.data.choices)

yield;
}
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { getById } from './getById';
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions packages/hubspot/src/computers/crm/entity/getAll.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const getAll = () => {}
1 change: 1 addition & 0 deletions packages/hubspot/src/computers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { AskChatGpt } from './AskChatGpt'
22 changes: 22 additions & 0 deletions packages/hubspot/src/hubspotProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Application, ComputerConfig, ComputerFactory, ServiceProvider } from '@data-story/core';
import * as computerConfigs from './computers'

export const hubspotProvider: ServiceProvider = {
register: (app: Application) => {
const configs = Object.values(computerConfigs as {[key: string]: ComputerConfig})
app.addComputers(configs);
},

boot: (app: Application) => {}
}

// Contacts.getAll

// Contacts.getById
// Contacts.create
// Contacts.update
// Contacts.archive

// Contacts.batch.create
// Contacts.batch.update
// Contacts.batch.archive
1 change: 1 addition & 0 deletions packages/hubspot/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { hubspotProvider } from './hubspotProvider'
36 changes: 36 additions & 0 deletions packages/hubspot/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"compilerOptions": {
"target": "ES6",
"lib": [
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"outDir": "dist",
"esModuleInterop": true,
"module": "commonjs",
"sourceMap": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"incremental": true,
"noImplicitAny": true,
"types": [
"vitest/globals"
],
"declaration": true
},
"ts-node": {
"compilerOptions": {
"module": "CommonJS"
}
},
"include": [
"./src/**/*.ts"
],
"exclude": [
"./node_modules"
]
}
14 changes: 14 additions & 0 deletions packages/hubspot/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
globals: true,
coverage: {
all: true,
exclude: [
'./**/*.test.ts',
'./dist/**',
]
},
},
})
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,19 @@ export const NodeSettingsModal = () => {
<div className="flex items-start justify-between px-8 py-2 border-solid border-slate-200 rounded-t">
<input
{...form.register('label')}
className="pr-4 bg-white mt-4 flex flex-col align-center justify-center text-lg text-gray-400 font-bold tracking widest"
className="pr-4 mt-4 bg-white flex flex-col align-center justify-center text-lg text-gray-400 font-bold tracking widest"
/>
<div className="cursor-pointer p-1 ml-auto text-black float-right text-3xl leading-none font-semibold outline-none focus:outline-none" onClick={close}>
<span className="text-gray-500 h-6 w-6 text-2xl block outline-none focus:outline-none">
<div className="flex">
{form.getValues('label') !== 'Signal' && <div className="flex flex-col pr-4 my-2 mt-3 italic flex flex-col align-center justify-center text-sm text-gray-400 font-base tracking widest">
renamed from {node.data.computer}
</div>}
<div className="cursor-pointer p-1 ml-auto text-black float-right text-3xl leading-none font-semibold outline-none focus:outline-none" onClick={close}>
<span className="text-gray-500 h-6 w-6 text-2xl block outline-none focus:outline-none">
×
</span>
</div>
</div>
</span>
</div>
</div>
</div>
{/* ***** TABS ***** */}
<div className="mx-8 flex space-x-8 text-xxs uppercase text-gray-400">
{Object.keys(TAB_COMPONENTS).map((key) => (
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Visual Programming | Data Transformation | ETL | Process design
![ds_readme_gif](https://user-images.githubusercontent.com/3457668/229267838-b8dcc5cc-9639-4f95-962b-48eae8250d4e.gif)


<a href="https://datastory.dev/" target="_blank">Docs</a>
<a href="https://datastory.dev/docs" target="_blank">Docs</a>
| <a href="https://datastory.dev/playground" target="_blank">Playground</a>


Expand Down

0 comments on commit 8b344eb

Please sign in to comment.