@taqueria/protocol 0.6.1 → 0.6.6

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/Config.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import createType, { Flatten } from '@taqueria/protocol/Base';
2
+ import * as Contract from '@taqueria/protocol/Contract';
2
3
  import * as Environment from '@taqueria/protocol/Environment';
3
4
  import * as InstalledPlugin from '@taqueria/protocol/InstalledPlugin';
4
5
  import * as NetworkConfig from '@taqueria/protocol/NetworkConfig';
@@ -89,6 +90,9 @@ const commonSchema = z.object({
89
90
  z.string({ description: 'config.artifactsDir' })
90
91
  .min(1, 'config.artifactsDir must have a value'),
91
92
  ),
93
+ contracts: z.record(
94
+ Contract.rawSchema,
95
+ ).optional(),
92
96
  }).describe('config');
93
97
 
94
98
  export const internalSchema = commonSchema.extend({
@@ -96,6 +100,7 @@ export const internalSchema = commonSchema.extend({
96
100
  sandbox: sandboxMap,
97
101
  environment: environmentMap,
98
102
  accounts: accountsMap,
103
+ contracts: z.record(Contract.schemas.schema).optional(),
99
104
  });
100
105
 
101
106
  export const rawSchema = commonSchema.extend({
package/Contract.ts ADDED
@@ -0,0 +1,35 @@
1
+ import createType, { Flatten } from '@taqueria/protocol/Base';
2
+ import * as SHA256 from '@taqueria/protocol/SHA256';
3
+ import { z } from 'zod';
4
+
5
+ export const rawSchema = z.object({
6
+ sourceFile: z.string().min(1),
7
+ hash: SHA256.rawSchema,
8
+ // TODO: Should plugin also be provided here?
9
+ });
10
+
11
+ export const internalSchema = z.object({
12
+ sourceFile: z.string().min(1),
13
+ hash: SHA256.schemas.schema,
14
+ });
15
+
16
+ type RawInput = z.infer<typeof rawSchema>;
17
+ type Input = z.infer<typeof internalSchema>;
18
+
19
+ const { schemas: generatedSchemas, factory } = createType<RawInput, Input>({
20
+ rawSchema,
21
+ internalSchema,
22
+ parseErrMsg: (value: unknown) => `${value} is not a valid contract`,
23
+ unknownErrMsg: 'Something went wrong trying to parse a contract',
24
+ });
25
+
26
+ export type Contract = z.infer<typeof generatedSchemas.schema>;
27
+
28
+ export type t = Contract;
29
+
30
+ export const { create, of, make } = factory;
31
+
32
+ export const schemas = {
33
+ ...generatedSchemas,
34
+ schema: generatedSchemas.schema.transform(val => val as Contract),
35
+ };
package/EphemeralState.ts CHANGED
@@ -5,7 +5,9 @@ import type { i18n } from '@taqueria/protocol/i18n';
5
5
  import * as InstalledPlugin from '@taqueria/protocol/InstalledPlugin';
6
6
  import * as Option from '@taqueria/protocol/Option';
7
7
  import * as ParsedOperation from '@taqueria/protocol/ParsedOperation';
8
- import * as ParsedPluginInfo from '@taqueria/protocol/ParsedPluginInfo';
8
+ import * as ParsedTemplate from '@taqueria/protocol/ParsedTemplate';
9
+ import * as PluginInfo from '@taqueria/protocol/PluginInfo';
10
+ import * as PluginResponseEncoding from '@taqueria/protocol/PluginResponseEncoding';
9
11
  import { E_TaqError, TaqError } from '@taqueria/protocol/TaqError';
10
12
  import * as Task from '@taqueria/protocol/Task';
11
13
  import * as Verb from '@taqueria/protocol/Verb';
@@ -30,12 +32,20 @@ const operationToPluginMap = z.record(
30
32
  ], { description: 'Operation/Plugin Mapping' }),
31
33
  );
32
34
 
35
+ const templateToPluginMap = z.record(
36
+ z.union([
37
+ InstalledPlugin.schemas.schema,
38
+ ParsedTemplate.schemas.schema,
39
+ ]),
40
+ );
41
+
33
42
  const rawSchema = z.object({
34
43
  build: z.string({ description: 'cache.build' }),
35
44
  configHash: z.string({ description: 'cache.configHash' }),
36
45
  tasks: taskToPluginMap,
37
46
  operations: operationToPluginMap,
38
- plugins: z.array(ParsedPluginInfo.schemas.schema, { description: 'cache.plugins' }),
47
+ templates: templateToPluginMap,
48
+ plugins: z.array(PluginInfo.schemas.schema, { description: 'cache.plugins' }),
39
49
  }).describe('Ephemeral State');
40
50
 
41
51
  type RawInput = z.infer<typeof rawSchema>;
@@ -50,6 +60,7 @@ export type EphemeralState = z.infer<typeof generatedSchemas.schema>;
50
60
  export type t = EphemeralState;
51
61
  export type TaskToPluginMap = z.infer<typeof taskToPluginMap>;
52
62
  export type OpToPluginMap = z.infer<typeof operationToPluginMap>;
63
+ export type TemplateToPluginMap = z.infer<typeof templateToPluginMap>;
53
64
 
54
65
  export const { create, of, make } = factory;
55
66
 
@@ -61,8 +72,8 @@ export const schemas = {
61
72
  /**
62
73
  * Private functions
63
74
  */
64
- type Counts = Record<Verb.t, ParsedPluginInfo.t[]>;
65
- const getTaskCounts = (pluginInfo: ParsedPluginInfo.t[]): Counts => {
75
+ type Counts = Record<Verb.t, PluginInfo.t[]>;
76
+ const getTaskCounts = (pluginInfo: PluginInfo.t[]): Counts => {
66
77
  return pluginInfo.reduce(
67
78
  (retval, pluginInfo) =>
68
79
  pluginInfo.tasks === undefined
@@ -70,7 +81,7 @@ const getTaskCounts = (pluginInfo: ParsedPluginInfo.t[]): Counts => {
70
81
  : pluginInfo.tasks.reduce(
71
82
  (retval: Counts, task: Task.t) => {
72
83
  const taskName = task.task;
73
- const providers: ParsedPluginInfo.t[] = retval[taskName]
84
+ const providers: PluginInfo.t[] = retval[taskName]
74
85
  ? [...retval[taskName], pluginInfo]
75
86
  : [pluginInfo];
76
87
  const mapping: Counts = {};
@@ -83,7 +94,28 @@ const getTaskCounts = (pluginInfo: ParsedPluginInfo.t[]): Counts => {
83
94
  );
84
95
  };
85
96
 
86
- const getOperationCounts = (pluginInfo: ParsedPluginInfo.t[]): Counts => {
97
+ const getTemplateCounts = (pluginInfo: PluginInfo.t[]): Counts => {
98
+ return pluginInfo.reduce(
99
+ (retval, pluginInfo) =>
100
+ !pluginInfo.templates
101
+ ? retval
102
+ : pluginInfo.templates.reduce(
103
+ (retval: Counts, template: ParsedTemplate.t) => {
104
+ const templateName = template.template;
105
+ const providers = retval[templateName]
106
+ ? [...retval[templateName], pluginInfo]
107
+ : [pluginInfo];
108
+ const mapping: Counts = {};
109
+ mapping[templateName] = providers.filter(provider => provider !== undefined);
110
+ return { ...retval, ...mapping };
111
+ },
112
+ retval,
113
+ ),
114
+ {} as Counts,
115
+ );
116
+ };
117
+
118
+ const getOperationCounts = (pluginInfo: PluginInfo.t[]): Counts => {
87
119
  return pluginInfo.reduce(
88
120
  (retval, pluginInfo) =>
89
121
  pluginInfo.operations === undefined
@@ -104,7 +136,7 @@ const getOperationCounts = (pluginInfo: ParsedPluginInfo.t[]): Counts => {
104
136
  );
105
137
  };
106
138
 
107
- const toChoices = (plugins: ParsedPluginInfo.t[]) =>
139
+ const toChoices = (plugins: PluginInfo.t[]) =>
108
140
  plugins.reduce(
109
141
  (retval, pluginInfo) => {
110
142
  return [...retval, pluginInfo.name as string, pluginInfo.alias as string];
@@ -112,14 +144,14 @@ const toChoices = (plugins: ParsedPluginInfo.t[]) =>
112
144
  [] as string[],
113
145
  );
114
146
 
115
- const isComposite = (name: Verb.t, counts: Counts) => counts[name].length > 1;
147
+ const isComposite = (name: Verb.t, counts: Counts) => counts[name] && counts[name].length > 1;
116
148
 
117
149
  const getInstalledPlugin = (config: Config.t, name: string) =>
118
150
  config.plugins?.find(
119
151
  (plugin: InstalledPlugin.t) => [`taqueria-plugin-${name}`, name].includes(plugin.name),
120
152
  );
121
153
 
122
- export const mapTasksToPlugins = (config: Config.t, pluginInfo: ParsedPluginInfo.t[], i18n: i18n) => {
154
+ export const mapTasksToPlugins = (config: Config.t, pluginInfo: PluginInfo.t[], i18n: i18n) => {
123
155
  const taskCounts = getTaskCounts(pluginInfo);
124
156
  return attemptP<TaqError, TaskToPluginMap>(async () =>
125
157
  await pluginInfo.reduce(
@@ -161,7 +193,7 @@ export const mapTasksToPlugins = (config: Config.t, pluginInfo: ParsedPluginInfo
161
193
  ).pipe(mapRej(rej => rej as TaqError));
162
194
  };
163
195
 
164
- export const mapOperationsToPlugins = (config: Config.t, pluginInfo: ParsedPluginInfo.t[], i18n: i18n) => {
196
+ export const mapOperationsToPlugins = (config: Config.t, pluginInfo: PluginInfo.t[], i18n: i18n) => {
165
197
  const opCounts = getOperationCounts(pluginInfo);
166
198
  return attemptP(async () =>
167
199
  await pluginInfo.reduce(
@@ -201,7 +233,49 @@ export const mapOperationsToPlugins = (config: Config.t, pluginInfo: ParsedPlugi
201
233
  ).pipe(mapRej(rej => rej as TaqError));
202
234
  };
203
235
 
204
- export const getTasks = (pluginInfo: ParsedPluginInfo.t[]) =>
236
+ export const mapTemplatesToPlugins = (config: Config.t, pluginInfo: PluginInfo.t[], i18n: i18n) => {
237
+ const tmplCounts = getTemplateCounts(pluginInfo);
238
+ return attemptP<TaqError, TemplateToPluginMap>(async () =>
239
+ await pluginInfo.reduce(
240
+ async (retval, pluginInfo) =>
241
+ !pluginInfo.templates
242
+ ? Promise.resolve({} as TemplateToPluginMap)
243
+ : await pluginInfo.templates!.reduce(
244
+ async (retval, { template }) => {
245
+ if (isComposite(template, tmplCounts)) {
246
+ const command = await eager(Command.make(template));
247
+ const compositeTmpl = await eager(ParsedTemplate.make({
248
+ template,
249
+ command,
250
+ description: i18n.__('providedByMany'),
251
+ options: [
252
+ await eager(Option.make({
253
+ flag: await eager(Verb.make('plugin')),
254
+ description: 'Specify which plugin should be used to execute this task',
255
+ choices: toChoices(tmplCounts[template]),
256
+ required: true,
257
+ })),
258
+ ],
259
+ handler: 'proxy',
260
+ encoding: PluginResponseEncoding.create('none'),
261
+ }));
262
+ return { ...await retval, [template]: compositeTmpl };
263
+ }
264
+
265
+ // Template is provided by just a single plugin
266
+ const installedPlugin = getInstalledPlugin(config, pluginInfo.name);
267
+ return installedPlugin
268
+ ? { ...await retval, [template]: installedPlugin }
269
+ : retval;
270
+ },
271
+ retval,
272
+ ),
273
+ Promise.resolve({} as TemplateToPluginMap),
274
+ )
275
+ ).pipe(mapRej(rej => rej as TaqError));
276
+ };
277
+
278
+ export const getTasks = (pluginInfo: PluginInfo.t[]) =>
205
279
  pluginInfo.reduce(
206
280
  (retval: Task.t[], pluginInfo) => [...retval, ...(pluginInfo.tasks ?? [])],
207
281
  [],
package/Option.ts CHANGED
@@ -17,6 +17,10 @@ export const internalSchema = z.object({
17
17
  ).optional(),
18
18
  required: z.boolean({ description: 'Option Is Required' }).default(false).optional(),
19
19
  boolean: z.boolean({ description: 'Option Is Boolean' }).default(false).optional(),
20
+ type: z.union(
21
+ [z.literal('string'), z.literal('number'), z.literal('boolean')],
22
+ { description: 'Positional Arg Datatype' },
23
+ ).optional(),
20
24
  }).describe('Option');
21
25
 
22
26
  export const rawSchema = z.object({
@@ -33,6 +37,10 @@ export const rawSchema = z.object({
33
37
  ).optional(),
34
38
  required: z.boolean({ description: 'Option Is Required' }).default(false).optional(),
35
39
  boolean: z.boolean({ description: 'Option Is Boolean' }).default(false).optional(),
40
+ type: z.union(
41
+ [z.literal('string'), z.literal('number'), z.literal('boolean')],
42
+ { description: 'Positional Arg Datatype' },
43
+ ).optional(),
36
44
  }).describe('Option');
37
45
 
38
46
  type RawInput = z.infer<typeof rawSchema>;
@@ -0,0 +1,40 @@
1
+ import createType from '@taqueria/protocol/Base';
2
+ import * as PluginResponseEncoding from '@taqueria/protocol/PluginResponseEncoding';
3
+ import * as Template from '@taqueria/protocol/Template';
4
+ import { z } from 'zod';
5
+
6
+ const internalSchema = Template
7
+ .internalSchema
8
+ .extend({
9
+ handler: z.string(),
10
+ encoding: PluginResponseEncoding.schemas.schema,
11
+ })
12
+ .describe('ParsedTemplate');
13
+
14
+ export const rawSchema = Template
15
+ .rawSchema
16
+ .extend({
17
+ handler: z.string(),
18
+ encoding: PluginResponseEncoding.schemas.schema,
19
+ })
20
+ .describe('ParsedTemplate');
21
+
22
+ type RawInput = z.infer<typeof rawSchema>;
23
+ type Input = z.infer<typeof internalSchema>;
24
+
25
+ export const { schemas: generatedSchemas, factory } = createType<RawInput, Input>({
26
+ rawSchema,
27
+ internalSchema,
28
+ parseErrMsg: (value: unknown) => `Could not parse the following template: ${value}`,
29
+ unknownErrMsg: 'Something went wrong trying to parse an template',
30
+ });
31
+
32
+ export type ParsedTemplate = z.infer<typeof generatedSchemas.schema>;
33
+ export type t = ParsedTemplate;
34
+
35
+ export const { create, make, of } = factory;
36
+
37
+ export const schemas = {
38
+ ...generatedSchemas,
39
+ schema: generatedSchemas.schema.transform(val => val as ParsedTemplate),
40
+ };
@@ -0,0 +1,28 @@
1
+ import createType from '@taqueria/protocol/Base';
2
+ import { z } from 'zod';
3
+
4
+ const rawSchema = z.union([
5
+ z.literal('checkRuntimeDependencies'),
6
+ z.literal('installRuntimeDependencies'),
7
+ z.literal('proxy'),
8
+ z.literal('proxyTemplate'),
9
+ z.literal('pluginInfo'),
10
+ ]);
11
+
12
+ const internalSchema = rawSchema;
13
+
14
+ export type PluginActionName = z.infer<typeof rawSchema>;
15
+ export type t = PluginActionName;
16
+
17
+ const pluginActionNotSupportedSchema = z.object({
18
+ status: z.literal('notSupported'),
19
+ msg: z.string(),
20
+ });
21
+
22
+ export type PluginActionNotSupportedResponse = z.infer<typeof pluginActionNotSupportedSchema>;
23
+
24
+ export const schemas = {
25
+ schema: internalSchema,
26
+ internalSchema,
27
+ rawSchema,
28
+ };
@@ -0,0 +1,33 @@
1
+ import createType from '@taqueria/protocol/Base';
2
+ import { z } from 'zod';
3
+
4
+ const rawRuntimeDependency = z.object({
5
+ name: z.string(),
6
+ path: z.string(),
7
+ version: z.string(),
8
+ kind: z.union([z.literal('required'), z.literal('optional')]),
9
+ });
10
+
11
+ type RawRuntimeDependencyInput = z.infer<typeof rawRuntimeDependency>;
12
+
13
+ export const { schemas, factory } = createType<RawRuntimeDependencyInput, RawRuntimeDependencyInput>({
14
+ rawSchema: rawRuntimeDependency,
15
+ internalSchema: rawRuntimeDependency,
16
+ parseErrMsg: (value: unknown) => `The following runtime dependency is invalid: ${value}`,
17
+ unknownErrMsg: 'Something went wrong trying to parse the template',
18
+ });
19
+
20
+ export type RuntimeDependency = z.infer<typeof schemas.schema>;
21
+
22
+ const runtimeDependencyReport = rawRuntimeDependency.extend({ met: z.boolean() });
23
+
24
+ export type RuntimeDependencyReport = z.infer<typeof runtimeDependencyReport>;
25
+
26
+ const dependenciesResponseSchema = z.object({
27
+ report: z.array(runtimeDependencyReport),
28
+ });
29
+
30
+ export type PluginDependenciesResponse = z.infer<typeof dependenciesResponseSchema>;
31
+ export type t = PluginDependenciesResponse;
32
+
33
+ export const { of, make, create } = factory;
package/PluginInfo.ts CHANGED
@@ -1,67 +1,76 @@
1
1
  import * as Alias from '@taqueria/protocol/Alias';
2
2
  import createType, { Flatten } from '@taqueria/protocol/Base';
3
- import * as Operation from '@taqueria/protocol/Operation';
3
+ import * as ParsedOperation from '@taqueria/protocol/ParsedOperation';
4
+ import * as ParsedTemplate from '@taqueria/protocol/ParsedTemplate';
4
5
  import * as Task from '@taqueria/protocol/Task';
5
6
  import * as VersionNumber from '@taqueria/protocol/VersionNumber';
6
7
  import { z } from 'zod';
7
8
 
8
- export const internalSchema = z.object({
9
+ export const rawSchema = z.object({
9
10
  name: z.string({ description: 'Plugin Name' }).min(1),
10
- version: VersionNumber.schemas.schema.describe('Plugin Version #'),
11
- schema: VersionNumber.schemas.schema.describe('Plugin Schema Version #'),
12
- alias: Alias.schemas.schema.describe('Plugin Alias'),
11
+ version: VersionNumber.rawSchema.describe('Plugin Version #'),
12
+ schema: VersionNumber.rawSchema.describe('Plugin Schema Version #'),
13
+ alias: Alias.rawSchema.describe('Plugin Alias'),
13
14
  tasks: z.preprocess(
14
15
  val => val ?? [],
15
16
  z.array(
16
17
  Task.schemas.schema.describe('Plugin Task'),
17
18
  { description: 'Plugin Tasks' },
18
- ).optional(),
19
- ),
19
+ ),
20
+ ).optional(),
20
21
  operations: z.preprocess(
21
22
  val => val ?? [],
22
23
  z.array(
23
- Operation.schemas.schema.describe('Plugin Operation'),
24
+ ParsedOperation.schemas.schema.describe('Plugin Operation'),
24
25
  { description: 'Plugin Operations' },
25
- ).optional(),
26
- ),
27
- }).describe('Plugin Schema');
26
+ ),
27
+ ).optional(),
28
+ templates: z.preprocess(
29
+ val => val ?? [],
30
+ z.array(
31
+ ParsedTemplate.schemas.schema.describe('Plugin Template'),
32
+ ),
33
+ ).optional(),
34
+ });
28
35
 
29
- export const rawSchema = z.object({
30
- name: z.string({ description: 'Plugin Name' }).min(1),
31
- version: VersionNumber.rawSchema.describe('Plugin Version #'),
32
- schema: VersionNumber.rawSchema.describe('Plugin Schema Version #'),
33
- alias: Alias.rawSchema.describe('Plugin Alias'),
36
+ export const internalSchema = rawSchema.extend({
37
+ version: VersionNumber.schemas.schema.describe('Plugin Version #'),
38
+ schema: VersionNumber.schemas.schema.describe('Plugin Schema Version #'),
39
+ alias: Alias.schemas.schema.describe('Plugin Alias'),
34
40
  tasks: z.preprocess(
35
41
  val => val ?? [],
36
42
  z.array(
37
- Task.rawSchema.describe('Plugin Task'),
43
+ Task.schemas.schema.describe('Plugin Task'),
38
44
  { description: 'Plugin Tasks' },
39
- ).optional(),
40
- ),
45
+ ),
46
+ ).optional(),
41
47
  operations: z.preprocess(
42
48
  val => val ?? [],
43
49
  z.array(
44
- Operation.rawSchema.describe('Plugin Operation'),
50
+ ParsedOperation.schemas.schema.describe('Plugin Operation'),
45
51
  { description: 'Plugin Operations' },
46
- ).optional(),
47
- ),
52
+ ),
53
+ ).optional(),
54
+ templates: z.preprocess(
55
+ val => val ?? [],
56
+ z.array(
57
+ ParsedTemplate.schemas.schema.describe('Plugin Template'),
58
+ ),
59
+ ).optional(),
48
60
  }).describe('Plugin Schema');
49
61
 
62
+ // export const rawSchema = internalSchema;
63
+
50
64
  type RawInput = z.infer<typeof rawSchema>;
51
65
  type Input = Flatten<z.infer<typeof internalSchema>>;
52
66
 
53
- export const { schemas: generatedSchemas, factory } = createType<RawInput, Input>({
67
+ export const { schemas, factory } = createType<RawInput, Input>({
54
68
  rawSchema,
55
69
  internalSchema,
56
70
  parseErrMsg: 'The schema returned from the plugin is invalid',
57
71
  unknownErrMsg: 'Something went wrong parsing the schema from a plugin',
58
72
  });
59
73
 
60
- export type PluginInfo = Flatten<z.infer<typeof generatedSchemas.schema>>;
74
+ export type PluginInfo = Flatten<z.infer<typeof schemas.schema>>;
61
75
  export type t = PluginInfo;
62
76
  export const { create, of, make } = factory;
63
-
64
- export const schemas = {
65
- ...generatedSchemas,
66
- schema: generatedSchemas.schema.transform(val => val as unknown as PluginInfo),
67
- };
@@ -0,0 +1,26 @@
1
+ import createType from '@taqueria/protocol/Base';
2
+ import { z } from 'zod';
3
+
4
+ export const rawSchema = z.object({
5
+ data: z.unknown().optional(),
6
+ render: z.union([
7
+ z.literal('none'),
8
+ z.literal('table'),
9
+ z.literal('string'),
10
+ ]).optional(),
11
+ });
12
+
13
+ type RawPluginJsonResponseInput = z.infer<typeof rawSchema>;
14
+
15
+ export const pluginJsonResponse = createType<RawPluginJsonResponseInput, RawPluginJsonResponseInput>({
16
+ rawSchema: rawSchema,
17
+ internalSchema: rawSchema,
18
+ parseErrMsg: (value: unknown) => `The following JSON response is invalid: ${value}`,
19
+ unknownErrMsg: 'Something went wrong trying to parse the template',
20
+ });
21
+
22
+ export type PluginJsonResponse = z.infer<typeof pluginJsonResponse.schemas.schema>;
23
+
24
+ export type t = PluginJsonResponse;
25
+
26
+ export const { schemas, factory } = pluginJsonResponse;
@@ -0,0 +1,24 @@
1
+ import createType from '@taqueria/protocol/Base';
2
+ import * as PluginJsonResponse from '@taqueria/protocol/PluginJsonResponse';
3
+ import { z } from 'zod';
4
+
5
+ const internalSchema = z.union([
6
+ PluginJsonResponse.schemas.internalSchema,
7
+ z.void(),
8
+ ]);
9
+
10
+ export const rawSchema = internalSchema;
11
+
12
+ type Input = z.infer<typeof internalSchema>;
13
+
14
+ export const { schemas, factory } = createType<Input, Input>({
15
+ rawSchema,
16
+ internalSchema,
17
+ parseErrMsg: 'The response from the proxy request is invalid',
18
+ unknownErrMsg: 'Something went wrong parsing the proxy response from the plugin',
19
+ });
20
+
21
+ export type PluginProxyResponse = z.infer<typeof schemas.schema>;
22
+ export type t = PluginProxyResponse;
23
+
24
+ export const { of, make, create } = factory;
@@ -0,0 +1,27 @@
1
+ import createType from '@taqueria/protocol/Base';
2
+ import { z } from 'zod';
3
+
4
+ export const rawSchema = z.preprocess(
5
+ (val: unknown) => val ?? 'none',
6
+ z.union([
7
+ z.literal('json'),
8
+ z.literal('application/json'),
9
+ z.literal('none'),
10
+ ])
11
+ .default('none')
12
+ .optional(),
13
+ );
14
+
15
+ type RawInput = z.infer<typeof rawSchema>;
16
+
17
+ export const { schemas, factory } = createType<RawInput, RawInput>({
18
+ rawSchema,
19
+ internalSchema: rawSchema,
20
+ parseErrMsg: (value: unknown) => `The following encoding is invalid: ${value}`,
21
+ unknownErrMsg: 'Something went wrong trying to parse the encoding',
22
+ });
23
+
24
+ export type PluginResponseEncoding = z.infer<typeof schemas.schema>;
25
+ export type t = PluginResponseEncoding;
26
+
27
+ export const { create, of, make } = factory;
@@ -0,0 +1,81 @@
1
+ import * as Alias from '@taqueria/protocol/Alias';
2
+ import createType from '@taqueria/protocol/Base';
3
+ import * as Operation from '@taqueria/protocol/Operation';
4
+ import * as PluginDependenciesResponse from '@taqueria/protocol/PluginDependenciesResponse';
5
+ import * as PluginInfo from '@taqueria/protocol/PluginInfo';
6
+ import * as PluginProxyResponse from '@taqueria/protocol/PluginProxyResponse';
7
+ import * as RequestArgs from '@taqueria/protocol/RequestArgs';
8
+ import * as Template from '@taqueria/protocol/Template';
9
+ import { z } from 'zod';
10
+
11
+ const proxyFnSchema = z
12
+ .function()
13
+ .args(RequestArgs.proxySchemas.schema)
14
+ .returns(z.promise(PluginProxyResponse.schemas.schema));
15
+
16
+ const runtimeDependenciesFn = z
17
+ .function()
18
+ .args(RequestArgs.schemas.schema)
19
+ .returns(z.promise(PluginDependenciesResponse.schemas.schema));
20
+
21
+ const internalSchema = PluginInfo.internalSchema.extend({
22
+ operations: z.preprocess(
23
+ val => val ?? [],
24
+ z.array(
25
+ Operation.schemas.schema,
26
+ { description: 'ParsedOperations' },
27
+ )
28
+ .optional(),
29
+ ),
30
+ templates: z.preprocess(
31
+ val => val ?? [],
32
+ z.array(
33
+ Template.schemas.schema,
34
+ ).optional(),
35
+ ),
36
+ proxy: proxyFnSchema.optional(),
37
+ checkRuntimeDependencies: runtimeDependenciesFn.optional(),
38
+ installRuntimeDependencies: runtimeDependenciesFn.optional(),
39
+ }).describe('ParsedPluginInfo');
40
+
41
+ export const rawSchema = PluginInfo.rawSchema.extend({
42
+ name: Alias.rawSchema.optional(),
43
+ operations: z.preprocess(
44
+ val => val ?? [],
45
+ z.array(
46
+ Operation.rawSchema,
47
+ { description: 'ParsedOperation' },
48
+ ),
49
+ )
50
+ .optional(),
51
+ templates: z.preprocess(
52
+ val => val ?? [],
53
+ z.array(
54
+ Template.schemas.schema,
55
+ ).optional(),
56
+ ),
57
+ proxy: proxyFnSchema.optional(),
58
+ checkRuntimeDependencies: runtimeDependenciesFn.optional(),
59
+ installRuntimeDependencies: runtimeDependenciesFn.optional(),
60
+ }).describe('ParsedPluginInfo');
61
+
62
+ type Input = z.infer<typeof internalSchema>;
63
+
64
+ export type RawPluginSchema = z.infer<typeof rawSchema>;
65
+
66
+ export const { schemas: generatedSchemas, factory } = createType<RawPluginSchema, Input>({
67
+ rawSchema,
68
+ internalSchema,
69
+ parseErrMsg: (value: unknown) =>
70
+ `The following plugin info gave us trouble when parsing the following plugin information: ${value}`,
71
+ unknownErrMsg: 'Something went wrong trying to parse the plugin information',
72
+ });
73
+
74
+ export type ParsedPluginInfo = z.infer<typeof generatedSchemas.schema>;
75
+ export type t = ParsedPluginInfo;
76
+ export const { create, of, make } = factory;
77
+
78
+ export const schemas = {
79
+ ...generatedSchemas,
80
+ schema: generatedSchemas.schema.transform(val => val as ParsedPluginInfo),
81
+ };
package/PositionalArg.ts CHANGED
@@ -13,19 +13,11 @@ export const rawSchema = z.object({
13
13
  [z.literal('string'), z.literal('number'), z.literal('boolean')],
14
14
  { description: 'Positional Arg Datatype' },
15
15
  ).optional(),
16
+ required: z.boolean().optional(),
16
17
  }).describe('Positional Arg');
17
18
 
18
- const internalSchema = z.object({
19
+ const internalSchema = rawSchema.extend({
19
20
  placeholder: HumanReadableIdentifier.schemas.schema.describe('Positional Arg Placeholder'),
20
- description: z.string({ description: 'Positional Arg Description' }).min(1),
21
- defaultValue: z.union(
22
- [z.string(), z.number(), z.boolean()],
23
- { description: 'Positional Arg Default Value' },
24
- ).optional(),
25
- type: z.union(
26
- [z.literal('string'), z.literal('number'), z.literal('boolean')],
27
- { description: 'Positional Arg Datatype' },
28
- ).optional(),
29
21
  }).describe('Positional Arg');
30
22
 
31
23
  type RawInput = z.infer<typeof rawSchema>;
package/RequestArgs.ts CHANGED
@@ -3,13 +3,16 @@ import * as LoadedConfig from '@taqueria/protocol/LoadedConfig';
3
3
  import { rawSchema as sanitizedArgsSchema } from '@taqueria/protocol/SanitizedArgs';
4
4
  import { z } from 'zod';
5
5
 
6
+ const taqRunSchema = z.union([
7
+ z.literal('pluginInfo'),
8
+ z.literal('proxy'),
9
+ z.literal('checkRuntimeDependencies'),
10
+ z.literal('installRuntimeDependencies'),
11
+ z.literal('proxyTemplate'),
12
+ ]);
13
+
6
14
  const rawSchema = sanitizedArgsSchema.extend({
7
- taqRun: z.union([
8
- z.literal('pluginInfo'),
9
- z.literal('proxy'),
10
- z.literal('checkRuntimeDependencies'),
11
- z.literal('installRuntimeDependencies'),
12
- ], { description: 'request.taq_run' }),
15
+ taqRun: taqRunSchema,
13
16
  config: z.preprocess(
14
17
  val => typeof val === 'string' ? JSON.parse(val) : val,
15
18
  LoadedConfig.rawSchema,
@@ -17,12 +20,7 @@ const rawSchema = sanitizedArgsSchema.extend({
17
20
  }).describe('RequestArgs').passthrough();
18
21
 
19
22
  const internalSchema = sanitizedArgsSchema.extend({
20
- taqRun: z.union([
21
- z.literal('pluginInfo'),
22
- z.literal('proxy'),
23
- z.literal('checkRuntimeDependencies'),
24
- z.literal('installRuntimeDependencies'),
25
- ], { description: 'request.taq_run' }),
23
+ taqRun: taqRunSchema,
26
24
  config: z.preprocess(
27
25
  val => typeof val === 'string' ? JSON.parse(val) : val,
28
26
  LoadedConfig.schemas.schema,
@@ -47,20 +45,37 @@ export const schemas = {
47
45
  schema: generatedSchemas.schema.transform(val => val as RequestArgs),
48
46
  };
49
47
 
50
- const rawProxySchema = rawSchema.extend({
48
+ const rawProxyTaskSchema = rawSchema.extend({
51
49
  task: z.string().min(1),
52
50
  }).describe('ProxyRequestArgs').passthrough();
53
51
 
54
- const internalProxySchema = internalSchema.extend({
52
+ const internalProxyTaskSchema = internalSchema.extend({
55
53
  task: z.string().min(1),
56
54
  }).describe('ProxyRequestArgs').passthrough();
57
55
 
58
- type RawProxyInput = z.infer<typeof rawProxySchema>;
59
- type ProxyInput = z.infer<typeof internalProxySchema>;
56
+ const rawProxyTemplateSchema = rawSchema.extend({
57
+ template: z.string().min(1),
58
+ });
59
+
60
+ const internalProxyTemplateSchema = rawSchema.extend({
61
+ template: z.string().min(1),
62
+ });
63
+
64
+ type RawProxyInput = z.infer<typeof rawProxyTaskSchema>;
65
+ type ProxyInput = z.infer<typeof internalProxyTaskSchema>;
66
+ type RawProxyTemplateInput = z.infer<typeof rawProxyTemplateSchema>;
67
+ type ProxyTemplateInput = z.infer<typeof internalProxyTemplateSchema>;
60
68
 
61
69
  export const proxy = createType<RawProxyInput, ProxyInput>({
62
- rawSchema: rawProxySchema,
63
- internalSchema: internalProxySchema,
70
+ rawSchema: rawProxyTaskSchema,
71
+ internalSchema: internalProxyTaskSchema,
72
+ parseErrMsg: 'The request is invalid',
73
+ unknownErrMsg: 'Something went wrong trying to parse the request',
74
+ });
75
+
76
+ export const proxyTemplate = createType<RawProxyTemplateInput, ProxyTemplateInput>({
77
+ rawSchema: rawProxyTemplateSchema,
78
+ internalSchema: internalProxyTemplateSchema,
64
79
  parseErrMsg: 'The request is invalid',
65
80
  unknownErrMsg: 'Something went wrong trying to parse the request',
66
81
  });
@@ -69,8 +84,14 @@ export const proxySchemas = proxy.schemas;
69
84
  export const proxyFactory = proxy.factory;
70
85
 
71
86
  export type ProxyRequestArgs = z.infer<typeof proxySchemas.schema>;
87
+ export type ProxyTemplateRequestArgs = z.infer<typeof proxyTemplate.schemas.schema>;
72
88
 
73
89
  export const createProxyRequestArgs = proxyFactory.from;
74
90
  export const makeProxyRequestArgs = proxyFactory.make;
75
91
  export const ofProxyRequestArgs = proxyFactory.of;
92
+
93
+ export const createProxyTemplateRequestArgs = proxyTemplate.factory.from;
94
+ export const makeProxyTemplateRequestArgs = proxyTemplate.factory.make;
95
+ export const ofProxyTemplateRequestArgs = proxyTemplate.factory.of;
96
+
76
97
  export const { create, make, of, from } = factory;
package/SanitizedArgs.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import createType from '@taqueria/protocol/Base';
2
+ import * as PluginResponseEncoding from '@taqueria/protocol/PluginResponseEncoding';
2
3
  import * as SanitizedAbsPath from '@taqueria/protocol/SanitizedAbsPath';
3
4
  import * as Url from '@taqueria/protocol/Url';
4
5
  import { z } from 'zod';
@@ -51,7 +52,6 @@ export const rawSchema = z.object({
51
52
  z.string().min(3),
52
53
  ),
53
54
  setVersion: z.string().min(3),
54
- template: z.string().min(1).optional(),
55
55
  pluginName: z.string().min(1).optional(),
56
56
  }, { description: 'Sanitizied Args' }).passthrough();
57
57
 
@@ -78,6 +78,10 @@ export const provisionRawSchema = rawSchema
78
78
  })
79
79
  .passthrough();
80
80
 
81
+ export const templateRawSchema = rawSchema.extend({
82
+ template: z.string().min(1),
83
+ }).passthrough();
84
+
81
85
  export const managePluginRawSchema = rawSchema.omit({ pluginName: true }).extend({
82
86
  pluginName: z.string().min(1),
83
87
  });
@@ -86,11 +90,34 @@ export const versionRawSchema = rawSchema.extend({
86
90
  version: z.boolean().default(true),
87
91
  });
88
92
 
93
+ export const addContractsRawSchema = z.preprocess(
94
+ val => {
95
+ const obj: {
96
+ contractName?: string;
97
+ sourceFile?: string;
98
+ } = typeof val === 'object' ? Object(val) : ({ contractName: '', sourceFile: '' });
99
+ return !obj.contractName && obj.sourceFile
100
+ ? { ...obj, contractName: obj['sourceFile'] }
101
+ : obj;
102
+ },
103
+ rawSchema.extend({
104
+ sourceFile: z.string().min(1),
105
+ contractName: z.string().min(1),
106
+ }),
107
+ );
108
+
109
+ export const removeContractsRawSchema = rawSchema.extend({
110
+ contractName: z.string().min(1),
111
+ });
112
+
89
113
  type RawInput = z.infer<typeof rawSchema>;
90
114
  type RawScaffoldInput = z.infer<typeof scaffoldRawSchema>;
91
115
  type RawProvisionInput = z.infer<typeof provisionRawSchema>;
92
116
  type RawManagePluginInput = z.infer<typeof managePluginRawSchema>;
93
117
  type RawVersionInput = z.infer<typeof versionRawSchema>;
118
+ type RawTemplateInput = z.infer<typeof templateRawSchema>;
119
+ type RawAddContractsInput = z.infer<typeof addContractsRawSchema>;
120
+ type RawRemoveContractsInput = z.infer<typeof removeContractsRawSchema>;
94
121
 
95
122
  export const { schemas: generatedSchemas, factory } = createType<RawInput, RawInput>({
96
123
  rawSchema,
@@ -132,10 +159,31 @@ export const uninstallTaskArgs = createType<RawManagePluginInput, RawManagePlugi
132
159
  unknownErrMsg: 'Something went wrong parsing the arguments for the uninstall task',
133
160
  });
134
161
 
162
+ export const createTaskArgs = createType<RawTemplateInput, RawTemplateInput>({
163
+ rawSchema: templateRawSchema,
164
+ parseErrMsg: 'The arguments provided are invalid for the create task',
165
+ unknownErrMsg: 'Something went wrong parsing the arguments for the create task',
166
+ });
167
+
168
+ export const addContractArgs = createType<RawAddContractsInput, RawAddContractsInput>({
169
+ rawSchema: addContractsRawSchema,
170
+ parseErrMsg: 'Please specify the source file to register.',
171
+ unknownErrMsg: 'Something went wrong parsing the arguments for registering a contract.',
172
+ });
173
+
174
+ export const removeContractsArgs = createType<RawRemoveContractsInput, RawRemoveContractsInput>({
175
+ rawSchema: removeContractsRawSchema,
176
+ parseErrMsg: 'Please specify the contract name to unregister.',
177
+ unknownErrMsg: 'Something went wrong parsing the arguments to unregister a contract.',
178
+ });
179
+
135
180
  export type ScaffoldTaskArgs = z.infer<typeof scaffoldTaskArgs.schemas.schema>;
136
181
  export type ProvisionTaskArgs = z.infer<typeof provisionTaskArgs.schemas.schema>;
137
182
  export type InstallTaskArgs = z.infer<typeof installTaskArgs.schemas.schema>;
138
183
  export type UninstallTaskArgs = z.infer<typeof uninstallTaskArgs.schemas.schema>;
184
+ export type CreateTaskArgs = z.infer<typeof createTaskArgs.schemas.schema>;
185
+ export type AddContractArgs = z.infer<typeof addContractArgs.schemas.schema>;
186
+ export type RemoveContractArgs = z.infer<typeof removeContractsArgs.schemas.schema>;
139
187
 
140
188
  export const createScaffoldTaskArgs = scaffoldTaskArgs.factory.from;
141
189
  export const makeScaffoldTaskArgs = scaffoldTaskArgs.factory.make;
@@ -152,3 +200,14 @@ export const ofInstallTaskArgs = installTaskArgs.factory.of;
152
200
  export const createUninstallTaskArgs = uninstallTaskArgs.factory.create;
153
201
  export const makeUninstallTaskArgs = uninstallTaskArgs.factory.make;
154
202
  export const ofUninstallTaskArgs = uninstallTaskArgs.factory.of;
203
+
204
+ export const createCreateTaskArgs = createTaskArgs.factory.create;
205
+ export const makeCreateTaskArgs = createTaskArgs.factory.make;
206
+ export const ofCreateTaskArgs = createTaskArgs.factory.of;
207
+ export const createAddContractArgs = addContractArgs.factory.create;
208
+ export const makeAddContractArgs = addContractArgs.factory.make;
209
+ export const ofAddContractArgs = addContractArgs.factory.of;
210
+
211
+ export const createRemoveContractsArgs = removeContractsArgs.factory.create;
212
+ export const makeRemoveContractsArgs = removeContractsArgs.factory.make;
213
+ export const ofRemoveContractsArgs = removeContractsArgs.factory.of;
@@ -0,0 +1,6 @@
1
+ // TODO - use zod schema
2
+ export interface ScaffoldType {
3
+ postInit?: string;
4
+ }
5
+
6
+ export type t = ScaffoldType;
package/TaqError.ts CHANGED
@@ -19,8 +19,11 @@ export type ErrorType =
19
19
  | 'E_PARSE'
20
20
  | 'E_PARSE_UNKNOWN'
21
21
  | 'E_INVALID_ARCH'
22
+ | 'E_CONTRACT_REGISTERED'
23
+ | 'E_CONTRACT_NOT_REGISTERED'
22
24
  | 'E_NO_PROVISIONS'
23
- | 'E_INTERNAL_LOGICAL_VALIDATION_FAILURE';
25
+ | 'E_INTERNAL_LOGICAL_VALIDATION_FAILURE'
26
+ | 'E_EXEC';
24
27
 
25
28
  export interface TaqError {
26
29
  readonly kind: ErrorType;
package/Task.ts CHANGED
@@ -2,22 +2,11 @@ import * as Alias from '@taqueria/protocol/Alias';
2
2
  import createType, { Flatten } from '@taqueria/protocol/Base';
3
3
  import * as Command from '@taqueria/protocol/Command';
4
4
  import * as Option from '@taqueria/protocol/Option';
5
+ import * as PluginResponseEncoding from '@taqueria/protocol/PluginResponseEncoding';
5
6
  import * as PositionalArg from '@taqueria/protocol/PositionalArg';
6
7
  import * as Verb from '@taqueria/protocol/Verb';
7
8
  import { z } from 'zod';
8
9
 
9
- const taskEncodingSchema = z.preprocess(
10
- (val: unknown) => val ?? 'none',
11
- z.union([
12
- z.literal('json'),
13
- z.literal('application/json'),
14
- z.literal('none'),
15
- ])
16
- .default('none')
17
- .describe('Task Encoding')
18
- .optional(),
19
- );
20
-
21
10
  const taskHandlerSchema = z.union([
22
11
  z.literal('proxy'),
23
12
  z.string().min(1),
@@ -30,20 +19,17 @@ export const rawSchema = z.object({
30
19
  description: z.string({ description: 'Task Description' }).min(3),
31
20
  example: z.string({ description: 'Task Example' }).optional(),
32
21
  hidden: z.boolean({ description: 'Task Is Hidden' }).default(false).optional(),
33
- encoding: taskEncodingSchema.describe('Task Encoding'),
22
+ encoding: PluginResponseEncoding.rawSchema.optional(),
34
23
  handler: taskHandlerSchema.describe('Task Handler'),
35
24
  options: z.array(Option.rawSchema).default([]).describe('Task Options').optional(),
36
25
  positionals: z.array(PositionalArg.rawSchema).default([]).describe('Task Positional Args').optional(),
37
26
  }).describe('Task');
38
27
 
39
- const internalSchema = z.object({
28
+ const internalSchema = rawSchema.extend({
40
29
  task: Verb.schemas.schema.describe('Task Name'),
41
30
  command: Command.schemas.schema.describe('Task Command'),
42
- aliases: z.array(Alias.rawSchema).default([]).describe('Task Aliases').optional(),
43
- description: z.string({ description: 'Task Description' }).min(3),
44
- example: z.string({ description: 'Task Example' }).optional(),
45
- hidden: z.boolean({ description: 'Task Is Hidden' }).default(false).optional(),
46
- encoding: taskEncodingSchema.describe('Task Encoding'),
31
+ aliases: z.array(Alias.schemas.schema).default([]).describe('Task Aliases').optional(),
32
+ encoding: PluginResponseEncoding.schemas.schema.optional(),
47
33
  handler: taskHandlerSchema.describe('Task Handler'),
48
34
  options: z.preprocess(
49
35
  val => val ?? [],
package/Template.ts ADDED
@@ -0,0 +1,76 @@
1
+ import createType from '@taqueria/protocol/Base';
2
+ import * as Command from '@taqueria/protocol/Command';
3
+ import * as Option from '@taqueria/protocol/Option';
4
+ import * as PluginJsonResponse from '@taqueria/protocol/PluginJsonResponse';
5
+ import * as PluginResponseEncoding from '@taqueria/protocol/PluginResponseEncoding';
6
+ import * as PositionalArg from '@taqueria/protocol/PositionalArg';
7
+ import * as RequestArgs from '@taqueria/protocol/RequestArgs';
8
+ import * as Verb from '@taqueria/protocol/Verb';
9
+ import { z } from 'zod';
10
+
11
+ const handlerSchema = z.union([
12
+ z.string().min(1),
13
+ z.function().args(RequestArgs.schemas.schema).returns(z.union([
14
+ z.void(),
15
+ PluginJsonResponse.schemas.schema,
16
+ PluginJsonResponse.schemas.internalSchema,
17
+ z.promise(
18
+ z.union([
19
+ z.void(),
20
+ PluginJsonResponse.schemas.schema,
21
+ PluginJsonResponse.schemas.internalSchema,
22
+ ]),
23
+ ),
24
+ ])),
25
+ ]);
26
+
27
+ export const rawSchema = z.object({
28
+ template: Verb.rawSchema,
29
+ command: Command.rawSchema,
30
+ description: z.string().min(4),
31
+ hidden: z.preprocess(
32
+ val => val ?? false,
33
+ z.boolean(),
34
+ ).optional(),
35
+ options: z.preprocess(
36
+ val => val ?? [],
37
+ z.array(Option.rawSchema),
38
+ ).optional(),
39
+ positionals: z.preprocess(
40
+ val => val ?? [],
41
+ z.array(PositionalArg.rawSchema),
42
+ ).optional(),
43
+ handler: handlerSchema.describe('Template Handler'),
44
+ encoding: PluginResponseEncoding.schemas.schema.optional(),
45
+ });
46
+
47
+ export const internalSchema = rawSchema.extend({
48
+ template: Verb.schemas.schema,
49
+ command: Command.schemas.schema,
50
+ options: z.preprocess(
51
+ val => val ?? [],
52
+ z.array(Option.schemas.schema),
53
+ ).optional(),
54
+ positionals: z.preprocess(
55
+ val => val ?? [],
56
+ z.array(PositionalArg.schemas.schema),
57
+ ).optional(),
58
+ });
59
+
60
+ type RawInput = z.infer<typeof rawSchema>;
61
+ type Input = z.infer<typeof internalSchema>;
62
+
63
+ export const { schemas: generatedSchemas, factory } = createType<RawInput, Input>({
64
+ rawSchema,
65
+ internalSchema,
66
+ parseErrMsg: (value: unknown) => `The following template is invalid: ${value}`,
67
+ unknownErrMsg: 'Something went wrong trying to parse the template',
68
+ });
69
+
70
+ export type Template = z.infer<typeof generatedSchemas.schema>;
71
+ export type t = Template;
72
+ export const { create, make, of } = factory;
73
+ export const schemas = {
74
+ ...generatedSchemas,
75
+ schema: generatedSchemas.schema.transform(val => val as unknown as Template),
76
+ };
package/i18n.ts CHANGED
@@ -54,6 +54,15 @@ export default async (): Promise<i18n> => {
54
54
  'buildDesc': 'Display build information about the current version',
55
55
  'pluginOption': "Use to specify what plugin you'd like when running this task.",
56
56
  'yesOptionDesc': 'Select "yes" to any prompt',
57
+ 'templateNotFound': 'Template not found. Perhaps you need to install a plugin?',
58
+ 'createDesc': 'Create files from pre-existing templates',
59
+ 'templateDesc': 'Name of the template to use',
60
+ 'addContractDesc': 'Add a contract to the contract registry',
61
+ 'addSourceFileDesc': 'Source file to add to the contract registry',
62
+ 'removeContractDesc': 'Remove a contract from the contract registry',
63
+ 'removeContractNameDesc': 'The name of the contract to remove',
64
+ 'noContractsRegistered': 'No registered contracts found',
65
+ 'listContractsDesc': 'List registered contracts',
57
66
  },
58
67
  },
59
68
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taqueria/protocol",
3
- "version": "0.6.1",
3
+ "version": "0.6.6",
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,108 +1,35 @@
1
- import * as Alias from '@taqueria/protocol/Alias';
2
- import * as Config from '@taqueria/protocol/Config';
3
- import * as EconomicalProtocolHash from '@taqueria/protocol/EconomicalProtocolHash';
4
- import * as Environment from '@taqueria/protocol/Environment';
5
- import * as EphemeralState from '@taqueria/protocol/EphemeralState';
6
- import * as HumanReadableIdentifier from '@taqueria/protocol/HumanReadableIdentifier';
7
- import * as i18n from '@taqueria/protocol/i18n';
8
- import * as InstalledPlugin from '@taqueria/protocol/InstalledPlugin';
9
- import * as LoadedConfig from '@taqueria/protocol/LoadedConfig';
10
- import * as NetworkConfig from '@taqueria/protocol/NetworkConfig';
11
- import * as Operation from '@taqueria/protocol/Operation';
12
- import * as Option from '@taqueria/protocol/Option';
13
- import * as ParsedOperation from '@taqueria/protocol/ParsedOperation';
14
- import * as ParsedPluginInfo from '@taqueria/protocol/ParsedPluginInfo';
15
- import * as PersistentState from '@taqueria/protocol/PersistentState';
16
- import * as PluginInfo from '@taqueria/protocol/PluginInfo';
17
- import * as PositionalArg from '@taqueria/protocol/PositionalArg';
18
- import * as RequestArgs from '@taqueria/protocol/RequestArgs';
19
- import * as SandboxAccountConfig from '@taqueria/protocol/SandboxAccountConfig';
20
- import * as SandboxConfig from '@taqueria/protocol/SandboxConfig';
21
- import * as SanitizedAbsPath from '@taqueria/protocol/SanitizedAbsPath';
22
- import * as SanitizedArgs from '@taqueria/protocol/SanitizedArgs';
23
- import * as SanitizedPath from '@taqueria/protocol/SanitizedPath';
24
- import * as SHA256 from '@taqueria/protocol/SHA256';
25
- import * as TaqError from '@taqueria/protocol/TaqError';
26
- import * as Task from '@taqueria/protocol/Task';
27
- import * as Url from '@taqueria/protocol/Url';
28
- import * as Verb from '@taqueria/protocol/Verb';
29
- import * as VersionNumber from '@taqueria/protocol/VersionNumber';
30
- export interface RuntimeDependency {
31
- readonly name: string;
32
- readonly path: string;
33
- readonly version: string;
34
- readonly kind: 'required' | 'optional';
35
- }
36
-
37
- export type PluginActionName =
38
- | 'checkRuntimeDependencies'
39
- | 'installRuntimeDependencies'
40
- | 'proxy'
41
- | 'pluginInfo'
42
- | string;
43
-
44
- export type PluginProxyAction = Task.t;
45
-
46
- export type PluginAction = 'checkRuntimeDependencies' | 'installRuntimeDependencies' | 'pluginInfo' | PluginProxyAction;
47
-
48
- export interface RuntimeDependencyReport extends RuntimeDependency {
49
- readonly met: boolean;
50
- }
51
-
52
- export interface CheckRuntimeDependenciesResponse {
53
- readonly report: RuntimeDependencyReport[];
54
- }
55
-
56
- export interface InstallRuntimeDependenciesResponse {
57
- readonly report: RuntimeDependencyReport[];
58
- }
59
-
60
- export type PluginActionNotSupportedResponse = {
61
- readonly status: 'notSupported';
62
- readonly msg: string;
63
- };
64
-
65
- export interface PluginJsonResponse {
66
- readonly data?: unknown;
67
- readonly render?: 'none' | 'string' | 'table';
68
- }
69
-
70
- export type PluginResponse =
71
- | PluginJsonResponse
72
- | CheckRuntimeDependenciesResponse
73
- | InstallRuntimeDependenciesResponse
74
- | PluginInfo.t
75
- | PluginActionNotSupportedResponse
76
- | void;
77
-
78
- export {
79
- Alias,
80
- Config,
81
- EconomicalProtocolHash,
82
- Environment,
83
- EphemeralState,
84
- HumanReadableIdentifier,
85
- i18n,
86
- InstalledPlugin,
87
- LoadedConfig,
88
- NetworkConfig,
89
- Operation,
90
- Option,
91
- ParsedOperation,
92
- ParsedPluginInfo,
93
- PersistentState,
94
- PluginInfo,
95
- PositionalArg,
96
- RequestArgs,
97
- SandboxAccountConfig,
98
- SandboxConfig,
99
- SanitizedAbsPath,
100
- SanitizedArgs,
101
- SanitizedPath,
102
- SHA256,
103
- TaqError,
104
- Task,
105
- Url,
106
- Verb,
107
- VersionNumber,
108
- };
1
+ export * as Alias from '@taqueria/protocol/Alias';
2
+ export * as Config from '@taqueria/protocol/Config';
3
+ export * as EconomicalProtocolHash from '@taqueria/protocol/EconomicalProtocolHash';
4
+ export * as Environment from '@taqueria/protocol/Environment';
5
+ export * as EphemeralState from '@taqueria/protocol/EphemeralState';
6
+ export * as HumanReadableIdentifier from '@taqueria/protocol/HumanReadableIdentifier';
7
+ export * as i18n from '@taqueria/protocol/i18n';
8
+ export * as InstalledPlugin from '@taqueria/protocol/InstalledPlugin';
9
+ export * as LoadedConfig from '@taqueria/protocol/LoadedConfig';
10
+ export * as NetworkConfig from '@taqueria/protocol/NetworkConfig';
11
+ export * as Operation from '@taqueria/protocol/Operation';
12
+ export * as Option from '@taqueria/protocol/Option';
13
+ export * as ParsedOperation from '@taqueria/protocol/ParsedOperation';
14
+ export * as ParsedTemplate from '@taqueria/protocol/ParsedTemplate';
15
+ export * as PersistentState from '@taqueria/protocol/PersistentState';
16
+ export * as PluginActionName from '@taqueria/protocol/PluginActionName';
17
+ export * as PluginInfo from '@taqueria/protocol/PluginInfo';
18
+ export * as PluginJsonResponse from '@taqueria/protocol/PluginJsonResponse';
19
+ export * as PluginResponseEncoding from '@taqueria/protocol/PluginResponseEncoding';
20
+ export * as PluginSchema from '@taqueria/protocol/PluginSchema';
21
+ export * as PositionalArg from '@taqueria/protocol/PositionalArg';
22
+ export * as RequestArgs from '@taqueria/protocol/RequestArgs';
23
+ export * as SandboxAccountConfig from '@taqueria/protocol/SandboxAccountConfig';
24
+ export * as SandboxConfig from '@taqueria/protocol/SandboxConfig';
25
+ export * as SanitizedAbsPath from '@taqueria/protocol/SanitizedAbsPath';
26
+ export * as SanitizedArgs from '@taqueria/protocol/SanitizedArgs';
27
+ export * as SanitizedPath from '@taqueria/protocol/SanitizedPath';
28
+ export * as ScaffoldConfig from '@taqueria/protocol/ScaffoldConfig';
29
+ export * as SHA256 from '@taqueria/protocol/SHA256';
30
+ export * as TaqError from '@taqueria/protocol/TaqError';
31
+ export * as Task from '@taqueria/protocol/Task';
32
+ export * as Template from '@taqueria/protocol/Template';
33
+ export * as Url from '@taqueria/protocol/Url';
34
+ export * as Verb from '@taqueria/protocol/Verb';
35
+ export * as VersionNumber from '@taqueria/protocol/VersionNumber';
@@ -1,47 +0,0 @@
1
- import createType from '@taqueria/protocol/Base';
2
- import * as ParsedOperation from '@taqueria/protocol/ParsedOperation';
3
- import * as PluginInfo from '@taqueria/protocol/PluginInfo';
4
- import { z } from 'zod';
5
-
6
- const internalSchema = PluginInfo.internalSchema.extend({
7
- operations: z.preprocess(
8
- val => val ?? [],
9
- z.array(
10
- ParsedOperation.schemas.schema,
11
- { description: 'ParsedOperations' },
12
- )
13
- .optional(),
14
- ),
15
- }).describe('ParsedPluginInfo');
16
-
17
- export const rawSchema = PluginInfo.internalSchema.extend({
18
- operations: z.preprocess(
19
- val => val ?? [],
20
- z.array(
21
- ParsedOperation.rawSchema,
22
- { description: 'ParsedOperation' },
23
- ),
24
- )
25
- .optional(),
26
- }).describe('ParsedPluginInfo');
27
-
28
- type Input = z.infer<typeof internalSchema>;
29
-
30
- type RawInput = z.infer<typeof rawSchema>;
31
-
32
- export const { schemas: generatedSchemas, factory } = createType<RawInput, Input>({
33
- rawSchema,
34
- internalSchema,
35
- parseErrMsg: (value: unknown) =>
36
- `The following plugin info gave us trouble when parsing the following plugin information: ${value}`,
37
- unknownErrMsg: 'Something went wrong trying to parse the plugin information',
38
- });
39
-
40
- export type ParsedPluginInfo = z.infer<typeof generatedSchemas.schema>;
41
- export type t = ParsedPluginInfo;
42
- export const { create, of, make } = factory;
43
-
44
- export const schemas = {
45
- ...generatedSchemas,
46
- schema: generatedSchemas.schema.transform(val => val as ParsedPluginInfo),
47
- };