@taqueria/protocol 0.0.0-pr-899-07313cc0 → 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.
- package/EphemeralState.ts +1 -70
- package/Option.ts +8 -2
- package/ParsedPluginInfo.ts +2 -21
- package/PersistentState.ts +0 -17
- package/PluginInfo.ts +0 -15
- package/PositionalArg.ts +4 -2
- package/SanitizedArgs.ts +2 -2
- package/package.json +1 -1
- package/taqueria-protocol-types.ts +0 -4
- package/Operation.ts +0 -70
- package/ParsedOperation.ts +0 -33
- package/Provisioner.ts +0 -61
- package/ProvisionerID.ts +0 -25
- package/Provisions.ts +0 -70
package/EphemeralState.ts
CHANGED
|
@@ -4,7 +4,6 @@ import * as Config from '@taqueria/protocol/Config';
|
|
|
4
4
|
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
|
-
import * as ParsedOperation from '@taqueria/protocol/ParsedOperation';
|
|
8
7
|
import * as ParsedPluginInfo from '@taqueria/protocol/ParsedPluginInfo';
|
|
9
8
|
import { E_TaqError, TaqError } from '@taqueria/protocol/TaqError';
|
|
10
9
|
import * as Task from '@taqueria/protocol/Task';
|
|
@@ -23,18 +22,11 @@ const taskToPluginMap = z.record(
|
|
|
23
22
|
Task.schemas.schema,
|
|
24
23
|
], { description: 'Task/Plugin Mapping' }),
|
|
25
24
|
);
|
|
26
|
-
const operationToPluginMap = z.record(
|
|
27
|
-
z.union([
|
|
28
|
-
InstalledPlugin.schemas.schema,
|
|
29
|
-
ParsedOperation.schemas.schema,
|
|
30
|
-
], { description: 'Operation/Plugin Mapping' }),
|
|
31
|
-
);
|
|
32
25
|
|
|
33
26
|
const rawSchema = z.object({
|
|
34
27
|
build: z.string({ description: 'cache.build' }),
|
|
35
28
|
configHash: z.string({ description: 'cache.configHash' }),
|
|
36
29
|
tasks: taskToPluginMap,
|
|
37
|
-
operations: operationToPluginMap,
|
|
38
30
|
plugins: z.array(ParsedPluginInfo.schemas.schema, { description: 'cache.plugins' }),
|
|
39
31
|
}).describe('Ephemeral State');
|
|
40
32
|
|
|
@@ -49,7 +41,6 @@ export const { schemas: generatedSchemas, factory } = createType<RawInput, RawIn
|
|
|
49
41
|
export type EphemeralState = z.infer<typeof generatedSchemas.schema>;
|
|
50
42
|
export type t = EphemeralState;
|
|
51
43
|
export type TaskToPluginMap = z.infer<typeof taskToPluginMap>;
|
|
52
|
-
export type OpToPluginMap = z.infer<typeof operationToPluginMap>;
|
|
53
44
|
|
|
54
45
|
export const { create, of, make } = factory;
|
|
55
46
|
|
|
@@ -83,27 +74,6 @@ const getTaskCounts = (pluginInfo: ParsedPluginInfo.t[]): Counts => {
|
|
|
83
74
|
);
|
|
84
75
|
};
|
|
85
76
|
|
|
86
|
-
const getOperationCounts = (pluginInfo: ParsedPluginInfo.t[]): Counts => {
|
|
87
|
-
return pluginInfo.reduce(
|
|
88
|
-
(retval, pluginInfo) =>
|
|
89
|
-
pluginInfo.operations === undefined
|
|
90
|
-
? retval
|
|
91
|
-
: pluginInfo.operations.reduce(
|
|
92
|
-
(retval: Counts, operation: ParsedOperation.t) => {
|
|
93
|
-
const operationName = operation.operation;
|
|
94
|
-
const providers = retval[operationName]
|
|
95
|
-
? [...retval[operationName], pluginInfo]
|
|
96
|
-
: [pluginInfo];
|
|
97
|
-
const mapping: Counts = {};
|
|
98
|
-
mapping[operationName] = providers.filter(provider => provider !== undefined);
|
|
99
|
-
return { ...retval, ...mapping };
|
|
100
|
-
},
|
|
101
|
-
retval,
|
|
102
|
-
),
|
|
103
|
-
{} as Counts,
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
77
|
const toChoices = (plugins: ParsedPluginInfo.t[]) =>
|
|
108
78
|
plugins.reduce(
|
|
109
79
|
(retval, pluginInfo) => {
|
|
@@ -141,6 +111,7 @@ export const mapTasksToPlugins = (config: Config.t, pluginInfo: ParsedPluginInfo
|
|
|
141
111
|
description: 'Specify which plugin should be used to execute this task',
|
|
142
112
|
choices: toChoices(taskCounts[task]),
|
|
143
113
|
required: true,
|
|
114
|
+
type: 'string',
|
|
144
115
|
})),
|
|
145
116
|
],
|
|
146
117
|
handler: 'proxy',
|
|
@@ -161,46 +132,6 @@ export const mapTasksToPlugins = (config: Config.t, pluginInfo: ParsedPluginInfo
|
|
|
161
132
|
).pipe(mapRej(rej => rej as TaqError));
|
|
162
133
|
};
|
|
163
134
|
|
|
164
|
-
export const mapOperationsToPlugins = (config: Config.t, pluginInfo: ParsedPluginInfo.t[], i18n: i18n) => {
|
|
165
|
-
const opCounts = getOperationCounts(pluginInfo);
|
|
166
|
-
return attemptP(async () =>
|
|
167
|
-
await pluginInfo.reduce(
|
|
168
|
-
async (retval, pluginInfo) =>
|
|
169
|
-
!pluginInfo.operations
|
|
170
|
-
? Promise.resolve({} as OpToPluginMap)
|
|
171
|
-
: await pluginInfo.operations.reduce(
|
|
172
|
-
async (retval, { operation }) => {
|
|
173
|
-
if (isComposite(operation, opCounts)) {
|
|
174
|
-
const command = await eager(Command.make(operation));
|
|
175
|
-
const compositeOp = await eager(ParsedOperation.make({
|
|
176
|
-
operation,
|
|
177
|
-
command,
|
|
178
|
-
description: i18n.__('providedByMany'),
|
|
179
|
-
options: [
|
|
180
|
-
await eager(Option.make({
|
|
181
|
-
flag: await eager(Verb.make('plugin')),
|
|
182
|
-
description: 'Specify which plugin should be used to execute this operation',
|
|
183
|
-
choices: toChoices(opCounts[operation]),
|
|
184
|
-
required: true,
|
|
185
|
-
})),
|
|
186
|
-
],
|
|
187
|
-
}));
|
|
188
|
-
return { ...await retval, [operation]: compositeOp };
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// Operation is provided by just a single plugin
|
|
192
|
-
const installedPlugin = getInstalledPlugin(config, pluginInfo.name);
|
|
193
|
-
return installedPlugin
|
|
194
|
-
? { ...await retval, [operation]: installedPlugin }
|
|
195
|
-
: retval;
|
|
196
|
-
},
|
|
197
|
-
retval,
|
|
198
|
-
),
|
|
199
|
-
Promise.resolve({} as OpToPluginMap),
|
|
200
|
-
)
|
|
201
|
-
).pipe(mapRej(rej => rej as TaqError));
|
|
202
|
-
};
|
|
203
|
-
|
|
204
135
|
export const getTasks = (pluginInfo: ParsedPluginInfo.t[]) =>
|
|
205
136
|
pluginInfo.reduce(
|
|
206
137
|
(retval: Task.t[], pluginInfo) => [...retval, ...(pluginInfo.tasks ?? [])],
|
package/Option.ts
CHANGED
|
@@ -16,7 +16,10 @@ export const internalSchema = z.object({
|
|
|
16
16
|
{ description: 'Option Choices' },
|
|
17
17
|
).optional(),
|
|
18
18
|
required: z.boolean({ description: 'Option Is Required' }).default(false).optional(),
|
|
19
|
-
|
|
19
|
+
type: z.union(
|
|
20
|
+
[z.literal('string'), z.literal('number'), z.literal('boolean')],
|
|
21
|
+
{ description: 'Positional Arg Datatype' },
|
|
22
|
+
),
|
|
20
23
|
}).describe('Option');
|
|
21
24
|
|
|
22
25
|
export const rawSchema = z.object({
|
|
@@ -32,7 +35,10 @@ export const rawSchema = z.object({
|
|
|
32
35
|
{ description: 'Option Choices' },
|
|
33
36
|
).optional(),
|
|
34
37
|
required: z.boolean({ description: 'Option Is Required' }).default(false).optional(),
|
|
35
|
-
|
|
38
|
+
type: z.union(
|
|
39
|
+
[z.literal('string'), z.literal('number'), z.literal('boolean')],
|
|
40
|
+
{ description: 'Positional Arg Datatype' },
|
|
41
|
+
),
|
|
36
42
|
}).describe('Option');
|
|
37
43
|
|
|
38
44
|
type RawInput = z.infer<typeof rawSchema>;
|
package/ParsedPluginInfo.ts
CHANGED
|
@@ -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
|
|
package/PersistentState.ts
CHANGED
|
@@ -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/PositionalArg.ts
CHANGED
|
@@ -12,7 +12,8 @@ export const rawSchema = z.object({
|
|
|
12
12
|
type: z.union(
|
|
13
13
|
[z.literal('string'), z.literal('number'), z.literal('boolean')],
|
|
14
14
|
{ description: 'Positional Arg Datatype' },
|
|
15
|
-
)
|
|
15
|
+
),
|
|
16
|
+
required: z.boolean().optional(),
|
|
16
17
|
}).describe('Positional Arg');
|
|
17
18
|
|
|
18
19
|
const internalSchema = z.object({
|
|
@@ -25,7 +26,8 @@ const internalSchema = z.object({
|
|
|
25
26
|
type: z.union(
|
|
26
27
|
[z.literal('string'), z.literal('number'), z.literal('boolean')],
|
|
27
28
|
{ description: 'Positional Arg Datatype' },
|
|
28
|
-
)
|
|
29
|
+
),
|
|
30
|
+
required: z.boolean().optional(),
|
|
29
31
|
}).describe('Positional Arg');
|
|
30
32
|
|
|
31
33
|
type RawInput = z.infer<typeof rawSchema>;
|
package/SanitizedArgs.ts
CHANGED
|
@@ -62,10 +62,10 @@ export const scaffoldRawSchema = rawSchema.extend({
|
|
|
62
62
|
|
|
63
63
|
export const provisionRawSchema = rawSchema
|
|
64
64
|
.extend({
|
|
65
|
-
|
|
65
|
+
task: z
|
|
66
66
|
.string()
|
|
67
67
|
.min(1)
|
|
68
|
-
.describe('
|
|
68
|
+
.describe('Task name'),
|
|
69
69
|
name: z
|
|
70
70
|
.string()
|
|
71
71
|
.min(1)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taqueria/protocol",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
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
|
-
};
|
package/ParsedOperation.ts
DELETED
|
@@ -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
|
-
};
|
package/Provisioner.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import createType from '@taqueria/protocol/Base';
|
|
2
|
-
import * as ProvisionerID from '@taqueria/protocol/ProvisionerID';
|
|
3
|
-
import { z } from 'zod';
|
|
4
|
-
|
|
5
|
-
export const rawSchema = z.object(
|
|
6
|
-
{
|
|
7
|
-
id: ProvisionerID.rawSchema,
|
|
8
|
-
plugin: z
|
|
9
|
-
.string()
|
|
10
|
-
.min(1)
|
|
11
|
-
.describe('Provisioner Plugin')
|
|
12
|
-
.optional(),
|
|
13
|
-
operation: z
|
|
14
|
-
.union([
|
|
15
|
-
z.string().min(1),
|
|
16
|
-
z.literal('custom'),
|
|
17
|
-
])
|
|
18
|
-
.describe('Provisioner Operation'),
|
|
19
|
-
command: z
|
|
20
|
-
.string()
|
|
21
|
-
.describe('Provisioner Custom Command')
|
|
22
|
-
.optional(),
|
|
23
|
-
label: z
|
|
24
|
-
.string()
|
|
25
|
-
.describe('Provisioner Label')
|
|
26
|
-
.optional(),
|
|
27
|
-
depends_on: z
|
|
28
|
-
.array(
|
|
29
|
-
ProvisionerID.rawSchema,
|
|
30
|
-
)
|
|
31
|
-
.optional(),
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
description: 'Provisioner',
|
|
35
|
-
},
|
|
36
|
-
)
|
|
37
|
-
.passthrough();
|
|
38
|
-
|
|
39
|
-
export const internalSchema = rawSchema.extend({
|
|
40
|
-
id: ProvisionerID.schemas.schema,
|
|
41
|
-
depends_on: z.array(ProvisionerID.schemas.schema).optional(),
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
type RawInput = z.infer<typeof rawSchema>;
|
|
45
|
-
type Input = z.infer<typeof internalSchema>;
|
|
46
|
-
|
|
47
|
-
export const { schemas: generatedSchemas, factory } = createType<RawInput, Input>({
|
|
48
|
-
rawSchema,
|
|
49
|
-
internalSchema,
|
|
50
|
-
parseErrMsg: 'There was a problem trying to parse the provisioner',
|
|
51
|
-
unknownErrMsg: 'Something went wrong trying to parse the provisioner',
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
export type Provisioner = z.infer<typeof generatedSchemas.schema>;
|
|
55
|
-
export type t = Provisioner;
|
|
56
|
-
export const { create, of, make } = factory;
|
|
57
|
-
|
|
58
|
-
export const schemas = {
|
|
59
|
-
...generatedSchemas,
|
|
60
|
-
schema: generatedSchemas.schema.transform(val => val as unknown as Provisioner),
|
|
61
|
-
};
|
package/ProvisionerID.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import createType from '@taqueria/protocol/Base';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
|
|
4
|
-
export const rawSchema = z
|
|
5
|
-
.string()
|
|
6
|
-
.min(1)
|
|
7
|
-
.regex(/^[A-Za-z0-9]+[A-Za-z0-9-_]+\.[A-Za-z0-9]+[A-Za-z0-9-_]+\.[A-Za-z0-9]+[A-Za-z0-9-_]+$/)
|
|
8
|
-
.describe('Provisioner ID');
|
|
9
|
-
|
|
10
|
-
type RawInput = z.infer<typeof rawSchema>;
|
|
11
|
-
|
|
12
|
-
export const { schemas: generatedSchemas, factory } = createType<RawInput, RawInput>({
|
|
13
|
-
rawSchema,
|
|
14
|
-
parseErrMsg: (value: unknown) => `${value} is not a valid provisioner ID`,
|
|
15
|
-
unknownErrMsg: 'Something went wrong trying to parse the provision ID',
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export type ProvisionerID = z.infer<typeof generatedSchemas.schema>;
|
|
19
|
-
export type t = ProvisionerID;
|
|
20
|
-
export const { create, of, make } = factory;
|
|
21
|
-
|
|
22
|
-
export const schemas = {
|
|
23
|
-
...generatedSchemas,
|
|
24
|
-
schema: generatedSchemas.schema.transform(val => val as ProvisionerID),
|
|
25
|
-
};
|
package/Provisions.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import createType, { Flatten } from '@taqueria/protocol/Base';
|
|
2
|
-
import * as Provisioner from '@taqueria/protocol/Provisioner';
|
|
3
|
-
import * as ProvisionerID from '@taqueria/protocol/ProvisionerID';
|
|
4
|
-
import { memoizy } from 'memoizy';
|
|
5
|
-
import { partitionArray, uniq } from 'rambda';
|
|
6
|
-
import { z } from 'zod';
|
|
7
|
-
|
|
8
|
-
const getInvalidIds = memoizy((provisions: Provisioner.t[]) => {
|
|
9
|
-
const ids = provisions.map(p => p.id);
|
|
10
|
-
return provisions.reduce(
|
|
11
|
-
(retval, provision) => {
|
|
12
|
-
const depends_on = provision.depends_on ?? [];
|
|
13
|
-
const invalid = partitionArray(
|
|
14
|
-
(id: ProvisionerID.t) => ids.includes(id),
|
|
15
|
-
depends_on,
|
|
16
|
-
).pop() as ProvisionerID.t[];
|
|
17
|
-
|
|
18
|
-
return uniq([...retval, ...invalid]);
|
|
19
|
-
},
|
|
20
|
-
[] as ProvisionerID.t[],
|
|
21
|
-
);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const rawSchema = z
|
|
25
|
-
.array(
|
|
26
|
-
Provisioner.rawSchema,
|
|
27
|
-
)
|
|
28
|
-
.refine(
|
|
29
|
-
provisions => getInvalidIds(provisions).length === 0,
|
|
30
|
-
provisions => ({
|
|
31
|
-
message:
|
|
32
|
-
`One or more of your provisioners depends on an invalid provisioner. The following provisioner ids were referenced that do not exist: ${
|
|
33
|
-
getInvalidIds(provisions).join(', ')
|
|
34
|
-
}`,
|
|
35
|
-
}),
|
|
36
|
-
)
|
|
37
|
-
.describe('Provisions');
|
|
38
|
-
|
|
39
|
-
type RawInput = z.infer<typeof rawSchema>;
|
|
40
|
-
|
|
41
|
-
const internalSchema = z
|
|
42
|
-
.array(Provisioner.schemas.schema)
|
|
43
|
-
.refine(
|
|
44
|
-
provisions => getInvalidIds(provisions).length === 0,
|
|
45
|
-
provisions => ({
|
|
46
|
-
message:
|
|
47
|
-
`One or more of your provisioners depends on an invalid provisioner. The following provisioner ids were referenced that do not exist: ${
|
|
48
|
-
getInvalidIds(provisions).join(', ')
|
|
49
|
-
}`,
|
|
50
|
-
}),
|
|
51
|
-
)
|
|
52
|
-
.describe('Provisions');
|
|
53
|
-
|
|
54
|
-
type Input = z.infer<typeof internalSchema>;
|
|
55
|
-
|
|
56
|
-
export const { schemas: generatedSchemas, factory } = createType<RawInput, Input>({
|
|
57
|
-
rawSchema,
|
|
58
|
-
internalSchema,
|
|
59
|
-
parseErrMsg: (value: unknown) => `The following provision is invalid: ${value}`,
|
|
60
|
-
unknownErrMsg: 'Something went wrong parsing the list of provisioners',
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
export type Provisions = Flatten<z.infer<typeof generatedSchemas.schema>>;
|
|
64
|
-
export type t = Provisions;
|
|
65
|
-
export const { create, of, make } = factory;
|
|
66
|
-
|
|
67
|
-
export const schemas = {
|
|
68
|
-
...generatedSchemas,
|
|
69
|
-
schema: generatedSchemas.schema.transform(val => val as Provisions),
|
|
70
|
-
};
|