quote0 1.0.0-alpha.0 → 1.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/dist/api/index.d.mts +98 -0
- package/dist/api/index.d.mts.map +1 -0
- package/dist/api/index.mjs +2 -0
- package/dist/api/index.mjs.map +1 -0
- package/dist/device-D31Czv7n.mjs +2 -0
- package/dist/device-D31Czv7n.mjs.map +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +6 -5
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Quote/0 SDK & CLI
|
|
2
|
+
|
|
3
|
+
TypeScript SDK and CLI for Quote/0.
|
|
4
|
+
|
|
5
|
+
> [!CAUTION]
|
|
6
|
+
> `quote0` is currently in early development stage. The API is not stable and may change without notice. Use at your own risk.
|
|
7
|
+
|
|
8
|
+
# Getting Started
|
|
9
|
+
|
|
10
|
+
## Use as CLI
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install -g quote0@alpha
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Then, call `quote0` in your terminal to see the usage.
|
|
17
|
+
|
|
18
|
+
## Use as SDK
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm install quote0@alpha
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import Quote0 from 'quote0'
|
|
26
|
+
|
|
27
|
+
const quote0 = new Quote0({
|
|
28
|
+
apiKey: 'dot_app_ABCD1234....EFGH5678',
|
|
29
|
+
})
|
|
30
|
+
```
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
//#region src/api/base.d.ts
|
|
2
|
+
interface BaseClientArgs {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
}
|
|
5
|
+
declare class BaseClient {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
constructor({
|
|
8
|
+
apiKey
|
|
9
|
+
}: BaseClientArgs);
|
|
10
|
+
static readonly API_ENDPOINT = "https://dot.mindreset.tech/api";
|
|
11
|
+
protected readonly apiEndpoint = "https://dot.mindreset.tech/api";
|
|
12
|
+
static readonly DISPLAY: {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
};
|
|
16
|
+
readonly display: {
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
};
|
|
20
|
+
protected composeApiUrl(path: string): string;
|
|
21
|
+
protected fetchApi(path: string, options?: RequestInit): Promise<unknown>;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/api/modules/content.d.ts
|
|
25
|
+
declare class ContentModule extends BaseClient {
|
|
26
|
+
next({
|
|
27
|
+
deviceId
|
|
28
|
+
}: {
|
|
29
|
+
deviceId: string;
|
|
30
|
+
}): Promise<{
|
|
31
|
+
code: number;
|
|
32
|
+
message: string;
|
|
33
|
+
}>;
|
|
34
|
+
pushImage({
|
|
35
|
+
deviceId
|
|
36
|
+
}: {
|
|
37
|
+
deviceId: string;
|
|
38
|
+
}, options: {
|
|
39
|
+
refreshNow?: boolean;
|
|
40
|
+
image: string;
|
|
41
|
+
link?: string;
|
|
42
|
+
border?: 0 | 1;
|
|
43
|
+
ditherType?: 'DIFFUSION' | 'ORDERED' | 'NONE';
|
|
44
|
+
ditherKernel?: 'THRESHOLD' | 'ATKINSON' | 'BURKES' | 'FLOYD_STEINBERG' | 'SIERRA2' | 'STUCKI' | 'JARVIS_JUDICE_NINKE' | 'DIFFUSION_ROW' | 'DIFFUSION_COLUMN' | 'DIFFUSION_2D';
|
|
45
|
+
taskKey?: string;
|
|
46
|
+
}): Promise<{
|
|
47
|
+
code: number;
|
|
48
|
+
message: string;
|
|
49
|
+
}>;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/api/modules/device.d.ts
|
|
53
|
+
declare class DeviceModule extends BaseClient {
|
|
54
|
+
list(): Promise<{
|
|
55
|
+
id: string;
|
|
56
|
+
series: string;
|
|
57
|
+
model: string;
|
|
58
|
+
edition: 1 | 2;
|
|
59
|
+
}[]>;
|
|
60
|
+
status({
|
|
61
|
+
deviceId
|
|
62
|
+
}: {
|
|
63
|
+
deviceId: string;
|
|
64
|
+
}): Promise<{
|
|
65
|
+
deviceId: string;
|
|
66
|
+
alias: string | null;
|
|
67
|
+
location: string | null;
|
|
68
|
+
status: {
|
|
69
|
+
version: string;
|
|
70
|
+
current: string;
|
|
71
|
+
description: string;
|
|
72
|
+
battery: string;
|
|
73
|
+
wifi: string;
|
|
74
|
+
};
|
|
75
|
+
renderInfo: {
|
|
76
|
+
last: string;
|
|
77
|
+
current: {
|
|
78
|
+
rotated: boolean;
|
|
79
|
+
border: number;
|
|
80
|
+
image: string[];
|
|
81
|
+
};
|
|
82
|
+
next: {
|
|
83
|
+
battery: string;
|
|
84
|
+
power: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
}>;
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/api/index.d.ts
|
|
91
|
+
declare class Quote0 extends BaseClient {
|
|
92
|
+
device: DeviceModule;
|
|
93
|
+
content: ContentModule;
|
|
94
|
+
constructor(args: BaseClientArgs);
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
export { Quote0 as default };
|
|
98
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/api/base.ts","../../src/api/modules/content.ts","../../src/api/modules/device.ts","../../src/api/index.ts"],"mappings":";UAAiB,cAAA;EACf,MAAA;AAAA;AAAA,cAGI,UAAA;EACJ,MAAA;;IACc;EAAA,GAAU,cAAA;EAAA,gBAIR,YAAA;EAAA,mBACG,WAAA;EAAA,gBAEH,OAAA;;;;WACP,OAAA;;;;YAEC,aAAA,CAAc,IAAA;EAAA,UAMR,QAAA,CAAS,IAAA,UAAc,OAAA,GAAU,WAAA,GAAW,OAAA;AAAA;;;cCpBxD,aAAA,SAAsB,UAAA;EACpB,IAAA,CAAA;IAAO;EAAA;IAAc,QAAA;EAAA,IAAkB,OAAA;;;;EAWvC,SAAA,CAAA;IACF;EAAA;IAAc,QAAA;EAAA,GAChB,OAAA;IACE,UAAA;IACA,KAAA;IACA,IAAA;IACA,MAAA;IACA,UAAA;IACA,YAAA;IAWA,OAAA;EAAA,IACD,OAAA;;;;;;;cChCC,YAAA,SAAqB,UAAA;EACnB,IAAA,CAAA,GAAI,OAAA;;;;;;EAWJ,MAAA,CAAA;IAAS;EAAA;IAAc,QAAA;EAAA,IAAkB,OAAA;;;;;MAQzC,OAAA;MACA,OAAA;MACA,WAAA;MACA,OAAA;MACA,IAAA;IAAA;;MAGA,IAAA;MACA,OAAA;QACE,OAAA;QACA,MAAA;QACA,KAAA;MAAA;MAEF,IAAA;QACE,OAAA;QACA,KAAA;MAAA;IAAA;EAAA;AAAA;;;cCjCJ,MAAA,SAAe,UAAA;EACnB,MAAA,EAAQ,YAAA;EACR,OAAA,EAAS,aAAA;cAEG,IAAA,EAAM,cAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/api/index.ts"],"sourcesContent":["import BaseClient, { type BaseClientArgs } from './base'\nimport ContentModule from './modules/content'\nimport DeviceModule from './modules/device'\n\nclass Quote0 extends BaseClient {\n device: DeviceModule\n content: ContentModule\n\n constructor(args: BaseClientArgs) {\n super(args)\n\n this.device = new DeviceModule(args)\n this.content = new ContentModule(args)\n }\n}\n\nexport default Quote0\n"],"mappings":"yDAIA,IAAM,EAAN,cAAqB,CAAW,CAC9B,OACA,QAEA,YAAY,EAAsB,CAChC,MAAM,EAAK,CAEX,KAAK,OAAS,IAAI,EAAa,EAAK,CACpC,KAAK,QAAU,IAAI,EAAc,EAAK"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=class e{apiKey;constructor({apiKey:e}){this.apiKey=e}static API_ENDPOINT=`https://dot.mindreset.tech/api`;apiEndpoint=e.API_ENDPOINT;static DISPLAY={width:296,height:152};display=e.DISPLAY;composeApiUrl(e){return e.startsWith(`/`)?this.apiEndpoint+e:this.apiEndpoint+`/`+e}async fetchApi(e,t){let n=this.composeApiUrl(e),r=Object.assign({method:`GET`,headers:{"Content-Type":`application/json`,Authorization:`Bearer `+this.apiKey}},t??{});try{let e=await fetch(n,r);if(e.ok)return await e.json();throw Error(`API request failed with status ${e.status}: ${e.statusText}`)}catch(e){throw e}}},t=class extends e{async next({deviceId:e}){return await this.fetchApi(`/authV2/open/device/${e}/next`,{method:`POST`})}async pushImage({deviceId:e},t){return await this.fetchApi(`/authV2/open/device/${e}/image`,{method:`POST`,body:JSON.stringify(t)})}},n=class extends e{async list(){return await this.fetchApi(`/authV2/open/devices`)}async status({deviceId:e}){return await this.fetchApi(`/authV2/open/device/${e}/status`)}};export{t as n,e as r,n as t};
|
|
2
|
+
//# sourceMappingURL=device-D31Czv7n.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-D31Czv7n.mjs","names":[],"sources":["../src/api/base.ts","../src/api/modules/content.ts","../src/api/modules/device.ts"],"sourcesContent":["export interface BaseClientArgs {\n apiKey: string\n}\n\nclass BaseClient {\n apiKey: string\n constructor({ apiKey }: BaseClientArgs) {\n this.apiKey = apiKey\n }\n\n static readonly API_ENDPOINT = 'https://dot.mindreset.tech/api'\n protected readonly apiEndpoint = BaseClient.API_ENDPOINT\n\n static readonly DISPLAY = { width: 296, height: 152 }\n readonly display = BaseClient.DISPLAY\n\n protected composeApiUrl(path: string) {\n return path.startsWith('/')\n ? this.apiEndpoint + path\n : this.apiEndpoint + '/' + path\n }\n\n protected async fetchApi(path: string, options?: RequestInit) {\n const url = this.composeApiUrl(path)\n const mergedOptions = Object.assign(\n {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: 'Bearer ' + this.apiKey,\n },\n },\n options ?? {},\n )\n\n try {\n const response = await fetch(url, mergedOptions)\n\n if (response.ok) {\n return await response.json()\n } else {\n throw new Error(\n `API request failed with status ${response.status}: ${response.statusText}`,\n )\n }\n } catch (error) {\n throw error\n }\n }\n}\n\nexport default BaseClient\n","import BaseClient from '../base'\n\nclass ContentModule extends BaseClient {\n async next({ deviceId }: { deviceId: string }) {\n const response = (await this.fetchApi(\n `/authV2/open/device/${deviceId}/next`,\n {\n method: 'POST',\n },\n )) as { code: number; message: string }\n\n return response\n }\n\n async pushImage(\n { deviceId }: { deviceId: string },\n options: {\n refreshNow?: boolean\n image: string\n link?: string\n border?: 0 | 1\n ditherType?: 'DIFFUSION' | 'ORDERED' | 'NONE'\n ditherKernel?:\n | 'THRESHOLD'\n | 'ATKINSON'\n | 'BURKES'\n | 'FLOYD_STEINBERG'\n | 'SIERRA2'\n | 'STUCKI'\n | 'JARVIS_JUDICE_NINKE'\n | 'DIFFUSION_ROW'\n | 'DIFFUSION_COLUMN'\n | 'DIFFUSION_2D'\n taskKey?: string\n },\n ) {\n const response = (await this.fetchApi(\n `/authV2/open/device/${deviceId}/image`,\n { method: 'POST', body: JSON.stringify(options) },\n )) as { code: number; message: string }\n\n return response\n }\n}\n\nexport default ContentModule\n","import BaseClient from '../base'\n\nclass DeviceModule extends BaseClient {\n async list() {\n const response = (await this.fetchApi(`/authV2/open/devices`)) as {\n id: string\n series: string\n model: string\n edition: 1 | 2\n }[]\n\n return response\n }\n\n async status({ deviceId }: { deviceId: string }) {\n const response = (await this.fetchApi(\n `/authV2/open/device/${deviceId}/status`,\n )) as {\n deviceId: string\n alias: string | null\n location: string | null\n status: {\n version: string\n current: string\n description: string\n battery: string\n wifi: string\n }\n renderInfo: {\n last: string\n current: {\n rotated: boolean\n border: number\n image: string[]\n }\n next: {\n battery: string\n power: string\n }\n }\n }\n\n return response\n }\n}\n\nexport default DeviceModule\n"],"mappings":"AAIA,IAAM,EAAN,MAAM,CAAW,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/index.mjs";import t from"yargs";import{hideBin as n}from"yargs/helpers";import{Box as r,Text as i,render as a}from"ink";import{Fragment as o,jsx as s,jsxs as c}from"react/jsx-runtime";import l from"react";import{UncontrolledTextInput as u}from"ink-text-input";import d from"conf";import{parse as f,stringify as p}from"yaml";function m({...e}){return s(r,{borderStyle:`round`,flexDirection:`column`,...e})}const h={border:(...e)=>({borderTop:e.includes(`top`),borderRight:e.includes(`right`),borderBottom:e.includes(`bottom`),borderLeft:e.includes(`left`)})};function g({isLast:e,...t}){return s(r,{...e!==!0&&{borderStyle:`single`,borderDimColor:!0,...h.border(`bottom`)},paddingX:1,flexDirection:`column`,...t})}function _({children:e}){let t=l.Children.toArray(e);return s(o,{children:[...t.map((e,n)=>s(g,{isLast:n===t.length-1,children:e}))]})}function v({leading:e,children:t,trailing:n,...a}){return c(r,{justifyContent:`space-between`,...a,children:[c(r,{children:[e&&c(o,{children:[e,s(i,{children:` `})]}),t]}),s(r,{children:n})]})}const y=new d({projectName:`quote0`,fileExtension:`yaml`,serialize:p,deserialize:f}),b=new e({apiKey:y.get(`apiKey`,``)});t(n(process.argv)).scriptName(`quote0`).command(`auth`,`Enter and save API key`,e=>e,async e=>{a(s(()=>{let[e,t]=l.useState(!1);return s(m,{children:c(_,{children:[s(v,{children:s(i,{children:`Authentication`})}),e?s(i,{dimColor:!0,children:`API key saved`}):s(u,{initialValue:y.get(`apiKey`,``),onSubmit:e=>{e.length===0?(y.delete(`apiKey`),t(!0)):(y.set(`apiKey`,e),t(!0))},placeholder:`API key…`,mask:`*`})]})})},{}))}).command(`device`,`Manage devices`,e=>e.command(`list`,`List all devices`,e=>e,async e=>{try{let e=await b.device.list();a(s(()=>s(m,{children:c(_,{children:[s(v,{trailing:c(i,{dimColor:!0,children:[e.length,`/`,e.length]}),children:s(i,{children:`Devices`})}),[...e.length===0?[s(v,{children:s(i,{dimColor:!0,children:`No devices found`})})]:e.map(e=>c(r,{flexDirection:`column`,children:[s(v,{trailing:s(i,{children:e.id}),children:s(i,{dimColor:!0,children:`ID`})}),s(v,{trailing:s(i,{children:e.series}),children:s(i,{dimColor:!0,children:`Series`})}),s(v,{trailing:s(i,{children:e.model}),children:s(i,{dimColor:!0,children:`Model`})}),s(v,{trailing:s(i,{children:e.edition}),children:s(i,{dimColor:!0,children:`Edition`})})]}))]]})}),{}))}catch(e){console.error(e)}}).command(`status <device-id>`,`Check device status`,e=>e.positional(`device-id`,{describe:`Device ID to check status for`,type:`string`}),async e=>{try{let t=await b.device.status({deviceId:e.deviceId});a(s(m,{children:c(_,{children:[s(v,{trailing:c(i,{children:[s(i,{dimColor:!0,children:`Device ID: `}),t.deviceId]}),children:c(r,{gap:1,children:[s(i,{children:t.alias}),s(i,{dimColor:!0,children:t.location}),s(i,{dimColor:!0,children:t.status.battery})]})}),s(r,{flexDirection:`column`,children:[...[[`Status`,t.status.current],[`Last Render`,t.renderInfo.last],[`Next Render (Battery)`,t.renderInfo.next.battery],[`Next Render (Power)`,t.renderInfo.next.power],[`Current Images`,t.renderInfo.current.image.length],[`Version`,c(i,{children:[s(i,{dimColor:!0,children:`v`}),t.status.version]})]].map(([e,t])=>s(v,{trailing:s(i,{children:t}),children:s(i,{dimColor:!0,children:e})}))]})]})}))}catch(e){console.error(e)}}),async e=>{}).command(`content`,`Manage content`,e=>e.command(`next <device-id>`,`Switch to next content`,e=>e.positional(`device-id`,{describe:`Device ID to switch content for`,type:`string`}),async e=>{try{let t=await b.content.next({deviceId:e.deviceId});a(s(m,{children:c(_,{children:[s(i,{children:`Next Content`}),s(i,{children:t.message})]})}))}catch(e){console.error(e)}}).command(`image`,`Push an image to device`,e=>e,async e=>{a(s(()=>s(m,{children:c(_,{children:[s(i,{children:`Progress`}),s(i,{dimColor:!0,children:`To be implemented`})]})}),{}))}),async e=>{}).demandCommand(1,`Please specify a command`).strict().parse();export{};
|
|
3
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/components/Container.tsx","../src/utils/ink-props-helpers.ts","../src/components/Section.tsx","../src/components/ListItem.tsx","../package.json","../src/config.ts","../src/index.tsx"],"sourcesContent":["import { Box } from 'ink'\nimport type React from 'react'\n\nexport default function Container({\n ...props\n}: React.ComponentProps<typeof Box>) {\n return <Box borderStyle=\"round\" flexDirection=\"column\" {...props} />\n}\n","const inkPropsHelpers = {\n border: (...directions: ('top' | 'right' | 'bottom' | 'left')[]) => {\n return {\n borderTop: directions.includes('top'),\n borderRight: directions.includes('right'),\n borderBottom: directions.includes('bottom'),\n borderLeft: directions.includes('left'),\n }\n },\n}\n\nexport default inkPropsHelpers\n","import { Box } from 'ink'\nimport { inkPropsHelpers } from '../utils'\nimport React from 'react'\n\nfunction Section({\n isLast,\n ...props\n}: React.ComponentProps<typeof Box> & { isLast?: boolean }) {\n return (\n <Box\n {...(isLast !== true && {\n borderStyle: 'single',\n borderDimColor: true,\n ...inkPropsHelpers.border('bottom'),\n })}\n paddingX={1}\n flexDirection=\"column\"\n {...props}\n />\n )\n}\n\nfunction SectionList({ children }: { children: React.ReactNode }) {\n const arrayChildren = React.Children.toArray(children)\n return (\n <>\n {...arrayChildren.map((child, i) => (\n <Section isLast={i === arrayChildren.length - 1}>{child}</Section>\n ))}\n </>\n )\n}\n\nexport { Section, SectionList }\nexport default Section\n","import { Box, Text } from 'ink'\n\nexport default function ListItem({\n leading,\n children,\n trailing,\n ...props\n}: React.ComponentProps<typeof Box> & {\n leading?: React.ReactNode\n children?: React.ReactNode\n trailing?: React.ReactNode\n}) {\n return (\n <Box justifyContent=\"space-between\" {...props}>\n <Box>\n {leading && (\n <>\n {leading}\n <Text> </Text>\n </>\n )}\n {children}\n </Box>\n <Box>{trailing}</Box>\n </Box>\n )\n}\n","","import Conf from 'conf'\nimport { parse, stringify } from 'yaml'\nimport { name } from '../package.json'\n\nconst config = new Conf({\n projectName: name,\n fileExtension: 'yaml',\n serialize: stringify,\n deserialize: parse,\n})\n\nexport default config\n","#!/usr/bin/env node\n\nimport yargs from 'yargs'\nimport { hideBin } from 'yargs/helpers'\nimport { Box, render, Text } from 'ink'\nimport Quote0 from './api'\nimport Container from './components/Container'\nimport { SectionList } from './components/Section'\nimport ListItem from './components/ListItem'\nimport { UncontrolledTextInput } from 'ink-text-input'\nimport config from './config'\nimport React from 'react'\n\nconst quote0 = new Quote0({\n apiKey: config.get('apiKey', ''),\n})\n\nyargs(hideBin(process.argv))\n .scriptName('quote0')\n .command(\n 'auth',\n 'Enter and save API key',\n yargs => yargs,\n async argv => {\n const Main = () => {\n const [submitted, setSubmitted] = React.useState(false)\n\n return (\n <Container>\n <SectionList>\n <ListItem>\n <Text>Authentication</Text>\n </ListItem>\n {!submitted ? (\n <UncontrolledTextInput\n initialValue={config.get('apiKey', '')}\n onSubmit={v => {\n if (v.length === 0) {\n config.delete('apiKey')\n setSubmitted(true)\n } else {\n config.set('apiKey', v)\n setSubmitted(true)\n }\n }}\n placeholder=\"API key…\"\n mask=\"*\"\n />\n ) : (\n <Text dimColor>API key saved</Text>\n )}\n </SectionList>\n </Container>\n )\n }\n\n render(<Main />)\n },\n )\n .command(\n 'device',\n 'Manage devices',\n yargs =>\n yargs\n .command(\n 'list',\n 'List all devices',\n yargs => yargs,\n async argv => {\n try {\n const devices = await quote0.device.list()\n\n const Main = () => (\n <Container>\n <SectionList>\n <ListItem\n trailing={\n <Text dimColor>\n {devices.length}/{devices.length}\n </Text>\n }\n >\n <Text>Devices</Text>\n </ListItem>\n {...devices.length === 0\n ? [\n <ListItem>\n <Text dimColor>No devices found</Text>\n </ListItem>,\n ]\n : devices.map(device => (\n <Box flexDirection=\"column\">\n <ListItem trailing={<Text>{device.id}</Text>}>\n <Text dimColor>ID</Text>\n </ListItem>\n <ListItem trailing={<Text>{device.series}</Text>}>\n <Text dimColor>Series</Text>\n </ListItem>\n <ListItem trailing={<Text>{device.model}</Text>}>\n <Text dimColor>Model</Text>\n </ListItem>\n <ListItem trailing={<Text>{device.edition}</Text>}>\n <Text dimColor>Edition</Text>\n </ListItem>\n </Box>\n ))}\n </SectionList>\n </Container>\n )\n\n render(<Main />)\n } catch (error) {\n console.error(error)\n }\n },\n )\n .command(\n 'status <device-id>',\n 'Check device status',\n yargs =>\n yargs.positional('device-id', {\n describe: 'Device ID to check status for',\n type: 'string',\n }),\n async argv => {\n try {\n const response = await quote0.device.status({\n deviceId: argv.deviceId!,\n })\n\n render(\n <Container>\n <SectionList>\n <ListItem\n trailing={\n <Text>\n <Text dimColor>Device ID: </Text>\n {response.deviceId}\n </Text>\n }\n >\n <Box gap={1}>\n <Text>{response.alias}</Text>\n <Text dimColor>{response.location}</Text>\n <Text dimColor>{response.status.battery}</Text>\n </Box>\n </ListItem>\n <Box flexDirection=\"column\">\n {...[\n ['Status', response.status.current],\n ['Last Render', response.renderInfo.last],\n [\n 'Next Render (Battery)',\n response.renderInfo.next.battery,\n ],\n ['Next Render (Power)', response.renderInfo.next.power],\n [\n 'Current Images',\n response.renderInfo.current.image.length,\n ],\n [\n 'Version',\n <Text>\n <Text dimColor>v</Text>\n {response.status.version}\n </Text>,\n ],\n ].map(([k, v]) => (\n <ListItem trailing={<Text>{v}</Text>}>\n <Text dimColor>{k}</Text>\n </ListItem>\n ))}\n </Box>\n </SectionList>\n </Container>,\n )\n } catch (error) {\n console.error(error)\n }\n },\n ),\n async argv => {},\n )\n .command(\n 'content',\n 'Manage content',\n yargs =>\n yargs\n .command(\n 'next <device-id>',\n 'Switch to next content',\n yargs =>\n yargs.positional('device-id', {\n describe: 'Device ID to switch content for',\n type: 'string',\n }),\n async argv => {\n try {\n const response = await quote0.content.next({\n deviceId: argv.deviceId!,\n })\n\n render(\n <Container>\n <SectionList>\n <Text>Next Content</Text>\n <Text>{response.message}</Text>\n </SectionList>\n </Container>,\n )\n } catch (error) {\n console.error(error)\n }\n },\n )\n .command(\n 'image',\n 'Push an image to device',\n yargs => yargs,\n async argv => {\n const Main = () => {\n return (\n <Container>\n <SectionList>\n <Text>Progress</Text>\n <Text dimColor>To be implemented</Text>\n </SectionList>\n </Container>\n )\n }\n\n render(<Main />)\n },\n ),\n async argv => {},\n )\n .demandCommand(1, 'Please specify a command')\n .strict()\n .parse()\n"],"mappings":";wVAGA,SAAwB,EAAU,CAChC,GAAG,GACgC,CACnC,OAAO,EAAC,EAAA,CAAI,YAAY,QAAQ,cAAc,SAAS,GAAI,GAAS,CCNtE,MAAM,EAAkB,CACtB,QAAS,GAAG,KACH,CACL,UAAW,EAAW,SAAS,MAAM,CACrC,YAAa,EAAW,SAAS,QAAQ,CACzC,aAAc,EAAW,SAAS,SAAS,CAC3C,WAAY,EAAW,SAAS,OAAO,CACxC,EAEJ,CCLD,SAAS,EAAQ,CACf,SACA,GAAG,GACuD,CAC1D,OACE,EAAC,EAAA,CACC,GAAK,IAAW,IAAQ,CACtB,YAAa,SACb,eAAgB,GAChB,GAAG,EAAgB,OAAO,SAAS,CACpC,CACD,SAAU,EACV,cAAc,SACd,GAAI,GACJ,CAIN,SAAS,EAAY,CAAE,YAA2C,CAChE,IAAM,EAAgB,EAAM,SAAS,QAAQ,EAAS,CACtD,OACE,EAAA,EAAA,CAAA,SACE,CAAA,GAAI,EAAc,KAAK,EAAO,IAC5B,EAAC,EAAA,CAAQ,OAAQ,IAAM,EAAc,OAAS,WAAI,GAAgB,CAClE,CAAC,CAAA,CACF,CC3BP,SAAwB,EAAS,CAC/B,UACA,WACA,WACA,GAAG,GAKF,CACD,OACE,EAAC,EAAA,CAAI,eAAe,gBAAgB,GAAI,YACtC,EAAC,EAAA,CAAA,SAAA,CACE,GACC,EAAA,EAAA,CAAA,SAAA,CACG,EACD,EAAC,EAAA,CAAA,SAAK,IAAA,CAAQ,CAAA,CAAA,CACb,CAEJ,EAAA,CAAA,CACG,CACN,EAAC,EAAA,CAAA,SAAK,EAAA,CAAe,CAAA,EACjB,CEpBV,MAAM,EAAS,IAAI,EAAK,CACtB,qBACA,cAAe,OACf,UAAW,EACX,YAAa,EACd,CAAC,CCII,EAAS,IAA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,2BAA2B,CAC5C,QAAQ,CACR,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quote0",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
4
|
+
"description": "TypeScript SDK and CLI for Quote/0.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/index.mjs",
|
|
6
|
+
"main": "dist/api/index.mjs",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
@@ -32,11 +32,12 @@
|
|
|
32
32
|
"typescript": "^5.9.3"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"
|
|
35
|
+
"conf": "^15.1.0",
|
|
36
36
|
"ink": "^6.8.0",
|
|
37
37
|
"ink-spinner": "^5.0.0",
|
|
38
|
-
"
|
|
38
|
+
"ink-text-input": "^6.0.0",
|
|
39
39
|
"react": "^19.2.4",
|
|
40
|
+
"yaml": "^2.8.2",
|
|
40
41
|
"yargs": "^18.0.0"
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|