@taqueria/protocol 0.0.0-pr-775-c1fcd4ee → 0.0.0-pr-776-28b91641
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/Base.ts +8 -4
- package/Config.ts +30 -17
- package/Environment.ts +1 -1
- package/LoadedConfig.ts +18 -10
- package/PersistentState.ts +33 -5
- package/RequestArgs.ts +4 -4
- package/SanitizedArgs.ts +1 -1
- package/Task.ts +5 -2
- package/Timestamp.ts +25 -0
- package/package.json +1 -1
package/Base.ts
CHANGED
|
@@ -58,7 +58,7 @@ export const createType = <R, I>(params: CreateTypeParams) => {
|
|
|
58
58
|
|
|
59
59
|
type T = z.infer<typeof schemas.schema>
|
|
60
60
|
|
|
61
|
-
const
|
|
61
|
+
const internalOf = (input: unknown) => {
|
|
62
62
|
try {
|
|
63
63
|
return resolve<T>(schemas.schema.parse(input))
|
|
64
64
|
}
|
|
@@ -77,15 +77,19 @@ export const createType = <R, I>(params: CreateTypeParams) => {
|
|
|
77
77
|
return toFutureParseUnknownErr<T>(previous, unknownMsg, input)
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
+
const of = internalOf
|
|
80
81
|
|
|
81
|
-
const make = (input: I) =>
|
|
82
|
+
const make = (input: I) => internalOf(input)
|
|
82
83
|
|
|
83
|
-
const create = (input: R | I
|
|
84
|
+
const create = (input: R | I) => schemas.schema.parse(input) as T
|
|
85
|
+
|
|
86
|
+
const from = (input: unknown) => schemas.schema.parse(input) as T
|
|
84
87
|
|
|
85
88
|
const factory = {
|
|
86
89
|
make,
|
|
87
90
|
of,
|
|
88
|
-
create
|
|
91
|
+
create,
|
|
92
|
+
from
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
return {
|
package/Config.ts
CHANGED
|
@@ -6,6 +6,20 @@ import * as Environment from "@taqueria/protocol/Environment"
|
|
|
6
6
|
import * as Tz from "@taqueria/protocol/Tz"
|
|
7
7
|
import createType, {Flatten} from "@taqueria/protocol/Base"
|
|
8
8
|
|
|
9
|
+
export const pluginsRawSchema = z.preprocess(
|
|
10
|
+
val => val ?? [],
|
|
11
|
+
z.array(
|
|
12
|
+
InstalledPlugin.rawSchema, {description: "config.plugins"}
|
|
13
|
+
)
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
export const pluginsInternalSchema = z.preprocess(
|
|
17
|
+
val => val ?? [],
|
|
18
|
+
z.array(
|
|
19
|
+
InstalledPlugin.schemas.schema, {description: "config.plugins"}
|
|
20
|
+
)
|
|
21
|
+
)
|
|
22
|
+
|
|
9
23
|
const networkMap = z
|
|
10
24
|
.record(
|
|
11
25
|
z.union([
|
|
@@ -27,13 +41,15 @@ const sandboxMap = z
|
|
|
27
41
|
{description: "Sandbox configurations"}
|
|
28
42
|
)
|
|
29
43
|
.optional()
|
|
44
|
+
|
|
45
|
+
const storageSchema = z.unknown().optional()
|
|
30
46
|
|
|
31
47
|
const environmentMap = z
|
|
32
48
|
.record(
|
|
33
49
|
z.union([
|
|
34
50
|
Environment.schemas.schema,
|
|
35
|
-
z.string(
|
|
36
|
-
|
|
51
|
+
z.string().min(1, "Default environment must reference the name of an existing environment."),
|
|
52
|
+
storageSchema
|
|
37
53
|
]),
|
|
38
54
|
{description: "Environment configurations"}
|
|
39
55
|
)
|
|
@@ -52,20 +68,15 @@ const accountsMap = z.preprocess(
|
|
|
52
68
|
)
|
|
53
69
|
|
|
54
70
|
const commonSchema = z.object({
|
|
55
|
-
language: z
|
|
56
|
-
|
|
57
|
-
.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
71
|
+
language: z.preprocess(
|
|
72
|
+
val => val ?? 'en',
|
|
73
|
+
z.union([
|
|
74
|
+
z.literal('en'),
|
|
75
|
+
z.literal('fr')
|
|
76
|
+
], {description: "config.language"})
|
|
61
77
|
.optional()
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
.preprocess(
|
|
65
|
-
(val: unknown) => val ?? "tests",
|
|
66
|
-
z.string({description: "config.testsDir"})
|
|
67
|
-
.min(1, "config.testsDir must have a value")
|
|
68
|
-
),
|
|
78
|
+
),
|
|
79
|
+
plugins: pluginsInternalSchema.optional(),
|
|
69
80
|
contractsDir: z
|
|
70
81
|
.preprocess(
|
|
71
82
|
(val: unknown) => val ?? "contracts",
|
|
@@ -88,6 +99,7 @@ export const internalSchema = commonSchema.extend({
|
|
|
88
99
|
})
|
|
89
100
|
|
|
90
101
|
export const rawSchema = commonSchema.extend({
|
|
102
|
+
plugins: pluginsRawSchema.optional(),
|
|
91
103
|
network: z
|
|
92
104
|
.record(
|
|
93
105
|
z.union([
|
|
@@ -111,7 +123,8 @@ export const rawSchema = commonSchema.extend({
|
|
|
111
123
|
z.union([
|
|
112
124
|
Environment.rawSchema,
|
|
113
125
|
z.string({description: "config.environment"})
|
|
114
|
-
.min(1, "Default environment must reference the name of an existing environment.")
|
|
126
|
+
.min(1, "Default environment must reference the name of an existing environment."),
|
|
127
|
+
storageSchema
|
|
115
128
|
])
|
|
116
129
|
)
|
|
117
130
|
.optional(),
|
|
@@ -123,7 +136,7 @@ export const rawSchema = commonSchema.extend({
|
|
|
123
136
|
.optional()
|
|
124
137
|
}).describe("config")
|
|
125
138
|
|
|
126
|
-
type RawInput =
|
|
139
|
+
type RawInput = z.infer<typeof rawSchema>
|
|
127
140
|
type Input = z.infer<typeof internalSchema>
|
|
128
141
|
|
|
129
142
|
export const {schemas, factory} = createType<RawInput, Input>({
|
package/Environment.ts
CHANGED
|
@@ -28,6 +28,6 @@ export const {schemas, factory} = createType<RawInput, RawInput>({
|
|
|
28
28
|
export type Environment = Flatten<z.infer<typeof schemas.schema>>
|
|
29
29
|
export type t = Environment
|
|
30
30
|
|
|
31
|
-
export const {create, make, of} = factory
|
|
31
|
+
export const {create, make, of, from} = factory
|
|
32
32
|
|
|
33
33
|
export const {internalSchema} = schemas
|
package/LoadedConfig.ts
CHANGED
|
@@ -4,17 +4,25 @@ import * as SanitizedAbsPath from '@taqueria/protocol/SanitizedAbsPath'
|
|
|
4
4
|
import * as SHA256 from '@taqueria/protocol/SHA256'
|
|
5
5
|
import createType, {Flatten} from "@taqueria/protocol/Base"
|
|
6
6
|
|
|
7
|
-
export const rawSchema = Config.rawSchema
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
export const rawSchema = Config.rawSchema
|
|
8
|
+
.omit({plugins: true})
|
|
9
|
+
.extend({
|
|
10
|
+
plugins: Config.pluginsRawSchema,
|
|
11
|
+
projectDir: SanitizedAbsPath.rawSchema.describe("loadedConfig.projectDir"),
|
|
12
|
+
configFile: SanitizedAbsPath.rawSchema.describe("loadedConfig.configFile"),
|
|
13
|
+
hash: SHA256.rawSchema.describe("loadedConfig.hash")
|
|
14
|
+
})
|
|
15
|
+
.describe("LoadedConfig")
|
|
12
16
|
|
|
13
|
-
export const internalSchema = Config.internalSchema
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
export const internalSchema = Config.internalSchema
|
|
18
|
+
.omit({plugins: true})
|
|
19
|
+
.extend({
|
|
20
|
+
plugins: Config.pluginsInternalSchema,
|
|
21
|
+
projectDir: SanitizedAbsPath.schemas.schema.describe("loadedConfig.projectDir"),
|
|
22
|
+
configFile: SanitizedAbsPath.schemas.schema.describe("loadedConfig.configFile"),
|
|
23
|
+
hash: SHA256.schemas.schema.describe("loadedConfig.hash")
|
|
24
|
+
})
|
|
25
|
+
.describe("LoadedConfig")
|
|
18
26
|
|
|
19
27
|
type RawInput = z.infer<typeof rawSchema>
|
|
20
28
|
type Input = Flatten<z.infer<typeof internalSchema>>
|
package/PersistentState.ts
CHANGED
|
@@ -1,22 +1,50 @@
|
|
|
1
1
|
import {z} from "zod"
|
|
2
|
+
import * as Verb from "@taqueria/protocol/Verb"
|
|
2
3
|
import * as SHA256 from "@taqueria/protocol/SHA256"
|
|
4
|
+
import * as Timestamp from "@taqueria/protocol/Timestamp"
|
|
3
5
|
import createType from "@taqueria/protocol/Base"
|
|
4
6
|
|
|
5
7
|
const rawOpSchema = z.object({
|
|
6
8
|
hash: SHA256.rawSchema.describe("state.op.hash"),
|
|
7
|
-
time:
|
|
9
|
+
time: Timestamp.rawSchema.describe("state.op.time"),
|
|
8
10
|
output: z.unknown().describe("state.op.output")
|
|
9
|
-
}).describe("Persistent State Operation")
|
|
11
|
+
}).describe("Persistent State Operation")
|
|
12
|
+
|
|
13
|
+
const rawTaskSchema = z.object({
|
|
14
|
+
time: Timestamp.rawSchema.describe("state.task.time"),
|
|
15
|
+
output: z.unknown().describe('state.task.output')
|
|
16
|
+
})
|
|
10
17
|
|
|
11
18
|
const internalOpSchema = z.object({
|
|
12
19
|
hash: SHA256.schemas.schema.describe("state.op.hash"),
|
|
13
|
-
time:
|
|
20
|
+
time: Timestamp.schemas.schema.describe("state.op.time"),
|
|
21
|
+
output: z.unknown().describe("state.op.output")
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const internalTaskSchema = z.object({
|
|
25
|
+
task: Verb.schemas.schema,
|
|
26
|
+
plugin: z.string().min(1),
|
|
27
|
+
time: Timestamp.schemas.schema.describe("state.task.time"),
|
|
14
28
|
output: z.unknown().describe("state.op.output")
|
|
15
29
|
})
|
|
16
30
|
|
|
17
|
-
export
|
|
31
|
+
export type PersistedTask = z.infer<typeof internalTaskSchema>
|
|
32
|
+
|
|
33
|
+
export type PersistedOperation = z.infer<typeof internalOpSchema>
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
export const rawSchema = z.object({
|
|
37
|
+
operations: z.record(rawOpSchema),
|
|
38
|
+
tasks: z.record(rawTaskSchema)
|
|
39
|
+
})
|
|
18
40
|
|
|
19
|
-
export const internalSchema = z.
|
|
41
|
+
export const internalSchema = z.object({
|
|
42
|
+
operations: z.record(internalOpSchema),
|
|
43
|
+
tasks: z.record(internalTaskSchema)
|
|
44
|
+
}).transform(val => ({
|
|
45
|
+
operations: val.operations as unknown as Record<string, PersistedOperation>,
|
|
46
|
+
tasks: val.tasks as unknown as Record<string, PersistedTask>
|
|
47
|
+
}))
|
|
20
48
|
|
|
21
49
|
type RawInput = z.infer<typeof rawSchema>
|
|
22
50
|
|
package/RequestArgs.ts
CHANGED
|
@@ -43,11 +43,11 @@ export type RequestArgs = z.infer<typeof schemas.schema>
|
|
|
43
43
|
export type t = RequestArgs
|
|
44
44
|
|
|
45
45
|
const rawProxySchema = rawSchema.extend({
|
|
46
|
-
task: z.string().
|
|
46
|
+
task: z.string().min(1)
|
|
47
47
|
}).describe("ProxyRequestArgs").passthrough()
|
|
48
48
|
|
|
49
49
|
const internalProxySchema = internalSchema.extend({
|
|
50
|
-
task: z.string().
|
|
50
|
+
task: z.string().min(1)
|
|
51
51
|
}).describe("ProxyRequestArgs").passthrough()
|
|
52
52
|
|
|
53
53
|
type RawProxyInput = z.infer<typeof rawProxySchema>
|
|
@@ -65,7 +65,7 @@ export const proxyFactory = proxy.factory
|
|
|
65
65
|
|
|
66
66
|
export type ProxyRequestArgs = z.infer<typeof proxySchemas.schema>
|
|
67
67
|
|
|
68
|
-
export const createProxyRequestArgs = proxyFactory.
|
|
68
|
+
export const createProxyRequestArgs = proxyFactory.from
|
|
69
69
|
export const makeProxyRequestArgs = proxyFactory.make
|
|
70
70
|
export const ofProxyRequestArgs = proxyFactory.of
|
|
71
|
-
export const {create, of,
|
|
71
|
+
export const {create, make, of, from} = factory
|
package/SanitizedArgs.ts
CHANGED
|
@@ -125,7 +125,7 @@ export type ProvisionTaskArgs = z.infer<typeof provisionTaskArgs.schemas.schema>
|
|
|
125
125
|
export type InstallTaskArgs = z.infer<typeof installTaskArgs.schemas.schema>
|
|
126
126
|
export type UninstallTaskArgs = z.infer<typeof uninstallTaskArgs.schemas.schema>
|
|
127
127
|
|
|
128
|
-
export const createScaffoldTaskArgs = scaffoldTaskArgs.factory.
|
|
128
|
+
export const createScaffoldTaskArgs = scaffoldTaskArgs.factory.from
|
|
129
129
|
export const makeScaffoldTaskArgs = scaffoldTaskArgs.factory.make
|
|
130
130
|
export const ofScaffoldTaskArgs = scaffoldTaskArgs.factory.of
|
|
131
131
|
|
package/Task.ts
CHANGED
|
@@ -18,7 +18,10 @@ const taskEncodingSchema = z.preprocess(
|
|
|
18
18
|
.optional()
|
|
19
19
|
)
|
|
20
20
|
|
|
21
|
-
const taskHandlerSchema = z.union([
|
|
21
|
+
const taskHandlerSchema = z.union([
|
|
22
|
+
z.literal('proxy'),
|
|
23
|
+
z.string().min(1),
|
|
24
|
+
])
|
|
22
25
|
|
|
23
26
|
export const rawSchema = z.object({
|
|
24
27
|
task: Verb.rawSchema.describe("Task Name"),
|
|
@@ -64,5 +67,5 @@ export type t = Task
|
|
|
64
67
|
export const {create, make, of} = factory
|
|
65
68
|
export const schemas = {
|
|
66
69
|
...generatedSchemas,
|
|
67
|
-
|
|
70
|
+
schema: generatedSchemas.schema.transform(val => val as unknown as Task)
|
|
68
71
|
}
|
package/Timestamp.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {z} from 'zod'
|
|
2
|
+
import createType from "@taqueria/protocol/Base"
|
|
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/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-776-28b91641",
|
|
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": {
|