@taqueria/protocol 0.2.1 → 0.4.0-rc1
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.ts +38 -0
- package/Base.ts +105 -0
- package/Command.ts +24 -0
- package/Config.ts +155 -0
- package/Crypto.ts +3 -0
- package/EconomicalProtocolHash.ts +26 -0
- package/Environment.ts +36 -0
- package/EphemeralState.ts +208 -0
- package/Faucet.ts +46 -0
- package/HumanReadableIdentifier.ts +24 -0
- package/InstalledPlugin.ts +28 -0
- package/LoadedConfig.ts +45 -0
- package/NetworkConfig.ts +39 -0
- package/Operation.ts +70 -0
- package/Option.ts +56 -0
- package/ParsedOperation.ts +33 -0
- package/ParsedPluginInfo.ts +47 -0
- package/PersistentState.ts +67 -0
- package/PluginInfo.ts +67 -0
- package/PositionalArg.ts +49 -0
- package/Provisioner.ts +61 -0
- package/ProvisionerID.ts +25 -0
- package/Provisions.ts +70 -0
- package/PublicKeyHash.ts +28 -0
- package/README.md +87 -3
- package/RequestArgs.ts +76 -0
- package/SHA256.ts +40 -0
- package/SandboxAccountConfig.ts +35 -0
- package/SandboxConfig.ts +63 -0
- package/SanitizedAbsPath.ts +23 -0
- package/SanitizedArgs.ts +154 -0
- package/SanitizedPath.ts +26 -0
- package/SingleChar.ts +23 -0
- package/TaqError.ts +73 -0
- package/Task.ts +71 -0
- package/Timestamp.ts +25 -0
- package/Tz.ts +22 -0
- package/Url.ts +28 -0
- package/Verb.ts +23 -0
- package/VersionNumber.ts +23 -0
- package/i18n.ts +63 -0
- package/package.json +39 -32
- package/taqueria-protocol-types.ts +90 -608
- package/url-join.ts +0 -73
- package/url-parse.ts +0 -150
package/Task.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as Alias from '@taqueria/protocol/Alias';
|
|
2
|
+
import createType, { Flatten } from '@taqueria/protocol/Base';
|
|
3
|
+
import * as Command from '@taqueria/protocol/Command';
|
|
4
|
+
import * as Option from '@taqueria/protocol/Option';
|
|
5
|
+
import * as PositionalArg from '@taqueria/protocol/PositionalArg';
|
|
6
|
+
import * as Verb from '@taqueria/protocol/Verb';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
|
|
9
|
+
const taskEncodingSchema = z.preprocess(
|
|
10
|
+
(val: unknown) => val ?? 'none',
|
|
11
|
+
z.union([
|
|
12
|
+
z.literal('json'),
|
|
13
|
+
z.literal('application/json'),
|
|
14
|
+
z.literal('none'),
|
|
15
|
+
])
|
|
16
|
+
.default('none')
|
|
17
|
+
.describe('Task Encoding')
|
|
18
|
+
.optional(),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const taskHandlerSchema = z.union([
|
|
22
|
+
z.literal('proxy'),
|
|
23
|
+
z.string().min(1),
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
export const rawSchema = z.object({
|
|
27
|
+
task: Verb.rawSchema.describe('Task Name'),
|
|
28
|
+
command: Command.rawSchema.describe('Task Command'),
|
|
29
|
+
aliases: z.array(Alias.rawSchema).default([]).describe('Task Aliases').optional(),
|
|
30
|
+
description: z.string({ description: 'Task Description' }).min(3),
|
|
31
|
+
example: z.string({ description: 'Task Example' }).optional(),
|
|
32
|
+
hidden: z.boolean({ description: 'Task Is Hidden' }).default(false).optional(),
|
|
33
|
+
encoding: taskEncodingSchema.describe('Task Encoding'),
|
|
34
|
+
handler: taskHandlerSchema.describe('Task Handler'),
|
|
35
|
+
options: z.array(Option.rawSchema).default([]).describe('Task Options').optional(),
|
|
36
|
+
positionals: z.array(PositionalArg.rawSchema).default([]).describe('Task Positional Args').optional(),
|
|
37
|
+
}).describe('Task');
|
|
38
|
+
|
|
39
|
+
const internalSchema = z.object({
|
|
40
|
+
task: Verb.schemas.schema.describe('Task Name'),
|
|
41
|
+
command: Command.schemas.schema.describe('Task Command'),
|
|
42
|
+
aliases: z.array(Alias.rawSchema).default([]).describe('Task Aliases').optional(),
|
|
43
|
+
description: z.string({ description: 'Task Description' }).min(3),
|
|
44
|
+
example: z.string({ description: 'Task Example' }).optional(),
|
|
45
|
+
hidden: z.boolean({ description: 'Task Is Hidden' }).default(false).optional(),
|
|
46
|
+
encoding: taskEncodingSchema.describe('Task Encoding'),
|
|
47
|
+
handler: taskHandlerSchema.describe('Task Handler'),
|
|
48
|
+
options: z.preprocess(
|
|
49
|
+
val => val ?? [],
|
|
50
|
+
z.array(Option.schemas.schema).describe('Task Options').optional(),
|
|
51
|
+
),
|
|
52
|
+
positionals: z.array(PositionalArg.schemas.schema).default([]).describe('Task Positional Args').optional(),
|
|
53
|
+
}).describe('Task');
|
|
54
|
+
|
|
55
|
+
type RawInput = z.infer<typeof rawSchema>;
|
|
56
|
+
type Input = z.infer<typeof internalSchema>;
|
|
57
|
+
|
|
58
|
+
export const { schemas: generatedSchemas, factory } = createType<RawInput, Input>({
|
|
59
|
+
rawSchema,
|
|
60
|
+
internalSchema,
|
|
61
|
+
parseErrMsg: (value: unknown) => `The following task is invalid: ${value}`,
|
|
62
|
+
unknownErrMsg: 'Something went wrong trying to parse the task',
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export type Task = z.infer<typeof generatedSchemas.schema>;
|
|
66
|
+
export type t = Task;
|
|
67
|
+
export const { create, make, of } = factory;
|
|
68
|
+
export const schemas = {
|
|
69
|
+
...generatedSchemas,
|
|
70
|
+
schema: generatedSchemas.schema.transform(val => val as unknown as Task),
|
|
71
|
+
};
|
package/Timestamp.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import createType from '@taqueria/protocol/Base';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export const rawSchema = z
|
|
5
|
+
.number({ description: 'Timestamp' })
|
|
6
|
+
.min(1651846877);
|
|
7
|
+
|
|
8
|
+
type Input = z.infer<typeof rawSchema>;
|
|
9
|
+
|
|
10
|
+
export const { factory, schemas: generatedSchemas } = createType<Input, Input>({
|
|
11
|
+
isStringLike: true,
|
|
12
|
+
rawSchema,
|
|
13
|
+
parseErrMsg: (value: unknown) => `${value} is an invalid timestamp`,
|
|
14
|
+
unknownErrMsg: `Something went wrong trying to parse a timestamp`,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type Timestamp = z.infer<typeof generatedSchemas.schema>;
|
|
18
|
+
export type t = Timestamp;
|
|
19
|
+
export const { create, make, of } = factory;
|
|
20
|
+
export const schemas = {
|
|
21
|
+
...generatedSchemas,
|
|
22
|
+
schema: generatedSchemas.schema.transform(val => val as Timestamp),
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const now = () => Date.now() as Timestamp;
|
package/Tz.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import createType from '@taqueria/protocol/Base';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export const rawSchema = z.string({ description: 'Tz' }).min(1).regex(/^\d([\d_]+\d)?$/);
|
|
5
|
+
|
|
6
|
+
type RawInput = z.infer<typeof rawSchema>;
|
|
7
|
+
|
|
8
|
+
export const { schemas: generatedSchemas, factory } = createType<RawInput, RawInput>({
|
|
9
|
+
isStringLike: true,
|
|
10
|
+
rawSchema,
|
|
11
|
+
parseErrMsg: (value: unknown) => `${value} is an invalid Tz amount`,
|
|
12
|
+
unknownErrMsg: 'Something went wrong when parsing the Tz amount',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export type Tz = z.infer<typeof generatedSchemas.schema>;
|
|
16
|
+
|
|
17
|
+
export const { create, of, make } = factory;
|
|
18
|
+
|
|
19
|
+
export const schemas = {
|
|
20
|
+
...generatedSchemas,
|
|
21
|
+
schema: generatedSchemas.schema.transform(val => val as Tz),
|
|
22
|
+
};
|
package/Url.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import createType from '@taqueria/protocol/Base';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export const rawSchema = z
|
|
5
|
+
.string({ description: 'Url' })
|
|
6
|
+
.url();
|
|
7
|
+
|
|
8
|
+
type RawInput = z.infer<typeof rawSchema>;
|
|
9
|
+
|
|
10
|
+
export const { schemas: generatedSchemas, factory } = createType<RawInput, RawInput>({
|
|
11
|
+
rawSchema,
|
|
12
|
+
isStringLike: true,
|
|
13
|
+
parseErrMsg: (value: unknown) => `${value} is an invalid url`,
|
|
14
|
+
unknownErrMsg: 'Something went wrong trying to parse the url',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const toComponents = (url: Url) => {
|
|
18
|
+
const parts = new URL(url.toString());
|
|
19
|
+
return parts;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type Url = z.infer<typeof generatedSchemas.schema>;
|
|
23
|
+
export type t = Url;
|
|
24
|
+
export const { create, of, make } = factory;
|
|
25
|
+
export const schemas = {
|
|
26
|
+
...generatedSchemas,
|
|
27
|
+
schema: generatedSchemas.schema.transform(val => val as Url),
|
|
28
|
+
};
|
package/Verb.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import createType from '@taqueria/protocol/Base';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export const rawSchema = z
|
|
5
|
+
.string({ description: 'Verb' })
|
|
6
|
+
.min(1, 'Must be a valid verb')
|
|
7
|
+
.regex(/^[A-Za-z\-\ ]+/, 'Must be a valid verb');
|
|
8
|
+
|
|
9
|
+
type Input = z.infer<typeof rawSchema>;
|
|
10
|
+
|
|
11
|
+
export const { factory, schemas: generatedSchemas } = createType<Input, Input>({
|
|
12
|
+
isStringLike: true,
|
|
13
|
+
rawSchema,
|
|
14
|
+
parseErrMsg: (value: unknown) => `${value} is not an invalid verb`,
|
|
15
|
+
unknownErrMsg: `Something went wrong trying to parse a verb`,
|
|
16
|
+
});
|
|
17
|
+
export type Verb = z.infer<typeof generatedSchemas.schema>;
|
|
18
|
+
export type t = Verb;
|
|
19
|
+
export const { create, make, of } = factory;
|
|
20
|
+
export const schemas = {
|
|
21
|
+
...generatedSchemas,
|
|
22
|
+
schema: generatedSchemas.schema.transform(val => val as Verb),
|
|
23
|
+
};
|
package/VersionNumber.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import createType from '@taqueria/protocol/Base';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
export const rawSchema = z.string({ description: 'Version Number' })
|
|
5
|
+
.min(1)
|
|
6
|
+
.regex(/^\d+\.\d+(\.\d+)*$/);
|
|
7
|
+
|
|
8
|
+
type RawInput = z.infer<typeof rawSchema>;
|
|
9
|
+
|
|
10
|
+
const { schemas: generatedSchemas, factory } = createType<RawInput, RawInput>({
|
|
11
|
+
isStringLike: true,
|
|
12
|
+
rawSchema,
|
|
13
|
+
parseErrMsg: (value: unknown) => `${value} is an invalid version number`,
|
|
14
|
+
unknownErrMsg: 'Something went wrong trying to parse the version number',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export type VersionNumber = z.infer<typeof generatedSchemas.schema>;
|
|
18
|
+
export type t = VersionNumber;
|
|
19
|
+
export const { create, of, make } = factory;
|
|
20
|
+
export const schemas = {
|
|
21
|
+
...generatedSchemas,
|
|
22
|
+
schema: generatedSchemas.schema.transform(val => val as VersionNumber),
|
|
23
|
+
};
|
package/i18n.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import i18next from 'i18next';
|
|
2
|
+
|
|
3
|
+
export interface i18n {
|
|
4
|
+
__: (...args: unknown[]) => string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type t = i18n;
|
|
8
|
+
|
|
9
|
+
export default async (): Promise<i18n> => {
|
|
10
|
+
// TODO: i18next is feature-rich, but rather large. Determine whether you need all of the functionality
|
|
11
|
+
const i18n = {
|
|
12
|
+
...await i18next.init({
|
|
13
|
+
lng: 'en',
|
|
14
|
+
debug: false,
|
|
15
|
+
resources: {
|
|
16
|
+
// TODO: Move to separate language files
|
|
17
|
+
en: {
|
|
18
|
+
translation: {
|
|
19
|
+
'appName': 'Taqueria',
|
|
20
|
+
'appDesc': 'Taqueria is an integrated environment for compiling, testing, and deploying Tezos software.',
|
|
21
|
+
'versionDesc': 'Display the version number of the Taqueria program',
|
|
22
|
+
'betaWarning': "Taqueria is currently in BETA. You've been warned. :)",
|
|
23
|
+
'configDirDesc': 'Config directory (default ./.taq)',
|
|
24
|
+
'initDesc': 'Initialize a new project',
|
|
25
|
+
'initPathDesc': 'Path to your project directory',
|
|
26
|
+
'scaffoldDesc': 'Generate a new project using pre-made scaffold',
|
|
27
|
+
'scaffoldUrlDesc': 'Alias or Url for the scaffold project',
|
|
28
|
+
'scaffoldProjectDirDesc': 'Path where to create the new project. This must be a new directory.',
|
|
29
|
+
'scaffoldDoneMsg': 'The project was created using the scaffold.',
|
|
30
|
+
'installDesc': 'Install a plugin',
|
|
31
|
+
'pluginInstalled': 'Plugin installed successfully',
|
|
32
|
+
'pluginUninstalled': 'Plugin uninstalled successfully',
|
|
33
|
+
'uninstallDesc': 'Uninstall a plugin',
|
|
34
|
+
'pluginNameDesc': 'The name of the plugin',
|
|
35
|
+
'promptForTask':
|
|
36
|
+
"Please specify which task you would like to execute. If you're starting a new project, please run 'init'.\n",
|
|
37
|
+
'pluginKindDesc': 'Kind of plugin (NPM, Binary)',
|
|
38
|
+
'pluginAlreadyInstalled': 'That plugin is already installed.',
|
|
39
|
+
'pluginOptionDesc': 'Use the task from this plugin',
|
|
40
|
+
'bootstrapMsg': "Project taq'ified!",
|
|
41
|
+
'maxConcurrencyDesc': 'Set the maximum concurrency limit used internally',
|
|
42
|
+
'providedByMany': 'Provided by more than one plugin. The option --plugin is required.',
|
|
43
|
+
'pluginDesc':
|
|
44
|
+
'Specify what plugin should execute this command. Use this when more than one plugin provide a task of the same name.',
|
|
45
|
+
'listNetworks': 'List known networks',
|
|
46
|
+
'envDesc': 'Specify an environment configuration',
|
|
47
|
+
'disableStateDesc': 'Does not use the saved state.json file. State is computed for each execution.',
|
|
48
|
+
'logPluginCallsDesc': 'Logs any execution calls to a plugin to the console',
|
|
49
|
+
'npmInitRequired': "This project isn't a valid NPM project. Please run: npm init",
|
|
50
|
+
'testFromVsCode': 'An internal command used by VS Code to test for the taq binary',
|
|
51
|
+
'fromVsCode': 'An internal flag used to indicate that taq is executed via vscode',
|
|
52
|
+
'buildDesc': 'Display build information about the current version',
|
|
53
|
+
'pluginOption': "Use to specify what plugin you'd like when running this task.",
|
|
54
|
+
'yesOptionDesc': 'Select "yes" to any prompt',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
59
|
+
__: i18next.t,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return i18n;
|
|
63
|
+
};
|
package/package.json
CHANGED
|
@@ -1,34 +1,41 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
2
|
+
"name": "@taqueria/protocol",
|
|
3
|
+
"version": "0.4.0-rc1",
|
|
4
|
+
"description": "A TypeScript package which contains types that are to be shared between @taqueria/node-sdk and @taqueria/taqueria.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"build": "echo 'Nothing to build.' && exit 0 "
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"taqueria",
|
|
12
|
+
"tezos",
|
|
13
|
+
"build",
|
|
14
|
+
"test",
|
|
15
|
+
"deploy",
|
|
16
|
+
"ecad",
|
|
17
|
+
"ecadlabs",
|
|
18
|
+
"protocol"
|
|
19
|
+
],
|
|
20
|
+
"author": "ECAD Labs",
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/ecadlabs/taqueria.git",
|
|
25
|
+
"directory": "taqueria-protocol"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/ecadlabs/taqueria/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/ecadlabs/taqueria#readme",
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"typescript": "^4.7.2"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@peculiar/webcrypto": "^1.4.0",
|
|
36
|
+
"batching-toposort": "^1.2.0",
|
|
37
|
+
"fluture": "^14.0.0",
|
|
38
|
+
"remeda": "^0.0.34",
|
|
39
|
+
"zod": "^3.17.3"
|
|
40
|
+
}
|
|
34
41
|
}
|