@taqueria/protocol 0.0.0-pr-902-0bc36f81 → 0.0.0-pr-902-45108945

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.
@@ -1,29 +1,10 @@
1
1
  import createType from '@taqueria/protocol/Base';
2
- import * as ParsedOperation from '@taqueria/protocol/ParsedOperation';
3
2
  import * as PluginInfo from '@taqueria/protocol/PluginInfo';
4
3
  import { z } from 'zod';
5
4
 
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');
5
+ const internalSchema = PluginInfo.internalSchema.extend({}).describe('ParsedPluginInfo');
16
6
 
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');
7
+ export const rawSchema = PluginInfo.internalSchema.extend({}).describe('ParsedPluginInfo');
27
8
 
28
9
  type Input = z.infer<typeof internalSchema>;
29
10
 
@@ -4,23 +4,11 @@ import * as Timestamp from '@taqueria/protocol/Timestamp';
4
4
  import * as Verb from '@taqueria/protocol/Verb';
5
5
  import { z } from 'zod';
6
6
 
7
- const rawOpSchema = z.object({
8
- hash: SHA256.rawSchema.describe('state.op.hash'),
9
- time: Timestamp.rawSchema.describe('state.op.time'),
10
- output: z.unknown().describe('state.op.output'),
11
- }).describe('Persistent State Operation');
12
-
13
7
  const rawTaskSchema = z.object({
14
8
  time: Timestamp.rawSchema.describe('state.task.time'),
15
9
  output: z.unknown().describe('state.task.output'),
16
10
  });
17
11
 
18
- const internalOpSchema = z.object({
19
- hash: SHA256.schemas.schema.describe('state.op.hash'),
20
- time: Timestamp.schemas.schema.describe('state.op.time'),
21
- output: z.unknown().describe('state.op.output'),
22
- });
23
-
24
12
  const internalTaskSchema = z.object({
25
13
  task: Verb.schemas.schema,
26
14
  plugin: z.string().min(1),
@@ -30,18 +18,13 @@ const internalTaskSchema = z.object({
30
18
 
31
19
  export type PersistedTask = z.infer<typeof internalTaskSchema>;
32
20
 
33
- export type PersistedOperation = z.infer<typeof internalOpSchema>;
34
-
35
21
  export const rawSchema = z.object({
36
- operations: z.record(rawOpSchema),
37
22
  tasks: z.record(rawTaskSchema),
38
23
  });
39
24
 
40
25
  export const internalSchema = z.object({
41
- operations: z.record(internalOpSchema),
42
26
  tasks: z.record(internalTaskSchema),
43
27
  }).transform(val => ({
44
- operations: val.operations as unknown as Record<string, PersistedOperation>,
45
28
  tasks: val.tasks as unknown as Record<string, PersistedTask>,
46
29
  }));
47
30
 
package/PluginInfo.ts CHANGED
@@ -1,6 +1,5 @@
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';
4
3
  import * as Task from '@taqueria/protocol/Task';
5
4
  import * as VersionNumber from '@taqueria/protocol/VersionNumber';
6
5
  import { z } from 'zod';
@@ -17,13 +16,6 @@ export const internalSchema = z.object({
17
16
  { description: 'Plugin Tasks' },
18
17
  ).optional(),
19
18
  ),
20
- operations: z.preprocess(
21
- val => val ?? [],
22
- z.array(
23
- Operation.schemas.schema.describe('Plugin Operation'),
24
- { description: 'Plugin Operations' },
25
- ).optional(),
26
- ),
27
19
  }).describe('Plugin Schema');
28
20
 
29
21
  export const rawSchema = z.object({
@@ -38,13 +30,6 @@ export const rawSchema = z.object({
38
30
  { description: 'Plugin Tasks' },
39
31
  ).optional(),
40
32
  ),
41
- operations: z.preprocess(
42
- val => val ?? [],
43
- z.array(
44
- Operation.rawSchema.describe('Plugin Operation'),
45
- { description: 'Plugin Operations' },
46
- ).optional(),
47
- ),
48
33
  }).describe('Plugin Schema');
49
34
 
50
35
  type RawInput = z.infer<typeof rawSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taqueria/protocol",
3
- "version": "0.0.0-pr-902-0bc36f81",
3
+ "version": "0.0.0-pr-902-45108945",
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": {
@@ -8,9 +8,7 @@ import * as i18n from '@taqueria/protocol/i18n';
8
8
  import * as InstalledPlugin from '@taqueria/protocol/InstalledPlugin';
9
9
  import * as LoadedConfig from '@taqueria/protocol/LoadedConfig';
10
10
  import * as NetworkConfig from '@taqueria/protocol/NetworkConfig';
11
- import * as Operation from '@taqueria/protocol/Operation';
12
11
  import * as Option from '@taqueria/protocol/Option';
13
- import * as ParsedOperation from '@taqueria/protocol/ParsedOperation';
14
12
  import * as ParsedPluginInfo from '@taqueria/protocol/ParsedPluginInfo';
15
13
  import * as PersistentState from '@taqueria/protocol/PersistentState';
16
14
  import * as PluginInfo from '@taqueria/protocol/PluginInfo';
@@ -86,9 +84,7 @@ export {
86
84
  InstalledPlugin,
87
85
  LoadedConfig,
88
86
  NetworkConfig,
89
- Operation,
90
87
  Option,
91
- ParsedOperation,
92
88
  ParsedPluginInfo,
93
89
  PersistentState,
94
90
  PluginInfo,
package/Operation.ts DELETED
@@ -1,70 +0,0 @@
1
- import createType, { Flatten } from '@taqueria/protocol/Base';
2
- import * as Command from '@taqueria/protocol/Command';
3
- import * as Option from '@taqueria/protocol/Option';
4
- import * as PersistentState from '@taqueria/protocol/PersistentState';
5
- import * as PositionalArg from '@taqueria/protocol/PositionalArg';
6
- import * as RequestArgs from '@taqueria/protocol/RequestArgs';
7
- import * as Verb from '@taqueria/protocol/Verb';
8
- import { z } from 'zod';
9
-
10
- type Handler = (state: PersistentState.t) => <T extends RequestArgs.t>(opts: T) => unknown;
11
-
12
- export const rawSchema = z.object({
13
- operation: Verb.rawSchema.describe('Operation Name'),
14
- command: Command.rawSchema.describe('Operation Command'),
15
- description: z.string({ description: 'Operation Description' }).optional(),
16
- positionals: z.array(PositionalArg.rawSchema).default([]).describe('Operation Positional Args').optional(),
17
- options: z.preprocess(
18
- (val: unknown) => val ?? [],
19
- z.array(
20
- Option.rawSchema.describe('Operation Option'),
21
- { description: 'Operation Options' },
22
- ).optional(),
23
- ),
24
- handler: z.function()
25
- .args(PersistentState.rawSchema)
26
- .returns(
27
- z.function()
28
- .args(RequestArgs.schemas.internalSchema),
29
- )
30
- .describe('Operation Handler')
31
- .transform((val: unknown) => val as Handler),
32
- }).describe('Operation');
33
-
34
- export const internalSchema = z.object({
35
- operation: Verb.schemas.schema.describe('Operation Name'),
36
- command: Command.schemas.schema.describe('Operation Command'),
37
- description: z.string({ description: 'Optionation Description' }).optional(),
38
- positionals: z.array(PositionalArg.schemas.schema).default([]).describe('Operation Positional Args').optional(),
39
- options: z.preprocess(
40
- (val: unknown) => val ?? [] as Option.t[],
41
- z.array(Option.schemas.schema.describe('Operation Option'), { description: 'Operation Options' }).optional(),
42
- ),
43
- handler: z.function()
44
- .args(PersistentState.rawSchema)
45
- .returns(
46
- z.function()
47
- .args(RequestArgs.schemas.schema),
48
- )
49
- .describe('Operation Handler')
50
- .transform((val: unknown) => val as Handler),
51
- }).describe('Operation');
52
-
53
- type Input = Flatten<z.infer<typeof internalSchema>>;
54
- type RawInput = z.infer<typeof rawSchema>;
55
-
56
- export const { schemas: generatedSchemas, factory } = createType<RawInput, Input>({
57
- rawSchema,
58
- internalSchema,
59
- parseErrMsg: (value: unknown) => `The following operation is invalid: ${value}`,
60
- unknownErrMsg: 'Something went wrong trying to parse the operation',
61
- });
62
-
63
- export type Operation = Flatten<z.infer<typeof generatedSchemas.schema>>;
64
- export type t = Operation;
65
- export const { make, of, create } = factory;
66
-
67
- export const schemas = {
68
- ...generatedSchemas,
69
- schema: generatedSchemas.schema.transform(val => val as Operation),
70
- };
@@ -1,33 +0,0 @@
1
- import createType from '@taqueria/protocol/Base';
2
- import * as Operation from '@taqueria/protocol/Operation';
3
- import { z } from 'zod';
4
-
5
- const internalSchema = Operation
6
- .internalSchema
7
- .describe('ParsedOperation')
8
- .omit({ handler: true });
9
-
10
- export const rawSchema = Operation
11
- .rawSchema
12
- .omit({ handler: true })
13
- .describe('ParsedOperation');
14
-
15
- type RawInput = z.infer<typeof rawSchema>;
16
- type Input = z.infer<typeof internalSchema>;
17
-
18
- export const { schemas: generatedSchemas, factory } = createType<RawInput, Input>({
19
- rawSchema,
20
- internalSchema,
21
- parseErrMsg: (value: unknown) => `Could not parse the following operation: ${value}`,
22
- unknownErrMsg: 'Something went wrong trying to parse an operation',
23
- });
24
-
25
- export type ParsedOperation = z.infer<typeof generatedSchemas.schema>;
26
- export type t = ParsedOperation;
27
-
28
- export const { create, make, of } = factory;
29
-
30
- export const schemas = {
31
- ...generatedSchemas,
32
- schema: generatedSchemas.schema.transform(val => val as ParsedOperation),
33
- };