diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 915e97d..d5b83cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,4 +15,5 @@ jobs: registry-url: 'https://registry.npmjs.org' - run: npm ci - run: npm run build + - run: npm run lint - run: npm run test diff --git a/.tool-versions b/.tool-versions index e0d4ee0..01de519 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1,2 @@ -nodejs 24.13.1 \ No newline at end of file +nodejs 24.13.1 +npm 11.12.1 diff --git a/actions/gls-action/Dockerfile b/actions/gls-action/Dockerfile new file mode 100644 index 0000000..468ccf3 --- /dev/null +++ b/actions/gls-action/Dockerfile @@ -0,0 +1,18 @@ +FROM node:24-alpine + +WORKDIR /app + +COPY code0-tech-* ./ + +COPY package.json package-lock.json tsconfig.base.json turbo.json ./ + +COPY actions/gls-action ./actions/gls-action + +RUN npm ci + +WORKDIR /app/actions/gls-actions + +RUN npm run build + + +CMD ["npm", "run", "start", "-w", "@code0-tech/gls-action"] \ No newline at end of file diff --git a/actions/gls-action/docker-compose.yml b/actions/gls-action/docker-compose.yml deleted file mode 100644 index b13d850..0000000 --- a/actions/gls-action/docker-compose.yml +++ /dev/null @@ -1,11 +0,0 @@ -version: "3.9" - -services: - gls-action: - image: node:20 - working_dir: /app - volumes: - - .:/app - command: sh -c "npm install && npx tsx src/index.ts" - env_file: - - .env \ No newline at end of file diff --git a/actions/gls-action/package-lock.json b/actions/gls-action/package-lock.json index 6c5216c..cb3b065 100644 --- a/actions/gls-action/package-lock.json +++ b/actions/gls-action/package-lock.json @@ -6,7 +6,404 @@ "packages": { "": { "name": "@code0-tech/gls-action", - "version": "0.0.0" + "version": "0.0.0", + "dependencies": { + "@code0-tech/hercules": "^0.0.1" + } + }, + "node_modules/@code0-tech/hercules": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/@code0-tech/hercules/-/hercules-0.0.1.tgz", + "integrity": "sha512-1k0bix2v1PmOZuua8BGDbiHgDAXDOMECuBZ/O4Shsm4mzX7r0ntyhR+IZ6DcbOGGw7ddR8FsoNQtJMhDiawxXQ==", + "license": "ISC", + "dependencies": { + "@code0-tech/tucana": "0.0.64", + "@grpc/grpc-js": "^1.14.3", + "@protobuf-ts/grpc-backend": "^2.11.1", + "@protobuf-ts/grpc-transport": "^2.11.1", + "@protobuf-ts/runtime": "^2.11.1", + "@protobuf-ts/runtime-rpc": "^2.11.1" + } + }, + "node_modules/@code0-tech/tucana": { + "version": "0.0.64", + "resolved": "https://registry.npmjs.org/@code0-tech/tucana/-/tucana-0.0.64.tgz", + "integrity": "sha512-HtFIRriZE/yaOwHHMGTB4dwO41L8kFkQCsdQX5MXUrtE90uZDjYwdLPZhxJI/WlgcmM6Xs8LBcazcbAoE7jDTw==", + "license": "Apache-2.0" + }, + "node_modules/@grpc/grpc-js": { + "version": "1.14.3", + "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-1.14.3.tgz", + "integrity": "sha512-Iq8QQQ/7X3Sac15oB6p0FmUg/klxQvXLeileoqrTRGJYLV+/9tubbr9ipz0GKHjmXVsgFPo/+W+2cA8eNcR+XA==", + "license": "Apache-2.0", + "dependencies": { + "@grpc/proto-loader": "^0.8.0", + "@js-sdsl/ordered-map": "^4.4.2" + }, + "engines": { + "node": ">=12.10.0" + } + }, + "node_modules/@grpc/proto-loader": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.8.0.tgz", + "integrity": "sha512-rc1hOQtjIWGxcxpb9aHAfLpIctjEnsDehj0DAiVfBlmT84uvR0uUtN2hEi/ecvWVjXUGf5qPF4qEgiLOx1YIMQ==", + "license": "Apache-2.0", + "dependencies": { + "lodash.camelcase": "^4.3.0", + "long": "^5.0.0", + "protobufjs": "^7.5.3", + "yargs": "^17.7.2" + }, + "bin": { + "proto-loader-gen-types": "build/bin/proto-loader-gen-types.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/@js-sdsl/ordered-map": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/@js-sdsl/ordered-map/-/ordered-map-4.4.2.tgz", + "integrity": "sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/js-sdsl" + } + }, + "node_modules/@protobuf-ts/grpc-backend": { + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@protobuf-ts/grpc-backend/-/grpc-backend-2.11.1.tgz", + "integrity": "sha512-llAkJ03SlR/+p70YBTMOAQqdkXWghsTWwlPuGXC+Hj99hDQq6fa2CoVePPqbcn7A7/aLBcPG/9Ag3yqlltldxw==", + "license": "Apache-2.0", + "dependencies": { + "@protobuf-ts/runtime": "^2.11.1", + "@protobuf-ts/runtime-rpc": "^2.11.1" + }, + "peerDependencies": { + "@grpc/grpc-js": "^1.8.22" + } + }, + "node_modules/@protobuf-ts/grpc-transport": { + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@protobuf-ts/grpc-transport/-/grpc-transport-2.11.1.tgz", + "integrity": "sha512-l6wrcFffY+tuNnuyrNCkRM8hDIsAZVLA8Mn7PKdVyYxITosYh60qW663p9kL6TWXYuDCL3oxH8ih3vLKTDyhtg==", + "license": "Apache-2.0", + "dependencies": { + "@protobuf-ts/runtime": "^2.11.1", + "@protobuf-ts/runtime-rpc": "^2.11.1" + }, + "peerDependencies": { + "@grpc/grpc-js": "^1.6.0" + } + }, + "node_modules/@protobuf-ts/runtime": { + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@protobuf-ts/runtime/-/runtime-2.11.1.tgz", + "integrity": "sha512-KuDaT1IfHkugM2pyz+FwiY80ejWrkH1pAtOBOZFuR6SXEFTsnb/jiQWQ1rCIrcKx2BtyxnxW6BWwsVSA/Ie+WQ==", + "license": "(Apache-2.0 AND BSD-3-Clause)" + }, + "node_modules/@protobuf-ts/runtime-rpc": { + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/@protobuf-ts/runtime-rpc/-/runtime-rpc-2.11.1.tgz", + "integrity": "sha512-4CqqUmNA+/uMz00+d3CYKgElXO9VrEbucjnBFEjqI4GuDrEQ32MaI3q+9qPBvIGOlL4PmHXrzM32vBPWRhQKWQ==", + "license": "Apache-2.0", + "dependencies": { + "@protobuf-ts/runtime": "^2.11.1" + } + }, + "node_modules/@protobufjs/aspromise": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", + "integrity": "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/base64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", + "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/codegen": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", + "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/eventemitter": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", + "integrity": "sha512-j9ednRT81vYJ9OfVuXG6ERSTdEL1xVsNgqpkxMsbIabzSo3goCjDIveeGv5d03om39ML71RdmrGNjG5SReBP/Q==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/fetch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", + "integrity": "sha512-lljVXpqXebpsijW71PZaCYeIcE5on1w5DlQy5WH6GLbFryLUrBD4932W/E2BSpfRJWseIL4v/KPgBFxDOIdKpQ==", + "license": "BSD-3-Clause", + "dependencies": { + "@protobufjs/aspromise": "^1.1.1", + "@protobufjs/inquire": "^1.1.0" + } + }, + "node_modules/@protobufjs/float": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", + "integrity": "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/inquire": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", + "integrity": "sha512-kdSefcPdruJiFMVSbn801t4vFK7KB/5gd2fYvrxhuJYg8ILrmn9SKSX2tZdV6V+ksulWqS7aXjBcRXl3wHoD9Q==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/path": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", + "integrity": "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/pool": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", + "integrity": "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw==", + "license": "BSD-3-Clause" + }, + "node_modules/@protobufjs/utf8": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", + "integrity": "sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==", + "license": "BSD-3-Clause" + }, + "node_modules/@types/node": { + "version": "25.5.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-25.5.0.tgz", + "integrity": "sha512-jp2P3tQMSxWugkCUKLRPVUpGaL5MVFwF8RDuSRztfwgN1wmqJeMSbKlnEtQqU8UrhTmzEmZdu2I6v2dpp7XIxw==", + "license": "MIT", + "dependencies": { + "undici-types": "~7.18.0" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "license": "MIT" + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "license": "MIT" + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/lodash.camelcase": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", + "integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==", + "license": "MIT" + }, + "node_modules/long": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz", + "integrity": "sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==", + "license": "Apache-2.0" + }, + "node_modules/protobufjs": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.5.4.tgz", + "integrity": "sha512-CvexbZtbov6jW2eXAvLukXjXUW1TzFaivC46BpWc/3BpcCysb5Vffu+B3XHMm8lVEuy2Mm4XGex8hBSg1yapPg==", + "hasInstallScript": true, + "license": "BSD-3-Clause", + "dependencies": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/node": ">=13.7.0", + "long": "^5.0.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/undici-types": { + "version": "7.18.2", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz", + "integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==", + "license": "MIT" + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "license": "MIT", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "license": "ISC", + "engines": { + "node": ">=12" + } } } } diff --git a/actions/gls-action/package.json b/actions/gls-action/package.json index 6a3abc2..1e8868d 100644 --- a/actions/gls-action/package.json +++ b/actions/gls-action/package.json @@ -6,7 +6,9 @@ "main": "./dist/index.js", "types": "./dist/index.d.ts", "scripts": { - "build": "tsc --build", - "lint": "eslint ." + "build": "vite build", + "lint": "eslint .", + "test": "vitest run", + "start": "node dist/main.js" } } diff --git a/actions/gls-action/src/config/authUrl.ts b/actions/gls-action/src/config/authUrl.ts new file mode 100644 index 0000000..9cef67e --- /dev/null +++ b/actions/gls-action/src/config/authUrl.ts @@ -0,0 +1,24 @@ +import {ActionSdk} from "@code0-tech/hercules"; + +export default (sdk: ActionSdk) => { + return sdk.registerConfigDefinitions( + { + identifier: "auth_url", + type: "TEXT", + defaultValue: "https://api.gls-group.net/oauth2/v2/token", + name: [ + { + code: "en-US", + content: "The Auth API url" + } + ], + description: [ + { + code: "en-US", + content: "The url of the Auth api ending in /token." + } + ], + linkedDataTypes: ["STRING"], + }, + ) +} diff --git a/actions/gls-action/src/config/clientId.ts b/actions/gls-action/src/config/clientId.ts new file mode 100644 index 0000000..15a5729 --- /dev/null +++ b/actions/gls-action/src/config/clientId.ts @@ -0,0 +1,23 @@ +import {ActionSdk} from "@code0-tech/hercules"; + +export default (sdk: ActionSdk) => { + return sdk.registerConfigDefinitions( + { + identifier: "client_id", + type: "TEXT", + name: [ + { + code: "en-US", + content: "Client ID" + } + ], + description: [ + { + code: "en-US", + content: "The client id to authenticate with the GLS API" + } + ], + linkedDataTypes: ["TEXT"], + }, + ) +} diff --git a/actions/gls-action/src/config/clientSecret.ts b/actions/gls-action/src/config/clientSecret.ts new file mode 100644 index 0000000..e6a0bcd --- /dev/null +++ b/actions/gls-action/src/config/clientSecret.ts @@ -0,0 +1,23 @@ +import {ActionSdk} from "@code0-tech/hercules"; + +export default (sdk: ActionSdk) => { + return sdk.registerConfigDefinitions( + { + identifier: "client_secret", + type: "TEXT", + name: [ + { + code: "en-US", + content: "Client secret" + } + ], + description: [ + { + code: "en-US", + content: "The client secret to authenticate with the GLS API" + } + ], + linkedDataTypes: ["TEXT"], + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/config/contactId.ts b/actions/gls-action/src/config/contactId.ts new file mode 100644 index 0000000..c2368df --- /dev/null +++ b/actions/gls-action/src/config/contactId.ts @@ -0,0 +1,24 @@ +import {ActionSdk} from "@code0-tech/hercules"; + +export default (sdk: ActionSdk) => { + return sdk.registerConfigDefinitions( + { + identifier: "contact_id", + type: "TEXT", + name: [ + { + code: "en-US", + content: "Contact ID" + } + ], + description: [ + { + code: "en-US", + content: "The contact id identifying the GLS account to use for the API requests. This contact must be linked to a GLS contract with API access." + } + ], + defaultValue: "", + linkedDataTypes: ["TEXT"], + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/config/defaultShipper.ts b/actions/gls-action/src/config/defaultShipper.ts new file mode 100644 index 0000000..65877ed --- /dev/null +++ b/actions/gls-action/src/config/defaultShipper.ts @@ -0,0 +1,23 @@ +import {ActionSdk} from "@code0-tech/hercules"; + +export default (sdk: ActionSdk) => { + return sdk.registerConfigDefinitions( + { + identifier: "default_shipper", + type: "GLS_SHIPPER", + name: [ + { + code: "en-US", + content: "Shipper" + } + ], + description: [ + { + code: "en-US", + content: "The shipper information to use for the shipments. This will be used if the shipper information is not provided in the shipment data." + } + ], + linkedDataTypes: ["GLS_SHIPPER"] + } + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/config/shipItApiUrl.ts b/actions/gls-action/src/config/shipItApiUrl.ts new file mode 100644 index 0000000..6e325c6 --- /dev/null +++ b/actions/gls-action/src/config/shipItApiUrl.ts @@ -0,0 +1,24 @@ +import {ActionSdk} from "@code0-tech/hercules"; + +export default (sdk: ActionSdk) => { + return sdk.registerConfigDefinitions( + { + identifier: "ship_it_api_url", + type: "TEXT", + defaultValue: " https://api.gls-group.net/shipit-farm/v1/backend/rs", + name: [ + { + code: "en-US", + content: "The ShipIt API url" + } + ], + description: [ + { + code: "en-US", + content: "The url of the GLS ShipIt API." + } + ], + linkedDataTypes: ["TEXT"], + }, + ) +} diff --git a/actions/gls-action/src/functions/cancelShipment.ts b/actions/gls-action/src/functions/cancelShipment.ts new file mode 100644 index 0000000..c08f9e9 --- /dev/null +++ b/actions/gls-action/src/functions/cancelShipment.ts @@ -0,0 +1,57 @@ +import {ActionSdk, HerculesFunctionContext, RuntimeErrorException} from "@code0-tech/hercules"; +import {cancelShipment} from "../helpers"; +import {CancelShipmentRequestData, CancelShipmentResponseData} from "../types/glsCancelShipment"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "cancelShipment", + name: [ + { + code: "en-US", + content: "Cancel shipment", + } + ], + description: [ + { + code: "en-US", + content: "Cancels a GLS shipment.", + } + ], + signature: "(data: GLS_CANCEL_SHIPMENT_REQUEST_DATA): GLS_CANCEL_SHIPMENT_RESPONSE_DATA", + parameters: [ + { + runtimeName: "data", + name: [ + { + code: "en-US", + content: "Data", + } + ], + description: [ + { + code: "en-US", + content: "The cancel shipment request data.", + } + ] + } + ], + linkedDataTypes: [ + "GLS_VALIDATE_SHIPMENT_REQUEST_DATA", + "GLS_VALIDATE_SHIPMENT_RESPONSE_DATA", + ], + }, + handler: async (data: CancelShipmentRequestData, context: HerculesFunctionContext): Promise => { + try { + return await cancelShipment(data, context) + } catch (error) { + if (typeof error === "string") { + throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", error) + } + throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", "An error occurred while creating the shipment.") + } + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/getAllowedServices.ts b/actions/gls-action/src/functions/getAllowedServices.ts new file mode 100644 index 0000000..dad11a3 --- /dev/null +++ b/actions/gls-action/src/functions/getAllowedServices.ts @@ -0,0 +1,69 @@ +import {ActionSdk, HerculesFunctionContext, RuntimeErrorException} from "@code0-tech/hercules"; +import {getAuthToken} from "../helpers"; +import axios from "axios"; +import { + AllowedServicesRequestData, + AllowedServicesResponseData, + AllowedServicesResponseDataSchema +} from "../types/glsAllowedServices"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "getAllowedServices", + name: [ + { + code: "en-US", + content: "Get allowed services", + } + ], + description: [ + { + code: "en-US", + content: "Returns the allowed GLS services for a given set of parameters.", + } + ], + signature: "(data: GLS_ALLOWED_SERVICES_REQUEST_DATA): GLS_ALLOWED_SERVICES_RESPONSE_DATA", + parameters: [ + { + runtimeName: "data", + name: [ + { + code: "en-US", + content: "Data", + } + ], + description: [ + { + code: "en-US", + content: "The allowed services request data.", + } + ] + } + ], + linkedDataTypes: [ + "GLS_ALLOWED_SERVICES_REQUEST_DATA", + "GLS_ALLOWED_SERVICES_RESPONSE_DATA", + ], + }, + handler: async (data: AllowedServicesRequestData, context: HerculesFunctionContext): Promise => { + try { + const url = context.matchedConfig.findConfig("ship_it_api_url") as string; + const result = await axios.post(`${url}/rs/shipments/allowedservices`, data, { + headers: { + Authorization: `Bearer ${await getAuthToken(context)}`, + "Content-Type": "application/glsVersion1+json" + } + }) + return AllowedServicesResponseDataSchema.parse(result.data) + } catch (error) { + if (typeof error === "string") { + throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", error) + } + throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", "An error occurred while creating the shipment.") + } + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/getEndOfDayReport.ts b/actions/gls-action/src/functions/getEndOfDayReport.ts new file mode 100644 index 0000000..150fca0 --- /dev/null +++ b/actions/gls-action/src/functions/getEndOfDayReport.ts @@ -0,0 +1,64 @@ +import {ActionSdk, HerculesFunctionContext, RuntimeErrorException} from "@code0-tech/hercules"; +import {getAuthToken} from "../helpers"; +import axios from "axios"; +import {EndOfDayRequestData, EndOfDayResponseData, EndOfDayResponseDataSchema} from "../types/glsEndOfDayRequest"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "getEndOfDayReport", + name: [ + { + code: "en-US", + content: "Get end of day report", + } + ], + description: [ + { + code: "en-US", + content: "Returns the GLS end of day report.", + } + ], + signature: "(data: GLS_END_OF_DAY_REQUEST_DATA): GLS_END_OF_DAY_RESPONSE_DATA", + parameters: [ + { + runtimeName: "data", + name: [ + { + code: "en-US", + content: "Data", + } + ], + description: [ + { + code: "en-US", + content: "The end of day report request data.", + } + ] + } + ], + linkedDataTypes: [ + "GLS_END_OF_DAY_REQUEST_DATA", + "GLS_END_OF_DAY_RESPONSE_DATA", + ], + }, + handler: async (data: EndOfDayRequestData, context: HerculesFunctionContext): Promise => { + const url = context.matchedConfig.findConfig("ship_it_api_url") as string; + + try { + const result = await axios.post(`${url}/rs/shipments/endofday?date=${data.date}`, {}, { + headers: { + Authorization: `Bearer ${await getAuthToken(context)}`, + "Content-Type": "application/glsVersion1+json" + } + }) + return EndOfDayResponseDataSchema.parse(result.data) + } catch (error: any) { + throw new RuntimeErrorException("GET_END_OF_DAY_INFO_FAILED", error.toString()) + } + + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/reprintParcel.ts b/actions/gls-action/src/functions/reprintParcel.ts new file mode 100644 index 0000000..2270586 --- /dev/null +++ b/actions/gls-action/src/functions/reprintParcel.ts @@ -0,0 +1,68 @@ +import {ActionSdk, HerculesFunctionContext, RuntimeErrorException} from "@code0-tech/hercules"; +import {getAuthToken} from "../helpers"; +import axios from "axios"; +import { + ReprintParcelRequestData, + ReprintParcelResponseData, + ReprintParcelResponseDataSchema +} from "../types/glsReprintParcel"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "reprintParcel", + name: [ + { + code: "en-US", + content: "Reprint parcel", + } + ], + description: [ + { + code: "en-US", + content: "Reprints the labels for a GLS parcel.", + } + ], + signature: "(data: GLS_REPRINT_PARCEL_REQUEST_DATA): GLS_REPRINT_PARCEL_RESPONSE_DATA", + parameters: [ + { + runtimeName: "data", + name: [ + { + code: "en-US", + content: "Data", + } + ], + description: [ + { + code: "en-US", + content: "The reprint parcel request data.", + } + ] + } + ], + linkedDataTypes: [ + "GLS_REPRINT_PARCEL_REQUEST_DATA", + "GLS_REPRINT_PARCEL_RESPONSE_DATA", + ], + }, + handler: async (data: ReprintParcelRequestData, context: HerculesFunctionContext): Promise => { + const url = context.matchedConfig.findConfig("ship_it_api_url") as string; + + try { + const result = await axios.post(`${url}/rs/shipments/reprintparcel`, data, { + headers: { + Authorization: `Bearer ${await getAuthToken(context)}`, + "Content-Type": "application/glsVersion1+json" + } + }) + return ReprintParcelResponseDataSchema.parse(result.data) + } catch (error: any) { + console.log(error) + throw new RuntimeErrorException("REPRINT_PARCEL_FAILED", error.toString()) + } + } + } + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/services/createAddresseeOnlyShipment.ts b/actions/gls-action/src/functions/services/createAddresseeOnlyShipment.ts new file mode 100644 index 0000000..866a3b3 --- /dev/null +++ b/actions/gls-action/src/functions/services/createAddresseeOnlyShipment.ts @@ -0,0 +1,47 @@ +import { + DEFAULT_DATA_TYPES_FOR_SERVICES, + DEFAULT_PARAMETERS_FOR_SERVICES, + DEFAULT_SIGNATURE_FOR_SERVICES, postShipmentHelper +} from "../../helpers"; +import {ActionSdk, HerculesFunctionContext} from "@code0-tech/hercules"; +import {ShipmentWithoutServices} from "../../types/glsShipment"; +import {CreateParcelsResponse} from "../../types/glsCreateParcelsResponse"; +import {PrintingOptions} from "../../types/glsPrintingOptions"; +import {CustomContent} from "../../types/glsCustomContent"; +import {ReturnOptions} from "../../types/glsReturnOptions"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createAddresseeOnlyShipment", + name: [ + { + code: "en-US", + content: "Create addressee only shipment", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS addressee only shipment.", + } + ], + signature: `(${DEFAULT_SIGNATURE_FOR_SERVICES}): GLS_CREATE_PARCELS_RESPONSE`, + parameters: [ + ...DEFAULT_PARAMETERS_FOR_SERVICES, + ], + linkedDataTypes: [ + ...DEFAULT_DATA_TYPES_FOR_SERVICES, + ] + }, + handler: async (context: HerculesFunctionContext, + shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, + ): Promise => { + return postShipmentHelper(context, [{ + AddresseeOnlyService: {} + }], shipment, printingOptions, customContent, returnOptions) + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/services/createDeliveryAtWorkShipment.ts b/actions/gls-action/src/functions/services/createDeliveryAtWorkShipment.ts new file mode 100644 index 0000000..2e48ea6 --- /dev/null +++ b/actions/gls-action/src/functions/services/createDeliveryAtWorkShipment.ts @@ -0,0 +1,145 @@ +import { + DEFAULT_DATA_TYPES_FOR_SERVICES, + DEFAULT_PARAMETERS_FOR_SERVICES, + DEFAULT_SIGNATURE_FOR_SERVICES, postShipmentHelper +} from "../../helpers"; +import {ActionSdk, HerculesFunctionContext} from "@code0-tech/hercules"; +import {ShipmentWithoutServices} from "../../types/glsShipment"; +import {PrintingOptions} from "../../types/glsPrintingOptions"; +import {CustomContent} from "../../types/glsCustomContent"; +import {ReturnOptions} from "../../types/glsReturnOptions"; +import {CreateParcelsResponse} from "../../types/glsCreateParcelsResponse"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createDeliveryAtWorkShipment", + name: [ + { + code: "en-US", + content: "Create delivery at work shipment", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS delivery at work shipment.", + } + ], + signature: `(recipientName: string, building: string, floor: number, ${DEFAULT_SIGNATURE_FOR_SERVICES}, alternateRecipientName?: string, room?: number, phonenumber?: string): GLS_CREATE_PARCELS_RESPONSE`, + parameters: [ + { + runtimeName: "recipientName", + name: [ + { + code: "en-US", + content: "Recipient name", + } + ], + description: [ + { + code: "en-US", + content: "The recipient name for the delivery at work shipment.", + } + ] + }, + { + runtimeName: "building", + name: [ + { + code: "en-US", + content: "Building", + } + ], + description: [ + { + code: "en-US", + content: "The building of the delivery at work shipment.", + } + ] + }, + { + runtimeName: "floor", + name: [ + { + code: "en-US", + content: "Floor", + } + ], + description: [ + { + code: "en-US", + content: "The floor of the delivery at work shipment.", + } + ] + }, + ...DEFAULT_PARAMETERS_FOR_SERVICES, + { + runtimeName: "alternateRecipientName", + name: [ + { + code: "en-US", + content: "Alternate recipient name", + } + ], + description: [ + { + code: "en-US", + content: "The alternate recipient name for the delivery at work shipment.", + } + ] + }, + { + runtimeName: "room", + name: [ + { + code: "en-US", + content: "Room", + } + ], + description: [ + { + code: "en-US", + content: "The room of the delivery at work shipment.", + } + ] + }, + { + runtimeName: "phonenumber", + name: [ + { + code: "en-US", + content: "Phone number", + } + ], + description: [ + { + code: "en-US", + content: "The phone number for the delivery at work shipment.", + } + ] + } + ], + linkedDataTypes: [ + ...DEFAULT_DATA_TYPES_FOR_SERVICES, + ] + }, + handler: async (context: HerculesFunctionContext, + recipientName: string, building: string, floor: number, + shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, + alternateRecipientName?: string, room?: number, phonenumber?: string): Promise => { + return postShipmentHelper(context, [{ + DeliveryAtWork: { + RecipientName: recipientName, + Building: building, + Floor: floor, + AlternateRecipientName: alternateRecipientName, + Room: room, + Phonenumber: phonenumber, + } + }], shipment, printingOptions, customContent, returnOptions) + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/services/createDeliveryNextWorkingDayShipment.ts b/actions/gls-action/src/functions/services/createDeliveryNextWorkingDayShipment.ts new file mode 100644 index 0000000..d3edcc9 --- /dev/null +++ b/actions/gls-action/src/functions/services/createDeliveryNextWorkingDayShipment.ts @@ -0,0 +1,50 @@ +import { + DEFAULT_DATA_TYPES_FOR_SERVICES, + DEFAULT_PARAMETERS_FOR_SERVICES, + DEFAULT_SIGNATURE_FOR_SERVICES, postShipmentHelper +} from "../../helpers"; +import {ActionSdk, HerculesFunctionContext, RuntimeErrorException} from "@code0-tech/hercules"; +import {ShipmentWithoutServices} from "../../types/glsShipment"; +import {PrintingOptions} from "../../types/glsPrintingOptions"; +import {CustomContent} from "../../types/glsCustomContent"; +import {ReturnOptions} from "../../types/glsReturnOptions"; +import {CreateParcelsResponse} from "../../types/glsCreateParcelsResponse"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createDeliveryNextWorkingDayShipment", + name: [ + { + code: "en-US", + content: "Create delivery next working day shipment", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS delivery next working day shipment.", + } + ], + signature: `(${DEFAULT_SIGNATURE_FOR_SERVICES}): GLS_CREATE_PARCELS_RESPONSE`, + parameters: [ + ...DEFAULT_PARAMETERS_FOR_SERVICES, + ], + linkedDataTypes: [ + ...DEFAULT_DATA_TYPES_FOR_SERVICES, + ] + }, + handler: async (context: HerculesFunctionContext, + shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, + ): Promise => { + if (shipment.Product != "EXPRESS") { + throw new RuntimeErrorException("INVALID_PRODUCT", "The product for Delivery Next Working Day service must be EXPRESS.") + } + return postShipmentHelper(context, [{ + EOB: {} + }], shipment, printingOptions, customContent, returnOptions) + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/services/createDeliverySaturdayShipment.ts b/actions/gls-action/src/functions/services/createDeliverySaturdayShipment.ts new file mode 100644 index 0000000..59ec597 --- /dev/null +++ b/actions/gls-action/src/functions/services/createDeliverySaturdayShipment.ts @@ -0,0 +1,51 @@ +import {ActionSdk, HerculesFunctionContext, RuntimeErrorException} from "@code0-tech/hercules"; +import { + DEFAULT_DATA_TYPES_FOR_SERVICES, + DEFAULT_PARAMETERS_FOR_SERVICES, + DEFAULT_SIGNATURE_FOR_SERVICES, postShipmentHelper +} from "../../helpers"; +import {ShipmentWithoutServices} from "../../types/glsShipment"; +import {PrintingOptions} from "../../types/glsPrintingOptions"; +import {CustomContent} from "../../types/glsCustomContent"; +import {ReturnOptions} from "../../types/glsReturnOptions"; +import {CreateParcelsResponse} from "../../types/glsCreateParcelsResponse"; + + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createDeliverySaturdayShipment", + name: [ + { + code: "en-US", + content: "Create delivery Saturday shipment", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS delivery Saturday shipment.", + } + ], + signature: `(${DEFAULT_SIGNATURE_FOR_SERVICES}): GLS_CREATE_PARCELS_RESPONSE`, + parameters: [ + ...DEFAULT_PARAMETERS_FOR_SERVICES, + ], + linkedDataTypes: [ + ...DEFAULT_DATA_TYPES_FOR_SERVICES, + ] + }, + handler: async (context: HerculesFunctionContext, + shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, + ): Promise => { + if (shipment.Product != "EXPRESS") { + throw new RuntimeErrorException("INVALID_PRODUCT", "The product for Delivery Friday service must be EXPRESS.") + } + return postShipmentHelper(context, [{ + SaturdayService: {} + }], shipment, printingOptions, customContent, returnOptions) + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/services/createDepositShipment.ts b/actions/gls-action/src/functions/services/createDepositShipment.ts new file mode 100644 index 0000000..2964d0d --- /dev/null +++ b/actions/gls-action/src/functions/services/createDepositShipment.ts @@ -0,0 +1,66 @@ +import {ActionSdk} from "@code0-tech/hercules"; +import { + DEFAULT_DATA_TYPES_FOR_SERVICES, + DEFAULT_PARAMETERS_FOR_SERVICES, + DEFAULT_SIGNATURE_FOR_SERVICES, postShipmentHelper +} from "../../helpers"; +import {HerculesFunctionContext} from "@code0-tech/hercules"; +import {ShipmentWithoutServices} from "../../types/glsShipment"; +import {PrintingOptions} from "../../types/glsPrintingOptions"; +import {CustomContent} from "../../types/glsCustomContent"; +import {ReturnOptions} from "../../types/glsReturnOptions"; +import {CreateParcelsResponse} from "../../types/glsCreateParcelsResponse"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createDepositShipment", + name: [ + { + code: "en-US", + content: "Create deposit shipment", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS deposit shipment.", + } + ], + signature: `(placeOfDeposit: string, ${DEFAULT_SIGNATURE_FOR_SERVICES}): GLS_CREATE_PARCELS_RESPONSE`, + parameters: [ + { + runtimeName: "placeOfDeposit", + name: [ + { + code: "en-US", + content: "Place of deposit", + } + ], + description: [ + { + code: "en-US", + content: "The place of deposit for the delivery.", + } + ] + }, + ...DEFAULT_PARAMETERS_FOR_SERVICES, + ], + linkedDataTypes: [ + ...DEFAULT_DATA_TYPES_FOR_SERVICES, + ] + }, + handler: + async (context: HerculesFunctionContext, + placeOfDeposit: string, + shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions): Promise => { + return postShipmentHelper(context, [{ + Deposit: { + PlaceOfDeposit: placeOfDeposit + } + }], shipment, printingOptions, customContent, returnOptions) + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/services/createExchangeShipment.ts b/actions/gls-action/src/functions/services/createExchangeShipment.ts new file mode 100644 index 0000000..7b99638 --- /dev/null +++ b/actions/gls-action/src/functions/services/createExchangeShipment.ts @@ -0,0 +1,83 @@ +import { + DEFAULT_DATA_TYPES_FOR_SERVICES, + DEFAULT_PARAMETERS_FOR_SERVICES, + DEFAULT_SIGNATURE_FOR_SERVICES, postShipmentHelper +} from "../../helpers"; +import {ActionSdk, HerculesFunctionContext} from "@code0-tech/hercules"; +import { PrintingOptions } from "../../types/glsPrintingOptions"; +import {AddressSchema} from "../../types/glsAddress"; +import {ShipmentWithoutServices} from "../../types/glsShipment"; +import {CustomContent} from "../../types/glsCustomContent"; +import {ReturnOptions} from "../../types/glsReturnOptions"; +import {CreateParcelsResponse} from "../../types/glsCreateParcelsResponse"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createExchangeShipment", + name: [ + { + code: "en-US", + content: "Create exchange shipment", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS exchange shipment.", + } + ], + signature: `(address: GLS_ADDRESS, ${DEFAULT_SIGNATURE_FOR_SERVICES}, expectedWeight?: number): GLS_CREATE_PARCELS_RESPONSE`, + parameters: [ + { + runtimeName: "address", + name: [ + { + code: "en-US", + content: "Address", + } + ], + description: [ + { + code: "en-US", + content: "The address of the exchange shipment.", + } + ] + }, + ...DEFAULT_PARAMETERS_FOR_SERVICES, + { + runtimeName: "expectedWeight", + name: [ + { + code: "en-US", + content: "Expected weight", + } + ], + description: [ + { + code: "en-US", + content: "The expected weight for the exchange shipment.", + } + ] + } + ], + linkedDataTypes: [ + ...DEFAULT_DATA_TYPES_FOR_SERVICES, + "GLS_ADDRESS" + ] + }, + handler: async (context: HerculesFunctionContext, + address: AddressSchema, + shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, + expectedWeight?: number): Promise => { + return postShipmentHelper(context, [{ + Exchange: { + Address: address, + ExpectedWeight: expectedWeight + } + }], shipment, printingOptions, customContent, returnOptions) + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/services/createFlexDeliveryShipment.ts b/actions/gls-action/src/functions/services/createFlexDeliveryShipment.ts new file mode 100644 index 0000000..99f5c29 --- /dev/null +++ b/actions/gls-action/src/functions/services/createFlexDeliveryShipment.ts @@ -0,0 +1,47 @@ +import { + DEFAULT_DATA_TYPES_FOR_SERVICES, + DEFAULT_PARAMETERS_FOR_SERVICES, + DEFAULT_SIGNATURE_FOR_SERVICES, postShipmentHelper +} from "../../helpers"; +import {ActionSdk, HerculesFunctionContext} from "@code0-tech/hercules"; +import {ShipmentWithoutServices} from "../../types/glsShipment"; +import {CreateParcelsResponse} from "../../types/glsCreateParcelsResponse"; +import {ReturnOptions} from "../../types/glsReturnOptions"; +import {CustomContent} from "../../types/glsCustomContent"; +import {PrintingOptions} from "../../types/glsPrintingOptions"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createFlexDeliveryShipment", + name: [ + { + code: "en-US", + content: "Create flex delivery shipment", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS flex delivery shipment.", + } + ], + signature: `(${DEFAULT_SIGNATURE_FOR_SERVICES}): GLS_CREATE_PARCELS_RESPONSE`, + parameters: [ + ...DEFAULT_PARAMETERS_FOR_SERVICES, + ], + linkedDataTypes: [ + ...DEFAULT_DATA_TYPES_FOR_SERVICES, + ] + }, + handler: async (context: HerculesFunctionContext, + shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, + ): Promise => { + return postShipmentHelper(context, [{ + FlexDeliveryService: {} + }], shipment, printingOptions, customContent, returnOptions) + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/services/createGuaranteed24Shipment.ts b/actions/gls-action/src/functions/services/createGuaranteed24Shipment.ts new file mode 100644 index 0000000..880bad9 --- /dev/null +++ b/actions/gls-action/src/functions/services/createGuaranteed24Shipment.ts @@ -0,0 +1,47 @@ +import { + DEFAULT_DATA_TYPES_FOR_SERVICES, + DEFAULT_PARAMETERS_FOR_SERVICES, + DEFAULT_SIGNATURE_FOR_SERVICES, postShipmentHelper +} from "../../helpers"; +import {ActionSdk, HerculesFunctionContext} from "@code0-tech/hercules"; +import {ShipmentWithoutServices} from "../../types/glsShipment"; +import {PrintingOptions} from "../../types/glsPrintingOptions"; +import {CustomContent} from "../../types/glsCustomContent"; +import {ReturnOptions} from "../../types/glsReturnOptions"; +import {CreateParcelsResponse} from "../../types/glsCreateParcelsResponse"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createGuaranteed24Shipment", + name: [ + { + code: "en-US", + content: "Create guaranteed 24 shipment", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS guaranteed 24 shipment.", + } + ], + signature: `(${DEFAULT_SIGNATURE_FOR_SERVICES}): GLS_CREATE_PARCELS_RESPONSE`, + parameters: [ + ...DEFAULT_PARAMETERS_FOR_SERVICES, + ], + linkedDataTypes: [ + ...DEFAULT_DATA_TYPES_FOR_SERVICES, + ] + }, + handler: async (context: HerculesFunctionContext, + shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, + ): Promise => { + return postShipmentHelper(context, [{ + Guaranteed24Service: {} + }], shipment, printingOptions, customContent, returnOptions) + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/services/createIdentPinShipment.ts b/actions/gls-action/src/functions/services/createIdentPinShipment.ts new file mode 100644 index 0000000..7f0a031 --- /dev/null +++ b/actions/gls-action/src/functions/services/createIdentPinShipment.ts @@ -0,0 +1,83 @@ +import { + DEFAULT_DATA_TYPES_FOR_SERVICES, + DEFAULT_PARAMETERS_FOR_SERVICES, + DEFAULT_SIGNATURE_FOR_SERVICES, postShipmentHelper +} from "../../helpers"; +import {ActionSdk, HerculesFunctionContext} from "@code0-tech/hercules"; +import {ShipmentWithoutServices} from "../../types/glsShipment"; +import {PrintingOptions} from "../../types/glsPrintingOptions"; +import {CustomContent} from "../../types/glsCustomContent"; +import {ReturnOptions} from "../../types/glsReturnOptions"; +import {CreateParcelsResponse} from "../../types/glsCreateParcelsResponse"; + + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createIdentPinShipment", + name: [ + { + code: "en-US", + content: "Create ident pin shipment", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS ident pin shipment.", + } + ], + signature: `(pin: string, ${DEFAULT_SIGNATURE_FOR_SERVICES}, birthDate: string): GLS_CREATE_PARCELS_RESPONSE`, + parameters: [ + { + runtimeName: "pin", + name: [ + { + code: "en-US", + content: "Pin", + } + ], + description: [ + { + code: "en-US", + content: "The pin for the ident pin shipment identification.", + } + ] + }, + ...DEFAULT_PARAMETERS_FOR_SERVICES, + { + runtimeName: "birthDate", + name: [ + { + code: "en-US", + content: "Birth date", + } + ], + description: [ + { + code: "en-US", + content: "The birth date for the ident pin shipment identification.", + } + ] + } + ], + linkedDataTypes: [ + ...DEFAULT_DATA_TYPES_FOR_SERVICES, + ] + }, + handler: async (context: HerculesFunctionContext, + pin: string, + shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, + birthDate?: string + ): Promise => { + return postShipmentHelper(context, [{ + IdentPin: { + PIN: pin, + Birthdate: birthDate, + } + }], shipment, printingOptions, customContent, returnOptions) + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/services/createIdentShipment.ts b/actions/gls-action/src/functions/services/createIdentShipment.ts new file mode 100644 index 0000000..a0ea990 --- /dev/null +++ b/actions/gls-action/src/functions/services/createIdentShipment.ts @@ -0,0 +1,115 @@ +import { + DEFAULT_DATA_TYPES_FOR_SERVICES, + DEFAULT_PARAMETERS_FOR_SERVICES, + DEFAULT_SIGNATURE_FOR_SERVICES, postShipmentHelper +} from "../../helpers"; +import {ActionSdk, HerculesFunctionContext} from "@code0-tech/hercules"; +import {ShipmentWithoutServices} from "../../types/glsShipment"; +import {PrintingOptions} from "../../types/glsPrintingOptions"; +import {CustomContent} from "../../types/glsCustomContent"; +import {ReturnOptions} from "../../types/glsReturnOptions"; +import {CreateParcelsResponse} from "../../types/glsCreateParcelsResponse"; + + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createIdentShipment", + name: [ + { + code: "en-US", + content: "Create ident shipment", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS ident shipment.", + } + ], + signature: `(birthDate: string, firstName: string, lastName: string, nationality: string, ${DEFAULT_SIGNATURE_FOR_SERVICES}): GLS_CREATE_PARCELS_RESPONSE`, + parameters: [ + { + runtimeName: "birthDate", + name: [ + { + code: "en-US", + content: "Birth date", + } + ], + description: [ + { + code: "en-US", + content: "The birth date for the ident shipment identification.", + } + ] + }, + { + runtimeName: "firstName", + name: [ + { + code: "en-US", + content: "First name", + } + ], + description: [ + { + code: "en-US", + content: "The first name for the ident shipment identification.", + } + ] + }, + { + runtimeName: "lastName", + name: [ + { + code: "en-US", + content: "Last name", + } + ], + description: [ + { + code: "en-US", + content: "The last name for the ident shipment identification.", + } + ] + }, + { + runtimeName: "nationality", + name: [ + { + code: "en-US", + content: "Nationality", + } + ], + description: [ + { + code: "en-US", + content: "The nationality for the ident shipment identification.", + } + ] + }, + ...DEFAULT_PARAMETERS_FOR_SERVICES, + ], + linkedDataTypes: [ + ...DEFAULT_DATA_TYPES_FOR_SERVICES, + ] + }, + handler: + async (context: HerculesFunctionContext, + birthDate: string, firstName: string, lastName: string, nationality: string, + shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, + ): Promise => { + return postShipmentHelper(context, [{ + Ident: { + Birthdate: birthDate, + Firstname: firstName, + Lastname: lastName, + Nationality: nationality + } + }], shipment, printingOptions, customContent, returnOptions) + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/services/createPickAndShipShipment.ts b/actions/gls-action/src/functions/services/createPickAndShipShipment.ts new file mode 100644 index 0000000..f1f101d --- /dev/null +++ b/actions/gls-action/src/functions/services/createPickAndShipShipment.ts @@ -0,0 +1,65 @@ +import { + DEFAULT_DATA_TYPES_FOR_SERVICES, + DEFAULT_PARAMETERS_FOR_SERVICES, + DEFAULT_SIGNATURE_FOR_SERVICES, postShipmentHelper +} from "../../helpers"; +import {ActionSdk, HerculesFunctionContext} from "@code0-tech/hercules"; +import {ShipmentWithoutServices} from "../../types/glsShipment"; +import {PrintingOptions} from "../../types/glsPrintingOptions"; +import {CustomContent} from "../../types/glsCustomContent"; +import {ReturnOptions} from "../../types/glsReturnOptions"; +import {CreateParcelsResponse} from "../../types/glsCreateParcelsResponse"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createPickAndShipShipment", + name: [ + { + code: "en-US", + content: "Create pick and ship shipment", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS pick and ship shipment.", + } + ], + signature: `(pickupDate: string, ${DEFAULT_SIGNATURE_FOR_SERVICES}): GLS_CREATE_PARCELS_RESPONSE`, + parameters: [ + { + runtimeName: "pickupDate", + name: [ + { + code: "en-US", + content: "Pickup date", + } + ], + description: [ + { + code: "en-US", + content: "The pickup date for the pick and ship shipment.", + } + ] + }, + ...DEFAULT_PARAMETERS_FOR_SERVICES, + ], + linkedDataTypes: [ + ...DEFAULT_DATA_TYPES_FOR_SERVICES, + ] + }, + handler: async (context: HerculesFunctionContext, + pickupDate: string, + shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, + ): Promise => { + return postShipmentHelper(context, [{ + PickAndShip: { + PickupDate: pickupDate + } + }], shipment, printingOptions, customContent, returnOptions) + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/services/createShopDeliveryShipment.ts b/actions/gls-action/src/functions/services/createShopDeliveryShipment.ts new file mode 100644 index 0000000..3595eaf --- /dev/null +++ b/actions/gls-action/src/functions/services/createShopDeliveryShipment.ts @@ -0,0 +1,65 @@ +import { + DEFAULT_DATA_TYPES_FOR_SERVICES, + DEFAULT_PARAMETERS_FOR_SERVICES, DEFAULT_SIGNATURE_FOR_SERVICES, postShipmentHelper, +} from "../../helpers"; +import {ActionSdk, HerculesFunctionContext} from "@code0-tech/hercules"; +import {ShipmentWithoutServices} from "../../types/glsShipment"; +import {PrintingOptions} from "../../types/glsPrintingOptions"; +import {CustomContent} from "../../types/glsCustomContent"; +import {ReturnOptions} from "../../types/glsReturnOptions"; +import { CreateParcelsResponse } from "../../types/glsCreateParcelsResponse"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createShopDeliveryShipment", + name: [ + { + code: "en-US", + content: "Create shop delivery shipment", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS shop delivery shipment.", + } + ], + signature: `(parcelShopId: string, ${DEFAULT_SIGNATURE_FOR_SERVICES}): GLS_CREATE_PARCELS_RESPONSE`, + parameters: [ + { + runtimeName: "parcelShopId", + name: [ + { + code: "en-US", + content: "Parcel shop Id", + } + ], + description: [ + { + code: "en-US", + content: "The ID of the parcel shop where the shipment should be delivered.", + } + ] + }, + ...DEFAULT_PARAMETERS_FOR_SERVICES + ], + linkedDataTypes: [ + ...DEFAULT_DATA_TYPES_FOR_SERVICES + ] + }, + handler: async (context: HerculesFunctionContext, parcelShopId: string, shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions): Promise => { + return postShipmentHelper(context, [{ + ShopDelivery: { + ParcelShopID: parcelShopId + } + }], shipment, printingOptions, customContent, returnOptions) + } + }, + ) +} + + + + diff --git a/actions/gls-action/src/functions/services/createShopReturnShipment.ts b/actions/gls-action/src/functions/services/createShopReturnShipment.ts new file mode 100644 index 0000000..df3a823 --- /dev/null +++ b/actions/gls-action/src/functions/services/createShopReturnShipment.ts @@ -0,0 +1,78 @@ +import { + DEFAULT_DATA_TYPES_FOR_SERVICES, + DEFAULT_PARAMETERS_FOR_SERVICES, + DEFAULT_SIGNATURE_FOR_SERVICES, postShipmentHelper +} from "../../helpers"; +import {ActionSdk, HerculesFunctionContext} from "@code0-tech/hercules"; +import {ShipmentWithoutServices} from "../../types/glsShipment"; +import {PrintingOptions} from "../../types/glsPrintingOptions"; +import {CustomContent} from "../../types/glsCustomContent"; +import {ReturnOptions} from "../../types/glsReturnOptions"; +import {CreateParcelsResponse} from "../../types/glsCreateParcelsResponse"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createShopReturnShipment", + name: [ + { + code: "en-US", + content: "Create shop return shipment", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS shop return shipment.", + } + ], + signature: `(numberOfLabels: number, ${DEFAULT_SIGNATURE_FOR_SERVICES}, returnQR: "PDF" | "PNG" | "ZPL"): GLS_CREATE_PARCELS_RESPONSE`, + parameters: [ + { + runtimeName: "parcelShopId", + name: [ + { + code: "en-US", + content: "Parcel shop Id", + } + ], + description: [ + { + code: "en-US", + content: "The ID of the parcel shop where the shipment should be delivered.", + } + ] + }, + ...DEFAULT_PARAMETERS_FOR_SERVICES, + { + runtimeName: "returnQR", + name: [ + { + code: "en-US", + content: "Return QR", + } + ], + description: [ + { + code: "en-US", + content: "The return QR of the shipment.", + } + ] + } + ], + linkedDataTypes: [ + ...DEFAULT_DATA_TYPES_FOR_SERVICES + ] + }, + handler: async (context: HerculesFunctionContext, numberOfLabels: number, shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, returnQR?: "PDF" | "PNG" | "ZPL"): Promise => { + return postShipmentHelper(context, [{ + ShopReturn: { + NumberOfLabels: numberOfLabels, + ReturnQR: returnQR + } + }], shipment, printingOptions, customContent, returnOptions) + } + }, + ) +} diff --git a/actions/gls-action/src/functions/services/createSignatureShipment.ts b/actions/gls-action/src/functions/services/createSignatureShipment.ts new file mode 100644 index 0000000..2842f38 --- /dev/null +++ b/actions/gls-action/src/functions/services/createSignatureShipment.ts @@ -0,0 +1,47 @@ +import { + DEFAULT_DATA_TYPES_FOR_SERVICES, + DEFAULT_PARAMETERS_FOR_SERVICES, + DEFAULT_SIGNATURE_FOR_SERVICES, postShipmentHelper +} from "../../helpers"; +import {ActionSdk, HerculesFunctionContext} from "@code0-tech/hercules"; +import {ShipmentWithoutServices} from "../../types/glsShipment"; +import {PrintingOptions} from "../../types/glsPrintingOptions"; +import {CustomContent} from "../../types/glsCustomContent"; +import {ReturnOptions} from "../../types/glsReturnOptions"; +import {CreateParcelsResponse} from "../../types/glsCreateParcelsResponse"; + +export default (sdk: ActionSdk) => { + sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createSignatureShipment", + name: [ + { + code: "en-US", + content: "Create signature shipment", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS signature shipment.", + } + ], + signature: `(${DEFAULT_SIGNATURE_FOR_SERVICES}): GLS_CREATE_PARCELS_RESPONSE`, + parameters: [ + ...DEFAULT_PARAMETERS_FOR_SERVICES, + ], + linkedDataTypes: [ + ...DEFAULT_DATA_TYPES_FOR_SERVICES, + ] + }, + handler: async (context: HerculesFunctionContext, + shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, + ): Promise => { + return postShipmentHelper(context, [{ + SignatureService: {} + }], shipment, printingOptions, customContent, returnOptions) + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/services/createTyreShipment.ts b/actions/gls-action/src/functions/services/createTyreShipment.ts new file mode 100644 index 0000000..4e47b37 --- /dev/null +++ b/actions/gls-action/src/functions/services/createTyreShipment.ts @@ -0,0 +1,47 @@ +import { + DEFAULT_DATA_TYPES_FOR_SERVICES, + DEFAULT_PARAMETERS_FOR_SERVICES, + DEFAULT_SIGNATURE_FOR_SERVICES, postShipmentHelper +} from "../../helpers"; +import {ActionSdk, HerculesFunctionContext} from "@code0-tech/hercules"; +import {ShipmentWithoutServices} from "../../types/glsShipment"; +import {PrintingOptions} from "../../types/glsPrintingOptions"; +import {CustomContent} from "../../types/glsCustomContent"; +import {ReturnOptions} from "../../types/glsReturnOptions"; +import {CreateParcelsResponse} from "../../types/glsCreateParcelsResponse"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createTyreShipment", + name: [ + { + code: "en-US", + content: "Create tyre shipment", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS tyre shipment.", + } + ], + signature: `(${DEFAULT_SIGNATURE_FOR_SERVICES}): GLS_CREATE_PARCELS_RESPONSE`, + parameters: [ + ...DEFAULT_PARAMETERS_FOR_SERVICES, + ], + linkedDataTypes: [ + ...DEFAULT_DATA_TYPES_FOR_SERVICES, + ] + }, + handler: async (context: HerculesFunctionContext, + shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, + ): Promise => { + return postShipmentHelper(context, [{ + TyreService: {} + }], shipment, printingOptions, customContent, returnOptions) + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/updateParcelWeight.ts b/actions/gls-action/src/functions/updateParcelWeight.ts new file mode 100644 index 0000000..3fbbbfa --- /dev/null +++ b/actions/gls-action/src/functions/updateParcelWeight.ts @@ -0,0 +1,67 @@ +import {ActionSdk, HerculesFunctionContext, RuntimeErrorException} from "@code0-tech/hercules"; +import {getAuthToken} from "../helpers"; +import axios from "axios"; +import { + UpdateParcelWeightRequestData, + UpdateParcelWeightResponseData, + UpdateParcelWeightResponseDataSchema +} from "../types/glsUpdateParcelWeight"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "updateParcelWeight", + name: [ + { + code: "en-US", + content: "Update parcel weight", + } + ], + description: [ + { + code: "en-US", + content: "Updates the weight of a GLS parcel.", + } + ], + signature: "(data: GLS_UPDATE_PARCEL_WEIGHT_REQUEST_DATA): GLS_END_OF_DAY_RESPONSE_DATA", + parameters: [ + { + runtimeName: "data", + name: [ + { + code: "en-US", + content: "Data", + } + ], + description: [ + { + code: "en-US", + content: "The update parcel weight request data.", + } + ] + } + ], + linkedDataTypes: [ + "GLS_UPDATE_PARCEL_WEIGHT_REQUEST_DATA", + "GLS_UPDATE_PARCEL_WEIGHT_RESPONSE_DATA", + ], + }, + handler: async (data: UpdateParcelWeightRequestData, context: HerculesFunctionContext): Promise => { + const url = context.matchedConfig.findConfig("ship_it_api_url") as string; + + try { + const result = await axios.post(`${url}/rs/shipments/updateparcelweight`, data, { + headers: { + Authorization: `Bearer ${await getAuthToken(context)}`, + "Content-Type": "application/glsVersion1+json" + } + }) + return UpdateParcelWeightResponseDataSchema.parse(result.data) + } catch (error: any) { + throw new RuntimeErrorException("UPDATE_PARCEL_WEIGHT_FAILED", error.toString()) + } + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/utils/createAddress.ts b/actions/gls-action/src/functions/utils/createAddress.ts new file mode 100644 index 0000000..77e0461 --- /dev/null +++ b/actions/gls-action/src/functions/utils/createAddress.ts @@ -0,0 +1,256 @@ +import {ActionSdk} from "@code0-tech/hercules"; +import {AddressSchema} from "../../types/glsAddress"; + +export default (sdk: ActionSdk) => { + sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createAddress", + signature: "Name1: string, CountryCode: string, City: string, Street: string, ZIPCode: string, Name2?: string, Name3?: string, Province?: string, StreetNumber?: string, ContactPerson?: string, FixedLinePhonenumber?: string, MobilePhonenumber?: string, Email?: string): GLS_ADDRESS", + name: [ + { + code: "en-US", + content: "Create address", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS address object which can be used for shipments.", + } + ], + parameters: [ + { + runtimeName: "Name1", + name: [ + { + code: "en-US", + content: "Name 1", + } + ], + description: [ + { + code: "en-US", + content: "The name of the recipient or company. Max length is 40 characters.", + } + ] + }, + { + runtimeName: "CountryCode", + name: [ + { + code: "en-US", + content: "Country code", + } + ], + description: [ + { + code: "en-US", + content: "The ISO alpha-2 country code. For example, DE for Germany or FR for France.", + } + ] + }, + { + runtimeName: "City", + name: [ + { + code: "en-US", + content: "City", + } + ], + description: [ + { + code: "en-US", + content: "The city of the address. Max length is 40 characters.", + } + ] + }, + { + runtimeName: "Street", + name: [ + { + code: "en-US", + content: "Street", + } + ], + description: [ + { + code: "en-US", + content: "The street name of the address. Min length is 4 characters.", + } + ] + }, + { + runtimeName: "ZIPCode", + name: [ + { + code: "en-US", + content: "ZIP code", + } + ], + description: [ + { + code: "en-US", + content: "The ZIP code of the address. Max length is 10 characters.", + } + ] + }, + { + runtimeName: "Name2", + name: [ + { + code: "en-US", + content: "Name 2", + } + ], + description: [ + { + code: "en-US", + content: "Additional name information. Max length is 40 characters.", + } + ] + }, + { + runtimeName: "Name3", + name: [ + { + code: "en-US", + content: "Name 3", + } + ], + description: [ + { + code: "en-US", + content: "Additional name information. Max length is 40 characters.", + } + ] + }, + { + runtimeName: "Province", + name: [ + { + code: "en-US", + content: "Province/State", + } + ], + description: [ + { + code: "en-US", + content: "The province or state of the address. Max length is 40 characters.", + } + ] + }, + { + runtimeName: "StreetNumber", + name: [ + { + code: "en-US", + content: "Street number", + } + ], + description: [ + { + code: "en-US", + content: "The street number of the address. Max length is 40 characters.", + } + ] + }, + { + runtimeName: "ContactPerson", + name: [ + { + code: "en-US", + content: "Contact person", + } + ], + description: [ + { + code: "en-US", + content: "The contact person for the address. Max length is 40 characters.", + } + ] + }, + { + runtimeName: "FixedLinePhonenumber", + name: [ + { + code: "en-US", + content: "Fixed line phone number", + } + ], + description: [ + { + code: "en-US", + content: "The fixed line phone number for the address. Max length is 35 characters.", + } + ] + }, + { + runtimeName: "MobilePhonenumber", + name: [ + { + code: "en-US", + content: "Mobile phone number", + }, + ], + description: [ + { + code: "en-US", + content: "The mobile phone number for the address. Max length is 35 characters.", + } + ] + }, + { + runtimeName: "Email", + name: [ + { + code: "en-US", + content: "Email", + } + ], + description: [ + { + code: "en-US", + content: "The email address for the address. Max length is 80 characters.", + } + ] + } + ], + linkedDataTypes: [ + "GLS_ADDRESS", + ] + }, + handler: ( + Name1: string, + CountryCode: string, + City: string, + Street: string, + ZIPCode: string, + Name2?: string, + Name3?: string, + Province?: string, + StreetNumber?: string, + ContactPerson?: string, + FixedLinePhonenumber?: string, + MobilePhonenumber?: string, + Email?: string + ): AddressSchema => { + return { + Name1, + Name2, + Name3, + CountryCode, + Province, + City, + Street, + StreetNumber, + ContactPerson, + FixedLinePhonenumber, + MobilePhonenumber, + eMail: Email, + ZIPCode + } + } + } + ) +} diff --git a/actions/gls-action/src/functions/utils/createConsignee.ts b/actions/gls-action/src/functions/utils/createConsignee.ts new file mode 100644 index 0000000..eab02a9 --- /dev/null +++ b/actions/gls-action/src/functions/utils/createConsignee.ts @@ -0,0 +1,101 @@ +import {ActionSdk} from "@code0-tech/hercules"; +import {AddressSchema} from "../../types/glsAddress"; +import {ConsigneeSchema} from "../../types/glsConsignee"; + +export default (sdk: ActionSdk) => { + sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createConsignee", + name: [ + { + code: "en-US", + content: "Create consignee", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS consignee object which can be used for shipments.", + } + ], + signature: "(consigneeId: string, costCenter: string, Address: GLS_ADDRESS, Category: \"BUSINESS\"|\"PRIVATE\"): GLS_CONSIGNEE", + parameters: [ + { + runtimeName: "consigneeId", + name: [ + { + code: "en-US", + content: "Consignee ID", + } + ], + description: [ + { + code: "en-US", + content: "The ID of the consignee. Max length is 40 characters.", + } + ] + }, + { + runtimeName: "costCenter", + name: [ + { + code: "en-US", + content: "Cost center", + } + ], + description: [ + { + code: "en-US", + content: "The cost center for the consignee. Max length is 80 characters.", + } + ] + }, + { + runtimeName: "Address", + name: [ + { + code: "en-US", + content: "Address", + } + ], + description: [ + { + code: "en-US", + content: "The address of the consignee.", + } + ] + + }, + { + runtimeName: "Category", + name: [ + { + code: "en-US", + content: "Category", + } + ], + description: [ + { + code: "en-US", + content: "The category of the consignee. Can be either BUSINESS or PRIVATE.", + } + ] + } + ], + linkedDataTypes: [ + "GLS_CONSIGNEE", + "GLS_ADDRESS" + ] + }, + handler: (consigneeId: string, costCenter: string, Address: AddressSchema, Category: "BUSINESS" | "PRIVATE"): ConsigneeSchema => { + return { + Address, + Category, + ConsigneeID: consigneeId, + CostCenter: costCenter + } + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/utils/createCustomContent.ts b/actions/gls-action/src/functions/utils/createCustomContent.ts new file mode 100644 index 0000000..898e656 --- /dev/null +++ b/actions/gls-action/src/functions/utils/createCustomContent.ts @@ -0,0 +1,87 @@ +import {ActionSdk} from "@code0-tech/hercules"; +import {CustomContent} from "../../types/glsCustomContent"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createCustomContent", + signature: "(barcodeContentType: \"TRACK_ID\"|\"GLS_SHIPMENT_REFERENCE\", customerLogo: string, hideShipperAddress?: boolean, barcodeType?: \"EAN_128\"|\"CODE_39\", barcode?: string): GLS_CUSTOM_CONTENT", + name: [ + { + code: "en-US", + content: "Create custom content", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS custom content object for shipment labels.", + } + ], + parameters: [ + { + runtimeName: "barcodeContentType", + name: [ + {code: "en-US", content: "Barcode content type"} + ], + description: [ + { + code: "en-US", + content: "Type of content encoded in the barcode (TRACK_ID or GLS_SHIPMENT_REFERENCE)." + } + ] + }, + { + runtimeName: "customerLogo", + name: [ + {code: "en-US", content: "Customer logo"} + ], + description: [ + {code: "en-US", content: "Base64-encoded customer logo to print on the label."} + ] + }, + { + runtimeName: "hideShipperAddress", + name: [ + {code: "en-US", content: "Hide shipper address"} + ], + description: [ + {code: "en-US", content: "Whether to hide the shipper address on the label."} + ] + }, + { + runtimeName: "barcodeType", + name: [ + {code: "en-US", content: "Barcode type"} + ], + description: [ + {code: "en-US", content: "Type of barcode to use (EAN_128 or CODE_39)."} + ] + }, + { + runtimeName: "barcode", + name: [ + {code: "en-US", content: "Barcode"} + ], + description: [ + {code: "en-US", content: "Barcode value to print on the label."} + ] + } + ], + linkedDataTypes: [ + "GLS_CUSTOM_CONTENT", + ] + }, + handler: (barcodeContentType: CustomContent["BarcodeContentType"], customerLogo: string, hideShipperAddress?: boolean, barcodeType?: CustomContent["BarcodeType"], barcode?: string): CustomContent => { + return { + Barcode: barcode, + BarcodeContentType: barcodeContentType, + BarcodeType: barcodeType, + CustomerLogo: customerLogo, + HideShipperAddress: hideShipperAddress, + } + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/utils/createPrintingOptions.ts b/actions/gls-action/src/functions/utils/createPrintingOptions.ts new file mode 100644 index 0000000..d41f551 --- /dev/null +++ b/actions/gls-action/src/functions/utils/createPrintingOptions.ts @@ -0,0 +1,51 @@ +import {ActionSdk} from "@code0-tech/hercules"; +import {PrintingOptions, ReturnLabels} from "../../types/glsPrintingOptions"; + +export default (sdk: ActionSdk) => { + sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createPrintingOptions", + signature: "(returnLabels: RETURN_LABELS): GLS_PRINTING_OPTIONS", + name: [ + { + code: "en-US", + content: "Create printing options", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS printing options object which can be used when creating shipments.", + } + ], + parameters: [ + { + runtimeName: "returnLabels", + name: [ + { + code: "en-US", + content: "Return labels", + } + ], + description: [ + { + code: "en-US", + content: "The return labels to be included in the shipment.", + } + ] + } + ], + linkedDataTypes: [ + "GLS_PRINTING_OPTIONS", + "RETURN_LABELS" + ] + }, + handler: (returnLabels: ReturnLabels): PrintingOptions => { + return { + ReturnLabels: returnLabels + } + } + }, + ) +} diff --git a/actions/gls-action/src/functions/utils/createShipmentUnit.ts b/actions/gls-action/src/functions/utils/createShipmentUnit.ts new file mode 100644 index 0000000..9d145c7 --- /dev/null +++ b/actions/gls-action/src/functions/utils/createShipmentUnit.ts @@ -0,0 +1,131 @@ +import {ActionSdk} from "@code0-tech/hercules"; +import { UnitService } from "../../types/glsUnitService"; +import {ShipmentUnit} from "../../types/glsShipmentUnit"; + +export default (sdk: ActionSdk) => { + sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "createShipmentUnit", + signature: "(weight: number, shipmentUnitReference?: string, partnerParcelNumber?: string, note1?: string, note2?: string, shipmentUnitService: GLS_SHIPMENT_UNIT_SERVICE): GLS_SHIPMENT_UNIT", + name: [ + { + code: "en-US", + content: "Create shipment unit", + } + ], + description: [ + { + code: "en-US", + content: "Creates a GLS shipment unit object which can be used for shipments.", + } + ], + parameters: [ + { + runtimeName: "weight", + name: [ + { + code: "en-US", + content: "Weight (kg)", + } + ], + description: [ + { + code: "en-US", + content: "The weight of the shipment unit in kilograms. Must be a positive number and greater than 0.10 and less than 99.", + } + ] + }, + { + runtimeName: "shipmentUnitReference", + name: [ + { + code: "en-US", + content: "Shipment unit reference", + } + ], + description: [ + { + code: "en-US", + content: "The reference for the shipment unit. Max length is 40 characters.", + } + ] + }, + { + runtimeName: "partnerParcelNumber", + name: [ + { + code: "en-US", + content: "Partner parcel number", + } + ], + description: [ + { + code: "en-US", + content: "The partner parcel number for the shipment unit. Max length is 50 characters.", + } + ] + }, + { + runtimeName: "note1", + name: [ + { + code: "en-US", + content: "Note 1", + } + ], + description: [ + { + code: "en-US", + content: "Note 1 for the shipment unit. Max length is 50 characters.", + } + ] + }, + { + runtimeName: "note2", + name: [ + { + code: "en-US", + content: "Note 2", + } + ], + description: [ + { + code: "en-US", + content: "Note 2 for the shipment unit. Max length is 50 characters.", + } + ] + }, + { + runtimeName: "shipmentUnitService", + name: [ + { + code: "en-US", + content: "Shipment unit service", + } + ], + description: [ + { + code: "en-US", + content: "The service associated with the shipment unit.", + } + ] + } + ], + linkedDataTypes: [ + "GLS_SHIPMENT_UNIT", + ] + }, + handler: (weight: number, shipmentUnitReference: string, partnerParcelNumber?: string, note1?: string, note2?: string, shipmentUnitService?: UnitService): ShipmentUnit => { + return { + ShipmentUnitReference: shipmentUnitReference, + Weight: weight, + PartnerParcelNumber: partnerParcelNumber, + Note1: note1, + Note2: note2, + Service: shipmentUnitService + } + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/functions/validateShipment.ts b/actions/gls-action/src/functions/validateShipment.ts new file mode 100644 index 0000000..5088640 --- /dev/null +++ b/actions/gls-action/src/functions/validateShipment.ts @@ -0,0 +1,68 @@ +import {ActionSdk, HerculesFunctionContext, RuntimeErrorException} from "@code0-tech/hercules"; +import {getAuthToken, transformValidateShipmentRequestDataToInternalFormat} from "../helpers"; +import axios from "axios"; +import { + ValidateShipmentRequestData, + ValidateShipmentResponseData, + ValidateShipmentResponseDataSchema +} from "../types/glsValidateShipment"; + +export default (sdk: ActionSdk) => { + return sdk.registerFunctionDefinitions( + { + definition: { + runtimeName: "validateShipment", + name: [ + { + code: "en-US", + content: "Validate shipment", + } + ], + description: [ + { + code: "en-US", + content: "Validates a GLS shipment.", + } + ], + signature: "(data: GLS_VALIDATE_SHIPMENT_REQUEST_DATA): GLS_VALIDATE_SHIPMENT_RESPONSE_DATA", + parameters: [ + { + runtimeName: "data", + name: [ + { + code: "en-US", + content: "Data", + } + ], + description: [ + { + code: "en-US", + content: "The shipment data to validate.", + } + ] + } + ], + linkedDataTypes: [ + "GLS_VALIDATE_SHIPMENT_REQUEST_DATA", + "GLS_VALIDATE_SHIPMENT_RESPONSE_DATA", + ], + }, + handler: async (data: ValidateShipmentRequestData, context: HerculesFunctionContext): Promise => { + const url = context?.matchedConfig.findConfig("ship_it_api_url") as string; + const contactID = context?.matchedConfig.findConfig("contact_id") as string || "" + + try { + const result = await axios.post(`${url}/rs/shipments/validate`, transformValidateShipmentRequestDataToInternalFormat(data, context, contactID), { + headers: { + Authorization: `Bearer ${await getAuthToken(context)}`, + "Content-Type": "application/glsVersion1+json" + } + }) + return ValidateShipmentResponseDataSchema.parse(result.data) + } catch (error: any) { + throw new RuntimeErrorException("VALIDATE_SHIPMENT_FAILED", error.toString()) + } + } + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/helpers.ts b/actions/gls-action/src/helpers.ts index 87a4898..b5a3101 100644 --- a/actions/gls-action/src/helpers.ts +++ b/actions/gls-action/src/helpers.ts @@ -1,25 +1,119 @@ import {ZodError, ZodObject} from "zod"; import {createAuxiliaryTypeStore, printNode, zodToTs} from "zod-to-ts"; import ts from "typescript"; -import { - AllowedServicesRequestData, AllowedServicesResponseData, AllowedServicesResponseDataSchema, - AuthenticationRequestData, AuthenticationRequestDataSchema, AuthenticationResponseDataSchema, - CancelShipmentRequestData, CancelShipmentResponseData, - CancelShipmentResponseDataSchema, CreateParcelsResponse, - CreateParcelsResponseSchema, CustomContent, EndOfDayRequestData, EndOfDayResponseData, - EndOfDayResponseDataSchema, InternalShipmentRequestData, - InternalShipmentServiceSchema, InternalShipmentUnitSchema, InternalShipper, InternalValidateShipmentRequestData, - PrintingOptions, - ReprintParcelRequestData, ReprintParcelResponseData, - ReprintParcelResponseDataSchema, ReturnOptions, ShipmentRequestData, ShipmentRequestDataSchema, ShipmentService, - ShipmentWithoutServices, Shipper, - UpdateParcelWeightRequestData, - UpdateParcelWeightResponseData, - UpdateParcelWeightResponseDataSchema, ValidateShipmentRequestData, ValidateShipmentResponseData, - ValidateShipmentResponseDataSchema -} from "./types"; import axios from "axios"; -import {HerculesFunctionContext, RuntimeErrorException} from "@code0-tech/hercules"; +import { + HerculesRuntimeFunctionDefinition, + HerculesFunctionContext, + RuntimeErrorException, + ActionSdk +} from "@code0-tech/hercules"; +import {InternalShipmentServiceSchema, ShipmentService} from "./types/glsShipmentService"; +import {ShipmentWithoutServices} from "./types/glsShipment"; +import { + CancelShipmentRequestData, + CancelShipmentResponseData, + CancelShipmentResponseDataSchema +} from "./types/glsCancelShipment"; +import { + InternalValidateShipmentRequestData, + ValidateShipmentRequestData +} from "./types/glsValidateShipment"; +import {InternalShipmentUnitSchema} from "./types/glsShipmentUnit"; +import {InternalShipper, ShipperSchema} from "./types/glsShipper"; +import {CreateParcelsResponse, CreateParcelsResponseSchema} from "./types/glsCreateParcelsResponse"; +import {PrintingOptions} from "./types/glsPrintingOptions"; +import {CustomContent} from "./types/glsCustomContent"; +import {ReturnOptions} from "./types/glsReturnOptions"; +import { + AuthenticationRequestData, + AuthenticationRequestDataSchema, + AuthenticationResponseDataSchema +} from "./types/auth"; +import { + InternalShipmentRequestData, + ShipmentRequestData, + ShipmentRequestDataSchema +} from "./types/shipmentRequest"; + + +export const DEFAULT_SIGNATURE_FOR_SERVICES = "shipment: GLS_SHIPMENT, printingOptions: GLS_PRINTING_OPTIONS, returnOptions?: GLS_RETURN_OPTIONS, customContent?: GLS_CUSTOM_CONTENT" +export const DEFAULT_PARAMETERS_FOR_SERVICES: HerculesRuntimeFunctionDefinition["parameters"] = [ + { + runtimeName: "shipment", + name: [ + { + code: "en-US", + content: "Shipment", + } + ], + description: [ + { + code: "en-US", + content: "The shipment for which to create the parcels. Must include all necessary information and services for the shipment.", + } + ] + }, + { + runtimeName: "printingOptions", + name: [ + { + code: "en-US", + content: "Printing options", + } + ], + description: [ + { + code: "en-US", + content: "The printing options for the shipment. Specifies options for the labels to be printed for the shipment.", + } + ] + }, + { + runtimeName: "returnOptions", + name: [ + { + code: "en-US", + content: "Return options", + } + ], + description: [ + { + code: "en-US", + content: "The return options for the shipment. Specifies options for return shipments.", + } + ] + }, + { + runtimeName: "customContent", + name: [ + { + code: "en-US", + content: "Custom content", + } + ], + description: [ + { + code: "en-US", + content: "The custom content for the shipment. Specifies options for custom content to be printed on the labels.", + } + ] + } +] as HerculesRuntimeFunctionDefinition["parameters"] +export const DEFAULT_DATA_TYPES_FOR_SERVICES = [ + "GLS_SHIPMENT", + "GLS_PRINTING_OPTIONS", + "GLS_RETURN_OPTIONS", + "GLS_CUSTOM_CONTENT", + "GLS_CREATE_PARCELS_RESPONSE" +] + +export function singleZodSchemaToTypescriptDef( + typeName: string, + zodSchema: ZodObject +) { + return zodSchemaToTypescriptDefs(typeName, zodSchema).get(typeName)!; +} export function zodSchemaToTypescriptDefs( typeName: string, @@ -88,123 +182,74 @@ export const getAuthToken = async (context: HerculesFunctionContext) => { return result.access_token } -export const validateShipment = async (data: ValidateShipmentRequestData, context: HerculesFunctionContext): Promise => { - const url = context?.matchedConfig.findConfig("ship_it_api_url") as string; - const contactID = context?.matchedConfig.findConfig("contact_id") as string || "" - - try { - const result = await axios.post(`${url}/rs/shipments/validate`, transformValidateShipmentRequestDataToInternalFormat(data, context, contactID), { - headers: { - Authorization: `Bearer ${await getAuthToken(context)}`, - "Content-Type": "application/glsVersion1+json" - } - }) - return ValidateShipmentResponseDataSchema.parse(result.data) - } catch (error: any) { - throw error - } - -} -export const reprintParcel = async (data: ReprintParcelRequestData, context: HerculesFunctionContext): Promise => { +export const cancelShipment = async (data: CancelShipmentRequestData, context: HerculesFunctionContext): Promise => { const url = context.matchedConfig.findConfig("ship_it_api_url") as string; + try { - const result = await axios.post(`${url}/rs/shipments/reprintparcel`, data, { + const result = await axios.post(`${url}/rs/shipments/cancel/${data.TrackID}`, {}, { headers: { Authorization: `Bearer ${await getAuthToken(context)}`, "Content-Type": "application/glsVersion1+json" } }) - return ReprintParcelResponseDataSchema.parse(result.data) + return CancelShipmentResponseDataSchema.parse(result.data) } catch (error: any) { - console.error("Error response from GLS API:", error) - throw error + if (error.response?.headers?.args) { + const headers = error.response.headers; + console.error("Error sending cancel shipment request to GLS API:", headers.error, headers.args) + throw new RuntimeErrorException("ERROR_CANCELING_GLS_SHIPMENT", `GLS API error: ${headers.error}, args: ${headers.args}`) + } + throw new RuntimeErrorException("ERROR_CANCELING_GLS_SHIPMENT") } } -export const updateParcelWeight = async (data: UpdateParcelWeightRequestData, context: HerculesFunctionContext): Promise => { - const url = context.matchedConfig.findConfig("ship_it_api_url") as string; - try { - const result = await axios.post(`${url}/rs/shipments/updateparcelweight`, data, { - headers: { - Authorization: `Bearer ${await getAuthToken(context)}`, - "Content-Type": "application/glsVersion1+json" - } - }) - return UpdateParcelWeightResponseDataSchema.parse(result.data) - } catch (error: any) { - console.log(error) - throw error +export function transformValidateShipmentRequestDataToInternalFormat(data: ValidateShipmentRequestData, context: HerculesFunctionContext | undefined, contactID: string): InternalValidateShipmentRequestData { + return { + ...data, + Shipment: { + ...data.Shipment, + Middleware: "CodeZeroviaGLS", + Shipper: getShipper(context, contactID, data.Shipment.Shipper), + Service: InternalShipmentServiceSchema.parse(data.Shipment.Service), + ShipmentUnit: InternalShipmentUnitSchema.parse(data.Shipment.ShipmentUnit) + } } - } -export const getEndOfDayInfo = async (data: EndOfDayRequestData, context: HerculesFunctionContext): Promise => { - const url = context.matchedConfig.findConfig("ship_it_api_url") as string; - try { - const result = await axios.post(`${url}/rs/shipments/endofday?date=${data.date}`, {}, { - headers: { - Authorization: `Bearer ${await getAuthToken(context)}`, - "Content-Type": "application/glsVersion1+json" - } - }) - return EndOfDayResponseDataSchema.parse(result.data) - } catch (error: any) { - console.error("Error response from GLS API:", error) - throw error - } -} +export function getShipper(context: HerculesFunctionContext | undefined, contactID: string | undefined, shipper?: ShipperSchema): InternalShipper { + const configShipper = context?.matchedConfig.findConfig("default_shipper") as ShipperSchema || undefined -export const getAllowedServices = async (data: AllowedServicesRequestData, context: HerculesFunctionContext): Promise => { - const url = context.matchedConfig.findConfig("ship_it_api_url") as string; + if (!shipper && !configShipper) { + throw new RuntimeErrorException("MISSING_SHIPPER_INFORMATION", "No shipper information provided in shipment data or configuration.") + } - try { - const result = await axios.post(`${url}/rs/shipments/allowedservices`, data, { - headers: { - Authorization: `Bearer ${await getAuthToken(context)}`, - "Content-Type": "application/glsVersion1+json" - } - }) - return AllowedServicesResponseDataSchema.parse(result.data) - } catch (error: any) { - if (error.response?.data) { - console.error("Error response from GLS API:", error.response.data) - } else if (error.response?.headers) { - const headers = error?.response.headers; - console.error("Error sending request to GLS API:", headers.error, headers.args) - throw new RuntimeErrorException("ERROR_FETCHING_ALLOWED_SERVICES", `GLS API error: ${headers.error}, args: ${headers.args}`) - } else if (error instanceof ZodError) { - console.error("Error sending request to GLS API:", error.message) - } else { - console.error("Error sending request to GLS API:", error) + if (shipper) { + return { + ...shipper, + ContactID: contactID } - throw error } + return { + ...configShipper, + ContactID: contactID + } } -export const cancelShipment = async (data: CancelShipmentRequestData, context: HerculesFunctionContext): Promise => { - const url = context.matchedConfig.findConfig("ship_it_api_url") as string; - - try { - const result = await axios.post(`${url}/rs/shipments/cancel/${data.TrackID}`, {}, { - headers: { - Authorization: `Bearer ${await getAuthToken(context)}`, - "Content-Type": "application/glsVersion1+json" - } - }) - return CancelShipmentResponseDataSchema.parse(result.data) - } catch (error: any) { - if (error.response?.headers?.args) { - const headers = error.response.headers; - console.error("Error sending cancel shipment request to GLS API:", headers.error, headers.args) - throw new RuntimeErrorException("ERROR_CANCELING_GLS_SHIPMENT", `GLS API error: ${headers.error}, args: ${headers.args}`) +export function transformShipmentRequestDataToInternalFormat(data: ShipmentRequestData, context: HerculesFunctionContext | undefined, contactID: string | undefined): InternalShipmentRequestData { + return { + ...data, + Shipment: { + ...data.Shipment, + Middleware: "CodeZeroviaGLS", + Shipper: getShipper(context, contactID, data.Shipment.Shipper), + Service: InternalShipmentServiceSchema.parse(data.Shipment.Service), + ShipmentUnit: InternalShipmentUnitSchema.parse(data.Shipment.ShipmentUnit) } - console.error("Error sending cancel shipment request to GLS API:", error) - throw error } } @@ -239,52 +284,6 @@ const postShipments = async (data: ShipmentRequestData, context: HerculesFunctio } } -export function transformValidateShipmentRequestDataToInternalFormat(data: ValidateShipmentRequestData, context: HerculesFunctionContext | undefined, contactID: string): InternalValidateShipmentRequestData { - return { - ...data, - Shipment: { - ...data.Shipment, - Middleware: "CodeZeroviaGLS", - Shipper: getShipper(context, contactID, data.Shipment.Shipper), - Service: InternalShipmentServiceSchema.parse(data.Shipment.Service), - ShipmentUnit: InternalShipmentUnitSchema.parse(data.Shipment.ShipmentUnit) - } - } -} - -function transformShipmentRequestDataToInternalFormat(data: ShipmentRequestData, context: HerculesFunctionContext | undefined, contactID: string | undefined): InternalShipmentRequestData { - return { - ...data, - Shipment: { - ...data.Shipment, - Middleware: "CodeZeroviaGLS", - Shipper: getShipper(context, contactID, data.Shipment.Shipper), - Service: InternalShipmentServiceSchema.parse(data.Shipment.Service), - ShipmentUnit: InternalShipmentUnitSchema.parse(data.Shipment.ShipmentUnit) - } - } -} - -function getShipper(context: HerculesFunctionContext | undefined, contactID: string | undefined, shipper?: Shipper): InternalShipper { - const configShipper = context?.matchedConfig.findConfig("shipper") as Shipper || undefined - - if (!shipper && !configShipper) { - throw new RuntimeErrorException("MISSING_SHIPPER_INFORMATION", "No shipper information provided in shipment data or configuration.") - } - - if (shipper) { - return { - ...shipper, - ContactID: contactID - } - } - - return { - ...configShipper, - ContactID: contactID - } -} - export async function postShipmentHelper(context: HerculesFunctionContext, services: ShipmentService, shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions): Promise { try { return await postShipments({ @@ -303,3 +302,19 @@ export async function postShipmentHelper(context: HerculesFunctionContext, servi throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", "An error occurred while creating the shipment.") } } + +export async function loadAllDefinitions(sdk: ActionSdk) { + const modules = import.meta.glob('./{types,functions,config}/**/*.ts'); + + for (const path in modules) { + const mod: any = await modules[path](); + + if (typeof mod.default === 'function') { + try { + await mod.default(sdk); + } catch (error) { + console.log(`Error registering functions from ${path}:`, error); + } + } + } +} \ No newline at end of file diff --git a/actions/gls-action/src/index.test.ts b/actions/gls-action/src/index.test.ts deleted file mode 100644 index 33e39ed..0000000 --- a/actions/gls-action/src/index.test.ts +++ /dev/null @@ -1,147 +0,0 @@ -import {describe, it, expect, vi, beforeEach, test} from "vitest"; -import {GrpcOptions} from "@protobuf-ts/grpc-transport"; - -const state = vi.hoisted(() => { - const state = { - registeredFunctionDefinitions: [] as HerculesRegisterFunctionParameter[], - dataTypes: [] as HerculesDataType[], - flowTypes: [] as HerculesFlowType[], - configDefinitions: [] as HerculesActionConfigurationDefinition[], - - createSdkMock: (config: any, configDefinition?: any) => { - state.configDefinitions = configDefinition ?? null; - - return { - config, - - registerFunctionDefinitions: (...defs: HerculesRegisterFunctionParameter[]) => { - state.registeredFunctionDefinitions = defs; - return Promise.resolve(); - }, - - registerConfigDefinitions: (...defs: any[]) => { - state.configDefinitions = defs; - return Promise.resolve(); - }, - - registerDataTypes: (...types: any[]) => { - state.dataTypes = types; - return Promise.resolve(); - }, - - registerFlowTypes: (...types: any[]) => { - state.flowTypes = types; - return Promise.resolve(); - }, - - fullyConnected: () => false, - connect: () => Promise.resolve([]), - onError: () => { - }, - getProjectActionConfigurations: () => [], - dispatchEvent: () => Promise.resolve(), - }; - }, - }; - - return state; -}); -vi.mock("@code0-tech/hercules", () => ({ - createSdk: state.createSdkMock, -})); - -import { - createSdk, - HerculesActionConfigurationDefinition, HerculesDataType, HerculesFlowType, HerculesRegisterFunctionParameter -} from "@code0-tech/hercules"; - -beforeEach(() => { - state.registeredFunctionDefinitions = null; - state.dataTypes = null; - state.flowTypes = null; - state.configDefinitions = null; -}); - -describe("Hercules SDK mock", () => { - it("registers config definitions", async () => { - const sdk = createSdk({ - authToken: "testToken", - aquilaUrl: "http://localhost:50051", - actionId: "testAction", - version: "1.0.0", - }); - - await sdk.registerConfigDefinitions({ - identifier: "config_test", - type: "STRING", - }); - - expect(state.configDefinitions).toEqual([ - {identifier: "config_test", type: "STRING"}, - ]); - }); - - it("registers data and flow types", async () => { - const sdk = createSdk({ - authToken: "testToken", - aquilaUrl: "http://localhost:50051", - actionId: "testAction", - version: "1.0.0", - }); - - await sdk.registerDataTypes({ - identifier: "Data1", - type: "string", - }); - - await sdk.registerFlowTypes({ - identifier: "Flow1", - editable: false, - }); - - expect(state.dataTypes).toEqual([ - {identifier: "Data1", type: "string"}, - ]); - - expect(state.flowTypes).toEqual([ - {identifier: "Flow1", editable: false}, - ]); - }); -}); - - -describe("executes index.ts", async () => { - it('should be valid', async () => { - vi.resetModules(); // clear module cache - await import("./index"); // now it runs - - state.dataTypes?.forEach((dataType: HerculesDataType) => { - expect(dataType.identifier.startsWith("GLS_"), `${dataType.identifier}: Identifier should start with GLS_`).toBeTruthy() - expect(dataType.name || [], `${dataType.identifier}: Name should be set`).not.toHaveLength(0) - expect(dataType.displayMessage || [], `${dataType.identifier}: Display message should be set`).not.toHaveLength(0) - }) - - state.configDefinitions?.forEach(value => { - expect(value.name || [], `${value.identifier}: Name should be set`).not.toHaveLength(0) - expect(value.description || [], `${value.identifier}: Description should be set`).not.toHaveLength(0) - expect(value.linkedDataTypes || [], `${value.identifier}: Linked data types should be set`).not.toHaveLength(0) - }) - - state.flowTypes?.forEach(value => { - expect(value.identifier.startsWith("GLS_"), `${value.identifier}: Identifier should start with GLS_`).toBeTruthy() - expect(value.name || [], `${value.identifier}: Name should be set`).not.toHaveLength(0) - expect(value.description || [], `${value.identifier}: Description should be set`).not.toHaveLength(0) - expect(value.displayMessage || [], `${value.identifier}: Display message should be set`).not.toHaveLength(0) - expect(value.documentation || [], `${value.identifier}: Documentation should be set`).not.toHaveLength(0) - }) - - state.registeredFunctionDefinitions?.forEach(value => { - expect(value.definition.name || [], `${value.definition.runtimeName}: Name should be set`).not.toHaveLength(0) - expect(value.definition.description || [], `${value.definition.runtimeName}: Description should be set`).not.toHaveLength(0) - value.definition.parameters.forEach(param => { - expect(param.name || [], `${value.definition.runtimeName} parameter ${param.runtimeName}: Name should be set`).not.toHaveLength(0) - expect(param.description || [], `${value.definition.runtimeName} parameter ${param.runtimeName}: Description should be set`).not.toHaveLength(0) - }) - }) - }); -}); \ No newline at end of file diff --git a/actions/gls-action/src/index.ts b/actions/gls-action/src/index.ts index fe20c4e..f7bae4b 100644 --- a/actions/gls-action/src/index.ts +++ b/actions/gls-action/src/index.ts @@ -1,2463 +1,33 @@ +import {createSdk} from "@code0-tech/hercules" import { - createSdk, HerculesActionProjectConfiguration, - HerculesFunctionContext, - HerculesRuntimeFunctionDefinition, - RuntimeErrorException -} from "@code0-tech/hercules" -import { - cancelShipment, getAllowedServices, getEndOfDayInfo, - postShipmentHelper, - reprintParcel, updateParcelWeight, - validateShipment, - zodSchemaToTypescriptDefs + loadAllDefinitions } from "./helpers"; -import { - Address, - AddressSchema, - AllowedServicesRequestData, - AllowedServicesRequestDataSchema, - AllowedServicesResponseData, - AllowedServicesResponseDataSchema, - CancelShipmentRequestData, - CancelShipmentRequestDataSchema, - CancelShipmentResponseData, - CancelShipmentResponseDataSchema, - Consignee, - ConsigneeSchema, - CreateParcelsResponse, - CreateParcelsResponseSchema, - CreateShopDeliveryRequestDataSchema, - CustomContent, - CustomContentSchema, - EndOfDayRequestData, - EndOfDayRequestDataSchema, - EndOfDayResponseData, - PrintingOptions, - PrintingOptionsSchema, - ReprintParcelRequestData, - ReprintParcelRequestDataSchema, - ReprintParcelResponseData, - ReprintParcelResponseDataSchema, - ReturnLabels, - ReturnOptions, - ReturnOptionsSchema, - ShipmentRequestDataSchema, - ShipmentSchema, - ShipmentServiceSchema, - ShipmentUnit, - ShipmentUnitSchema, - ShipmentWithoutServices, - ShipmentWithoutServicesSchema, - ShipperSchema, UnitService, - UnitServiceSchema, - UpdateParcelWeightRequestData, - UpdateParcelWeightRequestDataSchema, - UpdateParcelWeightResponseData, - UpdateParcelWeightResponseDataSchema, - ValidateShipmentRequestData, - ValidateShipmentRequestDataSchema, - ValidateShipmentResponseData, - ValidateShipmentResponseDataSchema -} from "./types"; -const sdk = createSdk({ +export const sdk = createSdk({ authToken: process.env.HERCULES_AUTH_TOKEN || "", aquilaUrl: process.env.HERCULES_AQUILA_URL || "127.0.0.1:50051", actionId: process.env.HERCULES_ACTION_ID || "gls-action", version: process.env.HERCULES_SDK_VERSION || "0.0.0", }) -let types: Map - -types = new Map([ - ...zodSchemaToTypescriptDefs( - "GLS_SHIPMENT_WITHOUT_SERVICES", - ShipmentWithoutServicesSchema, - ), - ...zodSchemaToTypescriptDefs( - "GLS_SHIPMENT_REQUEST_DATA", - ShipmentRequestDataSchema, - { - GLS_ADDRESS: AddressSchema, - GLS_CONSIGNEE: ConsigneeSchema, - GLS_UNIT_SERVICE: UnitServiceSchema, - GLS_SHIPMENT_UNIT: ShipmentUnitSchema, - GLS_SHIPPER: ShipperSchema, - GLS_SHIPMENT_SERVICE: ShipmentServiceSchema, - GLS_SHIPMENT: ShipmentSchema, - GLS_PRINTING_OPTIONS: PrintingOptionsSchema, - GLS_RETURN_OPTIONS: ReturnOptionsSchema, - GLS_CUSTOM_CONTENT: CustomContentSchema, - } - ), - ...zodSchemaToTypescriptDefs( - "GLS_CREATE_PARCELS_RESPONSE", - CreateParcelsResponseSchema - ), - ...zodSchemaToTypescriptDefs( - "GLS_CANCEL_SHIPMENT_REQUEST_DATA", - CancelShipmentRequestDataSchema - ), - ...zodSchemaToTypescriptDefs( - "GLS_CANCEL_SHIPMENT_RESPONSE_DATA", - CancelShipmentResponseDataSchema - ), - ...zodSchemaToTypescriptDefs( - "GLS_ALLOWED_SERVICES_REQUEST_DATA", - AllowedServicesRequestDataSchema, - ), - ...zodSchemaToTypescriptDefs( - "GLS_ALLOWED_SERVICES_RESPONSE_DATA", - AllowedServicesResponseDataSchema, - ), - ...zodSchemaToTypescriptDefs( - "GLS_END_OF_DAY_REQUEST_DATA", - EndOfDayRequestDataSchema, - ), - ...zodSchemaToTypescriptDefs( - "GLS_END_OF_DAY_RESPONSE_DATA", - EndOfDayRequestDataSchema, - { - GLS_ADDRESS: AddressSchema - } - ), - ...zodSchemaToTypescriptDefs( - "GLS_UPDATE_PARCEL_WEIGHT_REQUEST_DATA", - UpdateParcelWeightRequestDataSchema - ), - ...zodSchemaToTypescriptDefs( - "GLS_UPDATE_PARCEL_WEIGHT_RESPONSE_DATA", - UpdateParcelWeightResponseDataSchema - ), - ...zodSchemaToTypescriptDefs( - "GLS_REPRINT_PARCEL_REQUEST_DATA", - ReprintParcelRequestDataSchema - ), - ...zodSchemaToTypescriptDefs( - "GLS_REPRINT_PARCEL_RESPONSE_DATA", - ReprintParcelResponseDataSchema, - ), - ...zodSchemaToTypescriptDefs( - "GLS_VALIDATE_SHIPMENT_REQUEST_DATA", - ValidateShipmentRequestDataSchema, - { - GLS_SHIPMENT: ShipmentSchema - } - ), - ...zodSchemaToTypescriptDefs( - "GLS_VALIDATE_SHIPMENT_RESPONSE_DATA", - ValidateShipmentResponseDataSchema - ), - ...zodSchemaToTypescriptDefs( - "RETURN_LABELS", - PrintingOptionsSchema, - ), - ...zodSchemaToTypescriptDefs( - "CREATE_SHOP_DELIVERY_REQUEST_DATA", - CreateShopDeliveryRequestDataSchema, - { - GLS_ADDRESS: AddressSchema, - GLS_CONSIGNEE: ConsigneeSchema, - GLS_UNIT_SERVICE: UnitServiceSchema, - GLS_SHIPMENT_UNIT: ShipmentUnitSchema, - GLS_SHIPPER: ShipperSchema, - GLS_SHIPMENT_SERVICE: ShipmentServiceSchema, - GLS_SHIPMENT: ShipmentSchema, - GLS_PRINTING_OPTIONS: PrintingOptionsSchema, - GLS_RETURN_OPTIONS: ReturnOptionsSchema, - GLS_CUSTOM_CONTENT: CustomContentSchema, - } - ) -]) - -const defaultSignatureForServices = "shipment: GLS_SHIPMENT, printingOptions: GLS_PRINTING_OPTIONS, returnOptions?: GLS_RETURN_OPTIONS, customContent?: GLS_CUSTOM_CONTENT" -const defaultParametersForServices: HerculesRuntimeFunctionDefinition["parameters"] = [ - { - runtimeName: "shipment", - name: [ - { - code: "en-US", - content: "Shipment", - } - ], - description: [ - { - code: "en-US", - content: "The shipment for which to create the parcels. Must include all necessary information and services for the shipment.", - } - ] - }, - { - runtimeName: "printingOptions", - name: [ - { - code: "en-US", - content: "Printing options", - } - ], - description: [ - { - code: "en-US", - content: "The printing options for the shipment. Specifies options for the labels to be printed for the shipment.", - } - ] - }, - { - runtimeName: "returnOptions", - name: [ - { - code: "en-US", - content: "Return options", - } - ], - description: [ - { - code: "en-US", - content: "The return options for the shipment. Specifies options for return shipments.", - } - ] - }, - { - runtimeName: "customContent", - name: [ - { - code: "en-US", - content: "Custom content", - } - ], - description: [ - { - code: "en-US", - content: "The custom content for the shipment. Specifies options for custom content to be printed on the labels.", - } - ] - } -] -const defaultDataTypesForServices = [ - "GLS_SHIPMENT", - "GLS_PRINTING_OPTIONS", - "GLS_RETURN_OPTIONS", - "GLS_CUSTOM_CONTENT", - "GLS_CREATE_PARCELS_RESPONSE" -] - -sdk.registerFunctionDefinitions( - { - definition: { - runtimeName: "createAddress", - signature: "Name1: string, CountryCode: string, City: string, Street: string, ZIPCode: string, Name2?: string, Name3?: string, Province?: string, StreetNumber?: string, ContactPerson?: string, FixedLinePhonenumber?: string, MobilePhonenumber?: string, Email?: string): GLS_ADDRESS", - name: [ - { - code: "en-US", - content: "Create address", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS address object which can be used for shipments.", - } - ], - parameters: [ - { - runtimeName: "Name1", - name: [ - { - code: "en-US", - content: "Name 1", - } - ], - description: [ - { - code: "en-US", - content: "The name of the recipient or company. Max length is 40 characters.", - } - ] - }, - { - runtimeName: "CountryCode", - name: [ - { - code: "en-US", - content: "Country code", - } - ], - description: [ - { - code: "en-US", - content: "The ISO alpha-2 country code. For example, DE for Germany or FR for France.", - } - ] - }, - { - runtimeName: "City", - name: [ - { - code: "en-US", - content: "City", - } - ], - description: [ - { - code: "en-US", - content: "The city of the address. Max length is 40 characters.", - } - ] - }, - { - runtimeName: "Street", - name: [ - { - code: "en-US", - content: "Street", - } - ], - description: [ - { - code: "en-US", - content: "The street name of the address. Min length is 4 characters.", - } - ] - }, - { - runtimeName: "ZIPCode", - name: [ - { - code: "en-US", - content: "ZIP code", - } - ], - description: [ - { - code: "en-US", - content: "The ZIP code of the address. Max length is 10 characters.", - } - ] - }, - { - runtimeName: "Name2", - name: [ - { - code: "en-US", - content: "Name 2", - } - ], - description: [ - { - code: "en-US", - content: "Additional name information. Max length is 40 characters.", - } - ] - }, - { - runtimeName: "Name3", - name: [ - { - code: "en-US", - content: "Name 3", - } - ], - description: [ - { - code: "en-US", - content: "Additional name information. Max length is 40 characters.", - } - ] - }, - { - runtimeName: "Province", - name: [ - { - code: "en-US", - content: "Province/State", - } - ], - description: [ - { - code: "en-US", - content: "The province or state of the address. Max length is 40 characters.", - } - ] - }, - { - runtimeName: "StreetNumber", - name: [ - { - code: "en-US", - content: "Street number", - } - ], - description: [ - { - code: "en-US", - content: "The street number of the address. Max length is 40 characters.", - } - ] - }, - { - runtimeName: "ContactPerson", - name: [ - { - code: "en-US", - content: "Contact person", - } - ], - description: [ - { - code: "en-US", - content: "The contact person for the address. Max length is 40 characters.", - } - ] - }, - { - runtimeName: "FixedLinePhonenumber", - name: [ - { - code: "en-US", - content: "Fixed line phone number", - } - ], - description: [ - { - code: "en-US", - content: "The fixed line phone number for the address. Max length is 35 characters.", - } - ] - }, - { - runtimeName: "MobilePhonenumber", - name: [ - { - code: "en-US", - content: "Mobile phone number", - }, - ], - description: [ - { - code: "en-US", - content: "The mobile phone number for the address. Max length is 35 characters.", - } - ] - }, - { - runtimeName: "Email", - name: [ - { - code: "en-US", - content: "Email", - } - ], - description: [ - { - code: "en-US", - content: "The email address for the address. Max length is 80 characters.", - } - ] - } - ], - linkedDataTypes: [ - "GLS_ADDRESS", - ] - }, - handler: ( - Name1: string, - CountryCode: string, - City: string, - Street: string, - ZIPCode: string, - Name2?: string, - Name3?: string, - Province?: string, - StreetNumber?: string, - ContactPerson?: string, - FixedLinePhonenumber?: string, - MobilePhonenumber?: string, - Email?: string - ): Address => { - return { - Name1, - Name2, - Name3, - CountryCode, - Province, - City, - Street, - StreetNumber, - ContactPerson, - FixedLinePhonenumber, - MobilePhonenumber, - eMail: Email, - ZIPCode - } - } - }, - { - definition: { - runtimeName: "createConsignee", - name: [ - { - code: "en-US", - content: "Create consignee", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS consignee object which can be used for shipments.", - } - ], - signature: "(consigneeId: string, costCenter: string, Address: GLS_ADDRESS, Category: \"BUSINESS\"|\"PRIVATE\"): GLS_CONSIGNEE", - parameters: [ - { - runtimeName: "consigneeId", - name: [ - { - code: "en-US", - content: "Consignee ID", - } - ], - description: [ - { - code: "en-US", - content: "The ID of the consignee. Max length is 40 characters.", - } - ] - }, - { - runtimeName: "costCenter", - name: [ - { - code: "en-US", - content: "Cost center", - } - ], - description: [ - { - code: "en-US", - content: "The cost center for the consignee. Max length is 80 characters.", - } - ] - }, - { - runtimeName: "Address", - name: [ - { - code: "en-US", - content: "Address", - } - ], - description: [ - { - code: "en-US", - content: "The address of the consignee.", - } - ] - - }, - { - runtimeName: "Category", - name: [ - { - code: "en-US", - content: "Category", - } - ], - description: [ - { - code: "en-US", - content: "The category of the consignee. Can be either BUSINESS or PRIVATE.", - } - ] - } - ], - linkedDataTypes: [ - "GLS_CONSIGNEE", - "GLS_ADDRESS" - ] - }, - handler: (consigneeId: string, costCenter: string, Address: Address, Category: "BUSINESS" | "PRIVATE"): Consignee => { - return { - Address, - Category, - ConsigneeID: consigneeId, - CostCenter: costCenter - } - } - }, - { - definition: { - runtimeName: "createShipmentUnit", - signature: "(weight: number, shipmentUnitReference?: string, partnerParcelNumber?: string, note1?: string, note2?: string, shipmentUnitService: GLS_SHIPMENT_UNIT_SERVICE): GLS_SHIPMENT_UNIT", - name: [ - { - code: "en-US", - content: "Create shipment unit", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS shipment unit object which can be used for shipments.", - } - ], - parameters: [ - { - runtimeName: "weight", - name: [ - { - code: "en-US", - content: "Weight (kg)", - } - ], - description: [ - { - code: "en-US", - content: "The weight of the shipment unit in kilograms. Must be a positive number and greater than 0.10 and less than 99.", - } - ] - }, - { - runtimeName: "shipmentUnitReference", - name: [ - { - code: "en-US", - content: "Shipment unit reference", - } - ], - description: [ - { - code: "en-US", - content: "The reference for the shipment unit. Max length is 40 characters.", - } - ] - }, - { - runtimeName: "partnerParcelNumber", - name: [ - { - code: "en-US", - content: "Partner parcel number", - } - ], - description: [ - { - code: "en-US", - content: "The partner parcel number for the shipment unit. Max length is 50 characters.", - } - ] - }, - { - runtimeName: "note1", - name: [ - { - code: "en-US", - content: "Note 1", - } - ], - description: [ - { - code: "en-US", - content: "Note 1 for the shipment unit. Max length is 50 characters.", - } - ] - }, - { - runtimeName: "note2", - name: [ - { - code: "en-US", - content: "Note 2", - } - ], - description: [ - { - code: "en-US", - content: "Note 2 for the shipment unit. Max length is 50 characters.", - } - ] - }, - { - runtimeName: "shipmentUnitService", - name: [ - { - code: "en-US", - content: "Shipment unit service", - } - ], - description: [ - { - code: "en-US", - content: "The service associated with the shipment unit.", - } - ] - } - ], - linkedDataTypes: [ - "GLS_SHIPMENT_UNIT", - ] - }, - handler: (weight: number, shipmentUnitReference: string, partnerParcelNumber?: string, note1?: string, note2?: string, shipmentUnitService?: UnitService): ShipmentUnit => { - return { - ShipmentUnitReference: shipmentUnitReference, - Weight: weight, - PartnerParcelNumber: partnerParcelNumber, - Note1: note1, - Note2: note2, - Service: shipmentUnitService - } - } - }, - { - definition: { - runtimeName: "createPrintingOptions", - signature: "(returnLabels: RETURN_LABELS): GLS_PRINTING_OPTIONS", - name: [ - { - code: "en-US", - content: "Create printing options", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS printing options object which can be used when creating shipments.", - } - ], - parameters: [ - { - runtimeName: "returnLabels", - name: [ - { - code: "en-US", - content: "Return labels", - } - ], - description: [ - { - code: "en-US", - content: "The return labels to be included in the shipment.", - } - ] - } - ], - linkedDataTypes: [ - "GLS_PRINTING_OPTIONS", - "RETURN_LABELS" - ] - }, - handler: (returnLabels: ReturnLabels): PrintingOptions => { - return { - ReturnLabels: returnLabels - } - } - }, - { - definition: { - runtimeName: "createCustomContent", - signature: "(barcodeContentType: \"TRACK_ID\"|\"GLS_SHIPMENT_REFERENCE\", customerLogo: string, hideShipperAddress?: boolean, barcodeType?: \"EAN_128\"|\"CODE_39\", barcode?: string): GLS_CUSTOM_CONTENT", - name: [ - { - code: "en-US", - content: "Create custom content", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS custom content object for shipment labels.", - } - ], - parameters: [ - { - runtimeName: "barcodeContentType", - name: [ - {code: "en-US", content: "Barcode content type"} - ], - description: [ - { - code: "en-US", - content: "Type of content encoded in the barcode (TRACK_ID or GLS_SHIPMENT_REFERENCE)." - } - ] - }, - { - runtimeName: "customerLogo", - name: [ - {code: "en-US", content: "Customer logo"} - ], - description: [ - {code: "en-US", content: "Base64-encoded customer logo to print on the label."} - ] - }, - { - runtimeName: "hideShipperAddress", - name: [ - {code: "en-US", content: "Hide shipper address"} - ], - description: [ - {code: "en-US", content: "Whether to hide the shipper address on the label."} - ] - }, - { - runtimeName: "barcodeType", - name: [ - {code: "en-US", content: "Barcode type"} - ], - description: [ - {code: "en-US", content: "Type of barcode to use (EAN_128 or CODE_39)."} - ] - }, - { - runtimeName: "barcode", - name: [ - {code: "en-US", content: "Barcode"} - ], - description: [ - {code: "en-US", content: "Barcode value to print on the label."} - ] - } - ], - linkedDataTypes: [ - "GLS_CUSTOM_CONTENT", - ] - }, - handler: (barcodeContentType: CustomContent["BarcodeContentType"], customerLogo: string, hideShipperAddress?: boolean, barcodeType?: CustomContent["BarcodeType"], barcode?: string): CustomContent => { - return { - Barcode: barcode, - BarcodeContentType: barcodeContentType, - BarcodeType: barcodeType, - CustomerLogo: customerLogo, - HideShipperAddress: hideShipperAddress, - } - } - }, - { - definition: { - runtimeName: "createShopDeliveryShipment", - name: [ - { - code: "en-US", - content: "Create shop delivery shipment", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS shop delivery shipment.", - } - ], - signature: `(parcelShopId: string, ${defaultSignatureForServices}): GLS_CREATE_PARCELS_RESPONSE`, - parameters: [ - { - runtimeName: "parcelShopId", - name: [ - { - code: "en-US", - content: "Parcel shop Id", - } - ], - description: [ - { - code: "en-US", - content: "The ID of the parcel shop where the shipment should be delivered.", - } - ] - }, - ...defaultParametersForServices - ], - linkedDataTypes: [ - ...defaultDataTypesForServices - ] - }, - handler: async (context: HerculesFunctionContext, parcelShopId: string, shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions): Promise => { - return postShipmentHelper(context, [{ - ShopDelivery: { - ParcelShopID: parcelShopId - } - }], shipment, printingOptions, customContent, returnOptions) - } - }, - { - definition: { - runtimeName: "createShopReturnShipment", - name: [ - { - code: "en-US", - content: "Create shop return shipment", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS shop return shipment.", - } - ], - signature: `(numberOfLabels: number, ${defaultSignatureForServices}, returnQR: "PDF" | "PNG" | "ZPL"): GLS_CREATE_PARCELS_RESPONSE`, - parameters: [ - { - runtimeName: "parcelShopId", - name: [ - { - code: "en-US", - content: "Parcel shop Id", - } - ], - description: [ - { - code: "en-US", - content: "The ID of the parcel shop where the shipment should be delivered.", - } - ] - }, - ...defaultParametersForServices, - { - runtimeName: "returnQR", - name: [ - { - code: "en-US", - content: "Return QR", - } - ], - description: [ - { - code: "en-US", - content: "The return QR of the shipment.", - } - ] - } - ], - linkedDataTypes: [ - ...defaultDataTypesForServices - ] - }, - handler: async (context: HerculesFunctionContext, numberOfLabels: number, shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, returnQR?: "PDF" | "PNG" | "ZPL"): Promise => { - return postShipmentHelper(context, [{ - ShopReturn: { - NumberOfLabels: numberOfLabels, - ReturnQR: returnQR - } - }], shipment, printingOptions, customContent, returnOptions) - } - }, - { - definition: { - runtimeName: "createExchangeShipment", - name: [ - { - code: "en-US", - content: "Create exchange shipment", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS exchange shipment.", - } - ], - signature: `(address: GLS_ADDRESS, ${defaultSignatureForServices}, expectedWeight?: number): GLS_CREATE_PARCELS_RESPONSE`, - parameters: [ - { - runtimeName: "address", - name: [ - { - code: "en-US", - content: "Address", - } - ], - description: [ - { - code: "en-US", - content: "The address of the exchange shipment.", - } - ] - }, - ...defaultParametersForServices, - { - runtimeName: "expectedWeight", - name: [ - { - code: "en-US", - content: "Expected weight", - } - ], - description: [ - { - code: "en-US", - content: "The expected weight for the exchange shipment.", - } - ] - } - ], - linkedDataTypes: [ - ...defaultDataTypesForServices, - "GLS_ADDRESS" - ] - }, - handler: async (context: HerculesFunctionContext, - address: Address, - shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, - expectedWeight?: number): Promise => { - return postShipmentHelper(context, [{ - Exchange: { - Address: address, - ExpectedWeight: expectedWeight - } - }], shipment, printingOptions, customContent, returnOptions) - } - }, - { - definition: { - runtimeName: "createDeliveryAtWorkShipment", - name: [ - { - code: "en-US", - content: "Create delivery at work shipment", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS delivery at work shipment.", - } - ], - signature: `(recipientName: string, building: string, floor: number, ${defaultSignatureForServices}, alternateRecipientName?: string, room?: number, phonenumber?: string): GLS_CREATE_PARCELS_RESPONSE`, - parameters: [ - { - runtimeName: "recipientName", - name: [ - { - code: "en-US", - content: "Recipient name", - } - ], - description: [ - { - code: "en-US", - content: "The recipient name for the delivery at work shipment.", - } - ] - }, - { - runtimeName: "building", - name: [ - { - code: "en-US", - content: "Building", - } - ], - description: [ - { - code: "en-US", - content: "The building of the delivery at work shipment.", - } - ] - }, - { - runtimeName: "floor", - name: [ - { - code: "en-US", - content: "Floor", - } - ], - description: [ - { - code: "en-US", - content: "The floor of the delivery at work shipment.", - } - ] - }, - ...defaultParametersForServices, - { - runtimeName: "alternateRecipientName", - name: [ - { - code: "en-US", - content: "Alternate recipient name", - } - ], - description: [ - { - code: "en-US", - content: "The alternate recipient name for the delivery at work shipment.", - } - ] - }, - { - runtimeName: "room", - name: [ - { - code: "en-US", - content: "Room", - } - ], - description: [ - { - code: "en-US", - content: "The room of the delivery at work shipment.", - } - ] - }, - { - runtimeName: "phonenumber", - name: [ - { - code: "en-US", - content: "Phone number", - } - ], - description: [ - { - code: "en-US", - content: "The phone number for the delivery at work shipment.", - } - ] - } - ], - linkedDataTypes: [ - ...defaultDataTypesForServices, - ] - }, - handler: async (context: HerculesFunctionContext, - recipientName: string, building: string, floor: number, - shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, - alternateRecipientName?: string, room?: number, phonenumber?: string): Promise => { - return postShipmentHelper(context, [{ - DeliveryAtWork: { - RecipientName: recipientName, - Building: building, - Floor: floor, - AlternateRecipientName: alternateRecipientName, - Room: room, - Phonenumber: phonenumber, - } - }], shipment, printingOptions, customContent, returnOptions) - } - }, - { - definition: { - runtimeName: "createDepositShipment", - name: [ - { - code: "en-US", - content: "Create deposit shipment", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS deposit shipment.", - } - ], - signature: `(placeOfDeposit: string, ${defaultSignatureForServices}): GLS_CREATE_PARCELS_RESPONSE`, - parameters: [ - { - runtimeName: "placeOfDeposit", - name: [ - { - code: "en-US", - content: "Place of deposit", - } - ], - description: [ - { - code: "en-US", - content: "The place of deposit for the delivery.", - } - ] - }, - ...defaultParametersForServices, - ], - linkedDataTypes: [ - ...defaultDataTypesForServices, - ] - }, - handler: - async (context: HerculesFunctionContext, - placeOfDeposit: string, - shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions): Promise => { - return postShipmentHelper(context, [{ - Deposit: { - PlaceOfDeposit: placeOfDeposit - } - }], shipment, printingOptions, customContent, returnOptions) - } - }, - { - definition: { - runtimeName: "createIdentShipment", - name: [ - { - code: "en-US", - content: "Create ident shipment", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS ident shipment.", - } - ], - signature: `(birthDate: string, firstName: string, lastName: string, nationality: string, ${defaultSignatureForServices}): GLS_CREATE_PARCELS_RESPONSE`, - parameters: [ - { - runtimeName: "birthDate", - name: [ - { - code: "en-US", - content: "Birth date", - } - ], - description: [ - { - code: "en-US", - content: "The birth date for the ident shipment identification.", - } - ] - }, - { - runtimeName: "firstName", - name: [ - { - code: "en-US", - content: "First name", - } - ], - description: [ - { - code: "en-US", - content: "The first name for the ident shipment identification.", - } - ] - }, - { - runtimeName: "lastName", - name: [ - { - code: "en-US", - content: "Last name", - } - ], - description: [ - { - code: "en-US", - content: "The last name for the ident shipment identification.", - } - ] - }, - { - runtimeName: "nationality", - name: [ - { - code: "en-US", - content: "Nationality", - } - ], - description: [ - { - code: "en-US", - content: "The nationality for the ident shipment identification.", - } - ] - }, - ...defaultParametersForServices, - ], - linkedDataTypes: [ - ...defaultDataTypesForServices, - ] - }, - handler: - async (context: HerculesFunctionContext, - birthDate: string, firstName: string, lastName: string, nationality: string, - shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, - ): Promise => { - return postShipmentHelper(context, [{ - Ident: { - Birthdate: birthDate, - Firstname: firstName, - Lastname: lastName, - Nationality: nationality - } - }], shipment, printingOptions, customContent, returnOptions) - } - }, - { - definition: { - runtimeName: "createIdentPinShipment", - name: [ - { - code: "en-US", - content: "Create ident pin shipment", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS ident pin shipment.", - } - ], - signature: `(pin: string, ${defaultSignatureForServices}, birthDate: string): GLS_CREATE_PARCELS_RESPONSE`, - parameters: [ - { - runtimeName: "pin", - name: [ - { - code: "en-US", - content: "Pin", - } - ], - description: [ - { - code: "en-US", - content: "The pin for the ident pin shipment identification.", - } - ] - }, - ...defaultParametersForServices, - { - runtimeName: "birthDate", - name: [ - { - code: "en-US", - content: "Birth date", - } - ], - description: [ - { - code: "en-US", - content: "The birth date for the ident pin shipment identification.", - } - ] - } - ], - linkedDataTypes: [ - ...defaultDataTypesForServices, - ] - }, - handler: async (context: HerculesFunctionContext, - pin: string, - shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, - birthDate?: string - ): Promise => { - return postShipmentHelper(context, [{ - IdentPin: { - PIN: pin, - Birthdate: birthDate, - } - }], shipment, printingOptions, customContent, returnOptions) - } - }, - { - definition: { - runtimeName: "createPickAndShipShipment", - name: [ - { - code: "en-US", - content: "Create pick and ship shipment", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS pick and ship shipment.", - } - ], - signature: `(pickupDate: string, ${defaultSignatureForServices}): GLS_CREATE_PARCELS_RESPONSE`, - parameters: [ - { - runtimeName: "pickupDate", - name: [ - { - code: "en-US", - content: "Pickup date", - } - ], - description: [ - { - code: "en-US", - content: "The pickup date for the pick and ship shipment.", - } - ] - }, - ...defaultParametersForServices, - ], - linkedDataTypes: [ - ...defaultDataTypesForServices, - ] - }, - handler: async (context: HerculesFunctionContext, - pickupDate: string, - shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, - ): Promise => { - return postShipmentHelper(context, [{ - PickAndShip: { - PickupDate: pickupDate - } - }], shipment, printingOptions, customContent, returnOptions) - } - }, - { - definition: { - runtimeName: "createFlexDeliveryShipment", - name: [ - { - code: "en-US", - content: "Create flex delivery shipment", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS flex delivery shipment.", - } - ], - signature: `(${defaultSignatureForServices}): GLS_CREATE_PARCELS_RESPONSE`, - parameters: [ - ...defaultParametersForServices, - ], - linkedDataTypes: [ - ...defaultDataTypesForServices, - ] - }, - handler: async (context: HerculesFunctionContext, - shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, - ): Promise => { - return postShipmentHelper(context, [{ - FlexDeliveryService: {} - }], shipment, printingOptions, customContent, returnOptions) - } - }, - { - definition: { - runtimeName: "createSignatureShipment", - name: [ - { - code: "en-US", - content: "Create signature shipment", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS signature shipment.", - } - ], - signature: `(${defaultSignatureForServices}): GLS_CREATE_PARCELS_RESPONSE`, - parameters: [ - ...defaultParametersForServices, - ], - linkedDataTypes: [ - ...defaultDataTypesForServices, - ] - }, - handler: async (context: HerculesFunctionContext, - shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, - ): Promise => { - return postShipmentHelper(context, [{ - SignatureService: {} - }], shipment, printingOptions, customContent, returnOptions) - } - }, - { - definition: { - runtimeName: "createGuaranteed24Shipment", - name: [ - { - code: "en-US", - content: "Create guaranteed 24 shipment", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS guaranteed 24 shipment.", - } - ], - signature: `(${defaultSignatureForServices}): GLS_CREATE_PARCELS_RESPONSE`, - parameters: [ - ...defaultParametersForServices, - ], - linkedDataTypes: [ - ...defaultDataTypesForServices, - ] - }, - handler: async (context: HerculesFunctionContext, - shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, - ): Promise => { - return postShipmentHelper(context, [{ - Guaranteed24Service: {} - }], shipment, printingOptions, customContent, returnOptions) - } - }, - { - definition: { - runtimeName: "createAddresseeOnlyShipment", - name: [ - { - code: "en-US", - content: "Create addressee only shipment", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS addressee only shipment.", - } - ], - signature: `(${defaultSignatureForServices}): GLS_CREATE_PARCELS_RESPONSE`, - parameters: [ - ...defaultParametersForServices, - ], - linkedDataTypes: [ - ...defaultDataTypesForServices, - ] - }, - handler: async (context: HerculesFunctionContext, - shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, - ): Promise => { - return postShipmentHelper(context, [{ - AddresseeOnlyService: {} - }], shipment, printingOptions, customContent, returnOptions) - } - }, - { - definition: { - runtimeName: "createTyreShipment", - name: [ - { - code: "en-US", - content: "Create tyre shipment", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS tyre shipment.", - } - ], - signature: `(${defaultSignatureForServices}): GLS_CREATE_PARCELS_RESPONSE`, - parameters: [ - ...defaultParametersForServices, - ], - linkedDataTypes: [ - ...defaultDataTypesForServices, - ] - }, - handler: async (context: HerculesFunctionContext, - shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, - ): Promise => { - return postShipmentHelper(context, [{ - TyreService: {} - }], shipment, printingOptions, customContent, returnOptions) - } - }, - { - definition: { - runtimeName: "createDeliveryNextWorkingDayShipment", - name: [ - { - code: "en-US", - content: "Create delivery next working day shipment", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS delivery next working day shipment.", - } - ], - signature: `(${defaultSignatureForServices}): GLS_CREATE_PARCELS_RESPONSE`, - parameters: [ - ...defaultParametersForServices, - ], - linkedDataTypes: [ - ...defaultDataTypesForServices, - ] - }, - handler: async (context: HerculesFunctionContext, - shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, - ): Promise => { - if (shipment.Product != "EXPRESS") { - throw new RuntimeErrorException("INVALID_PRODUCT", "The product for Delivery Next Working Day service must be EXPRESS.") - } - return postShipmentHelper(context, [{ - EOB: {} - }], shipment, printingOptions, customContent, returnOptions) - } - }, - { - definition: { - runtimeName: "createDeliverySaturdayShipment", - name: [ - { - code: "en-US", - content: "Create delivery Saturday shipment", - } - ], - description: [ - { - code: "en-US", - content: "Creates a GLS delivery Saturday shipment.", - } - ], - signature: `(${defaultSignatureForServices}): GLS_CREATE_PARCELS_RESPONSE`, - parameters: [ - ...defaultParametersForServices, - ], - linkedDataTypes: [ - ...defaultDataTypesForServices, - ] - }, - handler: async (context: HerculesFunctionContext, - shipment: ShipmentWithoutServices, printingOptions: PrintingOptions, customContent?: CustomContent, returnOptions?: ReturnOptions, - ): Promise => { - if (shipment.Product != "EXPRESS") { - throw new RuntimeErrorException("INVALID_PRODUCT", "The product for Delivery Friday service must be EXPRESS.") - } - return postShipmentHelper(context, [{ - SaturdayService: {} - }], shipment, printingOptions, customContent, returnOptions) - } - }, - { - definition: { - runtimeName: "validateShipment", - name: [ - { - code: "en-US", - content: "Validate shipment", - } - ], - description: [ - { - code: "en-US", - content: "Validates a GLS shipment.", - } - ], - signature: "(data: GLS_VALIDATE_SHIPMENT_REQUEST_DATA): GLS_VALIDATE_SHIPMENT_RESPONSE_DATA", - parameters: [ - { - runtimeName: "data", - name: [ - { - code: "en-US", - content: "Data", - } - ], - description: [ - { - code: "en-US", - content: "The shipment data to validate.", - } - ] - } - ], - linkedDataTypes: [ - "GLS_VALIDATE_SHIPMENT_REQUEST_DATA", - "GLS_VALIDATE_SHIPMENT_RESPONSE_DATA", - ], - }, - handler: async (data: ValidateShipmentRequestData, context: HerculesFunctionContext): Promise => { - try { - return await validateShipment(data, context) - } catch (error) { - if (typeof error === "string") { - throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", error) - } - throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", "An error occurred while creating the shipment.") - } - } - }, - { - definition: { - runtimeName: "cancelShipment", - name: [ - { - code: "en-US", - content: "Cancel shipment", - } - ], - description: [ - { - code: "en-US", - content: "Cancels a GLS shipment.", - } - ], - signature: "(data: GLS_CANCEL_SHIPMENT_REQUEST_DATA): GLS_CANCEL_SHIPMENT_RESPONSE_DATA", - parameters: [ - { - runtimeName: "data", - name: [ - { - code: "en-US", - content: "Data", - } - ], - description: [ - { - code: "en-US", - content: "The cancel shipment request data.", - } - ] - } - ], - linkedDataTypes: [ - "GLS_VALIDATE_SHIPMENT_REQUEST_DATA", - "GLS_VALIDATE_SHIPMENT_RESPONSE_DATA", - ], - }, - handler: async (data: CancelShipmentRequestData, context: HerculesFunctionContext): Promise => { - try { - return await cancelShipment(data, context) - } catch (error) { - if (typeof error === "string") { - throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", error) - } - throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", "An error occurred while creating the shipment.") - } - } - }, - { - definition: { - runtimeName: "getAllowedServices", - name: [ - { - code: "en-US", - content: "Get allowed services", - } - ], - description: [ - { - code: "en-US", - content: "Returns the allowed GLS services for a given set of parameters.", - } - ], - signature: "(data: GLS_ALLOWED_SERVICES_REQUEST_DATA): GLS_ALLOWED_SERVICES_RESPONSE_DATA", - parameters: [ - { - runtimeName: "data", - name: [ - { - code: "en-US", - content: "Data", - } - ], - description: [ - { - code: "en-US", - content: "The allowed services request data.", - } - ] - } - ], - linkedDataTypes: [ - "GLS_ALLOWED_SERVICES_REQUEST_DATA", - "GLS_ALLOWED_SERVICES_RESPONSE_DATA", - ], - }, - handler: async (data: AllowedServicesRequestData, context: HerculesFunctionContext): Promise => { - try { - return await getAllowedServices(data, context) - } catch (error) { - if (typeof error === "string") { - throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", error) - } - throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", "An error occurred while creating the shipment.") - } - } - }, - { - definition: { - runtimeName: "getEndOfDayReport", - name: [ - { - code: "en-US", - content: "Get end of day report", - } - ], - description: [ - { - code: "en-US", - content: "Returns the GLS end of day report.", - } - ], - signature: "(data: GLS_END_OF_DAY_REQUEST_DATA): GLS_END_OF_DAY_RESPONSE_DATA", - parameters: [ - { - runtimeName: "data", - name: [ - { - code: "en-US", - content: "Data", - } - ], - description: [ - { - code: "en-US", - content: "The end of day report request data.", - } - ] - } - ], - linkedDataTypes: [ - "GLS_END_OF_DAY_REQUEST_DATA", - "GLS_END_OF_DAY_RESPONSE_DATA", - ], - }, - handler: async (data: EndOfDayRequestData, context: HerculesFunctionContext): Promise => { - try { - return await getEndOfDayInfo(data, context) - } catch (error) { - if (typeof error === "string") { - throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", error) - } - throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", "An error occurred while creating the shipment.") - } - } - }, - { - definition: { - runtimeName: "updateParcelWeight", - name: [ - { - code: "en-US", - content: "Update parcel weight", - } - ], - description: [ - { - code: "en-US", - content: "Updates the weight of a GLS parcel.", - } - ], - signature: "(data: GLS_UPDATE_PARCEL_WEIGHT_REQUEST_DATA): GLS_END_OF_DAY_RESPONSE_DATA", - parameters: [ - { - runtimeName: "data", - name: [ - { - code: "en-US", - content: "Data", - } - ], - description: [ - { - code: "en-US", - content: "The update parcel weight request data.", - } - ] - } - ], - linkedDataTypes: [ - "GLS_UPDATE_PARCEL_WEIGHT_REQUEST_DATA", - "GLS_UPDATE_PARCEL_WEIGHT_RESPONSE_DATA", - ], - }, - handler: async (data: UpdateParcelWeightRequestData, context: HerculesFunctionContext): Promise => { - try { - return await updateParcelWeight(data, context) - } catch (error) { - if (typeof error === "string") { - throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", error) - } - throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", "An error occurred while creating the shipment.") - } - } - }, - { - definition: { - runtimeName: "reprintParcel", - name: [ - { - code: "en-US", - content: "Reprint parcel", - } - ], - description: [ - { - code: "en-US", - content: "Reprints the labels for a GLS parcel.", - } - ], - signature: "(data: GLS_REPRINT_PARCEL_REQUEST_DATA): GLS_REPRINT_PARCEL_RESPONSE_DATA", - parameters: [ - { - runtimeName: "data", - name: [ - { - code: "en-US", - content: "Data", - } - ], - description: [ - { - code: "en-US", - content: "The reprint parcel request data.", - } - ] - } - ], - linkedDataTypes: [ - "GLS_REPRINT_PARCEL_REQUEST_DATA", - "GLS_REPRINT_PARCEL_RESPONSE_DATA", - ], - }, - handler: async (data: ReprintParcelRequestData, context: HerculesFunctionContext): Promise => { - try { - return await reprintParcel(data, context) - } catch (error) { - if (typeof error === "string") { - throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", error) - } - throw new RuntimeErrorException("ERROR_CREATING_GLS_SHIPMENT", "An error occurred while creating the shipment.") - } - } +async function main() { + try { + await loadAllDefinitions(sdk) + connectToSdk() + } catch (error) { + console.error(error) } -) - -sdk.registerDataTypes( - { - identifier: "GLS_ADDRESS", - type: types.get("GLS_ADDRESS")!!, - name: [ - { - code: "en-US", - content: "Address" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Address" - } - ] - }, - { - identifier: "GLS_CONSIGNEE", - type: types.get("GLS_CONSIGNEE")!!, - name: [ - { - code: "en-US", - content: "Consignee" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Consignee" - } - ], - linkedDataTypes: [ - "GLS_ADDRESS" - ] - }, - { - identifier: "GLS_UNIT_SERVICE", - type: types.get("GLS_UNIT_SERVICE")!!, - name: [ - { - code: "en-US", - content: "Unit Service" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Unit Service" - } - ] - }, - { - identifier: "GLS_SHIPMENT_UNIT", - type: types.get("GLS_SHIPMENT_UNIT")!!, - name: [ - { - code: "en-US", - content: "Shipment Unit" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Shipment Unit" - } - ], - linkedDataTypes: [ - "GLS_UNIT_SERVICE", - ] - }, - { - identifier: "GLS_SHIPPER", - type: types.get("GLS_SHIPPER")!!, - name: [ - { - code: "en-US", - content: "Shipper" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Shipper" - } - ], - linkedDataTypes: [ - "GLS_ADDRESS" - ] - }, - { - identifier: "GLS_SHIPMENT_SERVICE", - type: types.get("GLS_SHIPMENT_SERVICE")!!, - name: [ - { - code: "en-US", - content: "Shipment Service" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Shipment Service" - } - ] - }, - { - identifier: "GLS_SHIPMENT", - type: types.get("GLS_SHIPMENT")!!, - name: [ - { - code: "en-US", - content: "Shipment" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Shipment" - } - ], - linkedDataTypes: [ - "GLS_SHIPMENT_SERVICE", - "GLS_ADDRESS", - "GLS_SHIPMENT_UNIT", - "GLS_CONSIGNEE", - "GLS_SHIPPER" - ] - }, - { - identifier: "GLS_PRINTING_OPTIONS", - type: types.get("GLS_PRINTING_OPTIONS")!!, - name: [ - { - code: "en-US", - content: "Printing Options" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Printing Options" - } - ] - }, - { - identifier: "GLS_RETURN_OPTIONS", - type: types.get("GLS_RETURN_OPTIONS")!!, - name: [ - { - code: "en-US", - content: "Return Options" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Return Options" - } - ] - }, - { - identifier: "GLS_CUSTOM_CONTENT", - type: types.get("GLS_CUSTOM_CONTENT")!!, - name: [ - { - code: "en-US", - content: "Custom content" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Custom content" - } - ] - }, - { - identifier: "GLS_SHIPMENT_WITHOUT_SERVICES", - type: types.get("GLS_SHIPMENT_WITHOUT_SERVICES")!!, - name: [ - { - code: "en-US", - content: "Shipment without services" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Shipment without services" - } - ], - linkedDataTypes: [ - "GLS_SHIPMENT", - "GLS_PRINTING_OPTIONS", - "GLS_RETURN_OPTIONS", - "GLS_CUSTOM_CONTENT" - ] - }, - { - identifier: "GLS_CREATE_PARCELS_RESPONSE", - type: types.get("GLS_CREATE_PARCELS_RESPONSE")!!, - name: [ - { - code: "en-US", - content: "Create parcels response" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Create parcels response" - } - ] - }, - { - identifier: "GLS_CANCEL_SHIPMENT_REQUEST_DATA", - type: types.get("GLS_CANCEL_SHIPMENT_REQUEST_DATA")!!, - name: [ - { - code: "en-US", - content: "Cancel shipment request data" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Cancel shipment request data" - } - ] - }, - { - identifier: "GLS_CANCEL_SHIPMENT_RESPONSE_DATA", - type: types.get("GLS_CANCEL_SHIPMENT_RESPONSE_DATA")!!, - name: [ - { - code: "en-US", - content: "Cancel shipment response data" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Cancel shipment response data" - } - ] - }, - { - identifier: "GLS_ALLOWED_SERVICES_REQUEST_DATA", - type: types.get("GLS_ALLOWED_SERVICES_REQUEST_DATA")!!, - name: [ - { - code: "en-US", - content: "Allowed services request data" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Allowed services request data" - } - ] - }, - { - identifier: "GLS_ALLOWED_SERVICES_RESPONSE_DATA", - type: types.get("GLS_ALLOWED_SERVICES_RESPONSE_DATA")!!, - name: [ - { - code: "en-US", - content: "Allowed services response data" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Allowed services response data" - } - ] - }, - { - identifier: "GLS_END_OF_DAY_REQUEST_DATA", - type: types.get("GLS_END_OF_DAY_REQUEST_DATA")!!, - name: [ - { - code: "en-US", - content: "End of day request data" - } - ], - displayMessage: [ - { - code: "en-US", - content: "End of day request data" - } - ] - }, - { - identifier: "GLS_END_OF_DAY_RESPONSE_DATA", - type: types.get("GLS_END_OF_DAY_RESPONSE_DATA")!!, - name: [ - { - code: "en-US", - content: "End of day response data" - } - ], - displayMessage: [ - { - code: "en-US", - content: "End of day response data" - } - ] - }, - { - identifier: "GLS_UPDATE_PARCEL_WEIGHT_REQUEST_DATA", - type: types.get("GLS_UPDATE_PARCEL_WEIGHT_REQUEST_DATA")!!, - name: [ - { - code: "en-US", - content: "Update parcel weight request data" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Update parcel weight request data" - } - ] - }, - { - identifier: "GLS_UPDATE_PARCEL_WEIGHT_RESPONSE_DATA", - type: types.get("GLS_UPDATE_PARCEL_WEIGHT_RESPONSE_DATA")!!, - name: [ - { - code: "en-US", - content: "Update parcel weight response data" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Update parcel weight response data" - } - ] - }, - { - identifier: "GLS_REPRINT_PARCEL_REQUEST_DATA", - type: types.get("GLS_REPRINT_PARCEL_REQUEST_DATA")!!, - name: [ - { - code: "en-US", - content: "Reprint parcel request data" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Reprint parcel request data" - } - ] - }, - { - identifier: "GLS_REPRINT_PARCEL_RESPONSE_DATA", - type: types.get("GLS_REPRINT_PARCEL_RESPONSE_DATA")!!, - name: [ - { - code: "en-US", - content: "Reprint parcel response data" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Reprint parcel response data" - } - ] - }, - { - identifier: "GLS_VALIDATE_SHIPMENT_REQUEST_DATA", - type: types.get("GLS_VALIDATE_SHIPMENT_REQUEST_DATA")!!, - name: [ - { - code: "en-US", - content: "Validate shipment request data" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Validate shipment request data" - } - ] - }, - { - identifier: "GLS_VALIDATE_SHIPMENT_RESPONSE_DATA", - type: types.get("GLS_VALIDATE_SHIPMENT_RESPONSE_DATA")!!, - name: [ - { - code: "en-US", - content: "Validate shipment response data" - } - ], - displayMessage: [ - { - code: "en-US", - content: "Validate shipment response data" - } - ] - }, - { - identifier: "GLS_UNIT_SERVICE", - type: types.get("GLS_UNIT_SERVICE")!!, - name: [ - { - code: "en-US", - content: "GLS unit service" - } - ], - displayMessage: [ - { - code: "en-US", - content: "GLS unit service" - } - ] - } -) - - -sdk.registerConfigDefinitions( - { - identifier: "contact_id", - type: "STRING", - name: [ - { - code: "en-US", - content: "Contact ID" - } - ], - description: [ - { - code: "en-US", - content: "The contact id identifying the GLS account to use for the API requests. This contact must be linked to a GLS contract with API access." - } - ], - defaultValue: "", - linkedDataTypes: ["STRING"], - }, - { - identifier: "client_id", - type: "STRING", - name: [ - { - code: "en-US", - content: "Client ID" - } - ], - description: [ - { - code: "en-US", - content: "The client id to authenticate with the GLS API" - } - ], - linkedDataTypes: ["STRING"], - }, - { - identifier: "client_secret", - type: "STRING", - name: [ - { - code: "en-US", - content: "Client secret" - } - ], - description: [ - { - code: "en-US", - content: "The client secret to authenticate with the GLS API" - } - ], - linkedDataTypes: ["STRING"], - }, - { - identifier: "ship_it_api_url", - type: "STRING", - defaultValue: " https://api.gls-group.net/shipit-farm/v1/backend/rs", - name: [ - { - code: "en-US", - content: "The ShipIt API url" - } - ], - description: [ - { - code: "en-US", - content: "The url of the GLS ShipIt API." - } - ], - linkedDataTypes: ["STRING"], - }, - { - identifier: "auth_url", - type: "STRING", - defaultValue: "https://api.gls-group.net/oauth2/v2/token", - name: [ - { - code: "en-US", - content: "The Auth API url" - } - ], - description: [ - { - code: "en-US", - content: "The url of the Auth api ending in /token." - } - ], - linkedDataTypes: ["STRING"], - }, - { - identifier: "shipper", - type: "GLS_SHIPPER", - name: [ - { - code: "en-US", - content: "Shipper" - } - ], - description: [ - { - code: "en-US", - content: "The shipper information to use for the shipments. This will be used if the shipper information is not provided in the shipment data." - } - ], - linkedDataTypes: ["GLS_SHIPPER"] - } -).catch(reason => { - console.error("Failed to register config definitions:", reason) +} +main().catch(err => { + console.error(err) process.exit(1) }) -connectToSdk(); function connectToSdk() { - sdk.connect().then((_: HerculesActionProjectConfiguration[]) => { + sdk.connect().then(() => { console.log("SDK connected successfully"); - }).catch((_error) => { + }).catch(() => { console.error("Error connecting SDK:"); }) @@ -2468,4 +38,4 @@ function connectToSdk() { connectToSdk(); }, 5000) }) -} +} \ No newline at end of file diff --git a/actions/gls-action/src/types.ts b/actions/gls-action/src/types.ts deleted file mode 100644 index 6438c4b..0000000 --- a/actions/gls-action/src/types.ts +++ /dev/null @@ -1,601 +0,0 @@ -import {z} from 'zod'; - -export const AddressSchema = z.object({ - Name1: z.string().max(40), - Name2: z.string().max(40).optional(), - Name3: z.string().max(40).optional(), - CountryCode: z.string().max(2), - Province: z.string().max(40).optional(), - City: z.string().max(40), - Street: z.string().min(4), - StreetNumber: z.string().max(40).optional(), - ContactPerson: z.string().max(40).min(6).optional(), - FixedLinePhonenumber: z.string().max(35).min(4).optional(), - MobilePhonenumber: z.string().max(35).min(4).optional(), - eMail: z.string().max(80).optional(), - ZIPCode: z.string().max(10), -}) - -export type Address = z.infer - -export const ConsigneeSchema = z.object({ - ConsigneeID: z.string().max(40).optional(), - CostCenter: z.string().max(80).optional(), - Category: z.enum(["BUSINESS", "PRIVATE"]).optional(), - Address: AddressSchema -}) - -export type Consignee = z.infer - -export const ShipperSchema = z.object({ - AlternativeShipperAddress: AddressSchema.optional(), - Address: AddressSchema.optional(), -}) - -export type Shipper = z.infer - -export const InternalShipperSchema = ShipperSchema.extend({ - ContactID: z.string().optional() -}) - -export type InternalShipper = z.infer - -export const UnitServiceSchema = z.array(z.object({ - Cash: z.object({ - Reason: z.string().max(160), - Amount: z.number().min(1), - Currency: z.string().max(3).min(3) - }).optional(), - AddonLiability: z.object({ - Amount: z.number().min(1), - Currency: z.string().max(3).min(3), - ParcelContent: z.string().max(255) - }).optional(), - HazardousGoods: z.object({ - HarzardousGood: z.array( - z.object({ - Weight: z.number().min(1), - GLSHazNo: z.string().max(8) - })) - }).optional(), - ExWorks: z.object({}).optional(), - LimitedQuantities: z.object({ - Weight: z.number().optional() - }).optional() -})).optional() - -export type UnitService = z.infer - -// adding all service names -export const InternalUnitServiceSchema = z.array(z.object({ - Cash: z.object({ - serviceName: z.string("service_cash"), - Reason: z.string(), - Amount: z.number(), - Currency: z.string() - }).optional(), - AddonLiability: z.object({ - serviceName: z.string("service_addonliability"), - Amount: z.number(), - Currency: z.string(), - ParcelContent: z.string() - }).optional(), - HazardousGoods: z.object({ - serviceName: z.string("service_hazardousgoods"), - HarzardousGood: z.array( - z.object({ - Weight: z.number(), - GLSHazNo: z.string() - })) - }), - ExWorks: z.object({ - serviceName: z.string("service_exworks"), - }).optional(), - LimitedQuantities: z.object({ - serviceName: z.string("service_limitedquantities"), - Weight: z.number().optional() - }).optional() -})).optional() - - -export const ShipmentUnitSchema = z.array( - z.object({ - ShipmentUnitReference: z.string().max(40).optional(), - PartnerParcelNumber: z.string().max(50).optional(), - Weight: z.number().min(0.10).max(99), - Note1: z.string().max(50).optional(), - Note2: z.string().max(50).optional(), - Service: UnitServiceSchema, - }) -).min(1) - -export type ShipmentUnit = z.infer - -export const InternalShipmentUnitSchema = ShipmentUnitSchema.element.extend( - { - Service: InternalUnitServiceSchema.optional() - } -).array().min(1) - - -export const ShipmentServiceSchema = z.array(z.object({ - Service: z.object({ - serviceName: z.string() - }).optional(), - ShopDelivery: z.object({ - ParcelShopID: z.string().max(50) - }).optional(), - ShopReturn: z.object({ - NumberOfLabels: z.number(), - ReturnQR: z.enum(["PDF", "PNG", "ZPL"]).optional() - }).optional(), - Intercompany: z.object({ - Address: AddressSchema, - NumberOfLabels: z.number().min(1), - ExpectedWeight: z.number().min(1).optional() - }).optional(), - Exchange: z.object({ - Address: AddressSchema, - ExpectedWeight: z.number().min(1).optional() - }).optional(), - DeliveryAtWork: z.object({ - RecipientName: z.string().max(40), - AlternateRecipientName: z.string().max(40).optional(), - Building: z.string().max(40), - Floor: z.number(), - Room: z.number().optional(), - Phonenumber: z.string().max(35).optional() - }).optional(), - Deposit: z.object({ - PlaceOfDeposit: z.string().max(121), - }).optional(), - IdentPin: z.object({ - PIN: z.string().max(4), - Birthdate: z.iso.date().optional() - }).optional(), - Ident: z.object({ - Birthdate: z.iso.date(), - Firstname: z.string().max(40), - Lastname: z.string().max(40), - Nationality: z.string().max(2) - }).optional(), - PickAndShip: z.object({ - PickupDate: z.iso.date(), - }).optional(), - PickAndReturn: z.object({ - PickupDate: z.iso.date(), - }).optional(), - InboundLogistics: z.object().optional(), - DocumentReturnService: z.object().optional(), - CompleteDeliveryConsignmentService: z.object().optional(), - FlexDeliveryService: z.object().optional(), - SignatureService: z.object().optional(), - T24Service: z.object().optional(), - T48Service: z.object().optional(), - Guaranteed24Service: z.object().optional(), - AddresseeOnlyService: z.object().optional(), - TyreService: z.object().optional(), - '0800Service': z.object().optional(), - '0900Service': z.object().optional(), - '1000Service': z.object().optional(), - '1200Service': z.object().optional(), - '1300Service': z.object().optional(), - EOB: z.object().optional(), - Saturday1000Service: z.object().optional(), - Saturday1200Service: z.object().optional(), - SaturdayService: z.object().optional(), -})).optional() - -export type ShipmentService = z.infer - -export const InternalShipmentServiceSchema = z.array(z.object({ - Service: z.object({ - serviceName: z.string() - }).optional(), - ShopDelivery: z.object({ - serviceName: z.string().default("service_shopdelivery"), - ParcelShopID: z.string().max(50) - }).optional(), - ShopReturn: z.object({ - serviceName: z.string().default("service_shopreturn"), - NumberOfLabels: z.number(), - ReturnQR: z.enum(["PDF", "PNG", "ZPL"]).optional() - }).optional(), - Intercompany: z.object({ - serviceName: z.string().default("service_intercompany"), - Address: AddressSchema, - NumberOfLabels: z.number().min(1), - ExpectedWeight: z.number().min(1).optional() - }).optional(), - Exchange: z.object({ - serviceName: z.string().default("service_exchange"), - Address: AddressSchema, - ExpectedWeight: z.number().min(1).optional() - }).optional(), - DeliveryAtWork: z.object({ - serviceName: z.string().default("service_deliveryatwork"), - RecipientName: z.string().max(40), - AlternateRecipientName: z.string().max(40).optional(), - Building: z.string().max(40), - Floor: z.number(), - Room: z.number().optional(), - Phonenumber: z.string().max(35).optional() - }).optional(), - Deposit: z.object({ - serviceName: z.string().default("service_deposit"), - PlaceOfDeposit: z.string().max(121), - }).optional(), - IdentPin: z.object({ - serviceName: z.string().default("service_identpin"), - PIN: z.string().max(4), - Birthdate: z.date().optional() - }).optional(), - Ident: z.object({ - serviceName: z.string().default("service_ident"), - Birthdate: z.date(), - Firstname: z.string().max(40), - Lastname: z.string().max(40), - Nationality: z.string().max(2) - }).optional(), - PickAndShip: z.object({ - serviceName: z.string().default("service_pickandship"), - PickupDate: z.date(), - }).optional(), - PickAndReturn: z.object({ - serviceName: z.string().default("service_pickandreturn"), - PickupDate: z.date(), - }).optional(), - InboundLogistics: z.object({ - serviceName: z.string().default("service_inbound"), - }).optional(), - DocumentReturnService: z.object({ - serviceName: z.string().default("service_documentreturn"), - }).optional(), - CompleteDeliveryConsignmentService: z.object({ - serviceName: z.string().default("service_completedeliveryconsignment"), - }).optional(), - FlexDeliveryConsignmentService: z.object({ - serviceName: z.string().default("service_flexdelivery"), - }).optional(), - SignatureService: z.object({ - serviceName: z.string().default("service_signature"), - }).optional(), - T24Service: z.object({ - serviceName: z.string().default("service_t24"), - }).optional(), - T48Service: z.object({ - serviceName: z.string().default("service_t48"), - }).optional(), - Guaranteed24Service: z.object({ - serviceName: z.string().default("service_guaranteed24"), - }).optional(), - AddresseeOnlyService: z.object({ - serviceName: z.string().default("service_addresseeonly"), - }).optional(), - TyreService: z.object({ - serviceName: z.string().default("service_tyre"), - }).optional(), - '0800Service': z.object({ - serviceName: z.string().default("service_0800"), - }).optional(), - '0900Service': z.object({ - serviceName: z.string().default("service_0900"), - }).optional(), - '1000Service': z.object({ - serviceName: z.string().default("service_1000"), - }).optional(), - '1200Service': z.object({ - serviceName: z.string().default("service_1200"), - }).optional(), - '1300Service': z.object({ - serviceName: z.string().default("service_1300"), - }).optional(), - Saturday1000Service: z.object({ - serviceName: z.string().default("service_saturday_1000"), - }).optional(), - Saturday1200Service: z.object({ - serviceName: z.string().default("service_saturday_1200"), - }).optional(), - SaturdayService: z.object({ - serviceName: z.string().default("service_Saturday"), - }).optional(), -})).optional() - -export const ShipmentSchema = z.object({ - ShipmentReference: z.string().max(40).optional(), - ShipmentDate: z.date().optional(), - IncotermCode: z.int().max(99).optional(), - Identifier: z.string().max(40).optional(), - Product: z.enum(["PARCEL", "EXPRESS"]), - ExpressAltDeliveryAllowed: z.boolean().optional(), - Consignee: ConsigneeSchema, - Shipper: ShipperSchema.optional(), - Carrier: z.enum(["ROYALMAIL"]).optional(), - ShipmentUnit: ShipmentUnitSchema, - Service: ShipmentServiceSchema, - Return: z.object({ - Address: AddressSchema - }).optional() -}) - -export const ShipmentWithoutServicesSchema = ShipmentSchema.omit({Service: true}) - -export type ShipmentWithoutServices = z.infer - -export type Shipment = z.infer - -export const InternalShipmentSchma = ShipmentSchema.extend({ - Middleware: z.string().max(40), - Shipper: InternalShipperSchema, - Service: InternalShipmentServiceSchema, - ShipmentUnit: InternalShipmentUnitSchema -}) - - -export const PrintingOptionsSchema = z.object({ - ReturnLabels: z.object({ - TemplateSet: z.enum([ - "NONE", "D_200", "PF_4_I", "PF_4_I_200", "PF_4_I_300", "PF_8_D_200", "T_200_BF", "T_300_BF", "ZPL_200", "ZPL_200_TRACKID_EAN_128", "ZPL_200_TRACKID_CODE_39", "ZPL_200_REFNO_EAN_128", "ZPL_200_REFNO_CODE_39", "ZPL_300", "ZPL_300_TRACKID_EAN_128", "ZPL_300_TRACKID_CODE_39", "ZPL_300_REFNO_EAN_128", "ZPL_300_REFNO_CODE_39" - ]), - LabelFormat: z.enum(["PDF", "ZEBRA", "INTERMEC", "DATAMAX", "TOSHIBA", "PNG"]) - }).optional(), - useDefault: z.string().max(7).optional(), - DefinePrinter: z.object({ - LabelPrinter: z.string().max(255).optional(), - DocumentPrinter: z.string().max(255).optional(), - }).optional(), -}) - -export type PrintingOptions = z.infer -export type ReturnLabels = z.infer - -export const ReturnOptionsSchema = z.object({ - ReturnPrintData: z.boolean().default(true).optional(), - ReturnRoutingInfo: z.boolean().default(true).optional() -}) - -export type ReturnOptions = z.infer - -export const CustomContentSchema = z.object({ - CustomerLogo: z.string(), - BarcodeContentType: z.enum(["TRACK_ID", "GLS_SHIPMENT_REFERENCE"]), - Barcode: z.string().optional(), - BarcodeType: z.enum(["EAN_128", "CODE_39"]).optional(), - HideShipperAddress: z.boolean().optional() -}) - -export type CustomContent = z.infer - -export const ShipmentRequestDataSchema = z.object({ - Shipment: ShipmentSchema, - PrintingOptions: PrintingOptionsSchema, - ReturnOptions: ReturnOptionsSchema.optional(), - CustomContent: CustomContentSchema.optional(), -}) - - -export const CreateShopDeliveryRequestDataSchema = z.object({ - ParcelShopID: z.string().max(50), - Shipment: ShipmentWithoutServicesSchema, - PrintingOptions: PrintingOptionsSchema, - ReturnOptions: ReturnOptionsSchema.optional(), - CustomContent: CustomContentSchema.optional(), -}) - -export type CreateShopDeliveryRequestData = z.infer - -export const InternalShipmentRequestDataSchema = ShipmentRequestDataSchema.extend({ - Shipment: InternalShipmentSchma, -}) - -export type InternalShipmentRequestData = z.infer - -export type ShipmentRequestData = z.infer - -export const CreateParcelsResponseSchema = z.object({ - CreatedShipment: z.object({ - ShipmentReference: z.array(z.string()), - ParcelData: z.array(z.object({ - TrackID: z.string().min(8).max(8), - ParcelNumber: z.string(), - Barcodes: z.object({ - Primary2D: z.string(), - Secondary2D: z.string(), - Primary1D: z.string(), - Primary1DPrint: z.boolean(), - }), - RoutingInfo: z.object({ - Tour: z.string(), - InboundSortingFlag: z.string(), - FinalLocationCode: z.string(), - LastRoutingDate: z.iso.date(), - HubLocation: z.string(), - }) - })), - PrintData: z.array(z.object({ - Data: z.string(), - LabelFormat: z.enum(["PDF", "ZEBRA", "INTERMEC", "DATAMAX", "TOSHIBA", "PNG"]) - })), - CustomerID: z.string(), - PickupLocation: z.string(), - GDPR: z.array(z.string()) - }), -}) - - -export type CreateParcelsResponse = z.infer - -export const CancelShipmentRequestDataSchema = z.object({ - TrackID: z.string() -}) - -export type CancelShipmentRequestData = z.infer - -export const CancelShipmentResponseDataSchema = z.object({ - TrackID: z.string(), - result: z.enum(["CANCELLED", "CANCELLATION_PENDING", "SCANNED", "ERROR"]) -}) - -export type CancelShipmentResponseData = z.infer - -export const AllowedServicesRequestDataSchema = z.object({ - Source: z.object({ - CountryCode: z.string().max(2), - ZIPCode: z.string().max(10) - }), - Destination: z.object({ - CountryCode: z.string().max(2), - ZIPCode: z.string().max(10) - }), - ContactID: z.string().optional() -}) - -export type AllowedServicesRequestData = z.infer - -export const AllowedServicesResponseDataSchema = z.object({ - AllowedServices: z.array(z.union([ - z.object({ - ServiceName: z.string(), - }).strict(), - z.object({ - ProductName: z.string(), - }).strict() - ])) -}) - -export type AllowedServicesResponseData = z.infer - -export const EndOfDayRequestDataSchema = z.object({ - date: z.iso.date() -}) - - -export const EndOfDayResponseDataSchema = z.object({ - Shipments: z.array(z.object({ - ShippingDate: z.iso.date(), - Product: z.enum(["PARCEL", "EXPRESS"]), - Consignee: z.object({ - Address: AddressSchema - }), - Shipper: z.object({ - ContactID: z.string(), - AlternativeShipperAddress: AddressSchema.optional(), - }), - ShipmentUnit: z.array(z.object({ - Weight: z.string(), - TrackID: z.string(), - ParcelNumber: z.string() - })).optional() - })).optional() -}) - -export type EndOfDayRequestData = z.infer - -export type EndOfDayResponseData = z.infer - -export const AuthenticationRequestDataSchema = z.object({ - grant_type: z.string().default("client_credentials"), - client_id: z.string(), - client_secret: z.string(), - scope: z.string().optional() -}) - -export const UpdateParcelWeightRequestDataSchema = z.object({ - TrackID: z.string().max(8).optional(), - ParcelNumber: z.number().max(999999999999).optional(), - ShipmentReference: z.string().max(40).optional(), - ShipmentUnitReference: z.string().max(40).optional(), - PartnerParcelNumber: z.string().max(50).optional(), - Weight: z.number().min(0.10) -}) -export type UpdateParcelWeightRequestData = z.infer - -export const UpdateParcelWeightResponseDataSchema = z.object({ - UpdatedWeight: z.string() -}) - -export type UpdateParcelWeightResponseData = z.infer - -export const ReprintParcelRequestDataSchema = z.object({ - TrackID: z.string().max(8).optional(), - ParcelNumber: z.number().max(999999999999).optional(), - ShipmentReference: z.string().max(40).optional(), - ShipmentUnitReference: z.string().max(40).optional(), - PartnerParcelNumber: z.string().max(50).optional(), - CreationDate: z.iso.date(), - PrintingOptions: z.object({ - ReturnLabels: z.object({ - TemplateSet: z.enum(["NONE", "ZPL_200", "ZPL_300"]), - LabelFormat: z.enum(["PDF", "ZEBRA", "PNG", "PNG_200"]) - }) - }) -}) -export type ReprintParcelRequestData = z.infer - -export const ReprintParcelResponseDataSchema = z.object({ - CreatedShipment: z.object({ - ParcelData: z.array(z.object({ - TrackID: z.string().min(8).max(8), - ShipmentUnitReference: z.array(z.string()).optional(), - ParcelNumber: z.string(), - Barcodes: z.object({ - Primary2D: z.string(), - Secondary2D: z.string(), - Primary1D: z.string(), - Primary1DPrint: z.boolean(), - }), - RoutingInfo: z.object({ - Tour: z.string(), - InboundSortingFlag: z.string(), - FinalLocationCode: z.string(), - LastRoutingDate: z.iso.date(), - HubLocation: z.string(), - }) - })), - PrintData: z.array(z.object({ - Data: z.string(), - LabelFormat: z.enum(["PDF", "ZEBRA", "PNG", "PNG_200"]) - })), - CustomerID: z.string(), - PickupLocation: z.string(), - GDPR: z.array(z.string()) - }) -}) - -export type ReprintParcelResponseData = z.infer - - -export const InternalValidateShipmentRequestDataSchema = z.object({ - Shipment: InternalShipmentSchma, -}) - -export type InternalValidateShipmentRequestData = z.infer - -export const ValidateShipmentRequestDataSchema = z.object({ - Shipment: ShipmentSchema, -}) - -export type ValidateShipmentRequestData = z.infer - -export const ValidateShipmentResponseDataSchema = z.object({ - success: z.boolean(), - validationResult: z.object({ - Issues: z.array(z.object({ - Rule: z.string(), - Location: z.string(), - Parameters: z.array(z.string()).optional() - })) - }) -}) - -export type ValidateShipmentResponseData = z.infer - -export type AuthenticationRequestData = z.infer - -export const AuthenticationResponseDataSchema = z.object({ - access_token: z.string(), - token_type: z.string(), - expires_in: z.number(), -}) - -export type AuthenticationResponseData = z.infer \ No newline at end of file diff --git a/actions/gls-action/src/types/auth.ts b/actions/gls-action/src/types/auth.ts new file mode 100644 index 0000000..8173bba --- /dev/null +++ b/actions/gls-action/src/types/auth.ts @@ -0,0 +1,15 @@ +import z from "zod"; + +export const AuthenticationRequestDataSchema = z.object({ + grant_type: z.string().default("client_credentials"), + client_id: z.string(), + client_secret: z.string(), + scope: z.string().optional() +}) +export type AuthenticationRequestData = z.infer +export const AuthenticationResponseDataSchema = z.object({ + access_token: z.string(), + token_type: z.string(), + expires_in: z.number(), +}) +export type AuthenticationResponseData = z.infer \ No newline at end of file diff --git a/actions/gls-action/src/types/glsAddress.ts b/actions/gls-action/src/types/glsAddress.ts new file mode 100644 index 0000000..c75eb2c --- /dev/null +++ b/actions/gls-action/src/types/glsAddress.ts @@ -0,0 +1,42 @@ +import {ActionSdk} from "@code0-tech/hercules"; +import z from "zod" +import {singleZodSchemaToTypescriptDef} from "../helpers"; + +export const AddressSchema = z.object({ + Name1: z.string().max(40), + Name2: z.string().max(40).optional(), + Name3: z.string().max(40).optional(), + CountryCode: z.string().max(2), + Province: z.string().max(40).optional(), + City: z.string().max(40), + Street: z.string().min(4), + StreetNumber: z.string().max(40).optional(), + ContactPerson: z.string().max(40).min(6).optional(), + FixedLinePhonenumber: z.string().max(35).min(4).optional(), + MobilePhonenumber: z.string().max(35).min(4).optional(), + eMail: z.string().max(80).optional(), + ZIPCode: z.string().max(10), +}) +export type AddressSchema = z.infer + + +export default (sdk: ActionSdk) => { + return sdk.registerDataTypes( + { + identifier: "GLS_ADDRESS", + type: singleZodSchemaToTypescriptDef("GLS_ADDRESS", AddressSchema), + name: [ + { + code: "en-US", + content: "Address" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Address" + } + ] + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/types/glsAllowedServices.ts b/actions/gls-action/src/types/glsAllowedServices.ts new file mode 100644 index 0000000..8d4bd31 --- /dev/null +++ b/actions/gls-action/src/types/glsAllowedServices.ts @@ -0,0 +1,71 @@ +import {ActionSdk} from "@code0-tech/hercules"; +import {singleZodSchemaToTypescriptDef} from "../helpers"; +import z from "zod"; + +export const AllowedServicesRequestDataSchema = z.object({ + Source: z.object({ + CountryCode: z.string().max(2), + ZIPCode: z.string().max(10) + }), + Destination: z.object({ + CountryCode: z.string().max(2), + ZIPCode: z.string().max(10) + }), + ContactID: z.string().optional() +}) +export type AllowedServicesRequestData = z.infer +export const AllowedServicesResponseDataSchema = z.object({ + AllowedServices: z.array(z.union([ + z.object({ + ServiceName: z.string(), + }).strict(), + z.object({ + ProductName: z.string(), + }).strict() + ])) +}) +export type AllowedServicesResponseData = z.infer + +export default (sdk: ActionSdk) => { + + return sdk.registerDataTypes( + { + identifier: "GLS_ALLOWED_SERVICES_REQUEST_DATA", + type: singleZodSchemaToTypescriptDef( + "GLS_ALLOWED_SERVICES_REQUEST_DATA", + AllowedServicesRequestDataSchema, + ), + name: [ + { + code: "en-US", + content: "Allowed services request data" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Allowed services request data" + } + ] + }, + { + identifier: "GLS_ALLOWED_SERVICES_RESPONSE_DATA", + type: singleZodSchemaToTypescriptDef( + "GLS_ALLOWED_SERVICES_RESPONSE_DATA", + AllowedServicesResponseDataSchema, + ), + name: [ + { + code: "en-US", + content: "Allowed services response data" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Allowed services response data" + } + ] + }, + ) +} diff --git a/actions/gls-action/src/types/glsCancelShipment.ts b/actions/gls-action/src/types/glsCancelShipment.ts new file mode 100644 index 0000000..e2be4ca --- /dev/null +++ b/actions/gls-action/src/types/glsCancelShipment.ts @@ -0,0 +1,55 @@ +import {ActionSdk} from "@code0-tech/hercules"; +import {singleZodSchemaToTypescriptDef} from "../helpers"; +import z from "zod"; + +export const CancelShipmentRequestDataSchema = z.object({ + TrackID: z.string() +}) +export type CancelShipmentRequestData = z.infer +export const CancelShipmentResponseDataSchema = z.object({ + TrackID: z.string(), + result: z.enum(["CANCELLED", "CANCELLATION_PENDING", "SCANNED", "ERROR"]) +}) +export type CancelShipmentResponseData = z.infer + +export default (sdk: ActionSdk) => { + return sdk.registerDataTypes( + { + identifier: "GLS_CANCEL_SHIPMENT_REQUEST_DATA", + type: singleZodSchemaToTypescriptDef( + "GLS_CANCEL_SHIPMENT_REQUEST_DATA", + CancelShipmentRequestDataSchema + ), + name: [ + { + code: "en-US", + content: "Cancel shipment request data" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Cancel shipment request data" + } + ] + }, + { + identifier: "GLS_CANCEL_SHIPMENT_RESPONSE_DATA", + type: singleZodSchemaToTypescriptDef("GLS_CANCEL_SHIPMENT_RESPONSE_DATA", + CancelShipmentResponseDataSchema + ), + name: [ + { + code: "en-US", + content: "Cancel shipment response data" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Cancel shipment response data" + } + ] + } + ) +} diff --git a/actions/gls-action/src/types/glsConsignee.ts b/actions/gls-action/src/types/glsConsignee.ts new file mode 100644 index 0000000..b125b15 --- /dev/null +++ b/actions/gls-action/src/types/glsConsignee.ts @@ -0,0 +1,43 @@ +import {ActionSdk} from "@code0-tech/hercules"; +import {zodSchemaToTypescriptDefs} from "../helpers"; +import {AddressSchema} from "./glsAddress"; +import {z} from "zod"; + + +export const ConsigneeSchema = z.object({ + ConsigneeID: z.string().max(40).optional(), + CostCenter: z.string().max(80).optional(), + Category: z.enum(["BUSINESS", "PRIVATE"]).optional(), + Address: AddressSchema +}) +export type ConsigneeSchema = z.infer + +export default (sdk: ActionSdk) => { + return sdk.registerDataTypes( + { + identifier: "GLS_CONSIGNEE", + type: zodSchemaToTypescriptDefs( + "GLS_CONSIGNEE", + ConsigneeSchema, + { + GLS_ADDRESS: AddressSchema + } + ).get("GLS_CONSIGNEE")!, + name: [ + { + code: "en-US", + content: "Consignee" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Consignee" + } + ], + linkedDataTypes: [ + "GLS_ADDRESS" + ] + }, + ) +} diff --git a/actions/gls-action/src/types/glsCreateParcelsResponse.ts b/actions/gls-action/src/types/glsCreateParcelsResponse.ts new file mode 100644 index 0000000..6d510bc --- /dev/null +++ b/actions/gls-action/src/types/glsCreateParcelsResponse.ts @@ -0,0 +1,58 @@ +import {ActionSdk} from "@code0-tech/hercules"; +import {singleZodSchemaToTypescriptDef} from "../helpers"; +import {z} from "zod"; + +export const CreateParcelsResponseSchema = z.object({ + CreatedShipment: z.object({ + ShipmentReference: z.array(z.string()), + ParcelData: z.array(z.object({ + TrackID: z.string().min(8).max(8), + ParcelNumber: z.string(), + Barcodes: z.object({ + Primary2D: z.string(), + Secondary2D: z.string(), + Primary1D: z.string(), + Primary1DPrint: z.boolean(), + }), + RoutingInfo: z.object({ + Tour: z.string(), + InboundSortingFlag: z.string(), + FinalLocationCode: z.string(), + LastRoutingDate: z.iso.date(), + HubLocation: z.string(), + }) + })), + PrintData: z.array(z.object({ + Data: z.string(), + LabelFormat: z.enum(["PDF", "ZEBRA", "INTERMEC", "DATAMAX", "TOSHIBA", "PNG"]) + })), + CustomerID: z.string(), + PickupLocation: z.string(), + GDPR: z.array(z.string()) + }), +}) +export type CreateParcelsResponse = z.infer + +export default (sdk: ActionSdk) => { + return sdk.registerDataTypes( + { + identifier: "GLS_CREATE_PARCELS_RESPONSE", + type: singleZodSchemaToTypescriptDef( + "GLS_CREATE_PARCELS_RESPONSE", + CreateParcelsResponseSchema + ), + name: [ + { + code: "en-US", + content: "Create parcels response" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Create parcels response" + } + ] + }, + ) +} diff --git a/actions/gls-action/src/types/glsCustomContent.ts b/actions/gls-action/src/types/glsCustomContent.ts new file mode 100644 index 0000000..df751ab --- /dev/null +++ b/actions/gls-action/src/types/glsCustomContent.ts @@ -0,0 +1,37 @@ +import {ActionSdk} from "@code0-tech/hercules"; +import {singleZodSchemaToTypescriptDef} from "../helpers"; +import {z} from "zod"; + +export const CustomContentSchema = z.object({ + CustomerLogo: z.string(), + BarcodeContentType: z.enum(["TRACK_ID", "GLS_SHIPMENT_REFERENCE"]), + Barcode: z.string().optional(), + BarcodeType: z.enum(["EAN_128", "CODE_39"]).optional(), + HideShipperAddress: z.boolean().optional() +}) +export type CustomContent = z.infer + + +export default (sdk: ActionSdk) => { + return sdk.registerDataTypes( + { + identifier: "GLS_CUSTOM_CONTENT", + type: singleZodSchemaToTypescriptDef( + "GLS_CUSTOM_CONTENT", + CustomContentSchema + ), + name: [ + { + code: "en-US", + content: "Custom content" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Custom content" + } + ] + }, + ) +} diff --git a/actions/gls-action/src/types/glsEndOfDayRequest.ts b/actions/gls-action/src/types/glsEndOfDayRequest.ts new file mode 100644 index 0000000..50f4964 --- /dev/null +++ b/actions/gls-action/src/types/glsEndOfDayRequest.ts @@ -0,0 +1,71 @@ +import {ActionSdk} from "@code0-tech/hercules"; +import {singleZodSchemaToTypescriptDef} from "../helpers"; +import z from "zod"; +import {AddressSchema} from "./glsAddress"; + +export const EndOfDayRequestDataSchema = z.object({ + date: z.iso.date() +}) +export const EndOfDayResponseDataSchema = z.object({ + Shipments: z.array(z.object({ + ShippingDate: z.iso.date(), + Product: z.enum(["PARCEL", "EXPRESS"]), + Consignee: z.object({ + Address: AddressSchema + }), + Shipper: z.object({ + ContactID: z.string(), + AlternativeShipperAddress: AddressSchema.optional(), + }), + ShipmentUnit: z.array(z.object({ + Weight: z.string(), + TrackID: z.string(), + ParcelNumber: z.string() + })).optional() + })).optional() +}) +export type EndOfDayRequestData = z.infer +export type EndOfDayResponseData = z.infer + +export default (sdk: ActionSdk) => { + return sdk.registerDataTypes( + { + identifier: "GLS_END_OF_DAY_REQUEST_DATA", + type: singleZodSchemaToTypescriptDef( + "GLS_END_OF_DAY_REQUEST_DATA", + EndOfDayRequestDataSchema + ), + name: [ + { + code: "en-US", + content: "End of day request data" + } + ], + displayMessage: [ + { + code: "en-US", + content: "End of day request data" + } + ] + }, + { + identifier: "GLS_END_OF_DAY_RESPONSE_DATA", + type: singleZodSchemaToTypescriptDef( + "GLS_END_OF_DAY_RESPONSE_DATA", + EndOfDayResponseDataSchema + ), + name: [ + { + code: "en-US", + content: "End of day response data" + } + ], + displayMessage: [ + { + code: "en-US", + content: "End of day response data" + } + ] + }, + ) +} diff --git a/actions/gls-action/src/types/glsPrintingOptions.ts b/actions/gls-action/src/types/glsPrintingOptions.ts new file mode 100644 index 0000000..1abd541 --- /dev/null +++ b/actions/gls-action/src/types/glsPrintingOptions.ts @@ -0,0 +1,43 @@ +import {ActionSdk} from "@code0-tech/hercules"; +import {singleZodSchemaToTypescriptDef} from "../helpers"; +import {z} from "zod"; + +export const PrintingOptionsSchema = z.object({ + ReturnLabels: z.object({ + TemplateSet: z.enum([ + "NONE", "D_200", "PF_4_I", "PF_4_I_200", "PF_4_I_300", "PF_8_D_200", "T_200_BF", "T_300_BF", "ZPL_200", "ZPL_200_TRACKID_EAN_128", "ZPL_200_TRACKID_CODE_39", "ZPL_200_REFNO_EAN_128", "ZPL_200_REFNO_CODE_39", "ZPL_300", "ZPL_300_TRACKID_EAN_128", "ZPL_300_TRACKID_CODE_39", "ZPL_300_REFNO_EAN_128", "ZPL_300_REFNO_CODE_39" + ]), + LabelFormat: z.enum(["PDF", "ZEBRA", "INTERMEC", "DATAMAX", "TOSHIBA", "PNG"]) + }).optional(), + useDefault: z.string().max(7).optional(), + DefinePrinter: z.object({ + LabelPrinter: z.string().max(255).optional(), + DocumentPrinter: z.string().max(255).optional(), + }).optional(), +}) +export type PrintingOptions = z.infer +export type ReturnLabels = z.infer + +export default (sdk: ActionSdk) => { + return sdk.registerDataTypes( + { + identifier: "GLS_PRINTING_OPTIONS", + type: singleZodSchemaToTypescriptDef( + "GLS_PRINTING_OPTIONS", + PrintingOptionsSchema + ), + name: [ + { + code: "en-US", + content: "Printing Options" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Printing Options" + } + ] + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/types/glsReprintParcel.ts b/actions/gls-action/src/types/glsReprintParcel.ts new file mode 100644 index 0000000..34d639d --- /dev/null +++ b/actions/gls-action/src/types/glsReprintParcel.ts @@ -0,0 +1,92 @@ +import {ActionSdk} from "@code0-tech/hercules"; +import {singleZodSchemaToTypescriptDef} from "../helpers"; +import z from "zod"; + +export const ReprintParcelRequestDataSchema = z.object({ + TrackID: z.string().max(8).optional(), + ParcelNumber: z.number().max(999999999999).optional(), + ShipmentReference: z.string().max(40).optional(), + ShipmentUnitReference: z.string().max(40).optional(), + PartnerParcelNumber: z.string().max(50).optional(), + CreationDate: z.iso.date(), + PrintingOptions: z.object({ + ReturnLabels: z.object({ + TemplateSet: z.enum(["NONE", "ZPL_200", "ZPL_300"]), + LabelFormat: z.enum(["PDF", "ZEBRA", "PNG", "PNG_200"]) + }) + }) +}) +export type ReprintParcelRequestData = z.infer +export const ReprintParcelResponseDataSchema = z.object({ + CreatedShipment: z.object({ + ParcelData: z.array(z.object({ + TrackID: z.string().min(8).max(8), + ShipmentUnitReference: z.array(z.string()).optional(), + ParcelNumber: z.string(), + Barcodes: z.object({ + Primary2D: z.string(), + Secondary2D: z.string(), + Primary1D: z.string(), + Primary1DPrint: z.boolean(), + }), + RoutingInfo: z.object({ + Tour: z.string(), + InboundSortingFlag: z.string(), + FinalLocationCode: z.string(), + LastRoutingDate: z.iso.date(), + HubLocation: z.string(), + }) + })), + PrintData: z.array(z.object({ + Data: z.string(), + LabelFormat: z.enum(["PDF", "ZEBRA", "PNG", "PNG_200"]) + })), + CustomerID: z.string(), + PickupLocation: z.string(), + GDPR: z.array(z.string()) + }) +}) +export type ReprintParcelResponseData = z.infer + +export default (sdk: ActionSdk) => { + return sdk.registerDataTypes( + { + identifier: "GLS_REPRINT_PARCEL_REQUEST_DATA", + type: singleZodSchemaToTypescriptDef( + "GLS_REPRINT_PARCEL_REQUEST_DATA", + ReprintParcelRequestDataSchema + ), + name: [ + { + code: "en-US", + content: "Reprint parcel request data" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Reprint parcel request data" + } + ] + }, + { + identifier: "GLS_REPRINT_PARCEL_RESPONSE_DATA", + type: singleZodSchemaToTypescriptDef( + "GLS_REPRINT_PARCEL_RESPONSE_DATA", + ReprintParcelResponseDataSchema + ), + name: [ + { + code: "en-US", + content: "Reprint parcel response data" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Reprint parcel response data" + } + ] + }, + ) +} diff --git a/actions/gls-action/src/types/glsReturnOptions.ts b/actions/gls-action/src/types/glsReturnOptions.ts new file mode 100644 index 0000000..b94efc5 --- /dev/null +++ b/actions/gls-action/src/types/glsReturnOptions.ts @@ -0,0 +1,34 @@ +import {singleZodSchemaToTypescriptDef} from "../helpers"; +import {z} from "zod"; +import {ActionSdk} from "@code0-tech/hercules"; + + +export const ReturnOptionsSchema = z.object({ + ReturnPrintData: z.boolean().default(true).optional(), + ReturnRoutingInfo: z.boolean().default(true).optional() +}) +export type ReturnOptions = z.infer + +export default (sdk: ActionSdk) => { + return sdk.registerDataTypes( + { + identifier: "GLS_RETURN_OPTIONS", + type: singleZodSchemaToTypescriptDef( + "GLS_RETURN_OPTIONS", + ReturnOptionsSchema + ), + name: [ + { + code: "en-US", + content: "Return Options" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Return Options" + } + ] + }, + ) +} diff --git a/actions/gls-action/src/types/glsShipment.ts b/actions/gls-action/src/types/glsShipment.ts new file mode 100644 index 0000000..1e328f2 --- /dev/null +++ b/actions/gls-action/src/types/glsShipment.ts @@ -0,0 +1,101 @@ +import {zodSchemaToTypescriptDefs} from "../helpers"; +import {z} from "zod"; +import {ConsigneeSchema} from "./glsConsignee"; +import {AddressSchema} from "./glsAddress"; +import {InternalShipmentServiceSchema, ShipmentServiceSchema} from "./glsShipmentService"; +import {InternalShipmentUnitSchema, ShipmentUnitSchema} from "./glsShipmentUnit"; +import {InternalShipperSchema, ShipperSchema} from "./glsShipper"; +import {ActionSdk} from "@code0-tech/hercules"; + +export const ShipmentSchema = z.object({ + ShipmentReference: z.string().max(40).optional(), + ShipmentDate: z.date().optional(), + IncotermCode: z.int().max(99).optional(), + Identifier: z.string().max(40).optional(), + Product: z.enum(["PARCEL", "EXPRESS"]), + ExpressAltDeliveryAllowed: z.boolean().optional(), + Consignee: ConsigneeSchema, + Shipper: ShipperSchema.optional(), + Carrier: z.enum(["ROYALMAIL"]).optional(), + ShipmentUnit: ShipmentUnitSchema, + Service: z.lazy(() => ShipmentServiceSchema), + Return: z.object({ + Address: AddressSchema + }).optional() +}) +export const ShipmentWithoutServicesSchema = ShipmentSchema.omit({Service: true}) +export type ShipmentWithoutServices = z.infer +export type Shipment = z.infer +export const InternalShipmentSchma = ShipmentSchema.extend({ + Middleware: z.string().max(40), + Shipper: InternalShipperSchema, + Service: z.lazy(() => InternalShipmentServiceSchema), + ShipmentUnit: InternalShipmentUnitSchema +}) + +export default (sdk: ActionSdk) => { + return sdk.registerDataTypes( + { + identifier: "GLS_SHIPMENT", + type: zodSchemaToTypescriptDefs( + "GLS_SHIPMENT", + ShipmentSchema, + { + GLS_ADDRESS: AddressSchema, + GLS_CONSIGNEE: ConsigneeSchema, + GLS_SHIPMENT_UNIT: ShipmentUnitSchema, + GLS_SHIPPER: ShipperSchema, + GLS_SHIPMENT_SERVICE: ShipmentServiceSchema, + }).get("GLS_SHIPMENT")!, + name: [ + { + code: "en-US", + content: "Shipment" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Shipment" + } + ], + linkedDataTypes: [ + "GLS_SHIPMENT_SERVICE", + "GLS_ADDRESS", + "GLS_SHIPMENT_UNIT", + "GLS_CONSIGNEE", + "GLS_SHIPPER" + ] + }, + { + identifier: "GLS_SHIPMENT_WITHOUT_SERVICES", + type: zodSchemaToTypescriptDefs( + "GLS_SHIPMENT_WITHOUT_SERVICES", + ShipmentWithoutServicesSchema, + { + GLS_ADDRESS: AddressSchema, + GLS_CONSIGNEE: ConsigneeSchema, + GLS_SHIPMENT_UNIT: ShipmentUnitSchema, + GLS_SHIPPER: ShipperSchema, + }).get("GLS_SHIPMENT_WITHOUT_SERVICES")!, + name: [ + { + code: "en-US", + content: "Shipment without services" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Shipment without services" + } + ], + linkedDataTypes: [ + "GLS_ADDRESS", + "GLS_SHIPMENT_UNIT", + "GLS_CONSIGNEE", + "GLS_SHIPPER" + ] + }, + ) +} \ No newline at end of file diff --git a/actions/gls-action/src/types/glsShipmentService.ts b/actions/gls-action/src/types/glsShipmentService.ts new file mode 100644 index 0000000..5f85514 --- /dev/null +++ b/actions/gls-action/src/types/glsShipmentService.ts @@ -0,0 +1,217 @@ +import z from "zod"; +import {AddressSchema} from "./glsAddress"; +import {zodSchemaToTypescriptDefs} from "../helpers"; +import {ShipmentSchema} from "./glsShipment"; +import {ActionSdk} from "@code0-tech/hercules"; + + +export const ShipmentServiceSchema = z.array(z.object({ + Service: z.object({ + serviceName: z.string() + }).optional(), + ShopDelivery: z.object({ + ParcelShopID: z.string().max(50) + }).optional(), + ShopReturn: z.object({ + NumberOfLabels: z.number(), + ReturnQR: z.enum(["PDF", "PNG", "ZPL"]).optional() + }).optional(), + Intercompany: z.object({ + Address: AddressSchema, + NumberOfLabels: z.number().min(1), + ExpectedWeight: z.number().min(1).optional() + }).optional(), + Exchange: z.object({ + Address: AddressSchema, + ExpectedWeight: z.number().min(1).optional() + }).optional(), + DeliveryAtWork: z.object({ + RecipientName: z.string().max(40), + AlternateRecipientName: z.string().max(40).optional(), + Building: z.string().max(40), + Floor: z.number(), + Room: z.number().optional(), + Phonenumber: z.string().max(35).optional() + }).optional(), + Deposit: z.object({ + PlaceOfDeposit: z.string().max(121), + }).optional(), + IdentPin: z.object({ + PIN: z.string().max(4), + Birthdate: z.iso.date().optional() + }).optional(), + Ident: z.object({ + Birthdate: z.iso.date(), + Firstname: z.string().max(40), + Lastname: z.string().max(40), + Nationality: z.string().max(2) + }).optional(), + PickAndShip: z.object({ + PickupDate: z.iso.date(), + }).optional(), + PickAndReturn: z.object({ + PickupDate: z.iso.date(), + }).optional(), + InboundLogistics: z.object().optional(), + DocumentReturnService: z.object().optional(), + CompleteDeliveryConsignmentService: z.object().optional(), + FlexDeliveryService: z.object().optional(), + SignatureService: z.object().optional(), + T24Service: z.object().optional(), + T48Service: z.object().optional(), + Guaranteed24Service: z.object().optional(), + AddresseeOnlyService: z.object().optional(), + TyreService: z.object().optional(), + '0800Service': z.object().optional(), + '0900Service': z.object().optional(), + '1000Service': z.object().optional(), + '1200Service': z.object().optional(), + '1300Service': z.object().optional(), + EOB: z.object().optional(), + Saturday1000Service: z.object().optional(), + Saturday1200Service: z.object().optional(), + SaturdayService: z.object().optional(), +})).optional() +export type ShipmentService = z.infer +export const InternalShipmentServiceSchema = z.array(z.object({ + Service: z.object({ + serviceName: z.string() + }).optional(), + ShopDelivery: z.object({ + serviceName: z.string().default("service_shopdelivery"), + ParcelShopID: z.string().max(50) + }).optional(), + ShopReturn: z.object({ + serviceName: z.string().default("service_shopreturn"), + NumberOfLabels: z.number(), + ReturnQR: z.enum(["PDF", "PNG", "ZPL"]).optional() + }).optional(), + Intercompany: z.object({ + serviceName: z.string().default("service_intercompany"), + Address: AddressSchema, + NumberOfLabels: z.number().min(1), + ExpectedWeight: z.number().min(1).optional() + }).optional(), + Exchange: z.object({ + serviceName: z.string().default("service_exchange"), + Address: AddressSchema, + ExpectedWeight: z.number().min(1).optional() + }).optional(), + DeliveryAtWork: z.object({ + serviceName: z.string().default("service_deliveryatwork"), + RecipientName: z.string().max(40), + AlternateRecipientName: z.string().max(40).optional(), + Building: z.string().max(40), + Floor: z.number(), + Room: z.number().optional(), + Phonenumber: z.string().max(35).optional() + }).optional(), + Deposit: z.object({ + serviceName: z.string().default("service_deposit"), + PlaceOfDeposit: z.string().max(121), + }).optional(), + IdentPin: z.object({ + serviceName: z.string().default("service_identpin"), + PIN: z.string().max(4), + Birthdate: z.date().optional() + }).optional(), + Ident: z.object({ + serviceName: z.string().default("service_ident"), + Birthdate: z.date(), + Firstname: z.string().max(40), + Lastname: z.string().max(40), + Nationality: z.string().max(2) + }).optional(), + PickAndShip: z.object({ + serviceName: z.string().default("service_pickandship"), + PickupDate: z.date(), + }).optional(), + PickAndReturn: z.object({ + serviceName: z.string().default("service_pickandreturn"), + PickupDate: z.date(), + }).optional(), + InboundLogistics: z.object({ + serviceName: z.string().default("service_inbound"), + }).optional(), + DocumentReturnService: z.object({ + serviceName: z.string().default("service_documentreturn"), + }).optional(), + CompleteDeliveryConsignmentService: z.object({ + serviceName: z.string().default("service_completedeliveryconsignment"), + }).optional(), + FlexDeliveryConsignmentService: z.object({ + serviceName: z.string().default("service_flexdelivery"), + }).optional(), + SignatureService: z.object({ + serviceName: z.string().default("service_signature"), + }).optional(), + T24Service: z.object({ + serviceName: z.string().default("service_t24"), + }).optional(), + T48Service: z.object({ + serviceName: z.string().default("service_t48"), + }).optional(), + Guaranteed24Service: z.object({ + serviceName: z.string().default("service_guaranteed24"), + }).optional(), + AddresseeOnlyService: z.object({ + serviceName: z.string().default("service_addresseeonly"), + }).optional(), + TyreService: z.object({ + serviceName: z.string().default("service_tyre"), + }).optional(), + '0800Service': z.object({ + serviceName: z.string().default("service_0800"), + }).optional(), + '0900Service': z.object({ + serviceName: z.string().default("service_0900"), + }).optional(), + '1000Service': z.object({ + serviceName: z.string().default("service_1000"), + }).optional(), + '1200Service': z.object({ + serviceName: z.string().default("service_1200"), + }).optional(), + '1300Service': z.object({ + serviceName: z.string().default("service_1300"), + }).optional(), + Saturday1000Service: z.object({ + serviceName: z.string().default("service_saturday_1000"), + }).optional(), + Saturday1200Service: z.object({ + serviceName: z.string().default("service_saturday_1200"), + }).optional(), + SaturdayService: z.object({ + serviceName: z.string().default("service_Saturday"), + }).optional(), +})).optional() + +export default (sdk: ActionSdk) => { + return sdk.registerDataTypes( + { + identifier: "GLS_SHIPMENT_SERVICE", + type: zodSchemaToTypescriptDefs( + "XXX", + ShipmentSchema, + { + GLS_SHIPMENT_SERVICE: ShipmentServiceSchema, + } + ).get("GLS_SHIPMENT_SERVICE")!, // Hacky way because shipment service is defined as an array + name: [ + { + code: "en-US", + content: "Shipment Service" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Shipment Service" + } + ], + linkedDataTypes: [ + "GLS_ADDRESS" + ] + }, + ) +} diff --git a/actions/gls-action/src/types/glsShipmentUnit.ts b/actions/gls-action/src/types/glsShipmentUnit.ts new file mode 100644 index 0000000..baceb6b --- /dev/null +++ b/actions/gls-action/src/types/glsShipmentUnit.ts @@ -0,0 +1,53 @@ +import {z} from "zod"; +import {zodSchemaToTypescriptDefs} from "../helpers"; +import {ShipmentSchema} from "./glsShipment"; +import {InternalUnitServiceSchema, UnitServiceSchema} from "./glsUnitService"; +import {ActionSdk} from "@code0-tech/hercules"; + + +export const ShipmentUnitSchema = z.array( + z.object({ + ShipmentUnitReference: z.string().max(40).optional(), + PartnerParcelNumber: z.string().max(50).optional(), + Weight: z.number().min(0.10).max(99), + Note1: z.string().max(50).optional(), + Note2: z.string().max(50).optional(), + Service: UnitServiceSchema, + }) +).min(1) +export type ShipmentUnit = z.infer +export const InternalShipmentUnitSchema = ShipmentUnitSchema.element.extend( + { + Service: InternalUnitServiceSchema.optional() + } +).array().min(1) + +export default (sdk: ActionSdk) => { + return sdk.registerDataTypes( + { + identifier: "GLS_SHIPMENT_UNIT", + type: zodSchemaToTypescriptDefs( + "XXX", + ShipmentSchema, + { + GLS_SHIPMENT_UNIT: ShipmentUnitSchema, + } + ).get("GLS_SHIPMENT_UNIT")!, // Hacky because shipment unit is an array + name: [ + { + code: "en-US", + content: "Shipment Unit" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Shipment Unit" + } + ], + linkedDataTypes: [ + "GLS_UNIT_SERVICE", + ] + }, + ) +} diff --git a/actions/gls-action/src/types/glsShipper.ts b/actions/gls-action/src/types/glsShipper.ts new file mode 100644 index 0000000..2887d09 --- /dev/null +++ b/actions/gls-action/src/types/glsShipper.ts @@ -0,0 +1,44 @@ +import {z} from "zod"; +import {AddressSchema} from "./glsAddress"; +import {zodSchemaToTypescriptDefs} from "../helpers"; +import {ActionSdk} from "@code0-tech/hercules"; + +export const ShipperSchema = z.object({ + AlternativeShipperAddress: AddressSchema.optional(), + Address: AddressSchema.optional(), +}) +export type ShipperSchema = z.infer +export const InternalShipperSchema = ShipperSchema.extend({ + ContactID: z.string().optional() +}) +export type InternalShipper = z.infer + +export default (sdk: ActionSdk) => { + return sdk.registerDataTypes( + { + identifier: "GLS_SHIPPER", + type: zodSchemaToTypescriptDefs( + "GLS_SHIPPER", + ShipperSchema, + { + GLS_ADDRESS: AddressSchema + } + ).get("GLS_SHIPPER")!, + name: [ + { + code: "en-US", + content: "Shipper" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Shipper" + } + ], + linkedDataTypes: [ + "GLS_ADDRESS" + ] + } + ) +} diff --git a/actions/gls-action/src/types/glsUnitService.ts b/actions/gls-action/src/types/glsUnitService.ts new file mode 100644 index 0000000..8976cde --- /dev/null +++ b/actions/gls-action/src/types/glsUnitService.ts @@ -0,0 +1,87 @@ +import z from "zod" +import {zodSchemaToTypescriptDefs} from "../helpers"; +import {ShipmentSchema} from "./glsShipment"; +import {ActionSdk} from "@code0-tech/hercules"; + +export const UnitServiceSchema = z.array(z.object({ + Cash: z.object({ + Reason: z.string().max(160), + Amount: z.number().min(1), + Currency: z.string().max(3).min(3) + }).optional(), + AddonLiability: z.object({ + Amount: z.number().min(1), + Currency: z.string().max(3).min(3), + ParcelContent: z.string().max(255) + }).optional(), + HazardousGoods: z.object({ + HarzardousGood: z.array( + z.object({ + Weight: z.number().min(1), + GLSHazNo: z.string().max(8) + })) + }).optional(), + ExWorks: z.object({}).optional(), + LimitedQuantities: z.object({ + Weight: z.number().optional() + }).optional() +})).optional() +export type UnitService = z.infer +// adding all service names +export const InternalUnitServiceSchema = z.array(z.object({ + Cash: z.object({ + serviceName: z.string("service_cash"), + Reason: z.string(), + Amount: z.number(), + Currency: z.string() + }).optional(), + AddonLiability: z.object({ + serviceName: z.string("service_addonliability"), + Amount: z.number(), + Currency: z.string(), + ParcelContent: z.string() + }).optional(), + HazardousGoods: z.object({ + serviceName: z.string("service_hazardousgoods"), + HarzardousGood: z.array( + z.object({ + Weight: z.number(), + GLSHazNo: z.string() + })) + }), + ExWorks: z.object({ + serviceName: z.string("service_exworks"), + }).optional(), + LimitedQuantities: z.object({ + serviceName: z.string("service_limitedquantities"), + Weight: z.number().optional() + }).optional() +})).optional() + +export default (sdk: ActionSdk) => { + return sdk.registerDataTypes( + { + identifier: "GLS_UNIT_SERVICE", + type: zodSchemaToTypescriptDefs( + "XXX", + ShipmentSchema, + { + GLS_UNIT_SERVICE: UnitServiceSchema, + }).get("GLS_UNIT_SERVICE")!, // Hacky way because unit service is an arra + name: [ + { + code: "en-US", + content: "GLS unit service" + } + ], + displayMessage: [ + { + code: "en-US", + content: "GLS unit service" + } + ] + } + ) +} + + diff --git a/actions/gls-action/src/types/glsUpdateParcelWeight.ts b/actions/gls-action/src/types/glsUpdateParcelWeight.ts new file mode 100644 index 0000000..5a907c3 --- /dev/null +++ b/actions/gls-action/src/types/glsUpdateParcelWeight.ts @@ -0,0 +1,60 @@ +import z from "zod"; +import {singleZodSchemaToTypescriptDef} from "../helpers"; +import {ActionSdk} from "@code0-tech/hercules"; + +export const UpdateParcelWeightRequestDataSchema = z.object({ + TrackID: z.string().max(8).optional(), + ParcelNumber: z.number().max(999999999999).optional(), + ShipmentReference: z.string().max(40).optional(), + ShipmentUnitReference: z.string().max(40).optional(), + PartnerParcelNumber: z.string().max(50).optional(), + Weight: z.number().min(0.10) +}) +export type UpdateParcelWeightRequestData = z.infer +export const UpdateParcelWeightResponseDataSchema = z.object({ + UpdatedWeight: z.string() +}) +export type UpdateParcelWeightResponseData = z.infer + +export default (sdk: ActionSdk) => { + return sdk.registerDataTypes( + { + identifier: "GLS_UPDATE_PARCEL_WEIGHT_REQUEST_DATA", + type: singleZodSchemaToTypescriptDef( + "GLS_UPDATE_PARCEL_WEIGHT_REQUEST_DATA", + UpdateParcelWeightRequestDataSchema + ), + name: [ + { + code: "en-US", + content: "Update parcel weight request data" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Update parcel weight request data" + } + ] + }, + { + identifier: "GLS_UPDATE_PARCEL_WEIGHT_RESPONSE_DATA", + type: singleZodSchemaToTypescriptDef( + "GLS_UPDATE_PARCEL_WEIGHT_RESPONSE_DATA", + UpdateParcelWeightResponseDataSchema + ), + name: [ + { + code: "en-US", + content: "Update parcel weight response data" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Update parcel weight response data" + } + ] + }, + ) +} diff --git a/actions/gls-action/src/types/glsValidateShipment.ts b/actions/gls-action/src/types/glsValidateShipment.ts new file mode 100644 index 0000000..e22874f --- /dev/null +++ b/actions/gls-action/src/types/glsValidateShipment.ts @@ -0,0 +1,74 @@ +import {ActionSdk} from "@code0-tech/hercules"; +import z from "zod"; +import {InternalShipmentSchma, ShipmentSchema} from "./glsShipment"; +import {singleZodSchemaToTypescriptDef, zodSchemaToTypescriptDefs} from "../helpers"; + + +export const ValidateShipmentRequestDataSchema = z.object({ + Shipment: ShipmentSchema, +}) +export type ValidateShipmentRequestData = z.infer +export const ValidateShipmentResponseDataSchema = z.object({ + success: z.boolean(), + validationResult: z.object({ + Issues: z.array(z.object({ + Rule: z.string(), + Location: z.string(), + Parameters: z.array(z.string()).optional() + })) + }) +}) +export type ValidateShipmentResponseData = z.infer +export const InternalValidateShipmentRequestDataSchema = z.object({ + Shipment: InternalShipmentSchma, +}) +export type InternalValidateShipmentRequestData = z.infer + +export default (sdk: ActionSdk) => { + return sdk.registerDataTypes( + { + identifier: "GLS_VALIDATE_SHIPMENT_REQUEST_DATA", + type: zodSchemaToTypescriptDefs( + "GLS_VALIDATE_SHIPMENT_REQUEST_DATA", + ValidateShipmentRequestDataSchema, + { + GLS_SHIPMENT: ShipmentSchema + } + ).get("GLS_VALIDATE_SHIPMENT_REQUEST_DATA")!, + name: [ + { + code: "en-US", + content: "Validate shipment request data" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Validate shipment request data" + } + ], + linkedDataTypes: [ + "GLS_SHIPMENT" + ] + }, + { + identifier: "GLS_VALIDATE_SHIPMENT_RESPONSE_DATA", + type: singleZodSchemaToTypescriptDef( + "GLS_VALIDATE_SHIPMENT_RESPONSE_DATA", + ValidateShipmentResponseDataSchema + ), + name: [ + { + code: "en-US", + content: "Validate shipment response data" + } + ], + displayMessage: [ + { + code: "en-US", + content: "Validate shipment response data" + } + ] + }, + ) +} diff --git a/actions/gls-action/src/types/shipmentRequest.ts b/actions/gls-action/src/types/shipmentRequest.ts new file mode 100644 index 0000000..d2509a8 --- /dev/null +++ b/actions/gls-action/src/types/shipmentRequest.ts @@ -0,0 +1,17 @@ +import z from "zod" +import {InternalShipmentSchma, ShipmentSchema} from "./glsShipment"; +import {PrintingOptionsSchema} from "./glsPrintingOptions"; +import {ReturnOptionsSchema} from "./glsReturnOptions"; +import {CustomContentSchema} from "./glsCustomContent"; + +export const ShipmentRequestDataSchema = z.object({ + Shipment: ShipmentSchema, + PrintingOptions: PrintingOptionsSchema, + ReturnOptions: ReturnOptionsSchema.optional(), + CustomContent: CustomContentSchema.optional(), +}) +export const InternalShipmentRequestDataSchema = ShipmentRequestDataSchema.extend({ + Shipment: InternalShipmentSchma, +}) +export type InternalShipmentRequestData = z.infer +export type ShipmentRequestData = z.infer \ No newline at end of file diff --git a/actions/gls-action/test/functions/reprintParcel.test.ts b/actions/gls-action/test/functions/reprintParcel.test.ts new file mode 100644 index 0000000..3f408a2 --- /dev/null +++ b/actions/gls-action/test/functions/reprintParcel.test.ts @@ -0,0 +1,128 @@ +import {describe, it, expect, vi, beforeEach} from "vitest"; +import {HerculesFunctionContext} from "@code0-tech/hercules"; +import { + ReprintParcelResponseData, + ReprintParcelResponseDataSchema +} from "../../src/types/glsReprintParcel"; +import {withBaseFunctionMock} from "../helpers/withBaseFunction"; +import {AuthenticationResponseData} from "../../src/types/auth"; + +const mockRequestData = { + CreationDate: "2024-01-01T00:00:00Z", + ParcelNumber: 0, + PartnerParcelNumber: "", + PrintingOptions: { + ReturnLabels: { + LabelFormat: "PDF", + TemplateSet: "ZPL_300" + } + }, + ShipmentReference: "", + ShipmentUnitReference: "", + TrackID: "SOME_TRACK_ID" +}; + +const createContext = (): HerculesFunctionContext => ({ + matchedConfig: { + projectId: 0, + configValues: [], + findConfig: (identifier) => { + const map: Record = { + client_id: "SOME_ID", + client_secret: "SOME_SECRET", + auth_url: "AUTH_URL", + ship_it_api_url: "API_URL" + }; + return map[identifier]; + } + }, + projectId: 0, + executionId: "SOME_ID" +}); + +describe("reprintParcel.ts", () => { + const postMock = vi.hoisted(() => vi.fn((url: string, data: any) => { + if (url === "AUTH_URL") { + const authResponse: AuthenticationResponseData = { + access_token: "TOKEN", + token_type: "Bearer", + expires_in: 14000 + }; + return {data: authResponse}; + } + + expect(data).toEqual(mockRequestData); + + const result: ReprintParcelResponseData = { + CreatedShipment: { + GDPR: [], + ParcelData: [], + PrintData: [], + CustomerID: "", + PickupLocation: "" + } + }; + + return {data: result}; + })); + + beforeEach(() => { + vi.resetModules(); + + vi.mock("axios", () => ({ + default: { + post: postMock + } + })); + }); + + it("registers function definitions and calls API endpoints correctly", async () => { + const register = await import("../../src/functions/reprintParcel"); + + await withBaseFunctionMock(register.default, async (state) => { + expect(state.registeredFunctionDefinitions).toHaveLength(1); + + const [reprintParcel] = state.registeredFunctionDefinitions; + + expect(reprintParcel.definition.runtimeName).toBe("reprintParcel"); + + const result = await reprintParcel.handler( + mockRequestData, + createContext() + ); + + expect(ReprintParcelResponseDataSchema.safeParse(result).success).toBe(true); + + expect(postMock).toHaveBeenCalledTimes(2); + + expect(postMock.mock.calls[0]).toEqual( + [ + "AUTH_URL", + { + grant_type: 'client_credentials', + client_id: createContext().matchedConfig.findConfig("client_id"), + client_secret: createContext().matchedConfig.findConfig("client_secret"), + }, + { + headers: { + 'Content-Type': "application/x-www-form-urlencoded" + } + } + ] + ); + + expect(postMock.mock.calls[1]).toEqual( + [ + "API_URL/rs/shipments/reprintparcel", + mockRequestData, + { + headers: { + Authorization: "Bearer TOKEN", + 'Content-Type': "application/glsVersion1+json" + } + } + ] + ); + }); + }); +}); \ No newline at end of file diff --git a/actions/gls-action/test/helpers/withBaseFunction.ts b/actions/gls-action/test/helpers/withBaseFunction.ts new file mode 100644 index 0000000..cb587fe --- /dev/null +++ b/actions/gls-action/test/helpers/withBaseFunction.ts @@ -0,0 +1,56 @@ +import {vi} from "vitest"; +import {SdkMockState} from "../index.test"; +import {withSdkMock} from "./withSdkMock"; +import {ActionSdk} from "@code0-tech/hercules"; + +export const withBaseFunctionMock = async ( + register: (sdk: ActionSdk) => Promise, + tests: (state: SdkMockState) => void +) => { + await withSdkMock(async (state) => { + const {createSdk} = await import("@code0-tech/hercules") + + vi.doMock("../helpers.ts", async (importOriginal) => { + const actual = await importOriginal() as any; + + return { + ...actual, + loadAllDefinitions: vi.fn(() => { + return Promise.resolve() + }) + } + }) + + const mockSdk = createSdk( + { + actionId: "", + version: "", + aquilaUrl: "", + authToken: "" + } + ) + + vi.doMock("../index.ts", () => ({ + sdk: mockSdk + })); + + vi.doMock("axios", () => { + return { + post: vi.fn(), + get: vi.fn(), + put: vi.fn(), + delete: vi.fn(), + }; + }); + + try { + await register(mockSdk) + + tests(state); + + } catch (error) { + console.error(error) + } + }) +} + diff --git a/actions/gls-action/test/helpers/withSdkMock.ts b/actions/gls-action/test/helpers/withSdkMock.ts new file mode 100644 index 0000000..6648559 --- /dev/null +++ b/actions/gls-action/test/helpers/withSdkMock.ts @@ -0,0 +1,77 @@ +import {beforeEach, vi} from "vitest"; +import { + ActionSdk, + HerculesActionConfigurationDefinition, + HerculesDataType, + HerculesFlowType, + HerculesRegisterFunctionParameter +} from "@code0-tech/hercules"; +import {SdkMockState} from "../index.test"; + +export const withSdkMock = async (tests: (state: SdkMockState) => void) => { + const state = vi.hoisted(() => { + const state: SdkMockState = { + registeredFunctionDefinitions: [] as HerculesRegisterFunctionParameter[], + dataTypes: [] as HerculesDataType[], + flowTypes: [] as HerculesFlowType[], + configDefinitions: [] as HerculesActionConfigurationDefinition[], + }; + return state + }) + + + vi.mock("@code0-tech/hercules", async (importOriginal) => { + const actual = await importOriginal() as any + return { + ...actual, + createSdk: (config, configDefinitions) => { + state.configDefinitions = configDefinitions || null + + const mockedActionSdk: ActionSdk = { + config: config, + registerFunctionDefinitions: (...defs: HerculesRegisterFunctionParameter[]) => { + state.registeredFunctionDefinitions = defs; + return Promise.resolve(); + }, + + registerConfigDefinitions: (...defs: HerculesActionConfigurationDefinition[]) => { + state.configDefinitions = defs; + return Promise.resolve(); + }, + + registerDataTypes: (...types: HerculesDataType[]) => { + state.dataTypes = types; + return Promise.resolve(); + }, + + registerFlowTypes: (...types: HerculesFlowType[]) => { + state.flowTypes = types; + return Promise.resolve(); + }, + fullyConnected: () => { + return true + }, + connect: vi.fn(() => { + return Promise.resolve([]); + }), + onError: vi.fn(), + dispatchEvent: vi.fn(), + getProjectActionConfigurations: vi.fn() + } + return mockedActionSdk + + } + } + + }) + + + beforeEach(() => { + state.registeredFunctionDefinitions = null; + state.dataTypes = null; + state.flowTypes = null; + state.configDefinitions = null; + }); + + tests(state); +} \ No newline at end of file diff --git a/actions/gls-action/test/index.test.ts b/actions/gls-action/test/index.test.ts new file mode 100644 index 0000000..b1e74c4 --- /dev/null +++ b/actions/gls-action/test/index.test.ts @@ -0,0 +1,104 @@ +import {describe, expect, it, vi} from "vitest"; +import { + HerculesActionConfigurationDefinition, + HerculesDataType, + HerculesFlowType, + HerculesRegisterFunctionParameter +} from "@code0-tech/hercules"; +import {withSdkMock} from "./helpers/withSdkMock"; + +export type SdkMockState = { + registeredFunctionDefinitions: HerculesRegisterFunctionParameter[] | null; + dataTypes: HerculesDataType[] | null; + flowTypes: HerculesFlowType[] | null; + configDefinitions: HerculesActionConfigurationDefinition[] | null; +} + + +describe("withSdkMock", () => { + withSdkMock((state) => { + it("registers config definitions", async () => { + const {createSdk} = await import("@code0-tech/hercules"); + + const sdk = createSdk({ + authToken: "testToken", + aquilaUrl: "http://localhost:50051", + actionId: "testAction", + version: "1.0.0", + }); + + await sdk.registerConfigDefinitions({ + identifier: "config_test", + type: "STRING", + }); + + expect(state.configDefinitions).toEqual([ + {identifier: "config_test", type: "STRING"}, + ]); + }); + + it("registers data and flow types", async () => { + const {createSdk} = await import("@code0-tech/hercules"); + + const sdk = createSdk({ + authToken: "testToken", + aquilaUrl: "http://localhost:50051", + actionId: "testAction", + version: "1.0.0", + }); + + await sdk.registerDataTypes({ + identifier: "Data1", + type: "string", + }); + + await sdk.registerFlowTypes({ + identifier: "Flow1", + editable: false, + }); + + expect(state.dataTypes).toEqual([ + {identifier: "Data1", type: "string"}, + ]); + + expect(state.flowTypes).toEqual([ + {identifier: "Flow1", editable: false}, + ]); + }); + + + it('should be valid', async () => { + vi.resetModules(); // clear module cache + await import("../src"); // now it runs + + state.dataTypes?.forEach((dataType: HerculesDataType) => { + expect(dataType.identifier.startsWith("GLS_"), `${dataType.identifier}: Identifier should start with GLS_`).toBeTruthy() + expect(dataType.name || [], `${dataType.identifier}: Name should be set`).not.toHaveLength(0) + expect(dataType.displayMessage || [], `${dataType.identifier}: Display message should be set`).not.toHaveLength(0) + }) + + state.configDefinitions?.forEach(value => { + expect(value.name || [], `${value.identifier}: Name should be set`).not.toHaveLength(0) + expect(value.description || [], `${value.identifier}: Description should be set`).not.toHaveLength(0) + expect(value.linkedDataTypes || [], `${value.identifier}: Linked data types should be set`).not.toHaveLength(0) + }) + + state.flowTypes?.forEach(value => { + expect(value.identifier.startsWith("GLS_"), `${value.identifier}: Identifier should start with GLS_`).toBeTruthy() + expect(value.name || [], `${value.identifier}: Name should be set`).not.toHaveLength(0) + expect(value.description || [], `${value.identifier}: Description should be set`).not.toHaveLength(0) + expect(value.displayMessage || [], `${value.identifier}: Display message should be set`).not.toHaveLength(0) + expect(value.documentation || [], `${value.identifier}: Documentation should be set`).not.toHaveLength(0) + }) + + state.registeredFunctionDefinitions?.forEach(value => { + expect(value.definition.name || [], `${value.definition.runtimeName}: Name should be set`).not.toHaveLength(0) + expect(value.definition.description || [], `${value.definition.runtimeName}: Description should be set`).not.toHaveLength(0) + value.definition.parameters?.forEach(param => { + expect(param.name || [], `${value.definition.runtimeName} parameter ${param.runtimeName}: Name should be set`).not.toHaveLength(0) + expect(param.description || [], `${value.definition.runtimeName} parameter ${param.runtimeName}: Description should be set`).not.toHaveLength(0) + }) + }) + }); + }); +}) diff --git a/actions/gls-action/tsconfig.json b/actions/gls-action/tsconfig.json index 599baca..8394117 100644 --- a/actions/gls-action/tsconfig.json +++ b/actions/gls-action/tsconfig.json @@ -3,6 +3,5 @@ "compilerOptions": { "outDir": "dist" }, - "include": ["src"], - "exclude": ["node_modules", "dist"] + "include": ["src"] } \ No newline at end of file diff --git a/actions/gls-action/vite.config.ts b/actions/gls-action/vite.config.ts new file mode 100644 index 0000000..f584efa --- /dev/null +++ b/actions/gls-action/vite.config.ts @@ -0,0 +1,30 @@ +import {defineConfig} from 'vite'; +import {resolve} from 'path'; + +export default defineConfig({ + build: { + target: 'node18', + ssr: true, + outDir: 'dist', + emptyOutDir: true, + rollupOptions: { + input: { + main: resolve(__dirname, 'src/index.ts'), + }, + external: [ + 'fs', + 'path', + 'os', + 'crypto', + 'stream', + 'util', + 'events', + 'buffer', + 'url', + 'zlib', + 'node:fs', + 'node:path' + ] + } + } +}); \ No newline at end of file diff --git a/actions/gls-action/vitest.config.ts b/actions/gls-action/vitest.config.ts new file mode 100644 index 0000000..918a608 --- /dev/null +++ b/actions/gls-action/vitest.config.ts @@ -0,0 +1,8 @@ +import baseConfig from "../../vitest.config"; +import { defineConfig, mergeConfig } from "vitest/config"; + +export default mergeConfig(baseConfig, defineConfig({ + test: { + include: ["**/*.{test,spec}.{ts,tsx}"] + } +})); \ No newline at end of file diff --git a/code0-tech-hercules-1.0.0.tgz b/code0-tech-hercules-1.0.0.tgz deleted file mode 100644 index 9970d16..0000000 Binary files a/code0-tech-hercules-1.0.0.tgz and /dev/null differ diff --git a/code0-tech-tucana-0.0.0.tgz b/code0-tech-tucana-0.0.0.tgz deleted file mode 100644 index 4492913..0000000 Binary files a/code0-tech-tucana-0.0.0.tgz and /dev/null differ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..85b210b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +version: "3.9" + +services: + gls-action: + build: + context: . + dockerfile: actions/gls-action/Dockerfile + container_name: gls-action \ No newline at end of file diff --git a/docs/Actions/GLS/configs.md b/docs/Actions/GLS/configs.md index 7a9b898..20d3de5 100644 --- a/docs/Actions/GLS/configs.md +++ b/docs/Actions/GLS/configs.md @@ -97,7 +97,7 @@ The value must be a valid `GLS_SHIPPER` object: ```json { - "Address": { + "AddressSchema": { "Name1": "My Company GmbH", "CountryCode": "DE", "City": "Berlin", diff --git a/docs/Actions/GLS/functions.md b/docs/Actions/GLS/functions.md index fbf2e4c..7633a68 100644 --- a/docs/Actions/GLS/functions.md +++ b/docs/Actions/GLS/functions.md @@ -69,7 +69,7 @@ Creates a GLS consignee (recipient) object for use in shipments. createConsignee( consigneeId: string, costCenter: string, - Address: GLS_ADDRESS, + AddressSchema: GLS_ADDRESS, Category: "BUSINESS" | "PRIVATE" ): GLS_CONSIGNEE ``` @@ -80,7 +80,7 @@ createConsignee( |-----------|------|----------|-------------| | `consigneeId` | string (max 40) | **Yes** | Unique ID for the consignee (your internal customer ID) | | `costCenter` | string (max 80) | **Yes** | Cost center for billing purposes | -| `Address` | GLS_ADDRESS | **Yes** | The delivery address for this consignee | +| `AddressSchema` | GLS_ADDRESS | **Yes** | The delivery address for this consignee | | `Category` | `"BUSINESS"` \| `"PRIVATE"` | **Yes** | Whether the consignee is a business or private recipient | **Returns:** [`GLS_CONSIGNEE`](types.md#GLS_CONSIGNEE) @@ -259,7 +259,7 @@ createExchangeShipment( | Parameter | Type | Required | Description | |-----------|------|----------|-------------| -| `address` | GLS_ADDRESS | **Yes** | Address for the exchange pickup | +| `address` | GLS_ADDRESS | **Yes** | AddressSchema for the exchange pickup | | `expectedWeight` | number (min 1) | No | Expected weight of the parcel being returned | --- @@ -602,7 +602,7 @@ getEndOfDayReport({ date }) │ ▼ GLS_END_OF_DAY_RESPONSE_DATA - └── Shipments[]: { ShippingDate, Product, Consignee, Shipper, ShipmentUnit[] } + └── Shipments[]: { ShippingDate, Product, ConsigneeSchema, ShipperSchema, ShipmentUnit[] } ``` --- diff --git a/docs/Actions/GLS/quick-start.md b/docs/Actions/GLS/quick-start.md index f76e485..60e2c8f 100644 --- a/docs/Actions/GLS/quick-start.md +++ b/docs/Actions/GLS/quick-start.md @@ -75,8 +75,8 @@ START parcelShopId: "12345" shipment: Product: "PARCEL" - Consignee: { Address: } - Shipper: { Address: } + ConsigneeSchema: { AddressSchema: } + ShipperSchema: { AddressSchema: } ShipmentUnit: [] printingOptions: │ diff --git a/docs/Actions/GLS/types.md b/docs/Actions/GLS/types.md index 4c3eb31..fd3af33 100644 --- a/docs/Actions/GLS/types.md +++ b/docs/Actions/GLS/types.md @@ -47,7 +47,7 @@ Represents the recipient of a shipment. | `ConsigneeID` | string | No | max 40 | Your internal customer/consignee ID | | `CostCenter` | string | No | max 80 | Cost center for billing | | `Category` | `"BUSINESS"` \| `"PRIVATE"` | No | — | Type of recipient | -| `Address` | GLS_ADDRESS | **Yes** | — | Physical delivery address | +| `AddressSchema` | GLS_ADDRESS | **Yes** | — | Physical delivery address | --- @@ -61,7 +61,7 @@ Represents the sender of a shipment. | Field | Type | Required | Description | |-----------------------------|-------------|----------|-------------------------------------------| -| `Address` | GLS_ADDRESS | No | Primary shipper address | +| `AddressSchema` | GLS_ADDRESS | No | Primary shipper address | | `AlternativeShipperAddress` | GLS_ADDRESS | No | Alternative address to print on the label | > **Note:** When used in the configuration (`shipper`), the action automatically includes the `ContactID` from the @@ -119,7 +119,7 @@ Each element is an object with one of the following service fields: |------------------------|------------------------------------------------------------------------------------------|------------------------------------| | `ShopDelivery` | `ParcelShopID` (max 50) | Delivery to a GLS Parcel Shop | | `ShopReturn` | `NumberOfLabels`, `ReturnQR?` | Return from a Parcel Shop | -| `Exchange` | `Address` (GLS_ADDRESS), `ExpectedWeight?` | Exchange delivery and pickup | +| `Exchange` | `AddressSchema` (GLS_ADDRESS), `ExpectedWeight?` | Exchange delivery and pickup | | `DeliveryAtWork` | `RecipientName`, `Building`, `Floor`, `Room?`, `Phonenumber?`, `AlternateRecipientName?` | Workplace delivery | | `Deposit` | `PlaceOfDeposit` (max 121) | Deposit without signature | | `IdentPin` | `PIN` (max 4), `Birthdate?` | PIN-based identity check | @@ -148,8 +148,8 @@ The complete shipment object including all services. | Field | Type | Required | Description | |-----------------------------|---------------------------|----------|--------------------------------------------------| | `Product` | `"PARCEL"` \| `"EXPRESS"` | **Yes** | Shipment product type | -| `Consignee` | GLS_CONSIGNEE | **Yes** | Recipient details | -| `Shipper` | GLS_SHIPPER | **Yes** | Sender details | +| `ConsigneeSchema` | GLS_CONSIGNEE | **Yes** | Recipient details | +| `ShipperSchema` | GLS_SHIPPER | **Yes** | Sender details | | `ShipmentUnit` | GLS_SHIPMENT_UNIT[] | **Yes** | Array of parcels (min 1) | | `Service` | GLS_SHIPMENT_SERVICE | No | Shipment-level services | | `ShipmentReference` | string (max 40) | No | Your internal shipment reference | @@ -158,7 +158,7 @@ The complete shipment object including all services. | `Identifier` | string (max 40) | No | Additional identifier | | `ExpressAltDeliveryAllowed` | boolean | No | Allow alternative delivery for express shipments | | `Carrier` | `"ROYALMAIL"` | No | Override carrier (UK only) | -| `Return.Address` | GLS_ADDRESS | No | Address for return shipments | +| `Return.AddressSchema` | GLS_ADDRESS | No | AddressSchema for return shipments | --- @@ -312,9 +312,9 @@ Response from the `getEndOfDayReport` function. |-------------------------------------------------|---------------------------|----------------------------------| | `Shipments[].ShippingDate` | ISO date | Date the shipment was dispatched | | `Shipments[].Product` | `"PARCEL"` \| `"EXPRESS"` | Product type | -| `Shipments[].Consignee.Address` | GLS_ADDRESS | Recipient address | -| `Shipments[].Shipper.ContactID` | string | GLS contact ID of shipper | -| `Shipments[].Shipper.AlternativeShipperAddress` | GLS_ADDRESS | Alternative shipper address | +| `Shipments[].ConsigneeSchema.AddressSchema` | GLS_ADDRESS | Recipient address | +| `Shipments[].ShipperSchema.ContactID` | string | GLS contact ID of shipper | +| `Shipments[].ShipperSchema.AlternativeShipperAddress` | GLS_ADDRESS | Alternative shipper address | | `Shipments[].ShipmentUnit[].TrackID` | string | Tracking ID | | `Shipments[].ShipmentUnit[].Weight` | string | Parcel weight | | `Shipments[].ShipmentUnit[].ParcelNumber` | string | GLS parcel number | @@ -412,10 +412,10 @@ Response from the `validateShipment` function. ``` GLS_SHIPMENT_WITHOUT_SERVICES - ├── Consignee: GLS_CONSIGNEE - │ └── Address: GLS_ADDRESS - ├── Shipper: GLS_SHIPPER - │ ├── Address: GLS_ADDRESS + ├── ConsigneeSchema: GLS_CONSIGNEE + │ └── AddressSchema: GLS_ADDRESS + ├── ShipperSchema: GLS_SHIPPER + │ ├── AddressSchema: GLS_ADDRESS │ └── AlternativeShipperAddress: GLS_ADDRESS └── ShipmentUnit[]: GLS_SHIPMENT_UNIT └── Service: GLS_UNIT_SERVICE diff --git a/docs/Actions/GLS/use-cases.md b/docs/Actions/GLS/use-cases.md index 405b692..1a36bfb 100644 --- a/docs/Actions/GLS/use-cases.md +++ b/docs/Actions/GLS/use-cases.md @@ -72,12 +72,12 @@ createShopDeliveryShipment( parcelShopId: "PSH-HH-001", shipment: { Product: "PARCEL", - Consignee: { + ConsigneeSchema: { ConsigneeID: "CUST-5678", Category: "PRIVATE", - Address: + AddressSchema: }, - Shipper: {}, ← uses default shipper from action config + ShipperSchema: {}, ← uses default shipper from action config ShipmentUnit: [] }, printingOptions: @@ -117,8 +117,8 @@ createShopDeliveryShipment( validateShipment({ Shipment: { Product: "PARCEL", - Consignee: { - Address: { + ConsigneeSchema: { + AddressSchema: { Name1: "Test Recipient", CountryCode: "DE", City: "Berlin", @@ -126,7 +126,7 @@ validateShipment({ ZIPCode: "10115" } }, - Shipper: {}, + ShipperSchema: {}, ShipmentUnit: [{ Weight: 0.5 }] } }) @@ -149,7 +149,7 @@ If `success` is `false`, inspect `validationResult.Issues` for details: "Issues": [ { "Rule": "MIN_LENGTH", - "Location": "Shipment.Consignee.Address.Street", + "Location": "Shipment.ConsigneeSchema.AddressSchema.Street", "Parameters": ["4"] } ] @@ -185,8 +185,8 @@ createShopReturnShipment( numberOfLabels: 1, shipment: { Product: "PARCEL", - Consignee: { - Address: { + ConsigneeSchema: { + AddressSchema: { Name1: "My Warehouse GmbH", CountryCode: "DE", City: "Frankfurt", @@ -194,7 +194,7 @@ createShopReturnShipment( ZIPCode: "60327" } }, - Shipper: {}, + ShipperSchema: {}, ShipmentUnit: [{ Weight: 2.0 }] }, printingOptions: { @@ -240,8 +240,8 @@ createIdentShipment( nationality: "DE", shipment: { Product: "PARCEL", - Consignee: { - Address: { + ConsigneeSchema: { + AddressSchema: { Name1: "Hans Mueller", CountryCode: "DE", City: "Munich", @@ -249,7 +249,7 @@ createIdentShipment( ZIPCode: "80333" } }, - Shipper: {}, + ShipperSchema: {}, ShipmentUnit: [{ Weight: 1.8 }] }, printingOptions: { @@ -296,8 +296,8 @@ Response: { "ShippingDate": "2025-01-15", "Product": "PARCEL", - "Consignee": { - "Address": { "Name1": "Jane Smith", "City": "Hamburg" } // ... and other parameters + "ConsigneeSchema": { + "AddressSchema": { "Name1": "Jane Smith", "City": "Hamburg" } // ... and other parameters }, "ShipmentUnit": [ { "TrackID": "12345678", "Weight": "1.2", "ParcelNumber": "00123456789" } @@ -407,8 +407,8 @@ Use this to dynamically enable/disable delivery options in your checkout flow. createDeliverySaturdayShipment( shipment: { Product: "EXPRESS", ← required! - Consignee: { - Address: { + ConsigneeSchema: { + AddressSchema: { Name1: "Weekend Shopper", CountryCode: "DE", City: "Cologne", @@ -416,7 +416,7 @@ createDeliverySaturdayShipment( ZIPCode: "50667" } }, - Shipper: {}, + ShipperSchema: {}, ShipmentUnit: [{ Weight: 0.8 }] }, printingOptions: { diff --git a/eslint.config.mjs b/eslint.config.mjs index b554e38..76e5ba6 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -4,13 +4,27 @@ import tseslint from "typescript-eslint"; import globals from "globals"; export default defineConfig([ - js.configs.recommended, - ...tseslint.configs.recommended, - globalIgnores(["**/dist/**", "**/node_modules/**"]), - { - files: ["scripts/**/*.mjs"], - languageOptions: { - globals: globals.node, + js.configs.recommended, + ...tseslint.configs.recommended, + globalIgnores(["**/dist/**", "**/node_modules/**"]), + + { + rules: { + "@typescript-eslint/no-explicit-any": "off", + }, + }, + + { + files: ["scripts/**/*.mjs"], + languageOptions: { + globals: globals.node, + }, }, - }, + { + "rules": { + "@typescript-eslint/no-unused-vars": [ + "error" + ] + } + } ]); diff --git a/package-lock.json b/package-lock.json index 7e986e4..f45fe06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,9 +11,9 @@ "actions/*" ], "dependencies": { - "@code0-tech/hercules": "file:code0-tech-hercules-1.0.0.tgz", - "@code0-tech/tucana": "0.0.60", + "@code0-tech/hercules": "file:code0-tech-hercules-0.0.0.tgz", "axios": "^1.13.6", + "vite": "^7.3.1", "zod": "^4.3.6", "zod-to-ts": "^2.0.0" }, @@ -21,6 +21,7 @@ "@eslint/js": "^10.0.0", "eslint": "^10.0.0", "globals": "^17.4.0", + "turbo": "^2.8.21", "typescript": "^5", "typescript-eslint": "^8.0.0", "vitest": "^4.0.0" @@ -40,9 +41,9 @@ "link": true }, "node_modules/@code0-tech/hercules": { - "version": "1.0.0", - "resolved": "file:code0-tech-hercules-1.0.0.tgz", - "integrity": "sha512-lIVC5tyYOzxd3e7cFCbKwfQ6vu9RllKmmyApila1+QY04OQfAost6yo2BWCt8YQBF9/PXC78mCAIRQ0Cpi3Kkg==", + "version": "0.0.0", + "resolved": "file:code0-tech-hercules-0.0.0.tgz", + "integrity": "sha512-MwoauVdEnfA7IvODjPt2aPbQe8m0xmFAq+smn/sIId/yeJ1ldmoJjhtDFeXpYgS6fLZQ09lgpXrTYmZAiyRPsQ==", "license": "ISC", "dependencies": { "@code0-tech/tucana": "file:code0-tech-tucana-0.0.0.tgz", @@ -56,13 +57,7 @@ "node_modules/@code0-tech/hercules/node_modules/@code0-tech/tucana": { "version": "0.0.0", "resolved": "file:code0-tech-tucana-0.0.0.tgz", - "integrity": "sha512-xxkxozi1zAPZcS3N7ctKzR12aL0pIrGQZgCnIt2QdlR1rpQX+Hg3dMbz9gyXmTi5Q6aMW0xm6e4BwsSF+TodIQ==", - "license": "Apache-2.0" - }, - "node_modules/@code0-tech/tucana": { - "version": "0.0.60", - "resolved": "https://registry.npmjs.org/@code0-tech/tucana/-/tucana-0.0.60.tgz", - "integrity": "sha512-rduTbTy+LfGdwr7s8KXLersWe2BRwUu2UTi/TjdbUCirOn9ulO3Q1u23hQg1zh+LiGuONIdAGjf/fYbHVa/pmw==", + "integrity": "sha512-ZXpWELHdEYyeJaGue9Lq2t0sqnR4F77fxwsAaim0Q7gkilsCCzIFYPy4t3cRhfhKtw3iSknDOGrtFqvAaH6D5w==", "license": "Apache-2.0" }, "node_modules/@esbuild/aix-ppc64": { @@ -72,7 +67,6 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -89,7 +83,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -106,7 +99,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -123,7 +115,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -140,7 +131,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -157,7 +147,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -174,7 +163,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -191,7 +179,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -208,7 +195,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -225,7 +211,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -242,7 +227,6 @@ "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -259,7 +243,6 @@ "cpu": [ "loong64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -276,7 +259,6 @@ "cpu": [ "mips64el" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -293,7 +275,6 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -310,7 +291,6 @@ "cpu": [ "riscv64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -327,7 +307,6 @@ "cpu": [ "s390x" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -344,7 +323,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -361,7 +339,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -378,7 +355,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -395,7 +371,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -412,7 +387,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -429,7 +403,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -446,7 +419,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -463,7 +435,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -480,7 +451,6 @@ "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -497,7 +467,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -841,13 +810,12 @@ "license": "BSD-3-Clause" }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.59.0.tgz", - "integrity": "sha512-upnNBkA6ZH2VKGcBj9Fyl9IGNPULcjXRlg0LLeaioQWueH30p6IXtJEbKAgvyv+mJaMxSm1l6xwDXYjpEMiLMg==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.60.0.tgz", + "integrity": "sha512-WOhNW9K8bR3kf4zLxbfg6Pxu2ybOUbB2AjMDHSQx86LIF4rH4Ft7vmMwNt0loO0eonglSNy4cpD3MKXXKQu0/A==", "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -855,13 +823,12 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.59.0.tgz", - "integrity": "sha512-hZ+Zxj3SySm4A/DylsDKZAeVg0mvi++0PYVceVyX7hemkw7OreKdCvW2oQ3T1FMZvCaQXqOTHb8qmBShoqk69Q==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.60.0.tgz", + "integrity": "sha512-u6JHLll5QKRvjciE78bQXDmqRqNs5M/3GVqZeMwvmjaNODJih/WIrJlFVEihvV0MiYFmd+ZyPr9wxOVbPAG2Iw==", "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -869,13 +836,12 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.59.0.tgz", - "integrity": "sha512-W2Psnbh1J8ZJw0xKAd8zdNgF9HRLkdWwwdWqubSVk0pUuQkoHnv7rx4GiF9rT4t5DIZGAsConRE3AxCdJ4m8rg==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.60.0.tgz", + "integrity": "sha512-qEF7CsKKzSRc20Ciu2Zw1wRrBz4g56F7r/vRwY430UPp/nt1x21Q/fpJ9N5l47WWvJlkNCPJz3QRVw008fi7yA==", "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -883,13 +849,12 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.59.0.tgz", - "integrity": "sha512-ZW2KkwlS4lwTv7ZVsYDiARfFCnSGhzYPdiOU4IM2fDbL+QGlyAbjgSFuqNRbSthybLbIJ915UtZBtmuLrQAT/w==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.60.0.tgz", + "integrity": "sha512-WADYozJ4QCnXCH4wPB+3FuGmDPoFseVCUrANmA5LWwGmC6FL14BWC7pcq+FstOZv3baGX65tZ378uT6WG8ynTw==", "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -897,13 +862,12 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.59.0.tgz", - "integrity": "sha512-EsKaJ5ytAu9jI3lonzn3BgG8iRBjV4LxZexygcQbpiU0wU0ATxhNVEpXKfUa0pS05gTcSDMKpn3Sx+QB9RlTTA==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.60.0.tgz", + "integrity": "sha512-6b8wGHJlDrGeSE3aH5mGNHBjA0TTkxdoNHik5EkvPHCt351XnigA4pS7Wsj/Eo9Y8RBU6f35cjN9SYmCFBtzxw==", "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -911,13 +875,12 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.59.0.tgz", - "integrity": "sha512-d3DuZi2KzTMjImrxoHIAODUZYoUUMsuUiY4SRRcJy6NJoZ6iIqWnJu9IScV9jXysyGMVuW+KNzZvBLOcpdl3Vg==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.60.0.tgz", + "integrity": "sha512-h25Ga0t4jaylMB8M/JKAyrvvfxGRjnPQIR8lnCayyzEjEOx2EJIlIiMbhpWxDRKGKF8jbNH01NnN663dH638mA==", "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -925,13 +888,12 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.59.0.tgz", - "integrity": "sha512-t4ONHboXi/3E0rT6OZl1pKbl2Vgxf9vJfWgmUoCEVQVxhW6Cw/c8I6hbbu7DAvgp82RKiH7TpLwxnJeKv2pbsw==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.60.0.tgz", + "integrity": "sha512-RzeBwv0B3qtVBWtcuABtSuCzToo2IEAIQrcyB/b2zMvBWVbjo8bZDjACUpnaafaxhTw2W+imQbP2BD1usasK4g==", "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -939,13 +901,12 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.59.0.tgz", - "integrity": "sha512-CikFT7aYPA2ufMD086cVORBYGHffBo4K8MQ4uPS/ZnY54GKj36i196u8U+aDVT2LX4eSMbyHtyOh7D7Zvk2VvA==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.60.0.tgz", + "integrity": "sha512-Sf7zusNI2CIU1HLzuu9Tc5YGAHEZs5Lu7N1ssJG4Tkw6e0MEsN7NdjUDDfGNHy2IU+ENyWT+L2obgWiguWibWQ==", "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -953,13 +914,12 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.59.0.tgz", - "integrity": "sha512-jYgUGk5aLd1nUb1CtQ8E+t5JhLc9x5WdBKew9ZgAXg7DBk0ZHErLHdXM24rfX+bKrFe+Xp5YuJo54I5HFjGDAA==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.60.0.tgz", + "integrity": "sha512-DX2x7CMcrJzsE91q7/O02IJQ5/aLkVtYFryqCjduJhUfGKG6yJV8hxaw8pZa93lLEpPTP/ohdN4wFz7yp/ry9A==", "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -967,13 +927,12 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.59.0.tgz", - "integrity": "sha512-peZRVEdnFWZ5Bh2KeumKG9ty7aCXzzEsHShOZEFiCQlDEepP1dpUl/SrUNXNg13UmZl+gzVDPsiCwnV1uI0RUA==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.60.0.tgz", + "integrity": "sha512-09EL+yFVbJZlhcQfShpswwRZ0Rg+z/CsSELFCnPt3iK+iqwGsI4zht3secj5vLEs957QvFFXnzAT0FFPIxSrkQ==", "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -981,13 +940,12 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-gnu": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.59.0.tgz", - "integrity": "sha512-gbUSW/97f7+r4gHy3Jlup8zDG190AuodsWnNiXErp9mT90iCy9NKKU0Xwx5k8VlRAIV2uU9CsMnEFg/xXaOfXg==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.60.0.tgz", + "integrity": "sha512-i9IcCMPr3EXm8EQg5jnja0Zyc1iFxJjZWlb4wr7U2Wx/GrddOuEafxRdMPRYVaXjgbhvqalp6np07hN1w9kAKw==", "cpu": [ "loong64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -995,13 +953,12 @@ ] }, "node_modules/@rollup/rollup-linux-loong64-musl": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.59.0.tgz", - "integrity": "sha512-yTRONe79E+o0FWFijasoTjtzG9EBedFXJMl888NBEDCDV9I2wGbFFfJQQe63OijbFCUZqxpHz1GzpbtSFikJ4Q==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.60.0.tgz", + "integrity": "sha512-DGzdJK9kyJ+B78MCkWeGnpXJ91tK/iKA6HwHxF4TAlPIY7GXEvMe8hBFRgdrR9Ly4qebR/7gfUs9y2IoaVEyog==", "cpu": [ "loong64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1009,13 +966,12 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-gnu": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.59.0.tgz", - "integrity": "sha512-sw1o3tfyk12k3OEpRddF68a1unZ5VCN7zoTNtSn2KndUE+ea3m3ROOKRCZxEpmT9nsGnogpFP9x6mnLTCaoLkA==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.60.0.tgz", + "integrity": "sha512-RwpnLsqC8qbS8z1H1AxBA1H6qknR4YpPR9w2XX0vo2Sz10miu57PkNcnHVaZkbqyw/kUWfKMI73jhmfi9BRMUQ==", "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1023,13 +979,12 @@ ] }, "node_modules/@rollup/rollup-linux-ppc64-musl": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.59.0.tgz", - "integrity": "sha512-+2kLtQ4xT3AiIxkzFVFXfsmlZiG5FXYW7ZyIIvGA7Bdeuh9Z0aN4hVyXS/G1E9bTP/vqszNIN/pUKCk/BTHsKA==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.60.0.tgz", + "integrity": "sha512-Z8pPf54Ly3aqtdWC3G4rFigZgNvd+qJlOE52fmko3KST9SoGfAdSRCwyoyG05q1HrrAblLbk1/PSIV+80/pxLg==", "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1037,13 +992,12 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.59.0.tgz", - "integrity": "sha512-NDYMpsXYJJaj+I7UdwIuHHNxXZ/b/N2hR15NyH3m2qAtb/hHPA4g4SuuvrdxetTdndfj9b1WOmy73kcPRoERUg==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.60.0.tgz", + "integrity": "sha512-3a3qQustp3COCGvnP4SvrMHnPQ9d1vzCakQVRTliaz8cIp/wULGjiGpbcqrkv0WrHTEp8bQD/B3HBjzujVWLOA==", "cpu": [ "riscv64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1051,13 +1005,12 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.59.0.tgz", - "integrity": "sha512-nLckB8WOqHIf1bhymk+oHxvM9D3tyPndZH8i8+35p/1YiVoVswPid2yLzgX7ZJP0KQvnkhM4H6QZ5m0LzbyIAg==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.60.0.tgz", + "integrity": "sha512-pjZDsVH/1VsghMJ2/kAaxt6dL0psT6ZexQVrijczOf+PeP2BUqTHYejk3l6TlPRydggINOeNRhvpLa0AYpCWSQ==", "cpu": [ "riscv64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1065,13 +1018,12 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.59.0.tgz", - "integrity": "sha512-oF87Ie3uAIvORFBpwnCvUzdeYUqi2wY6jRFWJAy1qus/udHFYIkplYRW+wo+GRUP4sKzYdmE1Y3+rY5Gc4ZO+w==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.60.0.tgz", + "integrity": "sha512-3ObQs0BhvPgiUVZrN7gqCSvmFuMWvWvsjG5ayJ3Lraqv+2KhOsp+pUbigqbeWqueGIsnn+09HBw27rJ+gYK4VQ==", "cpu": [ "s390x" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1079,13 +1031,12 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.59.0.tgz", - "integrity": "sha512-3AHmtQq/ppNuUspKAlvA8HtLybkDflkMuLK4DPo77DfthRb71V84/c4MlWJXixZz4uruIH4uaa07IqoAkG64fg==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.60.0.tgz", + "integrity": "sha512-EtylprDtQPdS5rXvAayrNDYoJhIz1/vzN2fEubo3yLE7tfAw+948dO0g4M0vkTVFhKojnF+n6C8bDNe+gDRdTg==", "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1093,13 +1044,12 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.59.0.tgz", - "integrity": "sha512-2UdiwS/9cTAx7qIUZB/fWtToJwvt0Vbo0zmnYt7ED35KPg13Q0ym1g442THLC7VyI6JfYTP4PiSOWyoMdV2/xg==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.60.0.tgz", + "integrity": "sha512-k09oiRCi/bHU9UVFqD17r3eJR9bn03TyKraCrlz5ULFJGdJGi7VOmm9jl44vOJvRJ6P7WuBi/s2A97LxxHGIdw==", "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1107,13 +1057,12 @@ ] }, "node_modules/@rollup/rollup-openbsd-x64": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.59.0.tgz", - "integrity": "sha512-M3bLRAVk6GOwFlPTIxVBSYKUaqfLrn8l0psKinkCFxl4lQvOSz8ZrKDz2gxcBwHFpci0B6rttydI4IpS4IS/jQ==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.60.0.tgz", + "integrity": "sha512-1o/0/pIhozoSaDJoDcec+IVLbnRtQmHwPV730+AOD29lHEEo4F5BEUB24H0OBdhbBBDwIOSuf7vgg0Ywxdfiiw==", "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1121,13 +1070,12 @@ ] }, "node_modules/@rollup/rollup-openharmony-arm64": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.59.0.tgz", - "integrity": "sha512-tt9KBJqaqp5i5HUZzoafHZX8b5Q2Fe7UjYERADll83O4fGqJ49O1FsL6LpdzVFQcpwvnyd0i+K/VSwu/o/nWlA==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.60.0.tgz", + "integrity": "sha512-pESDkos/PDzYwtyzB5p/UoNU/8fJo68vcXM9ZW2V0kjYayj1KaaUfi1NmTUTUpMn4UhU4gTuK8gIaFO4UGuMbA==", "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1135,13 +1083,12 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.59.0.tgz", - "integrity": "sha512-V5B6mG7OrGTwnxaNUzZTDTjDS7F75PO1ae6MJYdiMu60sq0CqN5CVeVsbhPxalupvTX8gXVSU9gq+Rx1/hvu6A==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.60.0.tgz", + "integrity": "sha512-hj1wFStD7B1YBeYmvY+lWXZ7ey73YGPcViMShYikqKT1GtstIKQAtfUI6yrzPjAy/O7pO0VLXGmUVWXQMaYgTQ==", "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1149,13 +1096,12 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.59.0.tgz", - "integrity": "sha512-UKFMHPuM9R0iBegwzKF4y0C4J9u8C6MEJgFuXTBerMk7EJ92GFVFYBfOZaSGLu6COf7FxpQNqhNS4c4icUPqxA==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.60.0.tgz", + "integrity": "sha512-SyaIPFoxmUPlNDq5EHkTbiKzmSEmq/gOYFI/3HHJ8iS/v1mbugVa7dXUzcJGQfoytp9DJFLhHH4U3/eTy2Bq4w==", "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1163,13 +1109,12 @@ ] }, "node_modules/@rollup/rollup-win32-x64-gnu": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.59.0.tgz", - "integrity": "sha512-laBkYlSS1n2L8fSo1thDNGrCTQMmxjYY5G0WFWjFFYZkKPjsMBsgJfGf4TLxXrF6RyhI60L8TMOjBMvXiTcxeA==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.60.0.tgz", + "integrity": "sha512-RdcryEfzZr+lAr5kRm2ucN9aVlCCa2QNq4hXelZxb8GG0NJSazq44Z3PCCc8wISRuCVnGs0lQJVX5Vp6fKA+IA==", "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1177,13 +1122,12 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.59.0.tgz", - "integrity": "sha512-2HRCml6OztYXyJXAvdDXPKcawukWY2GpR5/nxKp4iBgiO3wcoEGkAaqctIbZcNB6KlUQBIqt8VYkNSj2397EfA==", + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.60.0.tgz", + "integrity": "sha512-PrsWNQ8BuE00O3Xsx3ALh2Df8fAj9+cvvX9AIA6o4KpATR98c9mud4XtDWVvsEuyia5U4tVSTKygawyJkjm60w==", "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1197,6 +1141,90 @@ "dev": true, "license": "MIT" }, + "node_modules/@turbo/darwin-64": { + "version": "2.8.21", + "resolved": "https://registry.npmjs.org/@turbo/darwin-64/-/darwin-64-2.8.21.tgz", + "integrity": "sha512-kfGoM0Iw8ZNZpbds+4IzOe0hjvHldqJwUPRAjXJi3KBxg/QOZL95N893SRoMtf2aJ+jJ3dk32yPkp8rvcIjP9g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@turbo/darwin-arm64": { + "version": "2.8.21", + "resolved": "https://registry.npmjs.org/@turbo/darwin-arm64/-/darwin-arm64-2.8.21.tgz", + "integrity": "sha512-o9HEflxUEyr987x0cTUzZBhDOyL6u95JmdmlkH2VyxAw7zq2sdtM5e72y9ufv2N5SIoOBw1fVn9UES5VY5H6vQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@turbo/linux-64": { + "version": "2.8.21", + "resolved": "https://registry.npmjs.org/@turbo/linux-64/-/linux-64-2.8.21.tgz", + "integrity": "sha512-uTxlCcXWy5h1fSSymP8XSJ+AudzEHMDV3IDfKX7+DGB8kgJ+SLoTUAH7z4OFA7I/l2sznz0upPdbNNZs91YMag==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@turbo/linux-arm64": { + "version": "2.8.21", + "resolved": "https://registry.npmjs.org/@turbo/linux-arm64/-/linux-arm64-2.8.21.tgz", + "integrity": "sha512-cdHIcxNcihHHkCHp0Y4Zb60K4Qz+CK4xw1gb6s/t/9o4SMeMj+hTBCtoW6QpPnl9xPYmxuTou8Zw6+cylTnREg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@turbo/windows-64": { + "version": "2.8.21", + "resolved": "https://registry.npmjs.org/@turbo/windows-64/-/windows-64-2.8.21.tgz", + "integrity": "sha512-/iBj4OzbqEY8CX+eaeKbBTMZv2CLXNrt0692F7HnK7LcyYwyDecaAiSET6ZzL4opT7sbwkKvzAC/fhqT3Quu1A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@turbo/windows-arm64": { + "version": "2.8.21", + "resolved": "https://registry.npmjs.org/@turbo/windows-arm64/-/windows-arm64-2.8.21.tgz", + "integrity": "sha512-95tMA/ZbIidJFUUtkmqioQ1gf3n3I1YbRP3ZgVdWTVn2qVbkodcIdGXBKRHHrIbRsLRl99SiHi/L7IxhpZDagQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@types/chai": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", @@ -1226,7 +1254,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", - "dev": true, "license": "MIT" }, "node_modules/@types/json-schema": { @@ -1688,9 +1715,9 @@ } }, "node_modules/brace-expansion": { - "version": "5.0.4", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.4.tgz", - "integrity": "sha512-h+DEnpVvxmfVefa4jFbCf5HdH5YMDXRsmKflpf1pILZWRFlTbJpxeU55nJl4Smt5HQaGzg1o6RHFPJaOqnmBDg==", + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.5.tgz", + "integrity": "sha512-VZznLgtwhn+Mact9tfiwx64fA9erHH/MCXEUfB/0bX/6Fz6ny5EGTXYltMocqg4xFAQZtnO3DHWWXi8RiuN7cQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1892,7 +1919,6 @@ "version": "0.27.3", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.3.tgz", "integrity": "sha512-8VwMnyGCONIs6cWue2IdpHxHnAjzxnw2Zr7MkVxB2vjmQ2ivqGFb4LEG3SMnv0Gb2F/G/2yA8zUaiL1gywDCCg==", - "dev": true, "hasInstallScript": true, "license": "MIT", "bin": { @@ -2149,7 +2175,6 @@ "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", - "dev": true, "license": "MIT", "engines": { "node": ">=12.0.0" @@ -2254,7 +2279,6 @@ "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, "hasInstallScript": true, "license": "MIT", "optional": true, @@ -2596,7 +2620,6 @@ "version": "3.3.11", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", - "dev": true, "funding": [ { "type": "github", @@ -2710,14 +2733,12 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", - "dev": true, "license": "ISC" }, "node_modules/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", - "dev": true, + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", + "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", "license": "MIT", "engines": { "node": ">=12" @@ -2730,7 +2751,6 @@ "version": "8.5.8", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.8.tgz", "integrity": "sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg==", - "dev": true, "funding": [ { "type": "opencollective", @@ -2815,10 +2835,9 @@ } }, "node_modules/rollup": { - "version": "4.59.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.59.0.tgz", - "integrity": "sha512-2oMpl67a3zCH9H79LeMcbDhXW/UmWG/y2zuqnF2jQq5uq9TbM9TVyXvA4+t+ne2IIkBdrLpAaRQAvo7YI/Yyeg==", - "dev": true, + "version": "4.60.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.60.0.tgz", + "integrity": "sha512-yqjxruMGBQJ2gG4HtjZtAfXArHomazDHoFwFFmZZl0r7Pdo7qCIXKqKHZc8yeoMgzJJ+pO6pEEHa+V7uzWlrAQ==", "license": "MIT", "dependencies": { "@types/estree": "1.0.8" @@ -2831,31 +2850,31 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.59.0", - "@rollup/rollup-android-arm64": "4.59.0", - "@rollup/rollup-darwin-arm64": "4.59.0", - "@rollup/rollup-darwin-x64": "4.59.0", - "@rollup/rollup-freebsd-arm64": "4.59.0", - "@rollup/rollup-freebsd-x64": "4.59.0", - "@rollup/rollup-linux-arm-gnueabihf": "4.59.0", - "@rollup/rollup-linux-arm-musleabihf": "4.59.0", - "@rollup/rollup-linux-arm64-gnu": "4.59.0", - "@rollup/rollup-linux-arm64-musl": "4.59.0", - "@rollup/rollup-linux-loong64-gnu": "4.59.0", - "@rollup/rollup-linux-loong64-musl": "4.59.0", - "@rollup/rollup-linux-ppc64-gnu": "4.59.0", - "@rollup/rollup-linux-ppc64-musl": "4.59.0", - "@rollup/rollup-linux-riscv64-gnu": "4.59.0", - "@rollup/rollup-linux-riscv64-musl": "4.59.0", - "@rollup/rollup-linux-s390x-gnu": "4.59.0", - "@rollup/rollup-linux-x64-gnu": "4.59.0", - "@rollup/rollup-linux-x64-musl": "4.59.0", - "@rollup/rollup-openbsd-x64": "4.59.0", - "@rollup/rollup-openharmony-arm64": "4.59.0", - "@rollup/rollup-win32-arm64-msvc": "4.59.0", - "@rollup/rollup-win32-ia32-msvc": "4.59.0", - "@rollup/rollup-win32-x64-gnu": "4.59.0", - "@rollup/rollup-win32-x64-msvc": "4.59.0", + "@rollup/rollup-android-arm-eabi": "4.60.0", + "@rollup/rollup-android-arm64": "4.60.0", + "@rollup/rollup-darwin-arm64": "4.60.0", + "@rollup/rollup-darwin-x64": "4.60.0", + "@rollup/rollup-freebsd-arm64": "4.60.0", + "@rollup/rollup-freebsd-x64": "4.60.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.60.0", + "@rollup/rollup-linux-arm-musleabihf": "4.60.0", + "@rollup/rollup-linux-arm64-gnu": "4.60.0", + "@rollup/rollup-linux-arm64-musl": "4.60.0", + "@rollup/rollup-linux-loong64-gnu": "4.60.0", + "@rollup/rollup-linux-loong64-musl": "4.60.0", + "@rollup/rollup-linux-ppc64-gnu": "4.60.0", + "@rollup/rollup-linux-ppc64-musl": "4.60.0", + "@rollup/rollup-linux-riscv64-gnu": "4.60.0", + "@rollup/rollup-linux-riscv64-musl": "4.60.0", + "@rollup/rollup-linux-s390x-gnu": "4.60.0", + "@rollup/rollup-linux-x64-gnu": "4.60.0", + "@rollup/rollup-linux-x64-musl": "4.60.0", + "@rollup/rollup-openbsd-x64": "4.60.0", + "@rollup/rollup-openharmony-arm64": "4.60.0", + "@rollup/rollup-win32-arm64-msvc": "4.60.0", + "@rollup/rollup-win32-ia32-msvc": "4.60.0", + "@rollup/rollup-win32-x64-gnu": "4.60.0", + "@rollup/rollup-win32-x64-msvc": "4.60.0", "fsevents": "~2.3.2" } }, @@ -2906,7 +2925,6 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", - "dev": true, "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" @@ -2973,7 +2991,6 @@ "version": "0.2.15", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", - "dev": true, "license": "MIT", "dependencies": { "fdir": "^6.5.0", @@ -3009,6 +3026,24 @@ "typescript": ">=4.8.4" } }, + "node_modules/turbo": { + "version": "2.8.21", + "resolved": "https://registry.npmjs.org/turbo/-/turbo-2.8.21.tgz", + "integrity": "sha512-FlJ8OD5Qcp0jTAM7E4a/RhUzRNds2GzKlyxHKA6N247VLy628rrxAGlMpIXSz6VB430+TiQDJ/SMl6PL1lu6wQ==", + "dev": true, + "license": "MIT", + "bin": { + "turbo": "bin/turbo" + }, + "optionalDependencies": { + "@turbo/darwin-64": "2.8.21", + "@turbo/darwin-arm64": "2.8.21", + "@turbo/linux-64": "2.8.21", + "@turbo/linux-arm64": "2.8.21", + "@turbo/windows-64": "2.8.21", + "@turbo/windows-arm64": "2.8.21" + } + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -3079,7 +3114,6 @@ "version": "7.3.1", "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.1.tgz", "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", - "dev": true, "license": "MIT", "dependencies": { "esbuild": "^0.27.0", diff --git a/package.json b/package.json index 47aa1d1..03cbe81 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,10 @@ "workspaces": [ "actions/*" ], + "packageManager": "npm@11.12.1", "scripts": { "build": "npm run build --workspaces --if-present", + "start": "turbo run start", "test": "vitest run", "test:watch": "vitest", "lint": "eslint .", @@ -17,14 +19,15 @@ "@eslint/js": "^10.0.0", "eslint": "^10.0.0", "globals": "^17.4.0", + "turbo": "^2.8.21", "typescript": "^5", "typescript-eslint": "^8.0.0", "vitest": "^4.0.0" }, "dependencies": { - "@code0-tech/hercules": "file:code0-tech-hercules-1.0.0.tgz", - "@code0-tech/tucana": "0.0.60", + "@code0-tech/hercules": "file:code0-tech-hercules-0.0.0.tgz", "axios": "^1.13.6", + "vite": "^7.3.1", "zod": "^4.3.6", "zod-to-ts": "^2.0.0" } diff --git a/tsconfig.base.json b/tsconfig.base.json index 61a8e05..fbfad07 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1,12 +1,14 @@ { "compilerOptions": { - "target": "ES2020", - "module": "commonjs", "esModuleInterop": true, - "declaration": true, - "outDir": "dist", + "module": "es2022", + "moduleResolution": "bundler", + "target": "es2020", + "lib": ["es2020", "dom"], "strict": false, "skipLibCheck": true, - "allowImportingTsExtensions": false - } + "types": ["vite/client"] + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist", "***/test/**", "**/*.test.ts"] } \ No newline at end of file diff --git a/turbo.json b/turbo.json new file mode 100644 index 0000000..8da0a4c --- /dev/null +++ b/turbo.json @@ -0,0 +1,7 @@ +{ + "tasks": { + "start": { + "cache": false + } + } +} \ No newline at end of file diff --git a/vitest.config.ts b/vitest.config.ts index b7adf4f..d246060 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,8 +1,11 @@ -import {defineConfig} from "vitest/config"; +import { defineConfig } from "vitest/config"; +import {resolve} from "path"; export default defineConfig({ test: { - include: ["actions/**/src/**/*.{test,spec}.{ts,tsx}"], - environment: "node" + include: [resolve(__dirname, "actions/**/*.{test,spec}.{ts,tsx}")], + environment: "node", + exclude: ["**/dist/**"], + setupFiles: [resolve(__dirname, "vitest.setup.ts")], }, -}); +}); \ No newline at end of file diff --git a/vitest.setup.ts b/vitest.setup.ts new file mode 100644 index 0000000..f3cb84c --- /dev/null +++ b/vitest.setup.ts @@ -0,0 +1,15 @@ +import { beforeEach, vi } from "vitest"; + +beforeEach(() => { + vi.spyOn(console, "error").mockImplementation((...args) => { + throw new Error(args.join(" ")); + }); +}); + +process.on("unhandledRejection", (err) => { + throw err; +}); + +process.on("uncaughtException", (err) => { + throw err; +}); \ No newline at end of file