@taqueria/protocol 0.0.0-pr-783-7fc9978a → 0.0.0-pr-776-b4c3aaa5

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 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 of = (input: R | I | unknown) => {
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) => of(input)
82
+ const make = (input: I) => internalOf(input)
82
83
 
83
- const create = (input: R | I | unknown) => schemas.schema.parse(input) as T
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([
@@ -32,8 +46,7 @@ const environmentMap = z
32
46
  .record(
33
47
  z.union([
34
48
  Environment.schemas.schema,
35
- z.string({description: "config.environment"})
36
- .min(1, "Default environment must reference the name of an existing environment.")
49
+ z.string().min(1, "Default environment must reference the name of an existing environment.")
37
50
  ]),
38
51
  {description: "Environment configurations"}
39
52
  )
@@ -52,20 +65,15 @@ const accountsMap = z.preprocess(
52
65
  )
53
66
 
54
67
  const commonSchema = z.object({
55
- language: z
56
- .union([z.literal('en'), z.literal('fr')], {description: "config.language"})
57
- .optional()
58
- .transform((val?: 'en' | 'fr' | string) => val ?? 'en'),
59
- plugins: z
60
- .array(InstalledPlugin.schemas.schema, {description: "config.plugins"})
68
+ language: z.preprocess(
69
+ val => val ?? 'en',
70
+ z.union([
71
+ z.literal('en'),
72
+ z.literal('fr')
73
+ ], {description: "config.language"})
61
74
  .optional()
62
- .transform((val: unknown) => (val ?? []) as InstalledPlugin.t[]),
63
- testsDir: z
64
- .preprocess(
65
- (val: unknown) => val ?? "tests",
66
- z.string({description: "config.testsDir"})
67
- .min(1, "config.testsDir must have a value")
68
- ),
75
+ ),
76
+ plugins: pluginsInternalSchema.optional(),
69
77
  contractsDir: z
70
78
  .preprocess(
71
79
  (val: unknown) => val ?? "contracts",
@@ -88,6 +96,7 @@ export const internalSchema = commonSchema.extend({
88
96
  })
89
97
 
90
98
  export const rawSchema = commonSchema.extend({
99
+ plugins: pluginsRawSchema.optional(),
91
100
  network: z
92
101
  .record(
93
102
  z.union([
@@ -123,7 +132,7 @@ export const rawSchema = commonSchema.extend({
123
132
  .optional()
124
133
  }).describe("config")
125
134
 
126
- type RawInput = Flatten<z.infer<typeof rawSchema>>
135
+ type RawInput = z.infer<typeof rawSchema>
127
136
  type Input = z.infer<typeof internalSchema>
128
137
 
129
138
  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.extend({
8
- projectDir: SanitizedAbsPath.rawSchema.describe("loadedConfig.projectDir"),
9
- configFile: SanitizedAbsPath.rawSchema.describe("loadedConfig.configFile"),
10
- hash: SHA256.rawSchema.describe("loadedConfig.hash")
11
- }).describe("LoadedConfig")
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.extend({
14
- projectDir: SanitizedAbsPath.schemas.schema.describe("loadedConfig.projectDir"),
15
- configFile: SanitizedAbsPath.schemas.schema.describe("loadedConfig.configFile"),
16
- hash: SHA256.schemas.schema.describe("loadedConfig.hash")
17
- }).describe("LoadedConfig")
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>>
@@ -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: z.number().min(1651846877).describe("state.op.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: z.number().min(1651846877).describe("state.op.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 const rawSchema = z.record(rawOpSchema)
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.record(internalOpSchema)
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().nonempty()
46
+ task: z.string().min(1)
47
47
  }).describe("ProxyRequestArgs").passthrough()
48
48
 
49
49
  const internalProxySchema = internalSchema.extend({
50
- task: z.string().nonempty()
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.create
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, make} = factory
71
+ export const {create, make, of, from} = factory
package/SanitizedArgs.ts CHANGED
@@ -45,7 +45,10 @@ import createType from "@taqueria/protocol/Base"
45
45
  plugin: z.string().min(1).optional(),
46
46
  env: z.union([z.literal('production'), z.literal('testing'), z.literal('development'), z.string().nonempty()]).default("development"),
47
47
  quickstart: z.string().min(1).optional(),
48
- setBuild: z.string().min(3),
48
+ setBuild: z.preprocess(
49
+ val => String(val),
50
+ z.string().min(3)
51
+ ),
49
52
  setVersion: z.string().min(3),
50
53
  template: z.string().min(1).optional(),
51
54
  pluginName: z.string().min(1).optional()
@@ -125,7 +128,7 @@ export type ProvisionTaskArgs = z.infer<typeof provisionTaskArgs.schemas.schema>
125
128
  export type InstallTaskArgs = z.infer<typeof installTaskArgs.schemas.schema>
126
129
  export type UninstallTaskArgs = z.infer<typeof uninstallTaskArgs.schemas.schema>
127
130
 
128
- export const createScaffoldTaskArgs = scaffoldTaskArgs.factory.create
131
+ export const createScaffoldTaskArgs = scaffoldTaskArgs.factory.from
129
132
  export const makeScaffoldTaskArgs = scaffoldTaskArgs.factory.make
130
133
  export const ofScaffoldTaskArgs = scaffoldTaskArgs.factory.of
131
134
 
package/Task.ts CHANGED
@@ -18,7 +18,10 @@ const taskEncodingSchema = z.preprocess(
18
18
  .optional()
19
19
  )
20
20
 
21
- const taskHandlerSchema = z.union([z.literal('proxy'), z.string()])
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
- // schema: generatedSchemas.schema.transform(val => val as unknown as Task)
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-783-7fc9978a",
3
+ "version": "0.0.0-pr-776-b4c3aaa5",
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": {