@tsplc/config 0.2.20 → 0.3.0
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/README.md +1 -1
- package/dist/build.js +38 -7
- package/dist/build.js.map +8 -7
- package/dist/index.js +260 -226
- package/dist/index.js.map +9 -8
- package/dist/project-files.js +18 -0
- package/dist/project-files.js.map +10 -0
- package/dist/schema.js +42 -16
- package/dist/schema.js.map +7 -6
- package/package.json +13 -2
- package/src/build-schema.ts +61 -0
- package/src/build.ts +15 -10
- package/src/compiler.ts +3 -0
- package/src/environment.ts +15 -7
- package/src/index.ts +37 -36
- package/src/loader.ts +3 -0
- package/src/project-files.ts +15 -0
- package/src/schema.ts +23 -27
package/src/schema.ts
CHANGED
|
@@ -1,45 +1,48 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import {
|
|
3
3
|
assemblyAddress,
|
|
4
|
+
type CodesysBuildConfig,
|
|
4
5
|
configSchema,
|
|
5
6
|
controllerDevices,
|
|
6
7
|
controllerTargetSchema,
|
|
7
8
|
cyclicTasksSchema,
|
|
8
9
|
directIoBindingSchema,
|
|
10
|
+
engineeringBuildOptions,
|
|
9
11
|
envName,
|
|
12
|
+
ethernetSchema,
|
|
10
13
|
fourPartVersion,
|
|
11
14
|
iecName,
|
|
12
15
|
ioBindingOptions,
|
|
13
|
-
ethernetSchema,
|
|
14
16
|
taskPriority,
|
|
15
17
|
tcpPort,
|
|
16
|
-
type CodesysBuildConfig,
|
|
17
18
|
} from "./build-schema.ts";
|
|
18
19
|
import {
|
|
19
20
|
durationSchema,
|
|
21
|
+
type PlcConfig,
|
|
20
22
|
taskSchema,
|
|
21
23
|
validateConfig as validateCompilerConfig,
|
|
22
|
-
type PlcConfig,
|
|
23
24
|
} from "./compiler.ts";
|
|
25
|
+
import { generatedDirectory } from "./project-files.ts";
|
|
24
26
|
|
|
27
|
+
export type {
|
|
28
|
+
CodesysBuildConfig,
|
|
29
|
+
Controller,
|
|
30
|
+
DeviceTree,
|
|
31
|
+
} from "./build-schema.ts";
|
|
25
32
|
export {
|
|
26
|
-
ns,
|
|
27
|
-
ms,
|
|
28
|
-
seconds,
|
|
29
|
-
definePlcConfig,
|
|
30
|
-
validateConfig,
|
|
31
33
|
type Duration,
|
|
34
|
+
definePlcConfig,
|
|
35
|
+
durationHelpers,
|
|
36
|
+
ms,
|
|
32
37
|
type NormalizedConfig,
|
|
38
|
+
ns,
|
|
33
39
|
type PlcConfig,
|
|
34
40
|
type SourceExport,
|
|
41
|
+
seconds,
|
|
35
42
|
type TargetDescriptor,
|
|
36
43
|
type TaskConfig,
|
|
44
|
+
validateConfig,
|
|
37
45
|
} from "./compiler.ts";
|
|
38
|
-
export type {
|
|
39
|
-
CodesysBuildConfig,
|
|
40
|
-
Controller,
|
|
41
|
-
DeviceTree,
|
|
42
|
-
} from "./build-schema.ts";
|
|
43
46
|
|
|
44
47
|
export const httpOptionsSchema = z
|
|
45
48
|
.strictObject({
|
|
@@ -121,7 +124,10 @@ const monitorSchema = z
|
|
|
121
124
|
.enum(["None", "Sign", "SignAndEncrypt"])
|
|
122
125
|
.default("SignAndEncrypt"),
|
|
123
126
|
securityPolicy: z.enum(["None", "Basic256Sha256"]).optional(),
|
|
124
|
-
certificateDirectory: z
|
|
127
|
+
certificateDirectory: z
|
|
128
|
+
.string()
|
|
129
|
+
.min(1)
|
|
130
|
+
.default(`${generatedDirectory}/opcua-pki`),
|
|
125
131
|
username: z.string().min(1).optional(),
|
|
126
132
|
passwordEnv: envName.optional(),
|
|
127
133
|
})
|
|
@@ -218,6 +224,8 @@ export const publicationSchema = z.strictObject({
|
|
|
218
224
|
development: z.array(z.string().nonempty()),
|
|
219
225
|
});
|
|
220
226
|
export type Publication = Readonly<Record<BuildTarget, readonly string[]>>;
|
|
227
|
+
/** Each IO binding's name with the published symbol path the compiler gave it. */
|
|
228
|
+
export const ioSymbolsSchema = z.record(z.string(), z.string());
|
|
221
229
|
/** A published PLC variable, as `Global.Field`. */
|
|
222
230
|
const hmiTarget = z.string().regex(/^\w+(\.\w+|\[\d+\])+$/);
|
|
223
231
|
const hmiControlSchema = z.discriminatedUnion("kind", [
|
|
@@ -482,7 +490,7 @@ export function compilerConfig(
|
|
|
482
490
|
engineering: {
|
|
483
491
|
kind: "v3.5",
|
|
484
492
|
...(config.build
|
|
485
|
-
? { build:
|
|
493
|
+
? { build: engineeringBuildOptions(config.build) }
|
|
486
494
|
: {}),
|
|
487
495
|
},
|
|
488
496
|
},
|
|
@@ -518,15 +526,3 @@ function mappedChannel(
|
|
|
518
526
|
!/^ARRAY/i.test(binding.type ?? "")
|
|
519
527
|
);
|
|
520
528
|
}
|
|
521
|
-
|
|
522
|
-
function compilerBuildOptions(build: CodesysBuildConfig) {
|
|
523
|
-
const {
|
|
524
|
-
sourceDir: _source,
|
|
525
|
-
entry: _entry,
|
|
526
|
-
outDir: _out,
|
|
527
|
-
task: _task,
|
|
528
|
-
tasks: _tasks,
|
|
529
|
-
...settings
|
|
530
|
-
} = build;
|
|
531
|
-
return settings;
|
|
532
|
-
}
|