@taqueria/protocol 0.0.0-pr-730-90eda834 → 0.0.0-pr-820-800fa10d
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 +29 -27
- package/Base.ts +84 -88
- package/Command.ts +18 -18
- package/Config.ts +129 -132
- package/Crypto.ts +2 -2
- package/EconomicalProtocolHash.ts +19 -19
- package/Environment.ts +28 -28
- package/EphemeralState.ts +179 -186
- package/Faucet.ts +37 -37
- package/HumanReadableIdentifier.ts +17 -17
- package/InstalledPlugin.ts +20 -20
- package/LoadedConfig.ts +36 -36
- package/NetworkConfig.ts +30 -30
- package/Operation.ts +61 -60
- package/Option.ts +46 -46
- package/ParsedOperation.ts +23 -23
- package/ParsedPluginInfo.ts +41 -41
- package/PersistentState.ts +46 -45
- package/PluginInfo.ts +59 -58
- package/PositionalArg.ts +39 -39
- package/Provisioner.ts +51 -51
- package/ProvisionerID.ts +18 -18
- package/Provisions.ts +50 -59
- package/PublicKeyHash.ts +22 -22
- package/RequestArgs.ts +57 -57
- package/SHA256.ts +33 -32
- package/SandboxAccountConfig.ts +25 -25
- package/SandboxConfig.ts +52 -52
- package/SanitizedAbsPath.ts +18 -18
- package/SanitizedArgs.ts +131 -134
- package/SanitizedPath.ts +20 -20
- package/SingleChar.ts +17 -17
- package/TaqError.ts +58 -61
- package/Task.ts +59 -59
- package/Timestamp.ts +18 -18
- package/Tz.ts +15 -15
- package/Url.ts +20 -20
- package/Verb.ts +18 -18
- package/VersionNumber.ts +19 -18
- package/i18n.ts +54 -56
- package/package.json +39 -39
- package/taqueria-protocol-types.ts +75 -86
package/Alias.ts
CHANGED
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import
|
|
1
|
+
import {z} from "zod"
|
|
2
|
+
import * as Verb from '@taqueria/protocol/Verb'
|
|
3
|
+
import * as SingleChar from '@taqueria/protocol/SingleChar'
|
|
4
|
+
import createType from "@taqueria/protocol/Base"
|
|
5
5
|
|
|
6
6
|
export const rawSchema = z
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
.union([
|
|
8
|
+
Verb.rawSchema,
|
|
9
|
+
SingleChar.rawSchema],
|
|
10
|
+
{description: "Alias"}
|
|
11
|
+
)
|
|
11
12
|
|
|
12
13
|
export const internalSchema = z
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
.union([
|
|
15
|
+
Verb.schemas.schema,
|
|
16
|
+
SingleChar.schemas.schema],
|
|
17
|
+
{description: "Alias"}
|
|
18
|
+
)
|
|
17
19
|
|
|
18
|
-
type RawInput = z.infer<typeof rawSchema
|
|
19
|
-
type Input = z.infer<typeof internalSchema
|
|
20
|
+
type RawInput = z.infer<typeof rawSchema>
|
|
21
|
+
type Input = z.infer<typeof internalSchema>
|
|
20
22
|
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})
|
|
23
|
+
const {schemas: generatedSchemas, factory} = createType<RawInput, Input>({
|
|
24
|
+
isStringLike: true,
|
|
25
|
+
rawSchema,
|
|
26
|
+
internalSchema,
|
|
27
|
+
parseErrMsg: (value: unknown) => `${value} is not a valid alias`,
|
|
28
|
+
unknownErrMsg: 'Something went wrong trying to parse an alias'
|
|
29
|
+
})
|
|
28
30
|
|
|
29
|
-
export type Alias = z.infer<typeof generatedSchemas.schema
|
|
31
|
+
export type Alias = z.infer<typeof generatedSchemas.schema>
|
|
30
32
|
|
|
31
|
-
export type t = Alias
|
|
33
|
+
export type t = Alias
|
|
32
34
|
|
|
33
|
-
export const {
|
|
35
|
+
export const {create, of, make} = factory
|
|
34
36
|
|
|
35
37
|
export const schemas = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
38
|
+
...generatedSchemas,
|
|
39
|
+
schema: generatedSchemas.schema.transform(val => val as Alias)
|
|
40
|
+
}
|
package/Base.ts
CHANGED
|
@@ -1,56 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {z, ZodError, ZodSchema} from 'zod'
|
|
2
|
+
import {toFutureParseErr, toFutureParseUnknownErr} from "@taqueria/protocol/TaqError"
|
|
3
|
+
import {resolve, FutureInstance} from "fluture"
|
|
4
4
|
|
|
5
|
-
type Future<L, R> = FutureInstance<L, R
|
|
5
|
+
type Future<L, R> = FutureInstance<L, R>
|
|
6
6
|
|
|
7
|
-
type ErrMsg = string | ((value: unknown) => string)
|
|
7
|
+
type ErrMsg = string | ((value: unknown) => string)
|
|
8
8
|
|
|
9
9
|
interface CreateSchemaParams {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
rawSchema: ZodSchema
|
|
11
|
+
internalSchema?: ZodSchema
|
|
12
|
+
transformer?: (value: unknown) => unknown,
|
|
13
|
+
isStringLike?: boolean
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
interface CreateTypeParams extends CreateSchemaParams {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
parseErrMsg: ErrMsg,
|
|
18
|
+
unknownErrMsg: ErrMsg
|
|
19
19
|
}
|
|
20
|
-
export type Flatten<T> = { [k in keyof T]: T[k] }
|
|
20
|
+
export type Flatten<T> = { [k in keyof T]: T[k] }
|
|
21
21
|
|
|
22
22
|
export const createSchema = <I>(params: CreateSchemaParams) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
schema,
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// TODO:
|
|
23
|
+
const {rawSchema, isStringLike} = params
|
|
24
|
+
const internalSchema = params.internalSchema ?? params.rawSchema
|
|
25
|
+
const noop = (val: unknown) => val
|
|
26
|
+
const transformer = params.transformer ?? noop
|
|
27
|
+
|
|
28
|
+
const schema = isStringLike
|
|
29
|
+
? internalSchema
|
|
30
|
+
.transform((val: unknown) => transformer(val) as I & {
|
|
31
|
+
readonly __kind: "generated" & z.infer<typeof internalSchema>
|
|
32
|
+
})
|
|
33
|
+
: internalSchema
|
|
34
|
+
.transform((val: unknown) => transformer(val) as Flatten<I & {
|
|
35
|
+
readonly __kind: "generated" & z.infer<typeof internalSchema>
|
|
36
|
+
}>)
|
|
37
|
+
|
|
38
|
+
type GeneratedSchema = typeof schema
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
rawSchema,
|
|
42
|
+
internalSchema,
|
|
43
|
+
schema
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
// TODO:
|
|
54
49
|
// TypeScript appears to have a bug with default generic values
|
|
55
50
|
// For instance, I'd like to use this:
|
|
56
51
|
// export const createType = <R, I = R>(params: CreateTypeParams) => {
|
|
@@ -58,48 +53,49 @@ export const createSchema = <I>(params: CreateSchemaParams) => {
|
|
|
58
53
|
// However, I == unknown when having I default to R if no I was given.
|
|
59
54
|
// So, we need to require R and I explicitly
|
|
60
55
|
export const createType = <R, I>(params: CreateTypeParams) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
56
|
+
const schemas = createSchema<I>(params)
|
|
57
|
+
const {parseErrMsg, unknownErrMsg} = params
|
|
58
|
+
|
|
59
|
+
type T = z.infer<typeof schemas.schema>
|
|
60
|
+
|
|
61
|
+
const internalOf = (input: unknown) => {
|
|
62
|
+
try {
|
|
63
|
+
return resolve<T>(schemas.schema.parse(input))
|
|
64
|
+
}
|
|
65
|
+
catch (previous) {
|
|
66
|
+
const parseMsg = typeof parseErrMsg === 'string'
|
|
67
|
+
? parseErrMsg
|
|
68
|
+
: parseErrMsg(input)
|
|
69
|
+
|
|
70
|
+
const unknownMsg = typeof unknownErrMsg === 'string'
|
|
71
|
+
? unknownErrMsg
|
|
72
|
+
: unknownErrMsg(input)
|
|
73
|
+
|
|
74
|
+
if (previous instanceof ZodError) {
|
|
75
|
+
return toFutureParseErr<T>(previous, parseMsg, input)
|
|
76
|
+
}
|
|
77
|
+
return toFutureParseUnknownErr<T>(previous, unknownMsg, input)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const of = internalOf
|
|
81
|
+
|
|
82
|
+
const make = (input: I) => internalOf(input)
|
|
83
|
+
|
|
84
|
+
const create = (input: R | I) => schemas.schema.parse(input) as T
|
|
85
|
+
|
|
86
|
+
const from = (input: unknown) => schemas.schema.parse(input) as T
|
|
87
|
+
|
|
88
|
+
const factory = {
|
|
89
|
+
make,
|
|
90
|
+
of,
|
|
91
|
+
create,
|
|
92
|
+
from
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
schemas,
|
|
97
|
+
factory
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export default createType
|
package/Command.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import {z} from 'zod'
|
|
2
|
+
import createType from "@taqueria/protocol/Base"
|
|
3
3
|
|
|
4
4
|
export const rawSchema = z
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
.string({description: "Command"})
|
|
6
|
+
.min(1)
|
|
7
|
+
.regex(/^([A-Za-z-_ ]+ ?)((\[.+\] ?)|(\<.+\>) ?)*$/, "Must be a command that can be interpreted using yargs")
|
|
8
8
|
|
|
9
|
-
type RawInput = z.infer<typeof rawSchema
|
|
9
|
+
type RawInput = z.infer<typeof rawSchema>
|
|
10
10
|
|
|
11
|
-
const {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
})
|
|
11
|
+
const {schemas: generatedSchemas, factory} = createType<RawInput, RawInput>({
|
|
12
|
+
isStringLike: true,
|
|
13
|
+
rawSchema,
|
|
14
|
+
parseErrMsg: (value: unknown) => `${value} is an invalid command. Expected format is: taskName [optional] <required>`,
|
|
15
|
+
unknownErrMsg: "Something went wrong when parsing the command"
|
|
16
|
+
})
|
|
17
17
|
|
|
18
|
-
export type Command = z.infer<typeof generatedSchemas.schema
|
|
19
|
-
export type t = Command
|
|
20
|
-
export const {
|
|
18
|
+
export type Command = z.infer<typeof generatedSchemas.schema>
|
|
19
|
+
export type t = Command
|
|
20
|
+
export const {create, make, of} = factory
|
|
21
21
|
export const schemas = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
22
|
+
...generatedSchemas,
|
|
23
|
+
schema: generatedSchemas.schema.transform(val => val as Command)
|
|
24
|
+
}
|
package/Config.ts
CHANGED
|
@@ -1,155 +1,152 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
6
|
-
import * as Tz from
|
|
7
|
-
import {
|
|
1
|
+
import {z} from 'zod'
|
|
2
|
+
import * as InstalledPlugin from '@taqueria/protocol/InstalledPlugin'
|
|
3
|
+
import * as NetworkConfig from '@taqueria/protocol/NetworkConfig'
|
|
4
|
+
import * as SandboxConfig from "@taqueria/protocol/SandboxConfig"
|
|
5
|
+
import * as Environment from "@taqueria/protocol/Environment"
|
|
6
|
+
import * as Tz from "@taqueria/protocol/Tz"
|
|
7
|
+
import createType, {Flatten} from "@taqueria/protocol/Base"
|
|
8
8
|
|
|
9
9
|
export const pluginsRawSchema = z.preprocess(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
);
|
|
10
|
+
val => val ?? [],
|
|
11
|
+
z.array(
|
|
12
|
+
InstalledPlugin.rawSchema, {description: "config.plugins"}
|
|
13
|
+
)
|
|
14
|
+
)
|
|
16
15
|
|
|
17
16
|
export const pluginsInternalSchema = z.preprocess(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
);
|
|
17
|
+
val => val ?? [],
|
|
18
|
+
z.array(
|
|
19
|
+
InstalledPlugin.schemas.schema, {description: "config.plugins"}
|
|
20
|
+
)
|
|
21
|
+
)
|
|
24
22
|
|
|
25
23
|
const networkMap = z
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
.record(
|
|
25
|
+
z.union([
|
|
26
|
+
NetworkConfig.schemas.schema,
|
|
27
|
+
z.string({description: "config.network"})
|
|
28
|
+
.nonempty("Default network must reference the name of an existing network configuration.")
|
|
29
|
+
]),
|
|
30
|
+
{description: "Network configurations"}
|
|
31
|
+
)
|
|
32
|
+
.optional()
|
|
35
33
|
|
|
36
34
|
const sandboxMap = z
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
.record(
|
|
36
|
+
z.union([
|
|
37
|
+
SandboxConfig.schemas.schema,
|
|
38
|
+
z.string({description: "config.sandbox"})
|
|
39
|
+
.min(1, "Default sandbox must reference the name of an existing sandbox configuration.")
|
|
40
|
+
]),
|
|
41
|
+
{description: "Sandbox configurations"}
|
|
42
|
+
)
|
|
43
|
+
.optional()
|
|
46
44
|
|
|
47
45
|
const environmentMap = z
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
.record(
|
|
47
|
+
z.union([
|
|
48
|
+
Environment.schemas.schema,
|
|
49
|
+
z.string().min(1, "Default environment must reference the name of an existing environment.")
|
|
50
|
+
]),
|
|
51
|
+
{description: "Environment configurations"}
|
|
52
|
+
)
|
|
53
|
+
.optional()
|
|
56
54
|
|
|
57
55
|
const accountsMap = z.preprocess(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
);
|
|
56
|
+
(val: unknown) => val ?? {
|
|
57
|
+
"bob": "5_000_000_000",
|
|
58
|
+
"alice": "5_000_000_000",
|
|
59
|
+
"john": "5_000_000_000",
|
|
60
|
+
},
|
|
61
|
+
z.record(
|
|
62
|
+
z.union([Tz.rawSchema, z.number()]),
|
|
63
|
+
{description: "config.accounts"}
|
|
64
|
+
)
|
|
65
|
+
)
|
|
69
66
|
|
|
70
67
|
const commonSchema = z.object({
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}).describe(
|
|
68
|
+
language: z.preprocess(
|
|
69
|
+
val => val ?? 'en',
|
|
70
|
+
z.union([
|
|
71
|
+
z.literal('en'),
|
|
72
|
+
z.literal('fr')
|
|
73
|
+
], {description: "config.language"})
|
|
74
|
+
.optional()
|
|
75
|
+
),
|
|
76
|
+
plugins: pluginsInternalSchema.optional(),
|
|
77
|
+
contractsDir: z
|
|
78
|
+
.preprocess(
|
|
79
|
+
(val: unknown) => val ?? "contracts",
|
|
80
|
+
z.string({description: "config.contractsDir"})
|
|
81
|
+
.min(1, "config.contractsDir must have a value")
|
|
82
|
+
),
|
|
83
|
+
artifactsDir: z
|
|
84
|
+
.preprocess(
|
|
85
|
+
(val: unknown) => val ?? "artifacts",
|
|
86
|
+
z.string({description: "config.artifactsDir"})
|
|
87
|
+
.min(1, "config.artifactsDir must have a value")
|
|
88
|
+
)
|
|
89
|
+
}).describe("config")
|
|
93
90
|
|
|
94
91
|
export const internalSchema = commonSchema.extend({
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
})
|
|
92
|
+
network: networkMap,
|
|
93
|
+
sandbox: sandboxMap,
|
|
94
|
+
environment: environmentMap,
|
|
95
|
+
accounts: accountsMap
|
|
96
|
+
})
|
|
100
97
|
|
|
101
98
|
export const rawSchema = commonSchema.extend({
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}).describe(
|
|
99
|
+
plugins: pluginsRawSchema.optional(),
|
|
100
|
+
network: z
|
|
101
|
+
.record(
|
|
102
|
+
z.union([
|
|
103
|
+
NetworkConfig.rawSchema,
|
|
104
|
+
z.string({description: "config.network"})
|
|
105
|
+
.min(1, "Default network must reference the name of an existing network configuration.")
|
|
106
|
+
])
|
|
107
|
+
)
|
|
108
|
+
.optional(),
|
|
109
|
+
sandbox: z
|
|
110
|
+
.record(
|
|
111
|
+
z.union([
|
|
112
|
+
SandboxConfig.rawSchema,
|
|
113
|
+
z.string({description: "config.sandbox"})
|
|
114
|
+
.min(1, "Default sandbox must reference the name of an existing sandbox configuration.")
|
|
115
|
+
])
|
|
116
|
+
)
|
|
117
|
+
.optional(),
|
|
118
|
+
environment: z
|
|
119
|
+
.record(
|
|
120
|
+
z.union([
|
|
121
|
+
Environment.rawSchema,
|
|
122
|
+
z.string({description: "config.environment"})
|
|
123
|
+
.min(1, "Default environment must reference the name of an existing environment.")
|
|
124
|
+
])
|
|
125
|
+
)
|
|
126
|
+
.optional(),
|
|
127
|
+
accounts: z
|
|
128
|
+
.record(
|
|
129
|
+
z.union([Tz.rawSchema, z.number()]),
|
|
130
|
+
{description: "config.accounts"}
|
|
131
|
+
)
|
|
132
|
+
.optional()
|
|
133
|
+
}).describe("config")
|
|
137
134
|
|
|
138
|
-
type RawInput = z.infer<typeof rawSchema
|
|
139
|
-
type Input = z.infer<typeof internalSchema
|
|
135
|
+
type RawInput = z.infer<typeof rawSchema>
|
|
136
|
+
type Input = z.infer<typeof internalSchema>
|
|
140
137
|
|
|
141
|
-
export const {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
})
|
|
138
|
+
export const {schemas: generatedSchemas, factory} = createType<RawInput, Input>({
|
|
139
|
+
rawSchema,
|
|
140
|
+
internalSchema,
|
|
141
|
+
parseErrMsg: (value: unknown) => `${value} is not a configuration`,
|
|
142
|
+
unknownErrMsg: "Something went wrong trying to parse your configuration"
|
|
143
|
+
})
|
|
147
144
|
|
|
148
|
-
export const {
|
|
149
|
-
export type Config = z.infer<typeof generatedSchemas.schema
|
|
150
|
-
export type t = Config
|
|
145
|
+
export const {create, of, make} = factory
|
|
146
|
+
export type Config = z.infer<typeof generatedSchemas.schema>
|
|
147
|
+
export type t = Config
|
|
151
148
|
|
|
152
149
|
export const schemas = {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
150
|
+
...generatedSchemas,
|
|
151
|
+
schema: generatedSchemas.schema.transform(val => val as Config)
|
|
152
|
+
}
|
package/Crypto.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export class Crypto {
|
|
2
|
-
|
|
3
|
-
}
|
|
2
|
+
subtle: SubtleCrypto = crypto.subtle
|
|
3
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import {z} from 'zod'
|
|
2
|
+
import createType from "@taqueria/protocol/Base"
|
|
3
3
|
|
|
4
4
|
export const rawSchema = z
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
.string({description: "Protocol hash"})
|
|
6
|
+
.refine(
|
|
7
|
+
value => (value.length === 51 && value[0] === 'P' && /[A-Za-z0-9]+/.test(value)),
|
|
8
|
+
value => ({message: `${value} is an invalid hash for an economical protocol`})
|
|
9
|
+
)
|
|
10
10
|
|
|
11
|
-
type RawInput = z.infer<typeof rawSchema
|
|
11
|
+
type RawInput = z.infer<typeof rawSchema>
|
|
12
12
|
|
|
13
|
-
export const {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
})
|
|
13
|
+
export const {schemas: generatedSchemas, factory} = createType<RawInput, RawInput>({
|
|
14
|
+
rawSchema,
|
|
15
|
+
parseErrMsg: (value: unknown) => `${value} is an invalid economical protocol hash`,
|
|
16
|
+
unknownErrMsg: "Somethign went wrong trying to parse the economical protocol hash"
|
|
17
|
+
})
|
|
18
18
|
|
|
19
|
-
export type EconomicalPrototypeHash = z.infer<typeof generatedSchemas.schema
|
|
20
|
-
export type t = EconomicalPrototypeHash
|
|
19
|
+
export type EconomicalPrototypeHash = z.infer<typeof generatedSchemas.schema>
|
|
20
|
+
export type t = EconomicalPrototypeHash
|
|
21
21
|
|
|
22
|
-
export const {
|
|
22
|
+
export const {create, of, make} = factory
|
|
23
23
|
export const schemas = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
24
|
+
...generatedSchemas,
|
|
25
|
+
schema: generatedSchemas.schema.transform(val => val as EconomicalPrototypeHash)
|
|
26
|
+
}
|