@taqueria/protocol 0.28.0 → 0.28.1
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/Alias.js +427 -6
- package/Alias.js.map +1 -1
- package/Base.js +25 -6
- package/Base.js.map +1 -1
- package/Command.js +427 -6
- package/Command.js.map +1 -1
- package/Config.js +427 -6
- package/Config.js.map +1 -1
- package/ConfigArtifactsDir.js +0 -2
- package/ConfigArtifactsDir.js.map +1 -1
- package/ConfigContractsDir.js +427 -6
- package/ConfigContractsDir.js.map +1 -1
- package/ConfigEnvironmentFileV2.js +427 -6
- package/ConfigEnvironmentFileV2.js.map +1 -1
- package/ConfigFileV2.js +427 -6
- package/ConfigFileV2.js.map +1 -1
- package/Contract.js +427 -6
- package/Contract.js.map +1 -1
- package/EconomicalProtocolHash.js +427 -6
- package/EconomicalProtocolHash.js.map +1 -1
- package/Environment.js +427 -6
- package/Environment.js.map +1 -1
- package/EphemeralState.js +102 -29
- package/EphemeralState.js.map +1 -1
- package/Faucet.js +427 -6
- package/Faucet.js.map +1 -1
- package/HumanReadableIdentifier.js +427 -6
- package/HumanReadableIdentifier.js.map +1 -1
- package/InstalledPlugin.js +427 -6
- package/InstalledPlugin.js.map +1 -1
- package/LoadedConfig.js +427 -6
- package/LoadedConfig.js.map +1 -1
- package/MetadataConfig.js +427 -6
- package/MetadataConfig.js.map +1 -1
- package/NetworkAccountConfig.js +427 -6
- package/NetworkAccountConfig.js.map +1 -1
- package/NetworkConfig.js +427 -6
- package/NetworkConfig.js.map +1 -1
- package/NonEmptyString.js +427 -6
- package/NonEmptyString.js.map +1 -1
- package/Operation.js +427 -6
- package/Operation.js.map +1 -1
- package/Option.js +427 -6
- package/Option.js.map +1 -1
- package/ParsedOperation.js +427 -6
- package/ParsedOperation.js.map +1 -1
- package/ParsedPluginInfo.js +552 -27
- package/ParsedPluginInfo.js.map +1 -1
- package/ParsedTemplate.js +427 -6
- package/ParsedTemplate.js.map +1 -1
- package/PersistentState.js +505 -50
- package/PersistentState.js.map +1 -1
- package/PluginActionName.js +427 -6
- package/PluginActionName.js.map +1 -1
- package/PluginDependenciesResponse.js +427 -6
- package/PluginDependenciesResponse.js.map +1 -1
- package/PluginInfo.js +505 -44
- package/PluginInfo.js.map +1 -1
- package/PluginJsonResponse.js +427 -6
- package/PluginJsonResponse.js.map +1 -1
- package/PluginProxyResponse.js +427 -6
- package/PluginProxyResponse.js.map +1 -1
- package/PluginResponseEncoding.js +427 -6
- package/PluginResponseEncoding.js.map +1 -1
- package/PluginSchema.js +577 -36
- package/PluginSchema.js.map +1 -1
- package/PositionalArg.js +427 -6
- package/PositionalArg.js.map +1 -1
- package/Provisioner.js +427 -6
- package/Provisioner.js.map +1 -1
- package/ProvisionerID.js +427 -6
- package/ProvisionerID.js.map +1 -1
- package/Provisions.js +427 -6
- package/Provisions.js.map +1 -1
- package/ProxyTaskArgs.js +427 -6
- package/ProxyTaskArgs.js.map +1 -1
- package/ProxyTemplateArgs.js +427 -6
- package/ProxyTemplateArgs.js.map +1 -1
- package/PublicKeyHash.js +427 -6
- package/PublicKeyHash.js.map +1 -1
- package/RequestArgs.js +427 -6
- package/RequestArgs.js.map +1 -1
- package/SHA256.js +88 -9
- package/SHA256.js.map +1 -1
- package/SandboxAccountConfig.js +427 -6
- package/SandboxAccountConfig.js.map +1 -1
- package/SandboxConfig.js +427 -6
- package/SandboxConfig.js.map +1 -1
- package/SanitizedAbsPath.js +77 -6
- package/SanitizedAbsPath.js.map +1 -1
- package/SanitizedArgs.js +514 -63
- package/SanitizedArgs.js.map +1 -1
- package/SanitizedPath.js +427 -6
- package/SanitizedPath.js.map +1 -1
- package/ScaffoldConfig.js +427 -6
- package/ScaffoldConfig.js.map +1 -1
- package/Settings.js +427 -6
- package/Settings.js.map +1 -1
- package/SingleChar.js +427 -6
- package/SingleChar.js.map +1 -1
- package/Task.js +427 -6
- package/Task.js.map +1 -1
- package/Template.js +425 -10
- package/Template.js.map +1 -1
- package/Timestamp.js +427 -6
- package/Timestamp.js.map +1 -1
- package/Tz.js +427 -6
- package/Tz.js.map +1 -1
- package/Url.js +427 -6
- package/Url.js.map +1 -1
- package/Verb.js +427 -6
- package/Verb.js.map +1 -1
- package/VersionNumber.js +427 -6
- package/VersionNumber.js.map +1 -1
- package/helpers.js.map +1 -1
- package/index.js +3485 -110
- package/index.js.map +1 -1
- package/out/types/Alias.js +385 -13
- package/out/types/Alias.js.map +1 -1
- package/out/types/BuildNumber.js +385 -13
- package/out/types/BuildNumber.js.map +1 -1
- package/out/types/Command.js +385 -13
- package/out/types/Command.js.map +1 -1
- package/out/types/Config.js +385 -13
- package/out/types/Config.js.map +1 -1
- package/out/types/ConfigAccount.js +385 -13
- package/out/types/ConfigAccount.js.map +1 -1
- package/out/types/ConfigArtifactsDir.js +385 -13
- package/out/types/ConfigArtifactsDir.js.map +1 -1
- package/out/types/ConfigContractsDir.js +385 -13
- package/out/types/ConfigContractsDir.js.map +1 -1
- package/out/types/ConfigEnvironmentFileV2.d.ts +4 -4
- package/out/types/ConfigEnvironmentFileV2.js +385 -13
- package/out/types/ConfigEnvironmentFileV2.js.map +1 -1
- package/out/types/ConfigFileV1.js +385 -13
- package/out/types/ConfigFileV1.js.map +1 -1
- package/out/types/ConfigFileV2.d.ts +4 -4
- package/out/types/ConfigFileV2.js +385 -13
- package/out/types/ConfigFileV2.js.map +1 -1
- package/out/types/Contract.js +385 -13
- package/out/types/Contract.js.map +1 -1
- package/out/types/CurrencyAmountV2.js +385 -13
- package/out/types/CurrencyAmountV2.js.map +1 -1
- package/out/types/EconomicalProtocolHash.js +385 -13
- package/out/types/EconomicalProtocolHash.js.map +1 -1
- package/out/types/Environment.js +385 -13
- package/out/types/Environment.js.map +1 -1
- package/out/types/EphemeralState.js +385 -13
- package/out/types/EphemeralState.js.map +1 -1
- package/out/types/Faucet.js +385 -13
- package/out/types/Faucet.js.map +1 -1
- package/out/types/HumanReadableIdentifier.js +385 -13
- package/out/types/HumanReadableIdentifier.js.map +1 -1
- package/out/types/InstalledPlugin.js +385 -13
- package/out/types/InstalledPlugin.js.map +1 -1
- package/out/types/LoadedConfig.js +385 -13
- package/out/types/LoadedConfig.js.map +1 -1
- package/out/types/MetadataConfig.js +385 -13
- package/out/types/MetadataConfig.js.map +1 -1
- package/out/types/NetworkAccountConfig.js +385 -13
- package/out/types/NetworkAccountConfig.js.map +1 -1
- package/out/types/NetworkConfig.js +385 -13
- package/out/types/NetworkConfig.js.map +1 -1
- package/out/types/NonEmptyString.js +385 -13
- package/out/types/NonEmptyString.js.map +1 -1
- package/out/types/Operation.js +385 -13
- package/out/types/Operation.js.map +1 -1
- package/out/types/Option.js +385 -13
- package/out/types/Option.js.map +1 -1
- package/out/types/ParsedConfig.js +385 -13
- package/out/types/ParsedConfig.js.map +1 -1
- package/out/types/ParsedOperation.js +385 -13
- package/out/types/ParsedOperation.js.map +1 -1
- package/out/types/ParsedTemplate.js +385 -13
- package/out/types/ParsedTemplate.js.map +1 -1
- package/out/types/PersistedOperation.js +385 -13
- package/out/types/PersistedOperation.js.map +1 -1
- package/out/types/PersistedTask.js +385 -13
- package/out/types/PersistedTask.js.map +1 -1
- package/out/types/PersistentState.js +385 -13
- package/out/types/PersistentState.js.map +1 -1
- package/out/types/PluginActionName.js +385 -13
- package/out/types/PluginActionName.js.map +1 -1
- package/out/types/PluginDependenciesResponse.js +385 -13
- package/out/types/PluginDependenciesResponse.js.map +1 -1
- package/out/types/PluginInfo.js +385 -13
- package/out/types/PluginInfo.js.map +1 -1
- package/out/types/PluginJsonResponse.js +385 -13
- package/out/types/PluginJsonResponse.js.map +1 -1
- package/out/types/PluginProxyResponse.js +385 -13
- package/out/types/PluginProxyResponse.js.map +1 -1
- package/out/types/PluginResponseEncoding.js +385 -13
- package/out/types/PluginResponseEncoding.js.map +1 -1
- package/out/types/PluginSchema.js +385 -13
- package/out/types/PluginSchema.js.map +1 -1
- package/out/types/PositionalArg.js +385 -13
- package/out/types/PositionalArg.js.map +1 -1
- package/out/types/Provisioner.js +385 -13
- package/out/types/Provisioner.js.map +1 -1
- package/out/types/ProvisionerID.js +385 -13
- package/out/types/ProvisionerID.js.map +1 -1
- package/out/types/Provisions.js +385 -13
- package/out/types/Provisions.js.map +1 -1
- package/out/types/ProxyTaskArgs.js +385 -13
- package/out/types/ProxyTaskArgs.js.map +1 -1
- package/out/types/ProxyTemplateArgs.js +385 -13
- package/out/types/ProxyTemplateArgs.js.map +1 -1
- package/out/types/PublicKeyHash.js +385 -13
- package/out/types/PublicKeyHash.js.map +1 -1
- package/out/types/RequestArgs.js +385 -13
- package/out/types/RequestArgs.js.map +1 -1
- package/out/types/RuntimeDependency.js +385 -13
- package/out/types/RuntimeDependency.js.map +1 -1
- package/out/types/RuntimeDependencyReport.js +385 -13
- package/out/types/RuntimeDependencyReport.js.map +1 -1
- package/out/types/SHA256.js +385 -13
- package/out/types/SHA256.js.map +1 -1
- package/out/types/SandboxAccount.d.js +19 -0
- package/out/types/SandboxAccount.d.js.map +1 -0
- package/out/types/SandboxAccount.d.ts +43 -0
- package/out/types/SandboxAccount.d.ts.map +1 -0
- package/out/types/SandboxAccount.js +442 -0
- package/out/types/SandboxAccount.js.map +1 -0
- package/out/types/SandboxAccountConfig.js +385 -13
- package/out/types/SandboxAccountConfig.js.map +1 -1
- package/out/types/SandboxAccounts.d.ts +4 -4
- package/out/types/SandboxAccounts.js +385 -13
- package/out/types/SandboxAccounts.js.map +1 -1
- package/out/types/SandboxConfig.js +385 -13
- package/out/types/SandboxConfig.js.map +1 -1
- package/out/types/SanitizedAbsPath.js +385 -13
- package/out/types/SanitizedAbsPath.js.map +1 -1
- package/out/types/SanitizedArgs.js +385 -13
- package/out/types/SanitizedArgs.js.map +1 -1
- package/out/types/SanitizedPath.js +385 -13
- package/out/types/SanitizedPath.js.map +1 -1
- package/out/types/ScaffoldConfig.js +385 -13
- package/out/types/ScaffoldConfig.js.map +1 -1
- package/out/types/Settings.js +385 -13
- package/out/types/Settings.js.map +1 -1
- package/out/types/SingleChar.js +385 -13
- package/out/types/SingleChar.js.map +1 -1
- package/out/types/Task.js +385 -13
- package/out/types/Task.js.map +1 -1
- package/out/types/Template.js +385 -13
- package/out/types/Template.js.map +1 -1
- package/out/types/Timestamp.js +385 -13
- package/out/types/Timestamp.js.map +1 -1
- package/out/types/Tz.js +385 -13
- package/out/types/Tz.js.map +1 -1
- package/out/types/TzKtConfig.js +385 -13
- package/out/types/TzKtConfig.js.map +1 -1
- package/out/types/Url.js +385 -13
- package/out/types/Url.js.map +1 -1
- package/out/types/Verb.js +385 -13
- package/out/types/Verb.js.map +1 -1
- package/out/types/VersionNumber.js +385 -13
- package/out/types/VersionNumber.js.map +1 -1
- package/out/types-strict.d.js.map +1 -1
- package/out/types-strict.d.ts +6 -3
- package/out/types-strict.d.ts.map +1 -1
- package/out/types-strict.js.map +1 -1
- package/out/types-zod.d.js.map +1 -1
- package/out/types-zod.d.ts +10 -3
- package/out/types-zod.d.ts.map +1 -1
- package/out/types-zod.js +5 -5
- package/out/types-zod.js.map +1 -1
- package/package.json +2 -1
- package/taqueria-protocol-types.js +2601 -76
- package/taqueria-protocol-types.js.map +1 -1
- package/tsup.config.d.ts.map +1 -1
- package/types-config-files.js.map +1 -1
- package/types.d.ts +3 -2
- package/types.d.ts.map +1 -1
- package/types.js.map +1 -1
- package/tzkt-config.js +79 -14
- package/tzkt-config.js.map +1 -1
package/EphemeralState.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,16 +15,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
19
|
|
|
26
20
|
// EphemeralState.ts
|
|
27
21
|
var EphemeralState_exports = {};
|
|
28
22
|
__export(EphemeralState_exports, {
|
|
29
|
-
create: () =>
|
|
23
|
+
create: () => create2,
|
|
30
24
|
factory: () => factory,
|
|
31
25
|
generatedSchemas: () => generatedSchemas,
|
|
32
26
|
getTasks: () => getTasks,
|
|
@@ -39,45 +33,124 @@ __export(EphemeralState_exports, {
|
|
|
39
33
|
});
|
|
40
34
|
module.exports = __toCommonJS(EphemeralState_exports);
|
|
41
35
|
var import_protocol = require("@taqueria/protocol");
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
|
|
37
|
+
// TaqError.ts
|
|
44
38
|
var import_fluture = require("fluture");
|
|
39
|
+
var E_TaqError = class extends Error {
|
|
40
|
+
constructor(taqErr) {
|
|
41
|
+
super(taqErr.msg);
|
|
42
|
+
this.context = taqErr.context;
|
|
43
|
+
this.kind = taqErr.kind;
|
|
44
|
+
this.name = this.kind;
|
|
45
|
+
this.previous = taqErr.previous;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var toFutureParseErr = (previous, msg, context) => (0, import_fluture.reject)(toParseErr(previous, msg, context)).pipe((0, import_fluture.map)((val) => val));
|
|
49
|
+
var toParseErr = (previous, msg, context) => create({
|
|
50
|
+
kind: "E_PARSE",
|
|
51
|
+
msg,
|
|
52
|
+
context,
|
|
53
|
+
previous
|
|
54
|
+
});
|
|
55
|
+
var toParseUnknownErr = (previous, msg, context) => create({
|
|
56
|
+
kind: "E_PARSE_UNKNOWN",
|
|
57
|
+
msg,
|
|
58
|
+
context,
|
|
59
|
+
previous
|
|
60
|
+
});
|
|
61
|
+
var toFutureParseUnknownErr = (previous, msg, context) => (0, import_fluture.reject)(toParseUnknownErr(previous, msg, context)).pipe((0, import_fluture.map)((val) => val));
|
|
62
|
+
var create = (err) => err;
|
|
63
|
+
|
|
64
|
+
// Base.ts
|
|
65
|
+
var import_fluture2 = require("fluture");
|
|
45
66
|
var import_zod = require("zod");
|
|
46
|
-
var
|
|
47
|
-
|
|
67
|
+
var createSchema = (params) => {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
const { rawSchema: rawSchema2, isStringLike } = params;
|
|
70
|
+
const internalSchema = (_a = params.internalSchema) != null ? _a : params.rawSchema;
|
|
71
|
+
const noop = (val) => val;
|
|
72
|
+
const transformer = (_b = params.transformer) != null ? _b : noop;
|
|
73
|
+
const schema = isStringLike ? internalSchema.transform(
|
|
74
|
+
(val) => transformer(val)
|
|
75
|
+
) : internalSchema.transform(
|
|
76
|
+
(val) => transformer(val)
|
|
77
|
+
);
|
|
78
|
+
return {
|
|
79
|
+
rawSchema: rawSchema2,
|
|
80
|
+
internalSchema,
|
|
81
|
+
schema
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
var createType = (params) => {
|
|
85
|
+
const schemas2 = createSchema(params);
|
|
86
|
+
const { parseErrMsg, unknownErrMsg } = params;
|
|
87
|
+
const internalOf = (input) => {
|
|
88
|
+
try {
|
|
89
|
+
return (0, import_fluture2.resolve)(schemas2.schema.parse(input));
|
|
90
|
+
} catch (previous) {
|
|
91
|
+
const parseMsg = typeof parseErrMsg === "string" ? parseErrMsg : parseErrMsg(input, previous);
|
|
92
|
+
const unknownMsg = typeof unknownErrMsg === "string" ? unknownErrMsg : unknownErrMsg(input);
|
|
93
|
+
if (previous instanceof import_zod.ZodError) {
|
|
94
|
+
return toFutureParseErr(previous, parseMsg, input);
|
|
95
|
+
}
|
|
96
|
+
return toFutureParseUnknownErr(previous, unknownMsg, input);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const of2 = internalOf;
|
|
100
|
+
const make2 = (input) => internalOf(input);
|
|
101
|
+
const create3 = (input) => schemas2.schema.parse(input);
|
|
102
|
+
const from = (input) => schemas2.schema.parse(input);
|
|
103
|
+
const factory2 = {
|
|
104
|
+
make: make2,
|
|
105
|
+
of: of2,
|
|
106
|
+
create: create3,
|
|
107
|
+
from
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
schemas: schemas2,
|
|
111
|
+
factory: factory2
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
var Base_default = createType;
|
|
115
|
+
|
|
116
|
+
// EphemeralState.ts
|
|
117
|
+
var import_fluture3 = require("fluture");
|
|
118
|
+
var import_zod2 = require("zod");
|
|
119
|
+
var eager = (f) => (0, import_fluture3.promise)(
|
|
120
|
+
(0, import_fluture3.mapRej)((err) => new E_TaqError(err))(f)
|
|
48
121
|
);
|
|
49
|
-
var taskToPluginMap =
|
|
50
|
-
|
|
122
|
+
var taskToPluginMap = import_zod2.z.record(
|
|
123
|
+
import_zod2.z.union([
|
|
51
124
|
import_protocol.InstalledPlugin.schemas.schema,
|
|
52
125
|
import_protocol.Task.schemas.schema
|
|
53
126
|
], { description: "Task/Plugin Mapping" })
|
|
54
127
|
);
|
|
55
|
-
var operationToPluginMap =
|
|
56
|
-
|
|
128
|
+
var operationToPluginMap = import_zod2.z.record(
|
|
129
|
+
import_zod2.z.union([
|
|
57
130
|
import_protocol.InstalledPlugin.schemas.schema,
|
|
58
131
|
import_protocol.ParsedOperation.schemas.schema
|
|
59
132
|
], { description: "Operation/Plugin Mapping" })
|
|
60
133
|
);
|
|
61
|
-
var templateToPluginMap =
|
|
62
|
-
|
|
134
|
+
var templateToPluginMap = import_zod2.z.record(
|
|
135
|
+
import_zod2.z.union([
|
|
63
136
|
import_protocol.InstalledPlugin.schemas.schema,
|
|
64
137
|
import_protocol.ParsedTemplate.schemas.schema
|
|
65
138
|
])
|
|
66
139
|
);
|
|
67
|
-
var rawSchema =
|
|
68
|
-
build:
|
|
69
|
-
configHash:
|
|
140
|
+
var rawSchema = import_zod2.z.object({
|
|
141
|
+
build: import_zod2.z.string({ description: "cache.build" }),
|
|
142
|
+
configHash: import_zod2.z.string({ description: "cache.configHash" }),
|
|
70
143
|
tasks: taskToPluginMap,
|
|
71
144
|
operations: operationToPluginMap,
|
|
72
145
|
templates: templateToPluginMap,
|
|
73
|
-
plugins:
|
|
146
|
+
plugins: import_zod2.z.array(import_protocol.PluginInfo.schemas.schema, { description: "cache.plugins" })
|
|
74
147
|
}).describe("Ephemeral State");
|
|
75
|
-
var { schemas: generatedSchemas, factory } = (
|
|
148
|
+
var { schemas: generatedSchemas, factory } = Base_default({
|
|
76
149
|
rawSchema,
|
|
77
150
|
parseErrMsg: (value) => `${value} is not a valid representation of ephemeral state`,
|
|
78
151
|
unknownErrMsg: "Something went wrong when parsing the ephemeral state"
|
|
79
152
|
});
|
|
80
|
-
var { create, of, make } = factory;
|
|
153
|
+
var { create: create2, of, make } = factory;
|
|
81
154
|
var schemas = {
|
|
82
155
|
...generatedSchemas,
|
|
83
156
|
schema: generatedSchemas.schema.transform((val) => val)
|
|
@@ -142,7 +215,7 @@ var getInstalledPlugin = (config, name) => {
|
|
|
142
215
|
};
|
|
143
216
|
var mapTasksToPlugins = (config, pluginInfo, i18n) => {
|
|
144
217
|
const taskCounts = getTaskCounts(pluginInfo);
|
|
145
|
-
return (0,
|
|
218
|
+
return (0, import_fluture3.attemptP)(
|
|
146
219
|
async () => await pluginInfo.reduce(
|
|
147
220
|
async (retval, pluginInfo2) => !pluginInfo2.tasks ? Promise.resolve({}) : await pluginInfo2.tasks.reduce(
|
|
148
221
|
async (retval2, { task, hidden }) => {
|
|
@@ -174,11 +247,11 @@ var mapTasksToPlugins = (config, pluginInfo, i18n) => {
|
|
|
174
247
|
),
|
|
175
248
|
Promise.resolve({})
|
|
176
249
|
)
|
|
177
|
-
).pipe((0,
|
|
250
|
+
).pipe((0, import_fluture3.mapRej)((rej) => rej));
|
|
178
251
|
};
|
|
179
252
|
var mapOperationsToPlugins = (config, pluginInfo, i18n) => {
|
|
180
253
|
const opCounts = getOperationCounts(pluginInfo);
|
|
181
|
-
return (0,
|
|
254
|
+
return (0, import_fluture3.attemptP)(
|
|
182
255
|
async () => await pluginInfo.reduce(
|
|
183
256
|
async (retval, pluginInfo2) => !pluginInfo2.operations ? Promise.resolve({}) : await pluginInfo2.operations.reduce(
|
|
184
257
|
async (retval2, { operation }) => {
|
|
@@ -208,11 +281,11 @@ var mapOperationsToPlugins = (config, pluginInfo, i18n) => {
|
|
|
208
281
|
),
|
|
209
282
|
Promise.resolve({})
|
|
210
283
|
)
|
|
211
|
-
).pipe((0,
|
|
284
|
+
).pipe((0, import_fluture3.mapRej)((rej) => rej));
|
|
212
285
|
};
|
|
213
286
|
var mapTemplatesToPlugins = (config, pluginInfo, i18n) => {
|
|
214
287
|
const tmplCounts = getTemplateCounts(pluginInfo);
|
|
215
|
-
return (0,
|
|
288
|
+
return (0, import_fluture3.attemptP)(
|
|
216
289
|
async () => await pluginInfo.reduce(
|
|
217
290
|
async (retval, pluginInfo2) => !pluginInfo2.templates ? Promise.resolve({}) : await pluginInfo2.templates.reduce(
|
|
218
291
|
async (retval2, { template, hidden }) => {
|
|
@@ -245,7 +318,7 @@ var mapTemplatesToPlugins = (config, pluginInfo, i18n) => {
|
|
|
245
318
|
),
|
|
246
319
|
Promise.resolve({})
|
|
247
320
|
)
|
|
248
|
-
).pipe((0,
|
|
321
|
+
).pipe((0, import_fluture3.mapRej)((rej) => rej));
|
|
249
322
|
};
|
|
250
323
|
var getTasks = (pluginInfo) => pluginInfo.reduce(
|
|
251
324
|
(retval, pluginInfo2) => {
|
package/EphemeralState.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["EphemeralState.ts"],"sourcesContent":["import {\n\tCommand,\n\tConfig,\n\tInstalledPlugin,\n\tNonEmptyString,\n\tOption,\n\tParsedOperation,\n\tParsedTemplate,\n\tPluginInfo,\n\tPluginResponseEncoding,\n\tTask,\n\tVerb,\n} from '@taqueria/protocol';\nimport createType from '@taqueria/protocol/Base';\nimport type { i18n } from '@taqueria/protocol/i18n';\nimport { E_TaqError, TaqError } from '@taqueria/protocol/TaqError';\nimport { attemptP, FutureInstance as Future, mapRej, promise } from 'fluture';\nimport { z } from 'zod';\n\nconst eager = <T>(f: Future<TaqError, T>) =>\n\tpromise(\n\t\tmapRej((err: TaqError) => new E_TaqError(err))(f),\n\t);\n\nconst taskToPluginMap = z.record(\n\tz.union([\n\t\tInstalledPlugin.schemas.schema,\n\t\tTask.schemas.schema,\n\t], { description: 'Task/Plugin Mapping' }),\n);\nconst operationToPluginMap = z.record(\n\tz.union([\n\t\tInstalledPlugin.schemas.schema,\n\t\tParsedOperation.schemas.schema,\n\t], { description: 'Operation/Plugin Mapping' }),\n);\n\nconst templateToPluginMap = z.record(\n\tz.union([\n\t\tInstalledPlugin.schemas.schema,\n\t\tParsedTemplate.schemas.schema,\n\t]),\n);\n\nconst rawSchema = z.object({\n\tbuild: z.string({ description: 'cache.build' }),\n\tconfigHash: z.string({ description: 'cache.configHash' }),\n\ttasks: taskToPluginMap,\n\toperations: operationToPluginMap,\n\ttemplates: templateToPluginMap,\n\tplugins: z.array(PluginInfo.schemas.schema, { description: 'cache.plugins' }),\n}).describe('Ephemeral State');\n\ntype RawInput = z.infer<typeof rawSchema>;\n\nexport const { schemas: generatedSchemas, factory } = createType<RawInput, RawInput>({\n\trawSchema,\n\tparseErrMsg: (value: unknown) => `${value} is not a valid representation of ephemeral state`,\n\tunknownErrMsg: 'Something went wrong when parsing the ephemeral state',\n});\n\nexport type EphemeralState = z.infer<typeof generatedSchemas.schema>;\nexport type t = EphemeralState;\nexport type TaskToPluginMap = z.infer<typeof taskToPluginMap>;\nexport type OpToPluginMap = z.infer<typeof operationToPluginMap>;\nexport type TemplateToPluginMap = z.infer<typeof templateToPluginMap>;\n\nexport const { create, of, make } = factory;\n\nexport const schemas = {\n\t...generatedSchemas,\n\tschema: generatedSchemas.schema.transform(val => val as EphemeralState),\n};\n\n/**\n * Private functions\n */\ntype Counts = Record<Verb.t, PluginInfo.t[]>;\nconst getTaskCounts = (pluginInfo: PluginInfo.t[]): Counts => {\n\treturn pluginInfo.reduce(\n\t\t(retval, pluginInfo) =>\n\t\t\tpluginInfo.tasks === undefined\n\t\t\t\t? {}\n\t\t\t\t: pluginInfo.tasks.reduce(\n\t\t\t\t\t(retval: Counts, task: Task.t) => {\n\t\t\t\t\t\tconst taskName = task.task;\n\t\t\t\t\t\tconst providers: PluginInfo.t[] = retval[taskName]\n\t\t\t\t\t\t\t? [...retval[taskName], pluginInfo]\n\t\t\t\t\t\t\t: [pluginInfo];\n\t\t\t\t\t\tconst mapping: Counts = {};\n\t\t\t\t\t\tmapping[taskName] = providers.filter(provider => provider !== undefined);\n\t\t\t\t\t\treturn { ...retval, ...mapping };\n\t\t\t\t\t},\n\t\t\t\t\tretval,\n\t\t\t\t),\n\t\t{} as Counts,\n\t);\n};\n\nconst getTemplateCounts = (pluginInfo: PluginInfo.t[]): Counts => {\n\treturn pluginInfo.reduce(\n\t\t(retval, pluginInfo) =>\n\t\t\t!pluginInfo.templates\n\t\t\t\t? retval\n\t\t\t\t: pluginInfo.templates.reduce(\n\t\t\t\t\t(retval: Counts, template: ParsedTemplate.t) => {\n\t\t\t\t\t\tconst templateName = template.template;\n\t\t\t\t\t\tconst providers = retval[templateName]\n\t\t\t\t\t\t\t? [...retval[templateName], pluginInfo]\n\t\t\t\t\t\t\t: [pluginInfo];\n\t\t\t\t\t\tconst mapping: Counts = {};\n\t\t\t\t\t\tmapping[templateName] = providers.filter(provider => provider !== undefined);\n\t\t\t\t\t\treturn { ...retval, ...mapping };\n\t\t\t\t\t},\n\t\t\t\t\tretval,\n\t\t\t\t),\n\t\t{} as Counts,\n\t);\n};\n\nconst getOperationCounts = (pluginInfo: PluginInfo.t[]): Counts => {\n\treturn pluginInfo.reduce(\n\t\t(retval, pluginInfo) =>\n\t\t\tpluginInfo.operations === undefined\n\t\t\t\t? retval\n\t\t\t\t: pluginInfo.operations.reduce(\n\t\t\t\t\t(retval: Counts, operation: ParsedOperation.t) => {\n\t\t\t\t\t\tconst operationName = operation.operation;\n\t\t\t\t\t\tconst providers = retval[operationName]\n\t\t\t\t\t\t\t? [...retval[operationName], pluginInfo]\n\t\t\t\t\t\t\t: [pluginInfo];\n\t\t\t\t\t\tconst mapping: Counts = {};\n\t\t\t\t\t\tmapping[operationName] = providers.filter(provider => provider !== undefined);\n\t\t\t\t\t\treturn { ...retval, ...mapping };\n\t\t\t\t\t},\n\t\t\t\t\tretval,\n\t\t\t\t),\n\t\t{} as Counts,\n\t);\n};\n\nconst toChoices = (plugins: PluginInfo.t[]) =>\n\tplugins.reduce(\n\t\t(retval, pluginInfo) => {\n\t\t\treturn [...retval, pluginInfo.name as NonEmptyString.t, pluginInfo.alias as NonEmptyString.t];\n\t\t},\n\t\t[] as NonEmptyString.t[],\n\t);\n\nconst isComposite = (name: Verb.t, counts: Counts) => counts[name] && counts[name].length > 1;\n\nconst getInstalledPlugin = (config: Config.t, name: string) =>\n\tconfig.plugins?.find(\n\t\t(plugin: InstalledPlugin.t) => [`taqueria-plugin-${name}`, name].includes(plugin.name),\n\t);\n\nexport const mapTasksToPlugins = (config: Config.t, pluginInfo: PluginInfo.t[], i18n: i18n) => {\n\tconst taskCounts = getTaskCounts(pluginInfo);\n\treturn attemptP<TaqError, TaskToPluginMap>(async () =>\n\t\tawait pluginInfo.reduce(\n\t\t\tasync (retval, pluginInfo) =>\n\t\t\t\t!pluginInfo.tasks\n\t\t\t\t\t? Promise.resolve({} as TaskToPluginMap)\n\t\t\t\t\t: await pluginInfo.tasks.reduce(\n\t\t\t\t\t\tasync (retval, { task, hidden }) => {\n\t\t\t\t\t\t\tif (isComposite(task, taskCounts)) {\n\t\t\t\t\t\t\t\tconst command = await eager(Command.make(task));\n\t\t\t\t\t\t\t\tconst compositeTask = await eager(Task.make({\n\t\t\t\t\t\t\t\t\ttask,\n\t\t\t\t\t\t\t\t\tcommand,\n\t\t\t\t\t\t\t\t\tdescription: await eager(NonEmptyString.make(i18n.__('providedByMany'))),\n\t\t\t\t\t\t\t\t\thidden,\n\t\t\t\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t\t\t\tawait eager(Option.make({\n\t\t\t\t\t\t\t\t\t\t\tflag: await eager(Verb.make('plugin')),\n\t\t\t\t\t\t\t\t\t\t\tdescription: await eager(\n\t\t\t\t\t\t\t\t\t\t\t\tNonEmptyString.make('Specify which plugin should be used to execute this task'),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tchoices: toChoices(taskCounts[task]),\n\t\t\t\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\thandler: 'proxy',\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\treturn { ...await retval, [task]: compositeTask };\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Task is provided by just a single plugin\n\t\t\t\t\t\t\tconst installedPlugin = getInstalledPlugin(config, pluginInfo.name);\n\t\t\t\t\t\t\treturn installedPlugin\n\t\t\t\t\t\t\t\t? { ...await retval, [task]: installedPlugin }\n\t\t\t\t\t\t\t\t: retval;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tretval,\n\t\t\t\t\t),\n\t\t\tPromise.resolve({} as TaskToPluginMap),\n\t\t)\n\t).pipe(mapRej(rej => rej as TaqError));\n};\n\nexport const mapOperationsToPlugins = (config: Config.t, pluginInfo: PluginInfo.t[], i18n: i18n) => {\n\tconst opCounts = getOperationCounts(pluginInfo);\n\treturn attemptP(async () =>\n\t\tawait pluginInfo.reduce(\n\t\t\tasync (retval, pluginInfo) =>\n\t\t\t\t!pluginInfo.operations\n\t\t\t\t\t? Promise.resolve({} as OpToPluginMap)\n\t\t\t\t\t: await pluginInfo.operations.reduce(\n\t\t\t\t\t\tasync (retval, { operation }) => {\n\t\t\t\t\t\t\tif (isComposite(operation, opCounts)) {\n\t\t\t\t\t\t\t\tconst command = await eager(Command.make(operation));\n\t\t\t\t\t\t\t\tconst compositeOp = await eager(ParsedOperation.make({\n\t\t\t\t\t\t\t\t\toperation,\n\t\t\t\t\t\t\t\t\tcommand,\n\t\t\t\t\t\t\t\t\tdescription: await eager(NonEmptyString.make(i18n.__('providedByMany'))),\n\t\t\t\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t\t\t\tawait eager(Option.make({\n\t\t\t\t\t\t\t\t\t\t\tflag: await eager(Verb.make('plugin')),\n\t\t\t\t\t\t\t\t\t\t\tdescription: await eager(\n\t\t\t\t\t\t\t\t\t\t\t\tNonEmptyString.make('Specify which plugin should be used to execute this operation'),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tchoices: toChoices(opCounts[operation]),\n\t\t\t\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\treturn { ...await retval, [operation]: compositeOp };\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Operation is provided by just a single plugin\n\t\t\t\t\t\t\tconst installedPlugin = getInstalledPlugin(config, pluginInfo.name);\n\t\t\t\t\t\t\treturn installedPlugin\n\t\t\t\t\t\t\t\t? { ...await retval, [operation]: installedPlugin }\n\t\t\t\t\t\t\t\t: retval;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tretval,\n\t\t\t\t\t),\n\t\t\tPromise.resolve({} as OpToPluginMap),\n\t\t)\n\t).pipe(mapRej(rej => rej as TaqError));\n};\n\nexport const mapTemplatesToPlugins = (config: Config.t, pluginInfo: PluginInfo.t[], i18n: i18n) => {\n\tconst tmplCounts = getTemplateCounts(pluginInfo);\n\treturn attemptP<TaqError, TemplateToPluginMap>(async () =>\n\t\tawait pluginInfo.reduce(\n\t\t\tasync (retval, pluginInfo) =>\n\t\t\t\t!pluginInfo.templates\n\t\t\t\t\t? Promise.resolve({} as TemplateToPluginMap)\n\t\t\t\t\t: await pluginInfo.templates!.reduce(\n\t\t\t\t\t\tasync (retval, { template, hidden }) => {\n\t\t\t\t\t\t\tif (isComposite(template, tmplCounts)) {\n\t\t\t\t\t\t\t\tconst command = await eager(Command.make(template));\n\t\t\t\t\t\t\t\tconst description = await eager(NonEmptyString.of(i18n.__('providedByMany')));\n\t\t\t\t\t\t\t\tconst compositeTmpl = await eager(ParsedTemplate.make({\n\t\t\t\t\t\t\t\t\ttemplate,\n\t\t\t\t\t\t\t\t\tcommand,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t\t\t\tawait eager(Option.make({\n\t\t\t\t\t\t\t\t\t\t\tflag: await eager(Verb.make('plugin')),\n\t\t\t\t\t\t\t\t\t\t\tdescription: await eager(\n\t\t\t\t\t\t\t\t\t\t\t\tNonEmptyString.make('Specify which plugin should be used to execute this task'),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tchoices: toChoices(tmplCounts[template]),\n\t\t\t\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\thandler: 'proxy',\n\t\t\t\t\t\t\t\t\tencoding: PluginResponseEncoding.create('none'),\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\treturn { ...await retval, [template]: compositeTmpl };\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Template is provided by just a single plugin\n\t\t\t\t\t\t\tconst installedPlugin = getInstalledPlugin(config, pluginInfo.name);\n\t\t\t\t\t\t\treturn installedPlugin\n\t\t\t\t\t\t\t\t? { ...await retval, [template]: installedPlugin }\n\t\t\t\t\t\t\t\t: retval;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tretval,\n\t\t\t\t\t),\n\t\t\tPromise.resolve({} as TemplateToPluginMap),\n\t\t)\n\t).pipe(mapRej(rej => rej as TaqError));\n};\n\nexport const getTasks = (pluginInfo: PluginInfo.t[]) =>\n\tpluginInfo.reduce(\n\t\t(retval: Task.t[], pluginInfo) => [...retval, ...(pluginInfo.tasks ?? [])],\n\t\t[],\n\t);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAYO;AACP,kBAAuB;AAEvB,sBAAqC;AACrC,qBAAoE;AACpE,iBAAkB;AAElB,IAAM,QAAQ,CAAI,UACjB;AAAA,MACC,uBAAO,CAAC,QAAkB,IAAI,2BAAW,GAAG,CAAC,EAAE,CAAC;AACjD;AAED,IAAM,kBAAkB,aAAE;AAAA,EACzB,aAAE,MAAM;AAAA,IACP,gCAAgB,QAAQ;AAAA,IACxB,qBAAK,QAAQ;AAAA,EACd,GAAG,EAAE,aAAa,sBAAsB,CAAC;AAC1C;AACA,IAAM,uBAAuB,aAAE;AAAA,EAC9B,aAAE,MAAM;AAAA,IACP,gCAAgB,QAAQ;AAAA,IACxB,gCAAgB,QAAQ;AAAA,EACzB,GAAG,EAAE,aAAa,2BAA2B,CAAC;AAC/C;AAEA,IAAM,sBAAsB,aAAE;AAAA,EAC7B,aAAE,MAAM;AAAA,IACP,gCAAgB,QAAQ;AAAA,IACxB,+BAAe,QAAQ;AAAA,EACxB,CAAC;AACF;AAEA,IAAM,YAAY,aAAE,OAAO;AAAA,EAC1B,OAAO,aAAE,OAAO,EAAE,aAAa,cAAc,CAAC;AAAA,EAC9C,YAAY,aAAE,OAAO,EAAE,aAAa,mBAAmB,CAAC;AAAA,EACxD,OAAO;AAAA,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AAC;AAC5E,kBAAM,gBAAgB,MAAM,MAAM,+BAAe,KAAK;AAAA,cACrD;AAAA,cACA;AAAA,cACA;AAAA,cACA,SAAS;AAAA,gBACR,MAAM,MAAM,uBAAO,KAAK;AAAA,kBACvB,MAAM,MAAM,MAAM,qBAAK,KAAK,QAAQ,CAAC;AAAA,kBACrC,aAAa,MAAM;AAAA,oBAClB,+BAAe,KAAK,0DAA0D;AAAA,kBAC/E;AAAA,kBACA,SAAS,UAAU,WAAW,SAAS;AAAA,kBACvC,UAAU;AAAA,gBACX,CAAC,CAAC;AAAA,cACH;AAAA,cACA,SAAS;AAAA,cACT,UAAU,uCAAuB,OAAO,MAAM;AAAA,YAC/C,CAAC,CAAC;AACF,mBAAO,EAAE,GAAG,MAAMA,SAAQ,CAAC,WAAW,cAAc;AAAA,UACrD;AAGA,gBAAM,kBAAkB,mBAAmB,QAAQD,YAAW,IAAI;AAClE,iBAAO,kBACJ,EAAE,GAAG,MAAMC,SAAQ,CAAC,WAAW,gBAAgB,IAC/CA;AAAA,QACJ;AAAA,QACA;AAAA,MACD;AAAA,MACF,QAAQ,QAAQ,CAAC,CAAwB;AAAA,IAC1C;AAAA,EACD,EAAE,SAAK,uBAAO,SAAO,GAAe,CAAC;AACtC;AAEO,IAAM,WAAW,CAAC,eACxB,WAAW;AAAA,EACV,CAAC,QAAkBD,gBAAY;AAjSjC;AAiSoC,YAAC,GAAG,QAAQ,IAAI,KAAAA,YAAW,UAAX,YAAoB,CAAC,CAAE;AAAA;AAAA,EACzE,CAAC;AACF;","names":["createType","pluginInfo","retval"]}
|
|
1
|
+
{"version":3,"sources":["EphemeralState.ts","TaqError.ts","Base.ts"],"sourcesContent":["import {\n\tCommand,\n\tConfig,\n\tInstalledPlugin,\n\tNonEmptyString,\n\tOption,\n\tParsedOperation,\n\tParsedTemplate,\n\tPluginInfo,\n\tPluginResponseEncoding,\n\tTask,\n\tVerb,\n} from '@taqueria/protocol';\nimport createType from './Base';\nimport type { i18n } from './i18n';\nimport { E_TaqError, TaqError } from './TaqError';\nimport { attemptP, FutureInstance as Future, mapRej, promise } from 'fluture';\nimport { z } from 'zod';\n\nconst eager = <T>(f: Future<TaqError, T>) =>\n\tpromise(\n\t\tmapRej((err: TaqError) => new E_TaqError(err))(f),\n\t);\n\nconst taskToPluginMap = z.record(\n\tz.union([\n\t\tInstalledPlugin.schemas.schema,\n\t\tTask.schemas.schema,\n\t], { description: 'Task/Plugin Mapping' }),\n);\nconst operationToPluginMap = z.record(\n\tz.union([\n\t\tInstalledPlugin.schemas.schema,\n\t\tParsedOperation.schemas.schema,\n\t], { description: 'Operation/Plugin Mapping' }),\n);\n\nconst templateToPluginMap = z.record(\n\tz.union([\n\t\tInstalledPlugin.schemas.schema,\n\t\tParsedTemplate.schemas.schema,\n\t]),\n);\n\nconst rawSchema = z.object({\n\tbuild: z.string({ description: 'cache.build' }),\n\tconfigHash: z.string({ description: 'cache.configHash' }),\n\ttasks: taskToPluginMap,\n\toperations: operationToPluginMap,\n\ttemplates: templateToPluginMap,\n\tplugins: z.array(PluginInfo.schemas.schema, { description: 'cache.plugins' }),\n}).describe('Ephemeral State');\n\ntype RawInput = z.infer<typeof rawSchema>;\n\nexport const { schemas: generatedSchemas, factory } = createType<RawInput, RawInput>({\n\trawSchema,\n\tparseErrMsg: (value: unknown) => `${value} is not a valid representation of ephemeral state`,\n\tunknownErrMsg: 'Something went wrong when parsing the ephemeral state',\n});\n\nexport type EphemeralState = z.infer<typeof generatedSchemas.schema>;\nexport type t = EphemeralState;\nexport type TaskToPluginMap = z.infer<typeof taskToPluginMap>;\nexport type OpToPluginMap = z.infer<typeof operationToPluginMap>;\nexport type TemplateToPluginMap = z.infer<typeof templateToPluginMap>;\n\nexport const { create, of, make } = factory;\n\nexport const schemas = {\n\t...generatedSchemas,\n\tschema: generatedSchemas.schema.transform(val => val as EphemeralState),\n};\n\n/**\n * Private functions\n */\ntype Counts = Record<Verb.t, PluginInfo.t[]>;\nconst getTaskCounts = (pluginInfo: PluginInfo.t[]): Counts => {\n\treturn pluginInfo.reduce(\n\t\t(retval, pluginInfo) =>\n\t\t\tpluginInfo.tasks === undefined\n\t\t\t\t? {}\n\t\t\t\t: pluginInfo.tasks.reduce(\n\t\t\t\t\t(retval: Counts, task: Task.t) => {\n\t\t\t\t\t\tconst taskName = task.task;\n\t\t\t\t\t\tconst providers: PluginInfo.t[] = retval[taskName]\n\t\t\t\t\t\t\t? [...retval[taskName], pluginInfo]\n\t\t\t\t\t\t\t: [pluginInfo];\n\t\t\t\t\t\tconst mapping: Counts = {};\n\t\t\t\t\t\tmapping[taskName] = providers.filter(provider => provider !== undefined);\n\t\t\t\t\t\treturn { ...retval, ...mapping };\n\t\t\t\t\t},\n\t\t\t\t\tretval,\n\t\t\t\t),\n\t\t{} as Counts,\n\t);\n};\n\nconst getTemplateCounts = (pluginInfo: PluginInfo.t[]): Counts => {\n\treturn pluginInfo.reduce(\n\t\t(retval, pluginInfo) =>\n\t\t\t!pluginInfo.templates\n\t\t\t\t? retval\n\t\t\t\t: pluginInfo.templates.reduce(\n\t\t\t\t\t(retval: Counts, template: ParsedTemplate.t) => {\n\t\t\t\t\t\tconst templateName = template.template;\n\t\t\t\t\t\tconst providers = retval[templateName]\n\t\t\t\t\t\t\t? [...retval[templateName], pluginInfo]\n\t\t\t\t\t\t\t: [pluginInfo];\n\t\t\t\t\t\tconst mapping: Counts = {};\n\t\t\t\t\t\tmapping[templateName] = providers.filter(provider => provider !== undefined);\n\t\t\t\t\t\treturn { ...retval, ...mapping };\n\t\t\t\t\t},\n\t\t\t\t\tretval,\n\t\t\t\t),\n\t\t{} as Counts,\n\t);\n};\n\nconst getOperationCounts = (pluginInfo: PluginInfo.t[]): Counts => {\n\treturn pluginInfo.reduce(\n\t\t(retval, pluginInfo) =>\n\t\t\tpluginInfo.operations === undefined\n\t\t\t\t? retval\n\t\t\t\t: pluginInfo.operations.reduce(\n\t\t\t\t\t(retval: Counts, operation: ParsedOperation.t) => {\n\t\t\t\t\t\tconst operationName = operation.operation;\n\t\t\t\t\t\tconst providers = retval[operationName]\n\t\t\t\t\t\t\t? [...retval[operationName], pluginInfo]\n\t\t\t\t\t\t\t: [pluginInfo];\n\t\t\t\t\t\tconst mapping: Counts = {};\n\t\t\t\t\t\tmapping[operationName] = providers.filter(provider => provider !== undefined);\n\t\t\t\t\t\treturn { ...retval, ...mapping };\n\t\t\t\t\t},\n\t\t\t\t\tretval,\n\t\t\t\t),\n\t\t{} as Counts,\n\t);\n};\n\nconst toChoices = (plugins: PluginInfo.t[]) =>\n\tplugins.reduce(\n\t\t(retval, pluginInfo) => {\n\t\t\treturn [...retval, pluginInfo.name as NonEmptyString.t, pluginInfo.alias as NonEmptyString.t];\n\t\t},\n\t\t[] as NonEmptyString.t[],\n\t);\n\nconst isComposite = (name: Verb.t, counts: Counts) => counts[name] && counts[name].length > 1;\n\nconst getInstalledPlugin = (config: Config.t, name: string) =>\n\tconfig.plugins?.find(\n\t\t(plugin: InstalledPlugin.t) => [`taqueria-plugin-${name}`, name].includes(plugin.name),\n\t);\n\nexport const mapTasksToPlugins = (config: Config.t, pluginInfo: PluginInfo.t[], i18n: i18n) => {\n\tconst taskCounts = getTaskCounts(pluginInfo);\n\treturn attemptP<TaqError, TaskToPluginMap>(async () =>\n\t\tawait pluginInfo.reduce(\n\t\t\tasync (retval, pluginInfo) =>\n\t\t\t\t!pluginInfo.tasks\n\t\t\t\t\t? Promise.resolve({} as TaskToPluginMap)\n\t\t\t\t\t: await pluginInfo.tasks.reduce(\n\t\t\t\t\t\tasync (retval, { task, hidden }) => {\n\t\t\t\t\t\t\tif (isComposite(task, taskCounts)) {\n\t\t\t\t\t\t\t\tconst command = await eager(Command.make(task));\n\t\t\t\t\t\t\t\tconst compositeTask = await eager(Task.make({\n\t\t\t\t\t\t\t\t\ttask,\n\t\t\t\t\t\t\t\t\tcommand,\n\t\t\t\t\t\t\t\t\tdescription: await eager(NonEmptyString.make(i18n.__('providedByMany'))),\n\t\t\t\t\t\t\t\t\thidden,\n\t\t\t\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t\t\t\tawait eager(Option.make({\n\t\t\t\t\t\t\t\t\t\t\tflag: await eager(Verb.make('plugin')),\n\t\t\t\t\t\t\t\t\t\t\tdescription: await eager(\n\t\t\t\t\t\t\t\t\t\t\t\tNonEmptyString.make('Specify which plugin should be used to execute this task'),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tchoices: toChoices(taskCounts[task]),\n\t\t\t\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\thandler: 'proxy',\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\treturn { ...await retval, [task]: compositeTask };\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Task is provided by just a single plugin\n\t\t\t\t\t\t\tconst installedPlugin = getInstalledPlugin(config, pluginInfo.name);\n\t\t\t\t\t\t\treturn installedPlugin\n\t\t\t\t\t\t\t\t? { ...await retval, [task]: installedPlugin }\n\t\t\t\t\t\t\t\t: retval;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tretval,\n\t\t\t\t\t),\n\t\t\tPromise.resolve({} as TaskToPluginMap),\n\t\t)\n\t).pipe(mapRej(rej => rej as TaqError));\n};\n\nexport const mapOperationsToPlugins = (config: Config.t, pluginInfo: PluginInfo.t[], i18n: i18n) => {\n\tconst opCounts = getOperationCounts(pluginInfo);\n\treturn attemptP(async () =>\n\t\tawait pluginInfo.reduce(\n\t\t\tasync (retval, pluginInfo) =>\n\t\t\t\t!pluginInfo.operations\n\t\t\t\t\t? Promise.resolve({} as OpToPluginMap)\n\t\t\t\t\t: await pluginInfo.operations.reduce(\n\t\t\t\t\t\tasync (retval, { operation }) => {\n\t\t\t\t\t\t\tif (isComposite(operation, opCounts)) {\n\t\t\t\t\t\t\t\tconst command = await eager(Command.make(operation));\n\t\t\t\t\t\t\t\tconst compositeOp = await eager(ParsedOperation.make({\n\t\t\t\t\t\t\t\t\toperation,\n\t\t\t\t\t\t\t\t\tcommand,\n\t\t\t\t\t\t\t\t\tdescription: await eager(NonEmptyString.make(i18n.__('providedByMany'))),\n\t\t\t\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t\t\t\tawait eager(Option.make({\n\t\t\t\t\t\t\t\t\t\t\tflag: await eager(Verb.make('plugin')),\n\t\t\t\t\t\t\t\t\t\t\tdescription: await eager(\n\t\t\t\t\t\t\t\t\t\t\t\tNonEmptyString.make('Specify which plugin should be used to execute this operation'),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tchoices: toChoices(opCounts[operation]),\n\t\t\t\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\treturn { ...await retval, [operation]: compositeOp };\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Operation is provided by just a single plugin\n\t\t\t\t\t\t\tconst installedPlugin = getInstalledPlugin(config, pluginInfo.name);\n\t\t\t\t\t\t\treturn installedPlugin\n\t\t\t\t\t\t\t\t? { ...await retval, [operation]: installedPlugin }\n\t\t\t\t\t\t\t\t: retval;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tretval,\n\t\t\t\t\t),\n\t\t\tPromise.resolve({} as OpToPluginMap),\n\t\t)\n\t).pipe(mapRej(rej => rej as TaqError));\n};\n\nexport const mapTemplatesToPlugins = (config: Config.t, pluginInfo: PluginInfo.t[], i18n: i18n) => {\n\tconst tmplCounts = getTemplateCounts(pluginInfo);\n\treturn attemptP<TaqError, TemplateToPluginMap>(async () =>\n\t\tawait pluginInfo.reduce(\n\t\t\tasync (retval, pluginInfo) =>\n\t\t\t\t!pluginInfo.templates\n\t\t\t\t\t? Promise.resolve({} as TemplateToPluginMap)\n\t\t\t\t\t: await pluginInfo.templates!.reduce(\n\t\t\t\t\t\tasync (retval, { template, hidden }) => {\n\t\t\t\t\t\t\tif (isComposite(template, tmplCounts)) {\n\t\t\t\t\t\t\t\tconst command = await eager(Command.make(template));\n\t\t\t\t\t\t\t\tconst description = await eager(NonEmptyString.of(i18n.__('providedByMany')));\n\t\t\t\t\t\t\t\tconst compositeTmpl = await eager(ParsedTemplate.make({\n\t\t\t\t\t\t\t\t\ttemplate,\n\t\t\t\t\t\t\t\t\tcommand,\n\t\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\t\toptions: [\n\t\t\t\t\t\t\t\t\t\tawait eager(Option.make({\n\t\t\t\t\t\t\t\t\t\t\tflag: await eager(Verb.make('plugin')),\n\t\t\t\t\t\t\t\t\t\t\tdescription: await eager(\n\t\t\t\t\t\t\t\t\t\t\t\tNonEmptyString.make('Specify which plugin should be used to execute this task'),\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tchoices: toChoices(tmplCounts[template]),\n\t\t\t\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\thandler: 'proxy',\n\t\t\t\t\t\t\t\t\tencoding: PluginResponseEncoding.create('none'),\n\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\treturn { ...await retval, [template]: compositeTmpl };\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Template is provided by just a single plugin\n\t\t\t\t\t\t\tconst installedPlugin = getInstalledPlugin(config, pluginInfo.name);\n\t\t\t\t\t\t\treturn installedPlugin\n\t\t\t\t\t\t\t\t? { ...await retval, [template]: installedPlugin }\n\t\t\t\t\t\t\t\t: retval;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tretval,\n\t\t\t\t\t),\n\t\t\tPromise.resolve({} as TemplateToPluginMap),\n\t\t)\n\t).pipe(mapRej(rej => rej as TaqError));\n};\n\nexport const getTasks = (pluginInfo: PluginInfo.t[]) =>\n\tpluginInfo.reduce(\n\t\t(retval: Task.t[], pluginInfo) => [...retval, ...(pluginInfo.tasks ?? [])],\n\t\t[],\n\t);\n","import { map, reject } from 'fluture';\nimport { ZodError } from 'zod';\n\nexport type ErrorType =\n\t| 'E_INVALID_PATH_DOES_NOT_EXIST'\n\t| 'E_INVALID_PATH_EXISTS_AND_NOT_AN_EMPTY_DIR'\n\t| 'E_INVALID_PATH_ALREADY_EXISTS'\n\t| 'E_INVALID_CONFIG'\n\t| 'E_INVALID_JSON'\n\t| 'E_FORK'\n\t| 'E_INVALID_TASK'\n\t| 'E_READFILE'\n\t| 'E_NPM_INIT'\n\t| 'E_INVALID_PLUGIN_RESPONSE'\n\t| 'E_INVALID_ARGS'\n\t| 'E_MKDIR_FAILED'\n\t| 'E_GIT_CLONE_FAILED'\n\t| 'E_PROVISION'\n\t| 'E_PARSE'\n\t| 'E_PARSE_UNKNOWN'\n\t| 'E_INVALID_ARCH'\n\t| 'E_NO_PROVISIONS'\n\t| 'E_INTERNAL_LOGICAL_VALIDATION_FAILURE'\n\t| 'E_EXEC'\n\t| 'E_OPT_IN_WARNING'\n\t| 'E_INVALID_OPTION'\n\t| 'E_TAQ_PROJECT_NOT_FOUND';\n\nexport interface TaqError {\n\treadonly kind: ErrorType;\n\tmsg: string;\n\tprevious?: TaqError | Error | unknown;\n\tcontext?: unknown;\n}\n\nexport type t = TaqError;\n\nexport class E_TaqError extends Error {\n\treadonly context;\n\treadonly kind;\n\treadonly previous;\n\tconstructor(taqErr: TaqError) {\n\t\tsuper(taqErr.msg);\n\t\tthis.context = taqErr.context;\n\t\tthis.kind = taqErr.kind;\n\t\tthis.name = this.kind;\n\t\tthis.previous = taqErr.previous;\n\t}\n}\n\nexport const toFutureParseErr = <T>(previous: ZodError, msg: string, context?: unknown) =>\n\treject(toParseErr(previous, msg, context))\n\t\t.pipe(map((val: unknown) => val as T));\n\nexport const toParseErr = (previous: ZodError, msg: string, context?: unknown) =>\n\tcreate({\n\t\tkind: 'E_PARSE',\n\t\tmsg: msg,\n\t\tcontext,\n\t\tprevious,\n\t});\n\nexport const toParseUnknownErr = (previous: Error | TaqError | E_TaqError | unknown, msg: string, context?: unknown) =>\n\tcreate({\n\t\tkind: 'E_PARSE_UNKNOWN',\n\t\tmsg: msg,\n\t\tcontext,\n\t\tprevious,\n\t});\n\nexport const toFutureParseUnknownErr = <T>(\n\tprevious: Error | TaqError | E_TaqError | unknown,\n\tmsg: string,\n\tcontext?: unknown,\n) =>\n\treject(toParseUnknownErr(previous, msg, context))\n\t\t.pipe(map((val: unknown) => val as T));\n\nexport const create = (err: TaqError) => err;\n","import { toFutureParseErr, toFutureParseUnknownErr } from './TaqError';\nimport { FutureInstance, resolve } from 'fluture';\nimport { z, ZodError, ZodSchema } from 'zod';\n\ntype Future<L, R> = FutureInstance<L, R>;\n\ntype ErrMsg = string | ((value: unknown, previous?: unknown) => string);\n\ninterface CreateSchemaParams {\n\trawSchema: ZodSchema;\n\tinternalSchema?: ZodSchema;\n\ttransformer?: (value: unknown) => unknown;\n\tisStringLike?: boolean;\n}\n\ninterface CreateTypeParams extends CreateSchemaParams {\n\tparseErrMsg: ErrMsg;\n\tunknownErrMsg: ErrMsg;\n}\nexport type Flatten<T> = { [k in keyof T]: T[k] };\n\nexport const createSchema = <I>(params: CreateSchemaParams) => {\n\tconst { rawSchema, isStringLike } = params;\n\tconst internalSchema = params.internalSchema ?? params.rawSchema;\n\tconst noop = (val: unknown) => val;\n\tconst transformer = params.transformer ?? noop;\n\n\tconst schema = isStringLike\n\t\t? internalSchema\n\t\t\t.transform((val: unknown) =>\n\t\t\t\ttransformer(val) as I & {\n\t\t\t\t\treadonly __type: 'generated' & z.infer<typeof internalSchema>;\n\t\t\t\t}\n\t\t\t)\n\t\t: internalSchema\n\t\t\t.transform((val: unknown) =>\n\t\t\t\ttransformer(val) as Flatten<\n\t\t\t\t\tI & {\n\t\t\t\t\t\treadonly __type: 'generated' & z.infer<typeof internalSchema>;\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t);\n\n\ttype GeneratedSchema = typeof schema;\n\n\treturn {\n\t\trawSchema,\n\t\tinternalSchema,\n\t\tschema,\n\t};\n};\n\n// TODO:\n// TypeScript appears to have a bug with default generic values\n// For instance, I'd like to use this:\n// export const createType = <R, I = R>(params: CreateTypeParams) => {\n//\n// However, I == unknown when having I default to R if no I was given.\n// So, we need to require R and I explicitly\nexport const createType = <R, I>(params: CreateTypeParams) => {\n\tconst schemas = createSchema<I>(params);\n\tconst { parseErrMsg, unknownErrMsg } = params;\n\n\ttype T = z.infer<typeof schemas.schema>;\n\n\tconst internalOf = (input: unknown) => {\n\t\ttry {\n\t\t\treturn resolve<T>(schemas.schema.parse(input));\n\t\t} catch (previous) {\n\t\t\tconst parseMsg = typeof parseErrMsg === 'string'\n\t\t\t\t? parseErrMsg\n\t\t\t\t: parseErrMsg(input, previous);\n\n\t\t\tconst unknownMsg = typeof unknownErrMsg === 'string'\n\t\t\t\t? unknownErrMsg\n\t\t\t\t: unknownErrMsg(input);\n\n\t\t\tif (previous instanceof ZodError) {\n\t\t\t\treturn toFutureParseErr<T>(previous, parseMsg, input);\n\t\t\t}\n\t\t\treturn toFutureParseUnknownErr<T>(previous, unknownMsg, input);\n\t\t}\n\t};\n\tconst of = internalOf;\n\n\tconst make = (input: I) => internalOf(input);\n\n\tconst create = (input: R | I) => schemas.schema.parse(input) as T;\n\n\tconst from = (input: unknown) => schemas.schema.parse(input) as T;\n\n\tconst factory = {\n\t\tmake,\n\t\tof,\n\t\tcreate,\n\t\tfrom,\n\t};\n\n\treturn {\n\t\tschemas,\n\t\tfactory,\n\t};\n};\n\nexport default createType;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAYO;;;ACZP,qBAA4B;AAqCrB,IAAM,aAA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":["create","import_fluture","rawSchema","schemas","of","make","create","factory","import_fluture","import_zod","create","pluginInfo","retval"]}
|