@taqueria/protocol 0.1.2 → 0.3.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taqueria/protocol",
3
- "version": "0.1.2",
3
+ "version": "0.3.0",
4
4
  "description": "A TypeScript package which contains types that are to be shared between @taqueria/node-sdk and @taqueria/taqueria.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,9 +1,9 @@
1
1
  // TODO - using .ts is necessary for Deno. Explore how to make this
2
2
  // consumable by Deno or the TypeScript compiler without any warnings
3
3
  // or errors emited
4
- // @ts-ignore
4
+ // @ts-ignore see above
5
5
  import {SanitizedAbsPath, SHA256} from '../taqueria-utils/taqueria-utils-types.ts'
6
- // @ts-ignore
6
+ // @ts-ignore see above
7
7
  import {urlParse} from './url-parse.ts'
8
8
 
9
9
  type URL = ReturnType<typeof urlParse>
@@ -223,9 +223,10 @@ export interface UnvalidatedTask {
223
223
  readonly aliases?: string[]
224
224
  readonly options?: (UnvalidatedOption|Option|undefined)[],
225
225
  readonly positionals?: (UnvalidatedPositionalArg|undefined|PositionalArg)[]
226
- readonly handler: "proxy" | string | string[]
226
+ readonly handler: TaskHandler
227
227
  readonly hidden?: boolean
228
228
  readonly example?: string
229
+ readonly encoding?: "json" | "application/json" | "none"
229
230
  }
230
231
 
231
232
  export interface UnvalidatedPluginInfo {
@@ -372,6 +373,8 @@ export class Option {
372
373
  }
373
374
  }
374
375
 
376
+ export type TaskEncoding = "none" | "json" | "application/json"
377
+
375
378
  const taskType: unique symbol = Symbol()
376
379
  export class Task {
377
380
  [taskType]: void
@@ -384,7 +387,8 @@ export class Option {
384
387
  readonly handler: TaskHandler
385
388
  readonly hidden: boolean
386
389
  readonly positionals: PositionalArg[]
387
- protected constructor(name: Verb, command: Command, description: string, handler: TaskHandler, options: Option[]=[], positionals: PositionalArg[]=[], aliases: Alias[]=[], hidden=false, example?: string) {
390
+ readonly encoding: TaskEncoding
391
+ protected constructor(name: Verb, command: Command, description: string, handler: TaskHandler, options: Option[]=[], positionals: PositionalArg[]=[], aliases: Alias[]=[], hidden=false, encoding="none", example?: string) {
388
392
  this.task = name
389
393
  this.command = command
390
394
  this.description = description
@@ -394,6 +398,9 @@ export class Option {
394
398
  this.hidden = hidden
395
399
  this.example = example
396
400
  this.positionals = positionals
401
+ this.encoding = ["none", "json", "application/json"].includes(encoding)
402
+ ? encoding as TaskEncoding
403
+ : "none"
397
404
  }
398
405
  static createAlias(value: string): Alias | undefined {
399
406
  return Verb.create(value) || SingleChar.create(value)
@@ -446,7 +453,7 @@ export class Option {
446
453
  )
447
454
 
448
455
  return name && command
449
- ? new Task(name, command, task.description, task.handler, options, positionals, aliases, task.hidden ? true : false, task.example)
456
+ ? new Task(name, command, task.description, task.handler, options, positionals, aliases, task.hidden ? true : false, task.encoding, task.example)
450
457
  : undefined
451
458
  }
452
459
  }
@@ -586,38 +593,34 @@ export interface Environment {
586
593
  readonly storage: Record<string, unknown>
587
594
  }
588
595
 
589
- export type PluginAction = "checkRuntimeDependencies" | "installRuntimeDependencies" | "proxy" | "pluginInfo" | string
596
+ export type PluginActionName = "checkRuntimeDependencies" | "installRuntimeDependencies" | "proxy" | "pluginInfo" | string
597
+
598
+ export type PluginProxyAction = Task
599
+
600
+ export type PluginAction = "checkRuntimeDependencies" | "installRuntimeDependencies" | "pluginInfo" | PluginProxyAction
590
601
 
591
602
  export interface RuntimeDependencyReport extends RuntimeDependency {
592
603
  readonly met: boolean
593
604
  }
594
605
 
595
- export interface CheckRuntimeDependenciesAction {
596
- readonly status: PluginResponseCode,
606
+ export interface CheckRuntimeDependenciesResponse {
597
607
  readonly report: RuntimeDependencyReport[]
598
608
  }
599
609
 
600
- export interface InstallRuntimeDependenciesAction {
601
- readonly status: PluginResponseCode,
610
+ export interface InstallRuntimeDependenciesResponse {
602
611
  readonly report: RuntimeDependencyReport[]
603
612
  }
604
613
 
605
- export type PluginResponseCode = "success" | "failed" | "notSupported"
606
-
607
- export type PluginActionNotSupported = {
614
+ export type PluginActionNotSupportedResponse = {
608
615
  readonly status: "notSupported",
609
616
  readonly msg: string
610
617
  }
611
618
 
612
- export interface ProxyAction {
613
- readonly status: PluginResponseCode,
614
- readonly stdout: string | unknown,
615
- readonly stderr: string,
619
+ export interface PluginJsonResponse {
620
+ readonly data?: unknown
616
621
  readonly render?: 'none' | 'string' | 'table'
617
622
  }
618
623
 
619
- export interface ActionPluginInfo extends UnvalidatedPluginInfo {
620
- readonly status: PluginResponseCode,
621
- }
624
+ export type ActionPluginInfo = UnvalidatedPluginInfo
622
625
 
623
- export type PluginResponse = ProxyAction | CheckRuntimeDependenciesAction | InstallRuntimeDependenciesAction | ActionPluginInfo | PluginActionNotSupported
626
+ export type PluginResponse = PluginJsonResponse | CheckRuntimeDependenciesResponse | InstallRuntimeDependenciesResponse | ActionPluginInfo | PluginActionNotSupportedResponse | void