@taqueria/protocol 0.0.0-pr-899-aeb9c96e → 0.0.0-pr-902-0bc36f81
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/PositionalArg.ts +4 -2
- package/SanitizedArgs.ts +2 -2
- package/package.json +1 -1
- 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/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-0bc36f81",
|
|
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": {
|
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
|
-
};
|