@platforma-sdk/workflow-tengo 2.10.0 → 2.10.2

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.
Files changed (32) hide show
  1. package/dist/tengo/lib/exec.R.lib.tengo +6 -6
  2. package/dist/tengo/lib/exec.internal.lib.tengo +2 -2
  3. package/dist/tengo/lib/exec.lib.tengo +6 -6
  4. package/dist/tengo/lib/exec.monetization.lib.tengo +6 -6
  5. package/dist/tengo/lib/exec.package.lib.tengo +5 -5
  6. package/dist/tengo/lib/exec.python.lib.tengo +5 -5
  7. package/dist/tengo/lib/exec.runenv.lib.tengo +3 -3
  8. package/dist/tengo/lib/file.internal.lib.tengo +3 -3
  9. package/dist/tengo/lib/file.lib.tengo +1 -1
  10. package/dist/tengo/lib/path.lib.tengo +8 -8
  11. package/dist/tengo/lib/pframes.spec.lib.tengo +3 -3
  12. package/dist/tengo/lib/pframes.util.lib.tengo +1 -1
  13. package/dist/tengo/lib/pframes.xsv.lib.tengo +1 -1
  14. package/dist/tengo/lib/tpl.lib.tengo +1 -1
  15. package/dist/tengo/lib/validation.lib.tengo +42 -17
  16. package/dist/tengo/lib/workdir.lib.tengo +10 -10
  17. package/dist/tengo/tpl/exec.R.create-renv.plj.gz +0 -0
  18. package/dist/tengo/tpl/exec.exec.plj.gz +0 -0
  19. package/dist/tengo/tpl/exec.monetization_to_json.plj.gz +0 -0
  20. package/dist/tengo/tpl/exec.python.create-venv.plj.gz +0 -0
  21. package/dist/tengo/tpl/exec.python.install-deps.plj.gz +0 -0
  22. package/dist/tengo/tpl/pframes.aggregate.plj.gz +0 -0
  23. package/dist/tengo/tpl/pframes.export-multiple-pcolumns.plj.gz +0 -0
  24. package/dist/tengo/tpl/pframes.export-pframe.plj.gz +0 -0
  25. package/dist/tengo/tpl/pframes.export-single-pcolumn.plj.gz +0 -0
  26. package/dist/tengo/tpl/pframes.import-dir.plj.gz +0 -0
  27. package/dist/tengo/tpl/pframes.map-pframe.plj.gz +0 -0
  28. package/dist/tengo/tpl/pframes.xsv-export-pframe.plj.gz +0 -0
  29. package/dist/tengo/tpl/pframes.xsv-import-map.plj.gz +0 -0
  30. package/dist/tengo/tpl/workdir.save.plj.gz +0 -0
  31. package/dist/tengo/tpl/workflow.build-ctx.plj.gz +0 -0
  32. package/package.json +1 -1
@@ -26,7 +26,7 @@ rVenvBuilder := func() {
26
26
 
27
27
  self = {
28
28
  operationMode: func(mode) {
29
- validation.assertJsonSchema(mode, "string",
29
+ validation.assertType(mode, "string",
30
30
  "exec.R.operationMode: <mode> must be string")
31
31
 
32
32
  ll.assert(mode == "remote" || mode == "dev-local",
@@ -37,7 +37,7 @@ rVenvBuilder := func() {
37
37
  },
38
38
 
39
39
  useToolset: func(name) {
40
- validation.assertJsonSchema(name, "string",
40
+ validation.assertType(name, "string",
41
41
  "exec.R.useToolset: <name> must be valid name of R packaging toolset (i.e. 'renv')")
42
42
  ll.assert(name != "", "exec.R.useToolset: toolset name must not be empty")
43
43
 
@@ -46,7 +46,7 @@ rVenvBuilder := func() {
46
46
  },
47
47
 
48
48
  runEnvDescriptor: func(descriptor) {
49
- validation.assertJsonSchema(descriptor, desc.runEnvScheme, "exec.R.runEnvDescriptor: <descriptor> must be run environment specification")
49
+ validation.assertType(descriptor, desc.runEnvScheme, "exec.R.runEnvDescriptor: <descriptor> must be run environment specification")
50
50
  ll.assert(descriptor.type == "R", "exec.R.runEnvDescriptor: not a 'R' run environment: %q", descriptor.type)
51
51
 
52
52
  rDescriptor = ll.fromStrict(descriptor)
@@ -54,14 +54,14 @@ rVenvBuilder := func() {
54
54
  },
55
55
 
56
56
  software: func(pkgRef) {
57
- validation.assertJsonSchema(pkgRef, validation.reference, "exec.R.software: <pkgRef> must be a reference to software package")
57
+ validation.assertType(pkgRef, validation.reference, "exec.R.software: <pkgRef> must be a reference to software package")
58
58
 
59
59
  softwareRef = pkgRef
60
60
  return self
61
61
  },
62
62
 
63
63
  dependencies: func(deps) {
64
- validation.assertJsonSchema(deps, { "any": "string" }, "exec.R.dependencies: <deps> must be map of reference file paths")
64
+ validation.assertType(deps, { "any": "string" }, "exec.R.dependencies: <deps> must be map of reference file paths")
65
65
 
66
66
  dependencies = deps
67
67
  return self
@@ -150,7 +150,7 @@ rVenvBuilder := func() {
150
150
  R: rPkg
151
151
  }
152
152
 
153
- validation.assertJsonSchema(rVenvInputs, internal.rVenvInputSchema, "incomplete R runenv configuration")
153
+ validation.assertType(rVenvInputs, internal.rVenvInputSchema, "incomplete R runenv configuration")
154
154
 
155
155
  tpl := render.create(createRenvTpl, rVenvInputs)
156
156
 
@@ -289,7 +289,7 @@ swToRunCmdOptions := func(softwareName, softwareVersion, softwareDescriptor) {
289
289
  "exec.internal.swToRunCmdOptions: software name must be a string, got %v", softwareName)
290
290
  ll.assert(is_string(softwareVersion),
291
291
  "exec.internal.swToRunCmdOptions: software version must be a string, got %v", softwareVersion)
292
- validation.assertJsonSchema(softwareDescriptor, desc.scheme,
292
+ validation.assertType(softwareDescriptor, desc.scheme,
293
293
  "exec.internal.swToRunCmdOptions: descriptor does not fit schema")
294
294
 
295
295
  result := undefined
@@ -316,7 +316,7 @@ swToRunCmdOptions := func(softwareName, softwareVersion, softwareDescriptor) {
316
316
  }
317
317
 
318
318
  binaryRunOptions := func(runOptions, mnzEnvs) {
319
- validation.assertJsonSchema(mnzEnvs, {"any": validation.reference})
319
+ validation.assertType(mnzEnvs, {"any": validation.reference})
320
320
 
321
321
  runCmdOpts := undefined
322
322
  if (is_undefined(ll.fromStrict(runOptions).software)) {
@@ -179,7 +179,7 @@ builder := func() {
179
179
  * @param value: string - the value of the environment variable.
180
180
  */
181
181
  env: func(name, value) {
182
- validation.assertJsonSchema([name, value], ["string"])
182
+ validation.assertType([name, value], ["string"])
183
183
  envs[name] = value
184
184
  envsTyped[name] = {
185
185
  type: execConstants.ARG_TYPE_STRING,
@@ -195,7 +195,7 @@ builder := func() {
195
195
  * @param value: string - the value of the environment variable.
196
196
  */
197
197
  envWithVar: func(name, value) {
198
- validation.assertJsonSchema([name, value], ["string"])
198
+ validation.assertType([name, value], ["string"])
199
199
 
200
200
  // deprecated: remove ARG_TYPE_VAR and this check after 15 Mar 2025
201
201
  t := feats.commandExpressions ? execConstants.ARG_TYPE_EXPRESSION : execConstants.ARG_TYPE_VAR
@@ -225,7 +225,7 @@ builder := func() {
225
225
  * @param envName: string - name of environment variable to set with value of secret.
226
226
  */
227
227
  secret: func(secretName, envName) {
228
- validation.assertJsonSchema([secretName, envName], ["string"])
228
+ validation.assertType([secretName, envName], ["string"])
229
229
  secrets[envName] = "{secrets."+secretName+"}"
230
230
  return self
231
231
  },
@@ -366,8 +366,8 @@ builder := func() {
366
366
 
367
367
  ll.assert(assets.isAssetInfo(asset),
368
368
  "exec.builder.addAsset: <asset> parameter is not an asset info. Provide the value obtained from assets.importAsset() here")
369
- validation.assertJsonSchema(destinationDir, "string", "exec.builder.addAsset: <destinationDir> is not a string. It must be a path inside working directory")
370
- validation.assertJsonSchema(pathsInArchive, ["string"], "exec.builder.addAsset: <pathsInArchive> must contain list of strings with paths inside archive")
369
+ validation.assertType(destinationDir, "string", "exec.builder.addAsset: <destinationDir> is not a string. It must be a path inside working directory")
370
+ validation.assertType(pathsInArchive, ["string"], "exec.builder.addAsset: <pathsInArchive> must contain list of strings with paths inside archive")
371
371
 
372
372
  assetIdKey := ll.idToString(asset._id)
373
373
  if is_undefined(assetRules[assetIdKey]) {
@@ -509,7 +509,7 @@ builder := func() {
509
509
  * a resource from which data we create a file.
510
510
  */
511
511
  writeFile: func(fileName, data, ...opts) {
512
- validation.assertJsonSchema(data, ["or",
512
+ validation.assertType(data, ["or",
513
513
  "string",
514
514
  "bytes",
515
515
  validation.reference])
@@ -39,7 +39,7 @@ schema := {
39
39
  "fileParams": {"any": fileParamsSchema}
40
40
  }
41
41
 
42
- /** Same as validation.assertJsonSchema(params, fileParamsSchema, ...),
42
+ /** Same as validation.assertType(params, fileParamsSchema, ...),
43
43
  * but with prettier errors for clients. */
44
44
  _validateParams := func(params) {
45
45
  ll.assert(ll.isMap(params), "monetization.validateParams(): mnz params must be a map")
@@ -48,7 +48,7 @@ _validateParams := func(params) {
48
48
  }
49
49
 
50
50
  _validateIsReady := func(mnz) {
51
- validation.assertJsonSchema(mnz, schema,
51
+ validation.assertType(mnz, schema,
52
52
  "monetization.assertIsReady(): monetization does not fit schema")
53
53
  ll.assert(len(mnz.productName) > 0,
54
54
  "monetization.assertIsReady(): product name must be set")
@@ -61,7 +61,7 @@ enable := func(mnz, productName) {
61
61
  ll.assert(is_string(productName),
62
62
  "monetization.enable(): product name must be a string, got %v", productName)
63
63
 
64
- validation.assertJsonSchema(mnz, schema,
64
+ validation.assertType(mnz, schema,
65
65
  "monetization.enable(): mnz object does not fit schema")
66
66
 
67
67
  mnz.enabled = true
@@ -79,7 +79,7 @@ shouldRun := func(mnz) {
79
79
  }
80
80
 
81
81
  toJson := func(mnz) {
82
- validation.assertJsonSchema(mnz, schema,
82
+ validation.assertType(mnz, schema,
83
83
  "monetization.toJson(): monetization object does not fit json schema")
84
84
 
85
85
  return ll.fromStrict(mnz)
@@ -87,12 +87,12 @@ toJson := func(mnz) {
87
87
 
88
88
  /** Adds monetization parameters by a file. */
89
89
  addFileParams := func(mnz, fileName, params) {
90
- validation.assertJsonSchema(mnz, schema,
90
+ validation.assertType(mnz, schema,
91
91
  "monetization.addFileParams(): monetization object does not fit json schema")
92
92
 
93
93
  _validateParams(params)
94
94
 
95
- validation.assertJsonSchema(params, fileParamsSchema,
95
+ validation.assertType(params, fileParamsSchema,
96
96
  "monetization.addFileParams(): file params does not fit json schema")
97
97
 
98
98
  ll.assert(mnz.enabled,
@@ -89,7 +89,7 @@ _useSettingsSchema := {
89
89
  use := func(settings) {
90
90
  res := smart.structBuilder(_RTYPE_PACKAGE_USE)
91
91
 
92
- validation.assertJsonSchema(settings, _useSettingsSchema, "package.use(<settings>): settings have invalid format")
92
+ validation.assertType(settings, _useSettingsSchema, "package.use(<settings>): settings have invalid format")
93
93
  settingsRes := smart.createJsonResource(settings)
94
94
 
95
95
  res.getField(_INPUT_PACKAGE_USE_SETTINGS).set(settingsRes)
@@ -132,14 +132,14 @@ pkgFileLoader := func(pkg) {
132
132
 
133
133
  self = {
134
134
  saveFile: func(path) {
135
- validation.assertJsonSchema(path, "string", "package.pkgFileLoader.saveFile: <path> must be string")
135
+ validation.assertType(path, "string", "package.pkgFileLoader.saveFile: <path> must be string")
136
136
  filePaths = append(filePaths, path)
137
137
 
138
138
  return self
139
139
  },
140
140
 
141
141
  saveFiles: func(paths) {
142
- validation.assertJsonSchema(paths, ["string"], "package.pkgFileLoader.saveFiles: <paths> must be array of strings")
142
+ validation.assertType(paths, ["string"], "package.pkgFileLoader.saveFiles: <paths> must be array of strings")
143
143
  for p in paths {
144
144
  self.saveFile(p)
145
145
  }
@@ -148,13 +148,13 @@ pkgFileLoader := func(pkg) {
148
148
  },
149
149
 
150
150
  saveFileContent: func(path) {
151
- validation.assertJsonSchema(path, "string", "package.pkgFileLoader.saveFileContent: <path> must be string")
151
+ validation.assertType(path, "string", "package.pkgFileLoader.saveFileContent: <path> must be string")
152
152
  fileContentPaths = append(fileContentPaths, path)
153
153
  return self
154
154
  },
155
155
 
156
156
  saveFilesContent: func(paths) {
157
- validation.assertJsonSchema(paths, ["string"], "package.pkgFileLoader.saveFilesContent: <paths> must be array of strings")
157
+ validation.assertType(paths, ["string"], "package.pkgFileLoader.saveFilesContent: <paths> must be array of strings")
158
158
  for p in paths {
159
159
  self.saveFileContent(p)
160
160
  }
@@ -26,7 +26,7 @@ pythonVenvBuilder := func() {
26
26
 
27
27
  self = {
28
28
  useToolset: func(name) {
29
- validation.assertJsonSchema(name, "string",
29
+ validation.assertType(name, "string",
30
30
  "exec.python.useToolset: <name> must be valid name of python packaging toolset (pip, pipenv and so on)")
31
31
  ll.assert(name != "", "exec.python.useToolset: toolset name must not be empty")
32
32
 
@@ -35,7 +35,7 @@ pythonVenvBuilder := func() {
35
35
  },
36
36
 
37
37
  runEnvDescriptor: func(descriptor) {
38
- validation.assertJsonSchema(descriptor, desc.runEnvScheme, "exec.python.runEnvDescriptor: <descriptor> must be run environment specification")
38
+ validation.assertType(descriptor, desc.runEnvScheme, "exec.python.runEnvDescriptor: <descriptor> must be run environment specification")
39
39
  ll.assert(descriptor.type == "python", "exec.python.runEnvDescriptor: not a 'python' run environment: %q", descriptor.type)
40
40
 
41
41
  pythonDescriptor = ll.fromStrict(descriptor)
@@ -43,14 +43,14 @@ pythonVenvBuilder := func() {
43
43
  },
44
44
 
45
45
  software: func(pkgRef) {
46
- validation.assertJsonSchema(pkgRef, validation.reference, "exec.python.software: <pkgRef> must be a reference to software package")
46
+ validation.assertType(pkgRef, validation.reference, "exec.python.software: <pkgRef> must be a reference to software package")
47
47
 
48
48
  softwareRef = pkgRef
49
49
  return self
50
50
  },
51
51
 
52
52
  dependencies: func(deps) {
53
- validation.assertJsonSchema(deps, { "any": "string" }, "exec.python.dependencies: <deps> must be map of reference file paths")
53
+ validation.assertType(deps, { "any": "string" }, "exec.python.dependencies: <deps> must be map of reference file paths")
54
54
 
55
55
  dependencies = deps
56
56
  return self
@@ -140,7 +140,7 @@ pythonVenvBuilder := func() {
140
140
  python: pythonPkg
141
141
  }
142
142
 
143
- validation.assertJsonSchema(pyVenvInputs, internal.pythonVenvInputSchema, "incomplete python runenv configuration")
143
+ validation.assertType(pyVenvInputs, internal.pythonVenvInputSchema, "incomplete python runenv configuration")
144
144
 
145
145
  tpl := render.create(createVenvTpl, pyVenvInputs)
146
146
 
@@ -27,14 +27,14 @@ saveBuilder := func(wd) {
27
27
 
28
28
  self = {
29
29
  addPath: func(path) {
30
- validation.assertJsonSchema(path, "string", "runenv.saveBuilder.addPath: <path> must be string")
30
+ validation.assertType(path, "string", "runenv.saveBuilder.addPath: <path> must be string")
31
31
 
32
32
  pathsToSave = append(pathsToSave, path)
33
33
  return self
34
34
  },
35
35
 
36
36
  envType: func(type) {
37
- validation.assertJsonSchema(type, "string", "runenv.saveBuilder.envType: <type> must be string")
37
+ validation.assertType(type, "string", "runenv.saveBuilder.envType: <type> must be string")
38
38
 
39
39
  envType = type
40
40
  return self
@@ -45,7 +45,7 @@ saveBuilder := func(wd) {
45
45
  */
46
46
  addPackage: func(key, pkgRef) {
47
47
  ll.assert(!maps.containsKey(packagesMap, key), "runenv.saveBuilder.addPackage: package %q was already added to SaveRunEnv builder", key)
48
- validation.assertJsonSchema(pkgRef, validation.reference, "runenv.saveBuilder.addPackage: <pkgRef> must be reference")
48
+ validation.assertType(pkgRef, validation.reference, "runenv.saveBuilder.addPackage: <pkgRef> must be reference")
49
49
 
50
50
  packagesMap[key] = pkgRef
51
51
  return self
@@ -31,7 +31,7 @@ RTYPE_BLOB_DOWNLOAD := { Name: "BlobDownload", Version: "2" }
31
31
  * 'handle' - reference to resource with 'progress' API.
32
32
  */
33
33
  createBlobImportExternal := func(settings) {
34
- validation.assertJsonSchema(settings, {
34
+ validation.assertType(settings, {
35
35
  "dataURL": "string",
36
36
  "dataHeaders,?": [["string"]],
37
37
  "dataVersion,?": "string"
@@ -52,7 +52,7 @@ createBlobImportExternal := func(settings) {
52
52
  * 'handle' - reference to resource with 'progress' API.
53
53
  */
54
54
  createBlobImportInternal := func(settings) {
55
- validation.assertJsonSchema(settings, {
55
+ validation.assertType(settings, {
56
56
  "path": "string",
57
57
  "storageId": "string",
58
58
  "maxSpeedBytes,?": "number",
@@ -74,7 +74,7 @@ createBlobImportInternal := func(settings) {
74
74
  * 'handle' - reference to resource with 'progress' and 'upload' APIs.
75
75
  */
76
76
  createBlobUpload := func(settings) {
77
- validation.assertJsonSchema(settings, {
77
+ validation.assertType(settings, {
78
78
  "modificationTime": "string",
79
79
  "localPath": "string",
80
80
  "pathSignature": "string",
@@ -32,7 +32,7 @@ json := import("json")
32
32
  * }
33
33
  */
34
34
  importFile := func(importFileHandle) {
35
- validation.assertJsonSchema(
35
+ validation.assertType(
36
36
  importFileHandle,
37
37
  `string,regex=^(upload://upload/.*|index://index/.*)`
38
38
  )
@@ -9,7 +9,7 @@ validation := import("@platforma-sdk/workflow-tengo:validation")
9
9
  * @param elems: ...string - any number of elements.
10
10
  */
11
11
  join := func(...elems) {
12
- validation.assertJsonSchema(elems, ["string"])
12
+ validation.assertType(elems, ["string"])
13
13
  return ll.filepathJoin(elems...)
14
14
  }
15
15
 
@@ -20,7 +20,7 @@ join := func(...elems) {
20
20
  * @param elems: ...string - any number of elements.
21
21
  */
22
22
  regexpJoin := func(...elems) {
23
- validation.assertJsonSchema(elems, ["string"])
23
+ validation.assertType(elems, ["string"])
24
24
  return ll.filepathRegexpJoin(elems...)
25
25
  }
26
26
 
@@ -32,7 +32,7 @@ regexpJoin := func(...elems) {
32
32
  * @param elems: ...string - any number of elements.
33
33
  */
34
34
  canonize := func(...elems) {
35
- validation.assertJsonSchema(elems, ["string"])
35
+ validation.assertType(elems, ["string"])
36
36
  return ll.filepathCanonize(elems...)
37
37
  }
38
38
 
@@ -51,12 +51,12 @@ separator := ll.pathSeparator
51
51
  * @return trimmed path: string - a path without the beginning and a path separator.
52
52
  */
53
53
  trimPrefix := func(path, prefix) {
54
- validation.assertJsonSchema([path, prefix], ["string"])
54
+ validation.assertType([path, prefix], ["string"])
55
55
  return text.trim_prefix(path, prefix+separator)
56
56
  }
57
57
 
58
58
  _sepOrDefault := func(...sep) {
59
- validation.assertJsonSchema(sep, [["or", "string", "char", "null"]])
59
+ validation.assertType(sep, [["or", "string", "char", "null"]])
60
60
 
61
61
  if slices.length(sep) == 0 {
62
62
  return separator
@@ -89,7 +89,7 @@ split := func(path, ...sep) {
89
89
  * @return components: []string - all directories and a file name at the end from their root.
90
90
  */
91
91
  getBasenameDirs := func(path, ...sep) {
92
- validation.assertJsonSchema(path, "string")
92
+ validation.assertType(path, "string")
93
93
  sep = _sepOrDefault(sep...)
94
94
 
95
95
  dirs := split(path, sep)
@@ -111,7 +111,7 @@ getBasenameDirs := func(path, ...sep) {
111
111
  * @return extension: string - the extension without the leading "."
112
112
  */
113
113
  getExtension := func(path, ...sep) {
114
- validation.assertJsonSchema(path, "string")
114
+ validation.assertType(path, "string")
115
115
  ext := ""
116
116
  sep = _sepOrDefault(sep...)
117
117
 
@@ -143,7 +143,7 @@ getExtension := func(path, ...sep) {
143
143
  * @param path: string - a path
144
144
  */
145
145
  assertIsValid := func(path) {
146
- validation.assertJsonSchema(path, "string")
146
+ validation.assertType(path, "string")
147
147
  if text.contains(path, "/") {
148
148
  ll.assert(
149
149
  text.contains(path, separator),
@@ -90,7 +90,7 @@ _TRACE_SCHEMA := [_TRACE_STEP_SCHEMA]
90
90
  */
91
91
  makeTrace := func(input, ...steps) {
92
92
  // validating input step structure
93
- validation.assertJsonSchema(steps, _TRACE_SCHEMA)
93
+ validation.assertType(steps, _TRACE_SCHEMA)
94
94
 
95
95
  currentTraceContent := undefined
96
96
  if is_string(input) {
@@ -105,7 +105,7 @@ makeTrace := func(input, ...steps) {
105
105
  if !is_undefined(currentTraceContent) {
106
106
  currentTrace = json.decode(currentTraceContent)
107
107
  // validating trace we just parsed
108
- validation.assertJsonSchema(currentTrace, _TRACE_SCHEMA)
108
+ validation.assertType(currentTrace, _TRACE_SCHEMA)
109
109
  }
110
110
 
111
111
  currentTrace = append(currentTrace, steps...)
@@ -116,7 +116,7 @@ makeTrace := func(input, ...steps) {
116
116
  valueStr: currentTraceStr,
117
117
  /** Injects trace information into column spec */
118
118
  inject: func(spec) {
119
- validation.assertJsonSchema(spec, P_COLUMN_SPEC_SCHEMA)
119
+ validation.assertType(spec, P_COLUMN_SPEC_SCHEMA)
120
120
  return maps.deepMerge(spec, {annotations: {"pl7.app/trace": currentTraceStr}})
121
121
  }
122
122
  })
@@ -258,7 +258,7 @@ purifySpec := func(spec) {
258
258
  }
259
259
  newSpec.columns = newCols
260
260
 
261
- validation.assertJsonSchema(newSpec, PFCONV_IMPORT_CFG_SCHEMA)
261
+ validation.assertType(newSpec, PFCONV_IMPORT_CFG_SCHEMA)
262
262
 
263
263
  return newSpec
264
264
  }
@@ -85,7 +85,7 @@ getColumnSpec := func(axesSpec, col) {
85
85
  importFile := func(xsvFile, xsvType, spec, ...ops) {
86
86
  ll.assert(xsvType == "csv" || xsvType == "tsv", "expected one of [tsv, csv] types")
87
87
 
88
- validation.assertJsonSchema(spec, util.PFCONV_IMPORT_CFG_SCHEMA)
88
+ validation.assertType(spec, util.PFCONV_IMPORT_CFG_SCHEMA)
89
89
 
90
90
  xsvFileName := "file." + xsvType
91
91
 
@@ -361,7 +361,7 @@ tpl := func() {
361
361
  if is_undefined(schema) {
362
362
  return
363
363
  }
364
- validation.assertJsonSchema(self.inputs(), schema)
364
+ validation.assertType(self.inputs(), schema)
365
365
  },
366
366
 
367
367
  /**
@@ -341,16 +341,32 @@ isValid := func(js, schema) {
341
341
  }
342
342
 
343
343
  /**
344
- * Asserts that a given JSON conforms to a given schema.
344
+ * Alias to ll.assert just for usage convenience
345
+ */
346
+ assert := func(condition, msg, ...args) {
347
+ ll.assert(condition, msg, args...)
348
+ }
349
+
350
+ /**
351
+ * Asserts that a given variable conforms to a given schema.
352
+ *
353
+ * Schema field value examples:
354
+ * - for scalar type checks:
355
+ * "string", "number", "char", "bytes", "bool" to check presence of value of given type
356
+ * "null" - value must be undefined
357
+ * "any" - any value is accepted (even undefined)
358
+ * ["or", "string", "number"] - value must be string or number
359
+ * - for arrays: ["string"], ["number"], ... (any valid scalar type)
360
+ * - for maps: {"name": "string", "age": "number"} - make sure <value> is map with "name" and "age" keys with given value types.
345
361
  *
346
- * @param js: any - the JSON to assert.
347
- * @param schema: any - the schema to assert against.
362
+ * @param value: any - the value to check.
363
+ * @param schema: any - the schema to assert against (see comments above)
348
364
  * @param failMsg: string - optional parameter with custom message to be printed on validation error
349
365
  */
350
- assertJsonSchema := func(js, schema, ...failMsg) {
351
- r := _validateJson(js, schema, "")
366
+ assertType := func(value, schema, ...failMsg) {
367
+ r := _validateJson(value, schema, "")
352
368
 
353
- msg := "JSON validation error"
369
+ msg := "type schema validation error"
354
370
  if len(failMsg) > 0 {
355
371
  msg = failMsg[0]
356
372
  }
@@ -360,6 +376,13 @@ assertJsonSchema := func(js, schema, ...failMsg) {
360
376
  }
361
377
  }
362
378
 
379
+ /**
380
+ * Alias to 'assertType' for backward compatibility
381
+ */
382
+ assertJsonSchema := func(js, schema, ...failMsg) {
383
+ assertType(js, schema, failMsg...)
384
+ }
385
+
363
386
  //
364
387
  // Domain-specific schemas and checks:
365
388
  //
@@ -435,15 +458,17 @@ refSchema := {
435
458
  }
436
459
 
437
460
  export ll.toStrict({
438
- success: success,
439
- fail: fail,
440
- isSuccess: isSuccess,
441
- isFail: isFail,
442
- checkJson: checkJson,
443
- isValid: isValid,
444
- assertJsonSchema: assertJsonSchema,
445
- resource: resource,
446
- reference: reference,
447
- resourceType: resourceType,
448
- ref: refSchema
461
+ success: success,
462
+ fail: fail,
463
+ isSuccess: isSuccess,
464
+ isFail: isFail,
465
+ checkJson: checkJson,
466
+ isValid: isValid,
467
+ assert: assert,
468
+ assertType: assertType,
469
+ assertJsonSchema: assertJsonSchema, // deprecated
470
+ resource: resource,
471
+ reference: reference,
472
+ resourceType: resourceType,
473
+ ref: refSchema
449
474
  })
@@ -126,13 +126,13 @@ _fill := func(workdir) {
126
126
  * be extracted into '<destinationDir>/a/b/file.txt', NOT '<destinationDir>/file.txt',
127
127
  */
128
128
  addFromZip: func(zipResource, destinationDir, pathsInArchive) {
129
- validation.assertJsonSchema(zipResource, validation.reference, "workdir.builder.addFromZip: <zipResource> is not smart.reference")
130
- validation.assertJsonSchema(destinationDir, "string", "workdir.builder.addFromZip: <destinationDir> is not a string. It must be a path inside working directory")
129
+ validation.assertType(zipResource, validation.reference, "workdir.builder.addFromZip: <zipResource> is not smart.reference")
130
+ validation.assertType(destinationDir, "string", "workdir.builder.addFromZip: <destinationDir> is not a string. It must be a path inside working directory")
131
131
 
132
132
  if (is_undefined(pathsInArchive)) {
133
133
  pathsInArchive = []
134
134
  }
135
- validation.assertJsonSchema(pathsInArchive, ["string"], "workdir.builder.addFromZip: <pathsInArchive> must contain list of strings with paths inside archive")
135
+ validation.assertType(pathsInArchive, ["string"], "workdir.builder.addFromZip: <pathsInArchive> must contain list of strings with paths inside archive")
136
136
 
137
137
  blobKey := ll.idToString(zipResource.id)
138
138
 
@@ -163,8 +163,8 @@ _fill := func(workdir) {
163
163
  * @param fileResource: reference - the file to add.
164
164
  */
165
165
  addFile: func(fileName, fileResource) {
166
- validation.assertJsonSchema(fileName, "string")
167
- validation.assertJsonSchema(fileResource, validation.reference)
166
+ validation.assertType(fileName, "string")
167
+ validation.assertType(fileResource, validation.reference)
168
168
 
169
169
  files[fileName] = fileResource
170
170
  blobs[fileName] = fileResource
@@ -190,7 +190,7 @@ _fill := func(workdir) {
190
190
  * @param contentRef: reference|any - the content as a reference to add or the content itself.
191
191
  */
192
192
  writeFile: func(fileName, contentRef) {
193
- validation.assertJsonSchema(fileName, "string")
193
+ validation.assertType(fileName, "string")
194
194
  values[fileName] = contentRef
195
195
  self._addDirs(fileName)
196
196
 
@@ -291,7 +291,7 @@ save := func(workdir) {
291
291
  * @param fileName: string - the name of the file.
292
292
  */
293
293
  saveFile: func(fileName) {
294
- validation.assertJsonSchema(fileName, "string")
294
+ validation.assertType(fileName, "string")
295
295
  sets.add(files, fileName)
296
296
  return self
297
297
  },
@@ -302,7 +302,7 @@ save := func(workdir) {
302
302
  * @param fileName: string - the name of the file.
303
303
  */
304
304
  saveFileContent: func(fileName) {
305
- validation.assertJsonSchema(fileName, "string")
305
+ validation.assertType(fileName, "string")
306
306
  sets.add(filesContent, fileName)
307
307
  return self
308
308
  },
@@ -314,7 +314,7 @@ save := func(workdir) {
314
314
  * @param regex: string - regex
315
315
  */
316
316
  saveFileSet: func(name, regex) {
317
- validation.assertJsonSchema(regex, "string")
317
+ validation.assertType(regex, "string")
318
318
  ll.assert(is_undefined(fileSets[name]), "file set with name '", name, "' is already in added")
319
319
  fileSets[name] = regex
320
320
  return self
@@ -327,7 +327,7 @@ save := func(workdir) {
327
327
  * @param regex: string - regex
328
328
  */
329
329
  saveFileSetContent: func(name, regex) {
330
- validation.assertJsonSchema(regex, "string")
330
+ validation.assertType(regex, "string")
331
331
  ll.assert(is_undefined(fileSetsContent[name]), "file set content with name '", name, "' is already in added")
332
332
  sets.add(fileSetsContent, regex)
333
333
  return self
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/workflow-tengo",
3
- "version": "2.10.0",
3
+ "version": "2.10.2",
4
4
  "description": "Tengo SDK library",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",