1 Commits

Author SHA1 Message Date
Gergő Jedlicska 352365220a move to a file based function input 2023-08-10 17:03:40 +02:00
5 changed files with 30 additions and 14 deletions
+2 -2
View File
@@ -15,8 +15,8 @@ inputs:
speckle_function_id:
description: 'The unique identifier of the function. Go to automate to generate one.'
required: true
speckle_function_input_schema:
description: 'JSON Schema of the parameters object required by the function.'
speckle_function_input_schema_file_path:
description: 'File path containing JSON Schema of the parameters object required by the function.'
required: false
speckle_function_command:
description: 'The command to run to execute the function in a runtime environment.'
Generated Vendored
+1 -1
View File
@@ -9,7 +9,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "toFormData": () => (/* binding */ toFormData)
/* harmony export */ });
/* harmony import */ var fetch_blob_from_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2777);
/* harmony import */ var fetch_blob_from_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7972);
/* harmony import */ var formdata_polyfill_esm_min_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8010);
Generated Vendored
+20 -8
View File
@@ -7137,6 +7137,13 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("net");
/***/ }),
/***/ 7561:
/***/ ((module) => {
module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs");
/***/ }),
/***/ 7742:
/***/ ((module) => {
@@ -7305,7 +7312,7 @@ const File = _File
/***/ }),
/***/ 2777:
/***/ 7972:
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
@@ -7316,8 +7323,8 @@ __nccwpck_require__.d(__webpack_exports__, {
// UNUSED EXPORTS: Blob, blobFrom, blobFromSync, default, fileFrom, fileFromSync
;// CONCATENATED MODULE: external "node:fs"
const external_node_fs_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs");
// EXTERNAL MODULE: external "node:fs"
var external_node_fs_ = __nccwpck_require__(7561);
;// CONCATENATED MODULE: external "node:path"
const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:path");
// EXTERNAL MODULE: ./node_modules/node-domexception/index.js
@@ -7334,7 +7341,7 @@ var fetch_blob = __nccwpck_require__(1410);
const { stat } = external_node_fs_namespaceObject.promises
const { stat } = external_node_fs_.promises
/**
* @param {string} path filepath on the disk
@@ -13594,8 +13601,8 @@ class AbortError extends FetchBaseError {
}
}
// EXTERNAL MODULE: ./node_modules/fetch-blob/from.js + 2 modules
var from = __nccwpck_require__(2777);
// EXTERNAL MODULE: ./node_modules/fetch-blob/from.js + 1 modules
var from = __nccwpck_require__(7972);
;// CONCATENATED MODULE: ./node_modules/node-fetch/src/index.js
/**
* Index.js
@@ -14010,11 +14017,14 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
// EXTERNAL MODULE: ./node_modules/@lifeomic/attempt/dist/src/index.js
var src = __nccwpck_require__(6494);
// EXTERNAL MODULE: external "node:fs"
var external_node_fs_ = __nccwpck_require__(7561);
;// CONCATENATED MODULE: ./src/main.ts
const InputVariablesSchema = z.object({
speckleAutomateUrl: z.string().url().nonempty(),
speckleToken: z.string().nonempty(),
@@ -14027,9 +14037,11 @@ const parseInputs = () => {
core.setSecret(speckleTokenRaw);
let speckleFunctionInputSchema = null;
try {
const rawInputSchema = core.getInput('speckle_function_input_schema');
if (rawInputSchema)
const rawInputSchemaPath = core.getInput('speckle_function_input_schema_file_path');
if (rawInputSchemaPath) {
const rawInputSchema = (0,external_node_fs_.readFileSync)(rawInputSchemaPath, 'utf-8');
speckleFunctionInputSchema = JSON.parse(rawInputSchema);
}
}
catch (err) {
core.setFailed(`Parsing the function input schema failed with: ${err}`);
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+6 -2
View File
@@ -2,6 +2,7 @@ import * as core from '@actions/core'
import { z } from 'zod'
import fetch from 'node-fetch'
import { retry } from '@lifeomic/attempt'
import { readFileSync } from 'node:fs'
const InputVariablesSchema = z.object({
speckleAutomateUrl: z.string().url().nonempty(),
@@ -19,8 +20,11 @@ const parseInputs = (): InputVariables => {
let speckleFunctionInputSchema: Record<string, unknown> | null = null
try {
const rawInputSchema = core.getInput('speckle_function_input_schema')
if (rawInputSchema) speckleFunctionInputSchema = JSON.parse(rawInputSchema)
const rawInputSchemaPath = core.getInput('speckle_function_input_schema_file_path')
if (rawInputSchemaPath) {
const rawInputSchema = readFileSync(rawInputSchemaPath, 'utf-8')
speckleFunctionInputSchema = JSON.parse(rawInputSchema)
}
} catch (err) {
core.setFailed(`Parsing the function input schema failed with: ${err}`)
throw err