├── .dockerignore ├── .eslintrc.js ├── .github ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── ci.yaml ├── .gitignore ├── .jshintrc ├── .mocharc.json ├── .nsprc ├── .snyk ├── CHANGELOG.md ├── CONTRIBUTING ├── Dockerfile.dev ├── Dockerfile.rel ├── LICENSE ├── NOTICE ├── README.md ├── azure-pipelines.yml ├── azure-templates └── test.yml ├── coding-style.md ├── docs ├── .swagger-codegen-ignore ├── .swagger-codegen │ └── VERSION ├── README.md ├── swagger.json └── swagger.yaml ├── generate-swagger.sh ├── logrotate.conf ├── package-lock.json ├── package.json ├── scripts ├── cli-tests.js ├── coverage.js ├── init.js ├── postinstall.js ├── postmantest.js ├── preuninstall.js ├── run-test.js ├── scripts-api.js ├── start-dev.js ├── start.js ├── stop.js ├── test.js └── util.js ├── src ├── cli │ ├── application.js │ ├── base-cli-handler.js │ ├── catalog.js │ ├── cli-data-types.js │ ├── config.js │ ├── controller.js │ ├── diagnostics.js │ ├── index.js │ ├── iofog.js │ ├── microservice.js │ ├── registry.js │ ├── start.js │ ├── tunnel.js │ └── user.js ├── config │ ├── constants.js │ ├── default.json │ ├── development.json │ ├── index.js │ ├── production.json │ └── test.json ├── controllers │ ├── agent-controller.js │ ├── application-controller.js │ ├── application-template-controller.js │ ├── catalog-controller.js │ ├── config-controller.js │ ├── controller.js │ ├── diagnostic-controller.js │ ├── edge-resource-controller.js │ ├── iofog-controller.js │ ├── kubelet-controller.js │ ├── microservices-controller.js │ ├── registry-controller.js │ ├── router-controller.js │ ├── routing-controller.js │ ├── tunnel-controller.js │ └── user-controller.js ├── daemon.js ├── data │ ├── constants.js │ ├── managers │ │ ├── access-token-manager.js │ │ ├── application-manager.js │ │ ├── application-template-manager.js │ │ ├── application-template-variable-manager.js │ │ ├── base-manager.js │ │ ├── catalog-item-image-manager.js │ │ ├── catalog-item-input-type-manager.js │ │ ├── catalog-item-manager.js │ │ ├── catalog-item-output-type-manager.js │ │ ├── change-tracking-manager.js │ │ ├── config-manager.js │ │ ├── edge-resource-manager.js │ │ ├── email-activation-code-manager.js │ │ ├── http-based-resource-interface-endpoints-manager.js │ │ ├── http-based-resource-interface-manager.js │ │ ├── hw-info-manager.js │ │ ├── iofog-access-token-manager.js │ │ ├── iofog-manager.js │ │ ├── iofog-provision-key-manager.js │ │ ├── iofog-type-manager.js │ │ ├── iofog-version-command-manager.js │ │ ├── kubelet-access-token-manager.js │ │ ├── microservice-arg-manager.js │ │ ├── microservice-env-manager.js │ │ ├── microservice-extra-host-manager.js │ │ ├── microservice-manager.js │ │ ├── microservice-port-manager.js │ │ ├── microservice-proxy-port-manager.js │ │ ├── microservice-public-mode-manager.js │ │ ├── microservice-public-port-manager.js │ │ ├── microservice-status-manager.js │ │ ├── registry-manager.js │ │ ├── router-connection-manager.js │ │ ├── router-manager.js │ │ ├── routing-manager.js │ │ ├── scheduler-access-token-manager.js │ │ ├── strace-diagnostics-manager.js │ │ ├── strace-manager.js │ │ ├── tags-manager.js │ │ ├── tunnel-manager.js │ │ ├── usb-info-manager.js │ │ ├── user-manager.js │ │ └── volume-mapping-manager.js │ ├── migrations │ │ ├── 20180930155645-create-user.js │ │ ├── 20180930164635-create-flow.js │ │ ├── 20180930173823-create-registry.js │ │ ├── 20180930184436-create-catalog-item.js │ │ ├── 20180930184703-create-fog-type.js │ │ ├── 20180930184921-create-catalog-item-image.js │ │ ├── 20180930194506-create-catalog-item-input-type.js │ │ ├── 20180930195746-create-catalog-item-output-type.js │ │ ├── 20180930204039-create-email-activation-code.js │ │ ├── 20180930225403-create-fog.js │ │ ├── 20180930225846-create-change-tracking.js │ │ ├── 20180930230219-create-fog-access-token.js │ │ ├── 20180930230626-create-fog-provision-key.js │ │ ├── 20180930231241-create-fog-version-command.js │ │ ├── 20180930231536-create-hw-info.js │ │ ├── 20180930232242-create-usb-info.js │ │ ├── 20180930232508-create-tunnel.js │ │ ├── 20181001062956-create-microservice.js │ │ ├── 20181001070828-create-microservice-port.js │ │ ├── 20181001071315-create-microservice-status.js │ │ ├── 20181001071628-create-connector.js │ │ ├── 20181001071858-create-connector-port.js │ │ ├── 20181001073429-create-strace-diagnostics.js │ │ ├── 20181003102815-create-volume-mapping.js │ │ ├── 20181003104606-create-access-token.js │ │ ├── 20181022110529-create-routing.js │ │ ├── 20181022114905-create-microservice-public-mode.js │ │ ├── 20181031094923-drop-need-update-col-microservices.js │ │ ├── 20181102105758-microservice-status-add-missing-time-cols.js │ │ ├── 20181102163657-microservice-add-col-remove.js │ │ ├── 20181105120036-change-tracking-container-to-microservice-renaming.js │ │ ├── 20181109132609-microservice-rename-updatedBy-to-userId.js │ │ ├── 20181109132704-microservice-port-rename-updatedBy-to-userId.js │ │ ├── 20181109132723-flow-remove-updatedBy.js │ │ ├── 20181113094807-add-missing-constraints.js │ │ ├── 20190117110458-create-tracking-event.js │ │ ├── 20190222135632-create-kubelet-access-token.js │ │ ├── 20190226111416-add-system-metrics-to-fog.js │ │ ├── 20190227154512-create-scheduler-access-token.js │ │ ├── 20190305142715-add-security-status-fields.js │ │ ├── 20190409055710-add-microservices-env.js │ │ ├── 20190410055710-add-microservices-arg.js │ │ ├── 20190704043715-agent-external-ip.js │ │ ├── 20190830071324-update catalog item images to be linked to microservice.js │ │ ├── 20190916030304-connector-health.js │ │ ├── 20190916030532-connector-port-deletion.js │ │ ├── 20200123000302-system-fog-and-flow.js │ │ ├── 20200123045032-fog-and-change-tracking.js │ │ ├── 20200123163412-create-router.js │ │ ├── 20200123205245-router-port-host-agent-config.js │ │ ├── 20200124040224-router-changed-flag.js │ │ ├── 20200202113124-create-public-ports.js │ │ ├── 20200213033350-create-config.js │ │ ├── 20200220210224-change-tracking-timestamp.js │ │ ├── 20200316011904-microservice-extra-host.js │ │ ├── 20200316032240-add-fog-host.js │ │ ├── 20200323050813-fog-update-messagespeed.js │ │ ├── 20200420020250-remove-connector.js │ │ ├── 20200423201804-add-volume-mapping-type.js │ │ ├── 20200506004924-add-route-name.js │ │ ├── 20200512044934-rename-flow.js │ │ ├── 20200512214530-add-application-to-routing.js │ │ ├── 20200901053246-add-percentage-msvc-status.js │ │ ├── 20201001230303-add-tags-fogs.js │ │ ├── 20201028005645-create-edge-resources.js │ │ ├── 20201105003849-create-edge-resources-agent-flag.js │ │ ├── 20201203011708-microservice-status-error-msg.js │ │ ├── 20201204003312-create_application_templates.js │ │ ├── 20210104191500-add_custom_to_edge_resources.js │ │ ├── 20210118012712-add_is_udp_to_port.js │ │ ├── 20211019214923-add-schemes-to-public-ports.js │ │ ├── 20211020014715-add-index-to-public-ports.js │ │ ├── 20211022010318-add-unique-constraint-msvc.js │ │ ├── 20211022013326-add-unique-constraint-route.js │ │ ├── 20220405053419-add-time-zone-agent-config.js │ │ ├── 20220409021708-drop-table-tracking.js │ │ ├── 20221021102712-add_is_proxy_to_port.js │ │ ├── 20221021132000-create-proxy-ports.js │ │ ├── 20221021152712-add_admin_port_to_proxy_ports.js │ │ ├── 20221031162712-add_tokens_to_proxy_ports.js │ │ └── 20221110151246-add_port_uuid_to_proxy_ports copy.js │ ├── models │ │ ├── accesstoken.js │ │ ├── agentEdgeResource.js │ │ ├── application.js │ │ ├── applicationTemplate.js │ │ ├── applicationTemplateVariable.js │ │ ├── catalogitem.js │ │ ├── catalogitemimage.js │ │ ├── catalogiteminputtype.js │ │ ├── catalogitemoutputtype.js │ │ ├── changetracking.js │ │ ├── config.js │ │ ├── edgeResource.js │ │ ├── edgeResourceOrchestrationTags.js │ │ ├── emailactivationcode.js │ │ ├── fog.js │ │ ├── fogaccesstoken.js │ │ ├── fogprovisionkey.js │ │ ├── fogtype.js │ │ ├── fogversioncommand.js │ │ ├── httpBasedResourceInterface.js │ │ ├── httpResourceInterfaceEndpoint.js │ │ ├── hwinfo.js │ │ ├── index.js │ │ ├── iofogTags.js │ │ ├── kubeletaccesstoken.js │ │ ├── microservice.js │ │ ├── microserviceExtraHost.js │ │ ├── microserviceProxyPort.js │ │ ├── microservicePublicPort.js │ │ ├── microservicearg.js │ │ ├── microserviceenv.js │ │ ├── microserviceport.js │ │ ├── microservicepublicmode.js │ │ ├── microservicestatus.js │ │ ├── registry.js │ │ ├── router-connection.js │ │ ├── router.js │ │ ├── routing.js │ │ ├── scheduleraccesstoken.js │ │ ├── stracediagnostics.js │ │ ├── tags.js │ │ ├── tunnel.js │ │ ├── usbinfo.js │ │ ├── user.js │ │ └── volumemapping.js │ ├── providers │ │ ├── database-factory.js │ │ ├── database-provider.js │ │ └── sqlite.js │ └── seeders │ │ ├── 20180928110125-insert-registry.js │ │ ├── 20180928111532-insert-catalog-item.js │ │ ├── 20180928112152-insert-iofog-type.js │ │ ├── 20180928121334-insert-catalog-item-image.js │ │ ├── 20190130112616-insert-logging-catalog-item.js │ │ ├── 20190131111441-insert-json-generator-catalog-item.js │ │ ├── 20190218103641-adding-default-configs.js │ │ ├── 20200122200231-insert-router-catalog-item.js │ │ ├── 20200313163114-update-router-catalog-item.js │ │ └── 20221019163114-insert-port-router-catalog-item.js ├── decorators │ ├── authorization-decorator.js │ ├── cli-decorator.js │ ├── response-decorator.js │ └── transaction-decorator.js ├── enums │ ├── fog-state.js │ └── microservice-state.js ├── helpers │ ├── app-helper.js │ ├── constants.js │ ├── error-messages.js │ ├── errors.js │ ├── proxy-broker-client.js │ └── template-helper.js ├── jobs │ ├── fog-status-job.js │ └── stopped-app-status-job.js ├── lib │ └── liquidjs │ │ ├── builtin │ │ ├── filters │ │ │ ├── array.d.ts │ │ │ ├── date.d.ts │ │ │ ├── html.d.ts │ │ │ ├── index.d.ts │ │ │ ├── math.d.ts │ │ │ ├── object.d.ts │ │ │ ├── string.d.ts │ │ │ └── url.d.ts │ │ └── tags │ │ │ ├── assign.d.ts │ │ │ ├── block.d.ts │ │ │ ├── break.d.ts │ │ │ ├── capture.d.ts │ │ │ ├── case.d.ts │ │ │ ├── comment.d.ts │ │ │ ├── continue.d.ts │ │ │ ├── cycle.d.ts │ │ │ ├── decrement.d.ts │ │ │ ├── for.d.ts │ │ │ ├── if.d.ts │ │ │ ├── include.d.ts │ │ │ ├── increment.d.ts │ │ │ ├── index.d.ts │ │ │ ├── layout.d.ts │ │ │ ├── raw.d.ts │ │ │ ├── render.d.ts │ │ │ ├── tablerow.d.ts │ │ │ └── unless.d.ts │ │ ├── cache │ │ ├── cache.d.ts │ │ └── lru.d.ts │ │ ├── context │ │ ├── block-mode.d.ts │ │ ├── context.d.ts │ │ └── scope.d.ts │ │ ├── drop │ │ ├── blank-drop.d.ts │ │ ├── comparable.d.ts │ │ ├── drop.d.ts │ │ ├── empty-drop.d.ts │ │ ├── forloop-drop.d.ts │ │ ├── null-drop.d.ts │ │ └── tablerowloop-drop.d.ts │ │ ├── fs │ │ ├── browser.d.ts │ │ ├── fs.d.ts │ │ └── node.d.ts │ │ ├── liquid-options.d.ts │ │ ├── liquid.browser.umd.js │ │ ├── liquid.browser.umd.js.map │ │ ├── liquid.d.ts │ │ ├── liquid.node.cjs.js │ │ ├── parser │ │ ├── filter-arg.d.ts │ │ ├── match-operator.d.ts │ │ ├── parse-stream.d.ts │ │ ├── parse-string-literal.d.ts │ │ ├── parser.d.ts │ │ ├── token-kind.d.ts │ │ ├── tokenizer.d.ts │ │ └── whitespace-ctrl.d.ts │ │ ├── render │ │ ├── boolean.d.ts │ │ ├── emitter.d.ts │ │ ├── expression.d.ts │ │ ├── operator.d.ts │ │ └── render.d.ts │ │ ├── template │ │ ├── filter │ │ │ ├── filter-impl-options.d.ts │ │ │ ├── filter-impl.d.ts │ │ │ ├── filter-map.d.ts │ │ │ └── filter.d.ts │ │ ├── html.d.ts │ │ ├── output.d.ts │ │ ├── tag │ │ │ ├── hash.d.ts │ │ │ ├── tag-impl-options.d.ts │ │ │ ├── tag-impl.d.ts │ │ │ ├── tag-map.d.ts │ │ │ └── tag.d.ts │ │ ├── template-impl.d.ts │ │ ├── template.d.ts │ │ └── value.d.ts │ │ ├── tokens │ │ ├── delimited-token.d.ts │ │ ├── filter-token.d.ts │ │ ├── hash-token.d.ts │ │ ├── html-token.d.ts │ │ ├── identifier-token.d.ts │ │ ├── literal-token.d.ts │ │ ├── number-token.d.ts │ │ ├── operator-token.d.ts │ │ ├── output-token.d.ts │ │ ├── property-access-token.d.ts │ │ ├── quoted-token.d.ts │ │ ├── range-token.d.ts │ │ ├── tag-token.d.ts │ │ ├── token.d.ts │ │ ├── toplevel-token.d.ts │ │ └── value-token.d.ts │ │ ├── types.d.ts │ │ └── util │ │ ├── assert.d.ts │ │ ├── async.d.ts │ │ ├── character.d.ts │ │ ├── collection.d.ts │ │ ├── error.d.ts │ │ ├── literal.d.ts │ │ ├── strftime.d.ts │ │ ├── type-guards.d.ts │ │ └── underscore.d.ts ├── logger │ └── index.js ├── main.js ├── routes │ ├── agent.js │ ├── application.js │ ├── applicationTemplate.js │ ├── capabilities.js │ ├── catalog.js │ ├── config.js │ ├── controller.js │ ├── diagnostics.js │ ├── edgeResource.js │ ├── flow.js │ ├── iofog.js │ ├── kubelet.js │ ├── microservices.js │ ├── registries.js │ ├── router.js │ ├── routing.js │ ├── tunnel.js │ └── user.js ├── schemas │ ├── agent.js │ ├── application-template.js │ ├── application.js │ ├── catalog.js │ ├── config.js │ ├── diagnostics.js │ ├── edgeResource.js │ ├── index.js │ ├── iofog.js │ ├── microservice.js │ ├── registry.js │ ├── routing.js │ ├── tunnel.js │ ├── user.js │ └── utils │ │ └── utils.js ├── server.js ├── services │ ├── access-token-service.js │ ├── agent-service.js │ ├── application-service.js │ ├── application-template-service.js │ ├── catalog-service.js │ ├── change-tracking-service.js │ ├── config-service.js │ ├── controller-service.js │ ├── diagnostic-service.js │ ├── edge-resource-service.js │ ├── email-activation-code-service.js │ ├── iofog-access-token-service.js │ ├── iofog-service.js │ ├── kubelet-access-token-service.js │ ├── kubelet-service.js │ ├── microservice-ports │ │ ├── default.js │ │ ├── factory.js │ │ └── proxy.js │ ├── microservices-service.js │ ├── registry-service.js │ ├── router-service.js │ ├── routing-service.js │ ├── scheduler-access-token-service.js │ ├── tunnel-service.js │ ├── user-service.js │ └── yaml-parser-service.js └── views │ ├── email-activation-temp.js │ ├── email-temp.js │ └── reset-password-temp.js └── test ├── application-template-update.yaml ├── application-template.yaml ├── application-test.yaml ├── application-update-test.yaml ├── mocha.opts ├── postman_collection.json ├── src ├── controllers │ ├── agent-controller.test.js │ ├── application-controller.test.js │ ├── catalog-controller.test.js │ ├── controller-controller.test.js │ ├── diagnostics-controller.test.js │ ├── iofog-controller.test.js │ ├── microservices-controller.test.js │ ├── registry-controller.test.js │ ├── router-controller.test.js │ ├── tunnel-controller.test.js │ └── user-controller.test.js ├── helpers │ └── app-helpers.test.js ├── middlewares │ └── rvaluesVarSubstitionMiddleware.test.js ├── services │ ├── access-token-service.test.js │ ├── agent-service.test.js │ ├── application-service.test.js │ ├── catalog-service.test.js │ ├── change-tracking-service.test.js │ ├── controller-service.test.js │ ├── diagnostic-service.test.js │ ├── email-activation-code-service.test.js │ ├── iofog-service.test.js │ ├── microservices-service.test.js │ ├── registry-service.test.js │ ├── router-service.test.js │ ├── tunnel-service.test.js │ └── user-service.test.js └── template │ ├── app.yml │ ├── simple.yml │ └── template-test.js └── support └── setup.js /.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .vscode 3 | *.sqlite 4 | .nyc_output 5 | /.idea 6 | /src/config/tracking-uuid 7 | *.sqlite-shm 8 | *.sqlite-wal 9 | *.pid 10 | /src/data/providers/* 11 | !/src/data/providers/sqlite.js 12 | !/src/data/providers/database-*.js 13 | /src/config/*-config.json 14 | .DS_Store 15 | iofogcontroller-*.tgz 16 | iofog-iofogcontroller-*.tgz -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | var OFF = 0, WARN = 1, ERROR = 2; 2 | 3 | module.exports = { 4 | 'env': { 5 | 'es6': true, 6 | 'node': true, 7 | }, 8 | 9 | 'extends': 'google', 10 | 'rules': { 11 | "linebreak-style": 0, 12 | 'require-jsdoc': [OFF, { 13 | 'require': { 14 | 'FunctionDeclaration': true, 15 | 'MethodDefinition': true, 16 | 'ClassDeclaration': false 17 | } 18 | }], 19 | 'max-len': [WARN, 132], 20 | 'no-invalid-this': OFF, 21 | 'no-multi-str': OFF, 22 | 'semi': [ERROR, 'never'], 23 | 'space-before-function-paren': OFF, 24 | 'object-curly-spacing': ['error', 'always'], 25 | }, 26 | 27 | 'parserOptions': { 28 | 'sourceType': 'module', 29 | 'ecmaVersion': 2017, 30 | } 31 | } -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 9 | 10 | - Does the iofog.org or README.md documentation need to change? 11 | - [ ] Yes 12 | - [ ] No 13 | 14 | ### Description 15 | 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .vscode 3 | *.sqlite 4 | .nyc_output 5 | /.idea 6 | /src/config/tracking-uuid 7 | *.sqlite-shm 8 | *.sqlite-wal 9 | *.pid 10 | /src/data/providers/* 11 | !/src/data/providers/sqlite.js 12 | !/src/data/providers/database-*.js 13 | /src/config/*-config.json 14 | .DS_Store 15 | iofogcontroller-*.tgz 16 | diagnostic/ 17 | iofog-iofogcontroller-*.tgz -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "esversion": 6, 3 | "asi": true 4 | } -------------------------------------------------------------------------------- /.mocharc.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": "test/support/setup.js", 3 | "ui": "bdd-lazy-var/global", 4 | "recursive": true 5 | } 6 | -------------------------------------------------------------------------------- /.nsprc: -------------------------------------------------------------------------------- 1 | { 2 | "1091459": { 3 | "notes": "" 4 | }, 5 | "1091725": { 6 | "notes": "" 7 | } 8 | } -------------------------------------------------------------------------------- /.snyk: -------------------------------------------------------------------------------- 1 | # Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. 2 | version: v1.13.5 3 | ignore: {} 4 | patch: {} 5 | -------------------------------------------------------------------------------- /Dockerfile.dev: -------------------------------------------------------------------------------- 1 | FROM node:hydrogen-buster AS builder 2 | 3 | ARG PKG_VERSION 4 | 5 | WORKDIR /tmp 6 | 7 | RUN npm i -g npm 8 | 9 | COPY package.json . 10 | 11 | COPY . . 12 | 13 | RUN npm i --build-from-source 14 | 15 | RUN npm version $PKG_VERSION --allow-same-version --no-git-tag-version 16 | 17 | RUN npm pack 18 | 19 | FROM node:hydrogen-alpine3.17 20 | 21 | RUN apk add sudo logrotate g++ make 22 | 23 | ENV NODE_ENV=development 24 | 25 | COPY logrotate.conf /etc/logrotate.conf 26 | 27 | # Install python/pip 28 | ENV PYTHONUNBUFFERED=1 29 | RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python 30 | RUN python3 -m ensurepip 31 | RUN pip3 install --no-cache --upgrade pip setuptools 32 | 33 | COPY --from=builder /tmp/iofog-iofogcontroller-*.tgz /tmp/iofog-controller.tgz 34 | 35 | RUN npm i -g /tmp/iofog-controller.tgz && \ 36 | rm -rf /tmp/iofog-controller.tgz && \ 37 | iofog-controller config dev-mode --on 38 | # RUN sudo rm -rf /usr/local/lib/node_modules/iofogcontroller/src/data/sqlite_files 39 | 40 | CMD [ "node", "/usr/local/lib/node_modules/@iofog/iofogcontroller/src/server.js" ] 41 | -------------------------------------------------------------------------------- /Dockerfile.rel: -------------------------------------------------------------------------------- 1 | FROM node:hydrogen-buster AS builder 2 | 3 | ARG PKG_VERSION 4 | 5 | WORKDIR /tmp 6 | 7 | # Required by node-gyp 8 | RUN apt install python3 9 | 10 | RUN npm i -g npm 11 | 12 | COPY package.json . 13 | 14 | COPY . . 15 | 16 | RUN npm i 17 | 18 | RUN npm version $PKG_VERSION --allow-same-version 19 | 20 | RUN npm pack 21 | 22 | FROM node:hydrogen-alpine3.17 23 | 24 | RUN apk add sudo logrotate g++ make 25 | 26 | COPY logrotate.conf /etc/logrotate.conf 27 | 28 | # Install python/pip 29 | ENV PYTHONUNBUFFERED=1 30 | RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python 31 | RUN python3 -m ensurepip 32 | RUN pip3 install --no-cache --upgrade pip setuptools 33 | 34 | COPY --from=builder /tmp/iofog-iofogcontroller-*.tgz /tmp/iofog-controller.tgz 35 | 36 | RUN npm i -g /tmp/iofog-controller.tgz && \ 37 | rm -rf /tmp/iofog-controller.tgz && \ 38 | iofog-controller config dev-mode --on 39 | 40 | CMD [ "node", "/usr/local/lib/node_modules/@iofog/iofogcontroller/src/server.js" ] 41 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | # Notices for Eclipse ioFog 2 | 3 | This content is produced and maintained by the Eclipse ioFog project. 4 | 5 | * Project home: https://projects.eclipse.org/projects/iot.iofog 6 | 7 | ## Trademarks 8 | 9 | Eclipse ioFog is a trademark of the Eclipse Foundation. 10 | 11 | ## Copyright 12 | 13 | All content is the property of the respective authors or their employers. For 14 | more information regarding authorship of content, please consult the listed 15 | source code repository logs. 16 | 17 | ## Declared Project Licenses 18 | 19 | This program and the accompanying materials are made available under the terms 20 | of the Eclipse Public License v. 2.0 which is available at 21 | http://www.eclipse.org/legal/epl-2.0. 22 | 23 | SPDX-License-Identifier: EPL-2.0 24 | 25 | ## Source Code 26 | 27 | The project maintains the following source code repositories: 28 | 29 | * https://github.com/eclipse-iofog 30 | * http://git.eclipse.org/c/iofog/org.eclipse.iofog.git 31 | 32 | ## Third-party Content 33 | 34 | ## Cryptography 35 | 36 | Content may contain encryption software. The country in which you are currently 37 | may have restrictions on the import, possession, and use, and/or re-export to 38 | another country, of encryption software. BEFORE using any encryption software, 39 | please check the country's laws, regulations and policies concerning the import, 40 | possession, or use, and re-export of encryption software, to see if this is 41 | permitted. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ioFog Controller 2 | 3 | ### Status 4 | 5 | ![](https://img.shields.io/github/release/iofog/controller.svg?style=flat) 6 | 7 | ![](https://img.shields.io/github/repo-size/iofog/controller.svg?style=flat) 8 | ![](https://img.shields.io/github/last-commit/iofog/controller.svg?style=flat) 9 | ![](https://img.shields.io/github/contributors/iofog/controller.svg?style=flat) 10 | ![](https://img.shields.io/github/issues/iofog/controller.svg?style=flat) 11 | 12 | ![Supports amd64 Architecture][amd64-shield] 13 | ![Supports aarch64 Architecture][arm64-shield] 14 | ![Supports armhf Architecture][arm-shield] 15 | 16 | [arm64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg 17 | [amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg 18 | [arm-shield]: https://img.shields.io/badge/armhf-yes-green.svg 19 | 20 | [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) 21 | 22 | ## Install 23 | 24 | The entire ioFog platform is best deployed through the unified CLI: `iofogctl`. 25 | 26 | Go to [iofog.org](https://iofog.org/docs/) to learn how to deploy the ioFog Control Plane and Agents. 27 | 28 | ## Usage 29 | ``` 30 | iofog-controller 31 | ``` 32 | 33 | For full installation and usage, visit [iofog.org](https://iofog.org/docs/). 34 | -------------------------------------------------------------------------------- /azure-templates/test.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | nodeVersion: '' 3 | jobs: 4 | - job: ${{ format('Node_{0}', parameters.nodeVersion) }} 5 | pool: 6 | vmImage: 'Ubuntu-20.04' 7 | steps: 8 | - task: NodeTool@0 9 | inputs: 10 | versionSpec: ${{ format('{0}.x', parameters.nodeVersion) }} 11 | displayName: 'Install Node.js' 12 | - script: | 13 | npm i 14 | displayName: Install dependencies 15 | 16 | - script: | 17 | npm run test -- junit 18 | displayName: 'unit tests' 19 | 20 | - script: | 21 | npm run postman_test 22 | displayName: 'integration tests' 23 | # Publish Test Results 24 | # Publish test results to Azure Pipelines 25 | - script: | 26 | ls -l 27 | displayName: 'list files (looking for test results)' 28 | - task: PublishTestResults@2 29 | inputs: 30 | testResultsFormat: 'JUnit' # Options: JUnit, NUnit, VSTest, xUnit, cTest 31 | testResultsFiles: '*-results.xml' 32 | searchFolder: '$(System.DefaultWorkingDirectory)' # Optional 33 | #mergeTestResults: false # Optional 34 | #failTaskOnFailedTests: false # Optional 35 | #testRunTitle: # Optional 36 | buildPlatform: ${{ format('Node_{0}', parameters.nodeVersion) }} # Optional 37 | testRunTitle: ${{ format('Node_{0}', parameters.nodeVersion) }} # Optional 38 | #buildConfiguration: # Optional 39 | #publishRunAttachments: true # Optional -------------------------------------------------------------------------------- /docs/.swagger-codegen-ignore: -------------------------------------------------------------------------------- 1 | # Swagger Codegen Ignore 2 | # Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen 3 | 4 | # Use this file to prevent files from being overwritten by the generator. 5 | # The patterns follow closely to .gitignore or .dockerignore. 6 | 7 | # As an example, the C# client generator defines ApiClient.cs. 8 | # You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: 9 | #ApiClient.cs 10 | 11 | # You can match any string of characters against a directory, file or extension with a single asterisk (*): 12 | #foo/*/qux 13 | # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux 14 | 15 | # You can recursively match patterns against a directory, file or extension with a double asterisk (**): 16 | #foo/**/qux 17 | # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux 18 | 19 | # You can also negate patterns with an exclamation (!). 20 | # For example, you can ignore all files in a docs folder with the file extension .md: 21 | #docs/*.md 22 | # Then explicitly reverse the ignore rule for a single file: 23 | #!docs/README.md 24 | -------------------------------------------------------------------------------- /docs/.swagger-codegen/VERSION: -------------------------------------------------------------------------------- 1 | 2.4.29 -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Swagger JSON 2 | This is a swagger JSON built by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. -------------------------------------------------------------------------------- /generate-swagger.sh: -------------------------------------------------------------------------------- 1 | docker run -v ./docs:/docs mitjaziv/swagger-codegen-cli generate -i /docs/swagger.yaml -l swagger -o /docs -------------------------------------------------------------------------------- /logrotate.conf: -------------------------------------------------------------------------------- 1 | /var/log/iofog-controller/iofog-controller.log { 2 | rotate 10 3 | size 10m 4 | compress 5 | notifempty 6 | missingok 7 | postrotate 8 | kill -HUP `cat /usr/local/lib/node_modules/iofogcontroller/src/iofog-controller.pid` 9 | endscript 10 | } 11 | -------------------------------------------------------------------------------- /scripts/coverage.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2018 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const execSync = require('child_process').execSync 15 | 16 | const { setDbEnvVars } = require('./util') 17 | 18 | function coverage () { 19 | const options = { 20 | env: { 21 | 'NODE_ENV': 'test', 22 | 'PATH': process.env.PATH 23 | }, 24 | stdio: [process.stdin, process.stdout, process.stderr] 25 | } 26 | 27 | options.env = setDbEnvVars(options.env) 28 | 29 | execSync('nyc mocha', options) 30 | } 31 | 32 | module.exports = { 33 | coverage: coverage 34 | } 35 | -------------------------------------------------------------------------------- /scripts/init.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2018 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const execSync = require('child_process').execSync 15 | 16 | const { setDbEnvVars } = require('./util') 17 | 18 | function init () { 19 | const options = { 20 | env: { 21 | 'NODE_ENV': 'production', 22 | 'VIEWER_PORT': '8008', 23 | 'PATH': process.env.PATH 24 | }, 25 | stdio: [process.stdin, process.stdout, process.stderr] 26 | } 27 | 28 | options.env = setDbEnvVars(options.env) 29 | 30 | execSync('node ./src/main.js init', options) 31 | } 32 | 33 | module.exports = { 34 | init: init 35 | } 36 | -------------------------------------------------------------------------------- /scripts/preuninstall.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2018 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const execSync = require('child_process').execSync 15 | const fs = require('fs') 16 | const version = require('../package').version 17 | const { backupDBs, backupConfigs, INSTALLATION_VARIABLES_FILE } = require('./util') 18 | 19 | function preuninstall () { 20 | const instalationVars = { 21 | prevVer: version 22 | } 23 | 24 | fs.writeFileSync(INSTALLATION_VARIABLES_FILE, JSON.stringify(instalationVars)) 25 | 26 | backupDBs() 27 | backupConfigs() 28 | 29 | const options = { 30 | stdio: [process.stdin, process.stdout, process.stderr] 31 | } 32 | execSync('iofog-controller stop', options) 33 | } 34 | 35 | module.exports = { 36 | preuninstall: preuninstall 37 | } 38 | -------------------------------------------------------------------------------- /scripts/run-test.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2018 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const { test } = require('./test') 15 | const { cliTest } = require('./cli-tests') 16 | const { coverage } = require('./coverage') 17 | const { postmanTest } = require('./postmantest') 18 | 19 | switch (process.argv[2]) { 20 | case 'test': 21 | test(process.argv[3] === 'junit') 22 | cliTest() 23 | break 24 | case 'cli-tests': 25 | cliTest() 26 | break 27 | case 'coverage': 28 | coverage() 29 | break 30 | case 'postmantest': 31 | postmanTest() 32 | break 33 | default: 34 | console.log('no script for this command') 35 | break 36 | } 37 | -------------------------------------------------------------------------------- /scripts/scripts-api.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2018 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const { start } = require('./start') 15 | const { startDev } = require('./start-dev') 16 | const { init } = require('./init') 17 | const { preuninstall } = require('./preuninstall') 18 | const { postinstall } = require('./postinstall') 19 | 20 | switch (process.argv[2]) { 21 | case 'start': 22 | start() 23 | break 24 | case 'start-dev': 25 | startDev() 26 | break 27 | case 'init': 28 | init() 29 | break 30 | case 'preuninstall': 31 | preuninstall() 32 | break 33 | case 'postinstall': 34 | postinstall() 35 | break 36 | default: 37 | console.log('no script for this command') 38 | break 39 | } 40 | -------------------------------------------------------------------------------- /scripts/start-dev.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2018 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const execSync = require('child_process').execSync 15 | 16 | const { setDbEnvVars } = require('./util') 17 | 18 | function startDev () { 19 | const options = { 20 | env: { 21 | 'NODE_ENV': 'development', 22 | 'VIEWER_PORT': '8008', 23 | 'PATH': process.env.PATH 24 | }, 25 | stdio: [process.stdin, process.stdout, process.stderr] 26 | } 27 | 28 | options.env = setDbEnvVars(options.env) 29 | 30 | execSync('node ./src/main.js start', options) 31 | } 32 | 33 | module.exports = { 34 | startDev: startDev 35 | } 36 | -------------------------------------------------------------------------------- /scripts/start.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2018 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const execSync = require('child_process').execSync 15 | 16 | const { setDbEnvVars } = require('./util') 17 | 18 | function start () { 19 | const options = { 20 | env: { 21 | 'NODE_ENV': 'production', 22 | 'VIEWER_PORT': '8008', 23 | 'PATH': process.env.PATH 24 | }, 25 | stdio: [process.stdin, process.stdout, process.stderr] 26 | } 27 | 28 | options.env = setDbEnvVars(options.env) 29 | 30 | if (process.env.VIEWER_PORT) { 31 | options.env.VIEWER_PORT = process.env.VIEWER_PORT 32 | } 33 | 34 | execSync('node ./src/main.js start', options) 35 | } 36 | 37 | module.exports = { 38 | start: start 39 | } 40 | -------------------------------------------------------------------------------- /scripts/stop.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2018 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const execSync = require('child_process').execSync 15 | 16 | const { setDbEnvVars } = require('./util') 17 | 18 | function stop () { 19 | const options = { 20 | env: { 21 | 'NODE_ENV': 'production', 22 | 'VIEWER_PORT': '8008', 23 | 'PATH': process.env.PATH 24 | }, 25 | stdio: [process.stdin, process.stdout, process.stderr] 26 | } 27 | 28 | options.env = setDbEnvVars(options.env) 29 | 30 | execSync('node ./src/main.js stop', options) 31 | } 32 | 33 | module.exports = { 34 | stop: stop 35 | } 36 | -------------------------------------------------------------------------------- /scripts/test.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2018 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const execSync = require('child_process').execSync 15 | const path = require('path') 16 | 17 | const { setDbEnvVars } = require('./util') 18 | 19 | function test (useReporter) { 20 | const options = { 21 | env: { 22 | 'NODE_ENV': 'test', 23 | 'VIEWER_PORT': '8008', 24 | 'PATH': process.env.PATH 25 | }, 26 | stdio: [process.stdin, process.stdout, process.stderr] 27 | } 28 | 29 | options.env = setDbEnvVars(options.env) 30 | 31 | const mochaBin = path.join(__dirname, '..', 'node_modules', 'mocha', 'bin', 'mocha') 32 | const mochaReporterOptions = '--reporter mocha-junit-reporter --reporter-options mochaFile=./unit-results.xml' 33 | const mocha = useReporter ? [mochaBin, mochaReporterOptions].join(' ') : mochaBin 34 | execSync(mocha, options) 35 | } 36 | 37 | module.exports = { 38 | test: test 39 | } 40 | -------------------------------------------------------------------------------- /src/cli/cli-data-types.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | function Integer (value) { 15 | return Number(value) 16 | } 17 | 18 | function Float (value) { 19 | return Number(value) 20 | } 21 | 22 | module.exports = { 23 | Integer: Integer, 24 | Float: Float 25 | } 26 | -------------------------------------------------------------------------------- /src/config/constants.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | module.exports = { 15 | 'App:Name': 'iofog-controller', 16 | 'Viewer:Port': 80, 17 | 18 | 'Server:Port': 51121, 19 | 'Server:DevMode': false, 20 | 21 | 'Email:ActivationEnabled': false, 22 | 'Email:HomeUrl': 'https://iofog.org', 23 | 24 | 'Service:LogsDirectory': '/var/log/iofog-controller', 25 | 'Service:LogsFileSize': 10485760, 26 | 'Service:LogsFileCount': 10, 27 | 28 | 'Settings:DefaultJobIntervalSeconds': 120, 29 | 'Settings:UserTokenExpirationIntervalSeconds': 3600, 30 | 'Settings:FogTokenExpirationIntervalSeconds': 3600, 31 | 'Settings:KubeletTokenExpirationIntervalSeconds': 3600, 32 | 'Settings:SchedulerTokenExpirationIntervalSeconds': 3600, 33 | 'Settings:FogStatusUpdateIntervalSeconds': 30, 34 | 'Settings:FogStatusUpdateTolerance': 3, 35 | 36 | 'Diagnostics:DiagnosticDir': 'diagnostic' 37 | } 38 | -------------------------------------------------------------------------------- /src/config/default.json: -------------------------------------------------------------------------------- 1 | { 2 | "App": { 3 | "Name": "iofog-controller" 4 | }, 5 | "Viewer": { 6 | "Port": 80 7 | }, 8 | "Kubelet": { 9 | "Uri": "http://localhost:1234" 10 | }, 11 | "Server": { 12 | "Port": 51121, 13 | "DevMode": false 14 | }, 15 | "Email": { 16 | "ActivationEnabled": false, 17 | "HomeUrl": "https://google.com" 18 | }, 19 | "Service": { 20 | "LogsDirectory": "/var/log/iofog-controller", 21 | "LogsFileSize": 10485760, 22 | "LogsFileCount": 10 23 | }, 24 | "Settings": { 25 | "DefaultJobIntervalSeconds": 120, 26 | "UserTokenExpirationIntervalSeconds": 3600, 27 | "FogTokenExpirationIntervalSeconds": 3600, 28 | "FogStatusUpdateIntervalSeconds": 30, 29 | "FogStatusUpdateTolerance": 3 30 | }, 31 | "Diagnostics": { 32 | "DiagnosticDir": "diagnostic" 33 | }, 34 | "PublicPorts": { 35 | "Range": "6000-7000", 36 | "ProxyBrokerUrl": "http://localhost:3000", 37 | "ProxyBrokerToken": "" 38 | }, 39 | "SystemImages": { 40 | "Router": { 41 | "1": "iofog/router:latest", 42 | "2": "iofog/router:latest" 43 | }, 44 | "Proxy": { 45 | "1": "iofog/proxy:latest", 46 | "2": "iofog/proxy-arm:latest" 47 | }, 48 | "PortRouter": { 49 | "1": "iofog/port-router:latest", 50 | "2": "iofog/port-router:latest" 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/config/development.json: -------------------------------------------------------------------------------- 1 | { 2 | "App": { 3 | "Name": "iofog-controller-dev" 4 | }, 5 | "Viewer": { 6 | "Port": 80 7 | }, 8 | "Kubelet": { 9 | "Uri": "http://localhost:1234" 10 | }, 11 | "Server": { 12 | "Port": 51121, 13 | "DevMode": true 14 | }, 15 | "Email": { 16 | "ActivationEnabled": false, 17 | "HomeUrl": "https://google.com" 18 | }, 19 | "Service": { 20 | "LogsDirectory": "/var/log/iofog-controller", 21 | "LogsFileSize": 10485760, 22 | "LogsFileCount": 10 23 | }, 24 | "Settings": { 25 | "UserTokenExpirationIntervalSeconds": 360000, 26 | "FogTokenExpirationIntervalSeconds": 3600000, 27 | "FogStatusUpdateIntervalSeconds": 30, 28 | "FogStatusUpdateTolerance": 3 29 | }, 30 | "Tunnel": { 31 | "Username": "username", 32 | "Password": "password", 33 | "Host": "23.253.111.231", 34 | "RsaKey": "rsa", 35 | "Lport": 22, 36 | "PortRange": "2000-10000" 37 | }, 38 | "Diagnostics": { 39 | "DiagnosticDir": "diagnostic" 40 | }, 41 | "Database": { 42 | "Provider": "sqlite", 43 | "Config": { 44 | "databaseName": "dev_database.sqlite", 45 | "logging": false, 46 | "transactionType": "IMMEDIATE", 47 | "pool": { 48 | "maxactive": 1, 49 | "max": 1, 50 | "min": 0, 51 | "idle": 20000 52 | } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /src/config/production.json: -------------------------------------------------------------------------------- 1 | { 2 | "App": { 3 | "Name": "iofog-controller" 4 | }, 5 | "Viewer": { 6 | "Port": 80 7 | }, 8 | "Server": { 9 | "Port": 51121, 10 | "DevMode": true 11 | }, 12 | "Email": { 13 | "ActivationEnabled": false 14 | }, 15 | "Service": { 16 | "LogsDirectory": "/var/log/iofog-controller", 17 | "LogsFileSize": 10485760, 18 | "LogsFileCount": 10 19 | }, 20 | "Settings": { 21 | "UserTokenExpirationIntervalSeconds": 3600, 22 | "FogTokenExpirationIntervalSeconds": 3600, 23 | "FogStatusUpdateIntervalSeconds": 30, 24 | "FogStatusUpdateTolerance": 3 25 | }, 26 | "PublicPorts": { 27 | "Provider": "default" 28 | }, 29 | "Database": { 30 | "Provider": "sqlite", 31 | "Config": { 32 | "databaseName": "prod_database.sqlite", 33 | "logging": false, 34 | "transactionType": "IMMEDIATE", 35 | "pool": { 36 | "maxactive": 1, 37 | "max": 1, 38 | "min": 0, 39 | "idle": 20000 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/config/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "Server": { 3 | "DevMode": true 4 | }, 5 | "Email": { 6 | "ActivationEnabled": false 7 | }, 8 | "Database": { 9 | "Provider": "sqlite", 10 | "Config": { 11 | "databaseName": "test_database.sqlite", 12 | "logging": false, 13 | "transactionType": "IMMEDIATE", 14 | "pool": { 15 | "maxactive": 1, 16 | "max": 1, 17 | "min": 0, 18 | "idle": 20000 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/controllers/config-controller.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const AuthDecorator = require('./../decorators/authorization-decorator') 15 | const ConfigService = require('../services/config-service') 16 | 17 | const upsertConfigElementEndpoint = async function (req, user) { 18 | const configData = req.body 19 | return ConfigService.upsertConfigElement(configData) 20 | } 21 | 22 | const listConfigEndpoint = async function (user) { 23 | return ConfigService.listConfig() 24 | } 25 | 26 | const getConfigEndpoint = async function (req, user) { 27 | const key = req.params.key 28 | return ConfigService.getConfigElement(key) 29 | } 30 | 31 | module.exports = { 32 | upsertConfigElementEndpoint: AuthDecorator.checkAuthToken(upsertConfigElementEndpoint), 33 | listConfigEndpoint: AuthDecorator.checkAuthToken(listConfigEndpoint), 34 | getConfigEndpoint: AuthDecorator.checkAuthToken(getConfigEndpoint) 35 | } 36 | -------------------------------------------------------------------------------- /src/controllers/controller.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const ControllerService = require('../services/controller-service') 15 | 16 | const statusControllerEndPoint = async function (req) { 17 | return ControllerService.statusController(false) 18 | } 19 | 20 | const emailActivationEndPoint = async function (req) { 21 | return ControllerService.emailActivation(false) 22 | } 23 | 24 | const fogTypesEndPoint = async function (req) { 25 | return ControllerService.getFogTypes(false) 26 | } 27 | 28 | module.exports = { 29 | statusControllerEndPoint: statusControllerEndPoint, 30 | emailActivationEndPoint: emailActivationEndPoint, 31 | fogTypesEndPoint: fogTypesEndPoint 32 | } 33 | -------------------------------------------------------------------------------- /src/controllers/router-controller.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const AuthDecorator = require('./../decorators/authorization-decorator') 15 | const RouterService = require('../services/router-service') 16 | 17 | const upsertDefaultRouter = async function (req) { 18 | const routerData = req.body 19 | return RouterService.upsertDefaultRouter(routerData) 20 | } 21 | 22 | const getRouterEndPoint = async function () { 23 | return RouterService.getDefaultRouter() 24 | } 25 | 26 | module.exports = { 27 | upsertDefaultRouter: AuthDecorator.checkAuthToken(upsertDefaultRouter), 28 | getRouterEndPoint: AuthDecorator.checkAuthToken(getRouterEndPoint) 29 | } 30 | -------------------------------------------------------------------------------- /src/data/constants.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | ROUTER_CATALOG_NAME: 'Router', 3 | PROXY_CATALOG_NAME: 'Proxy', 4 | PORT_ROUTER_CATALOG_NAME: 'PortRouter' 5 | } 6 | -------------------------------------------------------------------------------- /src/data/managers/access-token-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const AccessToken = models.AccessToken 17 | 18 | class AccessTokenManager extends BaseManager { 19 | getEntity () { 20 | return AccessToken 21 | } 22 | 23 | // no transaction required here, used by auth decorator 24 | updateExpirationTime (id, newTime) { 25 | return AccessToken.update({ 26 | expirationTime: newTime 27 | }, { 28 | where: { 29 | id: id 30 | } 31 | }) 32 | } 33 | } 34 | 35 | const instance = new AccessTokenManager() 36 | module.exports = instance 37 | -------------------------------------------------------------------------------- /src/data/managers/application-template-variable-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const ApplicationTemplateVariable = models.ApplicationTemplateVariable 17 | 18 | class ApplicationTemplateVariableManager extends BaseManager { 19 | getEntity () { 20 | return ApplicationTemplateVariable 21 | } 22 | } 23 | 24 | const instance = new ApplicationTemplateVariableManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/catalog-item-image-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const CatalogItemImage = models.CatalogItemImage 17 | 18 | class CatalogItemImageManager extends BaseManager { 19 | getEntity () { 20 | return CatalogItemImage 21 | } 22 | } 23 | 24 | const instance = new CatalogItemImageManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/catalog-item-input-type-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const CatalogItemInputType = models.CatalogItemInputType 17 | 18 | class CatalogItemInputTypeManager extends BaseManager { 19 | getEntity () { 20 | return CatalogItemInputType 21 | } 22 | } 23 | 24 | const instance = new CatalogItemInputTypeManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/catalog-item-output-type-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const CatalogItemOutputType = models.CatalogItemOutputType 17 | 18 | class CatalogItemOutputTypeManager extends BaseManager { 19 | getEntity () { 20 | return CatalogItemOutputType 21 | } 22 | } 23 | 24 | const instance = new CatalogItemOutputTypeManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/change-tracking-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const ChangeTracking = models.ChangeTracking 17 | 18 | class ChangeTrackingManager extends BaseManager { 19 | getEntity () { 20 | return ChangeTracking 21 | } 22 | } 23 | 24 | const instance = new ChangeTrackingManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/config-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const Config = models.Config 17 | 18 | class ConfigManager extends BaseManager { 19 | getEntity () { 20 | return Config 21 | } 22 | } 23 | 24 | const instance = new ConfigManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/edge-resource-manager.js: -------------------------------------------------------------------------------- 1 | const BaseManager = require('./base-manager') 2 | const models = require('../models') 3 | const { EdgeResource, Tags } = models 4 | 5 | class EdgeResourcesManager extends BaseManager { 6 | getEntity () { 7 | return EdgeResource 8 | } 9 | 10 | findAllWithOrchestrationTags (whereObj, transaction) { 11 | return EdgeResource.findAll({ 12 | include: [ 13 | { 14 | model: Tags, 15 | as: 'orchestrationTags' 16 | } 17 | ], 18 | where: whereObj 19 | }, { transaction }) 20 | } 21 | 22 | findOneWithOrchestrationTags (whereObj, transaction) { 23 | return EdgeResource.findOne({ 24 | include: [ 25 | { 26 | model: Tags, 27 | as: 'orchestrationTags' 28 | } 29 | ], 30 | where: whereObj 31 | }, { transaction }) 32 | } 33 | } 34 | 35 | const instance = new EdgeResourcesManager() 36 | module.exports = instance 37 | -------------------------------------------------------------------------------- /src/data/managers/http-based-resource-interface-endpoints-manager.js: -------------------------------------------------------------------------------- 1 | const BaseManager = require('./base-manager') 2 | const models = require('../models') 3 | const HTTPBasedResourceInterfaceEndpoint = models.HTTPBasedResourceInterfaceEndpoint 4 | 5 | class HTTPBasedResourceInterfaceEndpointsManager extends BaseManager { 6 | getEntity () { 7 | return HTTPBasedResourceInterfaceEndpoint 8 | } 9 | } 10 | 11 | const instance = new HTTPBasedResourceInterfaceEndpointsManager() 12 | module.exports = instance 13 | -------------------------------------------------------------------------------- /src/data/managers/http-based-resource-interface-manager.js: -------------------------------------------------------------------------------- 1 | const BaseManager = require('./base-manager') 2 | const models = require('../models') 3 | const HTTPBasedResourceInterface = models.HTTPBasedResourceInterface 4 | const HTTPBasedResourceInterfaceEndpoint = models.HTTPBasedResourceInterfaceEndpoint 5 | 6 | class HTTPBasedResourceInterfacesManager extends BaseManager { 7 | getEntity () { 8 | return HTTPBasedResourceInterface 9 | } 10 | 11 | async findOneWithEndpoints (whereObj, transaction) { 12 | return HTTPBasedResourceInterface.findOne({ 13 | include: [ 14 | { 15 | model: HTTPBasedResourceInterfaceEndpoint, 16 | as: 'endpoints' 17 | } 18 | ], 19 | where: whereObj 20 | }, { transaction }) 21 | } 22 | 23 | async findAllWithEndpoints (whereObj, transaction) { 24 | return HTTPBasedResourceInterface.findAll({ 25 | include: [ 26 | { 27 | model: HTTPBasedResourceInterfaceEndpoint, 28 | as: 'endpoints' 29 | } 30 | ], 31 | where: whereObj 32 | }, { transaction }) 33 | } 34 | } 35 | 36 | const instance = new HTTPBasedResourceInterfacesManager() 37 | module.exports = instance 38 | -------------------------------------------------------------------------------- /src/data/managers/hw-info-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const HWInfo = models.HWInfo 17 | 18 | class HWInfoManager extends BaseManager { 19 | getEntity () { 20 | return HWInfo 21 | } 22 | } 23 | 24 | const instance = new HWInfoManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/iofog-access-token-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const FogAccessToken = models.FogAccessToken 17 | 18 | class FogAccessTokenManager extends BaseManager { 19 | getEntity () { 20 | return FogAccessToken 21 | } 22 | 23 | // no transaction required here, used by auth decorator 24 | updateExpirationTime (id, newTime) { 25 | return FogAccessToken.update({ 26 | expirationTime: newTime 27 | }, { 28 | where: { 29 | id: id 30 | } 31 | }) 32 | } 33 | } 34 | 35 | const instance = new FogAccessTokenManager() 36 | module.exports = instance 37 | -------------------------------------------------------------------------------- /src/data/managers/iofog-provision-key-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const FogProvisionKey = models.FogProvisionKey 17 | 18 | class FogProvisionKeyManager extends BaseManager { 19 | getEntity () { 20 | return FogProvisionKey 21 | } 22 | } 23 | 24 | const instance = new FogProvisionKeyManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/iofog-type-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const FogType = models.FogType 17 | 18 | class FogTypeManager extends BaseManager { 19 | getEntity () { 20 | return FogType 21 | } 22 | } 23 | 24 | const instance = new FogTypeManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/iofog-version-command-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const FogVersionCommand = models.FogVersionCommand 17 | 18 | class FogVersionCommandManager extends BaseManager { 19 | getEntity () { 20 | return FogVersionCommand 21 | } 22 | } 23 | 24 | const instance = new FogVersionCommandManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/kubelet-access-token-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const KubeletAccessToken = models.KubeletAccessToken 17 | 18 | class KubeletAccessTokenManager extends BaseManager { 19 | getEntity () { 20 | return KubeletAccessToken 21 | } 22 | } 23 | 24 | const instance = new KubeletAccessTokenManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/microservice-arg-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const MicroserviceArg = models.MicroserviceArg 17 | 18 | const microserviceArgExcludedFields = [ 19 | 'id', 20 | 'microservice_uuid', 21 | 'microserviceUuid' 22 | ] 23 | 24 | class MicroserviceArgManager extends BaseManager { 25 | getEntity () { 26 | return MicroserviceArg 27 | } 28 | 29 | findAllExcludeFields (where, transaction) { 30 | return this.findAllWithAttributes(where, { exclude: microserviceArgExcludedFields }, transaction) 31 | } 32 | } 33 | 34 | const instance = new MicroserviceArgManager() 35 | module.exports = instance 36 | -------------------------------------------------------------------------------- /src/data/managers/microservice-env-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const MicroserviceEnv = models.MicroserviceEnv 17 | 18 | const microserviceEnvExcludedFields = [ 19 | 'id', 20 | 'microservice_uuid', 21 | 'microserviceUuid' 22 | ] 23 | 24 | class MicroserviceEnvManager extends BaseManager { 25 | getEntity () { 26 | return MicroserviceEnv 27 | } 28 | 29 | findAllExcludeFields (where, transaction) { 30 | return this.findAllWithAttributes(where, { exclude: microserviceEnvExcludedFields }, transaction) 31 | } 32 | } 33 | 34 | const instance = new MicroserviceEnvManager() 35 | module.exports = instance 36 | -------------------------------------------------------------------------------- /src/data/managers/microservice-proxy-port-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const MicroserviceProxyPort = models.MicroserviceProxyPort 17 | 18 | class MicroserviceProxyPortManager extends BaseManager { 19 | getEntity () { 20 | return MicroserviceProxyPort 21 | } 22 | } 23 | 24 | const instance = new MicroserviceProxyPortManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/microservice-public-mode-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const MicroservicePublicMode = models.MicroservicePublicMode 17 | 18 | class MicroservicePublicModeManager extends BaseManager { 19 | getEntity () { 20 | return MicroservicePublicMode 21 | } 22 | } 23 | 24 | const instance = new MicroservicePublicModeManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/microservice-public-port-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const MicroservicePublicPort = models.MicroservicePublicPort 17 | 18 | class MicroservicePublicPortManager extends BaseManager { 19 | getEntity () { 20 | return MicroservicePublicPort 21 | } 22 | } 23 | 24 | const instance = new MicroservicePublicPortManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/microservice-status-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const MicroserviceStatus = models.MicroserviceStatus 17 | 18 | const microserviceStatusExcludedFields = [ 19 | 'id', 20 | 'microservice_uuid', 21 | 'microserviceUuid', 22 | 'created_at', 23 | 'updated_at' 24 | ] 25 | 26 | class MicroserviceStatusManager extends BaseManager { 27 | getEntity () { 28 | return MicroserviceStatus 29 | } 30 | 31 | findAllExcludeFields (where, transaction) { 32 | return this.findAllWithAttributes(where, { exclude: microserviceStatusExcludedFields }, transaction) 33 | } 34 | } 35 | 36 | const instance = new MicroserviceStatusManager() 37 | module.exports = instance 38 | -------------------------------------------------------------------------------- /src/data/managers/registry-manager.js: -------------------------------------------------------------------------------- 1 | const BaseManager = require('./base-manager') 2 | const models = require('../models') 3 | const Registry = models.Registry 4 | 5 | class RegistryManager extends BaseManager { 6 | getEntity () { 7 | return Registry 8 | } 9 | } 10 | 11 | const instance = new RegistryManager() 12 | module.exports = instance 13 | -------------------------------------------------------------------------------- /src/data/managers/router-connection-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const RouterConnection = models.RouterConnection 17 | const Router = models.Router 18 | 19 | class RouterConnectionManager extends BaseManager { 20 | getEntity () { 21 | return RouterConnection 22 | } 23 | 24 | findAllWithRouters (where, transaction) { 25 | return RouterConnection.findAll({ 26 | include: [ 27 | { 28 | model: Router, 29 | as: 'source', 30 | required: true 31 | }, 32 | { 33 | model: Router, 34 | as: 'dest', 35 | required: true 36 | } 37 | ], 38 | where: where 39 | }, { transaction: transaction }) 40 | } 41 | } 42 | 43 | const instance = new RouterConnectionManager() 44 | module.exports = instance 45 | -------------------------------------------------------------------------------- /src/data/managers/router-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const Router = models.Router 17 | 18 | class RouterManager extends BaseManager { 19 | getEntity () { 20 | return Router 21 | } 22 | } 23 | 24 | const instance = new RouterManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/scheduler-access-token-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const SchedulerAccessToken = models.SchedulerAccessToken 17 | 18 | class SchedulerAccessTokenManager extends BaseManager { 19 | getEntity () { 20 | return SchedulerAccessToken 21 | } 22 | } 23 | 24 | const instance = new SchedulerAccessTokenManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/strace-diagnostics-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const StraceDiagnostics = models.StraceDiagnostics 17 | 18 | class StraceDiagnosticsManager extends BaseManager { 19 | getEntity () { 20 | return StraceDiagnostics 21 | } 22 | } 23 | 24 | const instance = new StraceDiagnosticsManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/tags-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const Tags = models.Tags 17 | 18 | class TagsManager extends BaseManager { 19 | getEntity () { 20 | return Tags 21 | } 22 | } 23 | 24 | const instance = new TagsManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/tunnel-manager.js: -------------------------------------------------------------------------------- 1 | const BaseManager = require('./base-manager') 2 | const models = require('../models') 3 | const Tunnel = models.Tunnel 4 | 5 | class TunnelManager extends BaseManager { 6 | getEntity () { 7 | return Tunnel 8 | } 9 | } 10 | 11 | const instance = new TunnelManager() 12 | module.exports = instance 13 | -------------------------------------------------------------------------------- /src/data/managers/usb-info-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const USBInfo = models.USBInfo 17 | 18 | class USBInfoManager extends BaseManager { 19 | getEntity () { 20 | return USBInfo 21 | } 22 | } 23 | 24 | const instance = new USBInfoManager() 25 | module.exports = instance 26 | -------------------------------------------------------------------------------- /src/data/managers/volume-mapping-manager.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const BaseManager = require('./base-manager') 15 | const models = require('../models') 16 | const VolumeMapping = models.VolumeMapping 17 | 18 | class VolumeMappingManager extends BaseManager { 19 | getEntity () { 20 | return VolumeMapping 21 | } 22 | 23 | findAll (where, transaction) { 24 | return VolumeMapping.findAll({ 25 | where: where, 26 | attributes: ['hostDestination', 'containerDestination', 'accessMode', 'id', 'type'] 27 | }, { transaction: transaction }) 28 | } 29 | } 30 | 31 | const instance = new VolumeMappingManager() 32 | module.exports = instance 33 | -------------------------------------------------------------------------------- /src/data/migrations/20180930155645-create-user.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | up: (queryInterface, Sequelize) => { 4 | return queryInterface.createTable('Users', { 5 | id: { 6 | allowNull: false, 7 | autoIncrement: true, 8 | primaryKey: true, 9 | type: Sequelize.INTEGER, 10 | field: 'id' 11 | }, 12 | firstName: { 13 | /* eslint-disable new-cap */ 14 | type: Sequelize.STRING(100), 15 | field: 'first_name', 16 | defaultValue: '' 17 | }, 18 | lastName: { 19 | /* eslint-disable new-cap */ 20 | type: Sequelize.STRING(100), 21 | field: 'last_name', 22 | defaultValue: '' 23 | }, 24 | email: { 25 | /* eslint-disable new-cap */ 26 | type: Sequelize.STRING(100), 27 | field: 'email', 28 | defaultValue: '' 29 | }, 30 | password: { 31 | /* eslint-disable new-cap */ 32 | type: Sequelize.STRING(100), 33 | field: 'password' 34 | }, 35 | tempPassword: { 36 | /* eslint-disable new-cap */ 37 | type: Sequelize.STRING(100), 38 | field: 'temp_password' 39 | }, 40 | emailActivated: { 41 | type: Sequelize.BOOLEAN, 42 | field: 'email_activated', 43 | defaultValue: false 44 | } 45 | }) 46 | }, 47 | down: (queryInterface, Sequelize) => { 48 | return queryInterface.dropTable('Users') 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/data/migrations/20180930173823-create-registry.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | up: (queryInterface, Sequelize) => { 4 | return queryInterface.createTable('Registries', { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | autoIncrement: true, 9 | allowNull: false, 10 | field: 'id' 11 | }, 12 | url: { 13 | type: Sequelize.TEXT, 14 | field: 'url' 15 | }, 16 | isPublic: { 17 | type: Sequelize.BOOLEAN, 18 | field: 'is_public' 19 | }, 20 | secure: { 21 | type: Sequelize.BOOLEAN, 22 | field: 'secure' 23 | }, 24 | certificate: { 25 | type: Sequelize.TEXT, 26 | field: 'certificate' 27 | }, 28 | requiresCert: { 29 | type: Sequelize.BOOLEAN, 30 | field: 'requires_cert' 31 | }, 32 | username: { 33 | type: Sequelize.TEXT, 34 | field: 'user_name' 35 | }, 36 | password: { 37 | type: Sequelize.TEXT, 38 | field: 'password' 39 | }, 40 | userEmail: { 41 | type: Sequelize.TEXT, 42 | field: 'user_email' 43 | }, 44 | userId: { 45 | type: Sequelize.INTEGER, 46 | field: 'user_id', 47 | references: { model: 'Users', key: 'id' }, 48 | onDelete: 'cascade' 49 | } 50 | }) 51 | }, 52 | down: (queryInterface, Sequelize) => { 53 | return queryInterface.dropTable('Registries') 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/data/migrations/20180930184703-create-fog-type.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | up: (queryInterface, Sequelize) => { 4 | return queryInterface.createTable('FogTypes', { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | autoIncrement: true, 9 | allowNull: false, 10 | field: 'id' 11 | }, 12 | name: { 13 | type: Sequelize.TEXT, 14 | field: 'name' 15 | }, 16 | image: { 17 | type: Sequelize.TEXT, 18 | field: 'image' 19 | }, 20 | description: { 21 | type: Sequelize.TEXT, 22 | field: 'description' 23 | }, 24 | networkCatalogItemId: { 25 | type: Sequelize.INTEGER, 26 | field: 'network_catalog_item_id', 27 | references: { model: 'CatalogItems', key: 'id' }, 28 | onDelete: 'cascade' 29 | }, 30 | halCatalogItemId: { 31 | type: Sequelize.INTEGER, 32 | field: 'hal_catalog_item_id', 33 | references: { model: 'CatalogItems', key: 'id' }, 34 | onDelete: 'cascade' 35 | }, 36 | bluetoothCatalogItemId: { 37 | type: Sequelize.INTEGER, 38 | field: 'bluetooth_catalog_item_id', 39 | references: { model: 'CatalogItems', key: 'id' }, 40 | onDelete: 'cascade' 41 | } 42 | }) 43 | }, 44 | down: (queryInterface, Sequelize) => { 45 | return queryInterface.dropTable('FogTypes') 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/data/migrations/20180930184921-create-catalog-item-image.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | up: (queryInterface, Sequelize) => { 4 | return queryInterface.createTable('CatalogItemImages', { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | autoIncrement: true, 9 | allowNull: false, 10 | field: 'id' 11 | }, 12 | containerImage: { 13 | type: Sequelize.TEXT, 14 | field: 'container_image' 15 | }, 16 | catalogItemId: { 17 | type: Sequelize.INTEGER, 18 | field: 'catalog_item_id', 19 | references: { model: 'CatalogItems', key: 'id' }, 20 | onDelete: 'cascade' 21 | }, 22 | fogTypeId: { 23 | type: Sequelize.INTEGER, 24 | field: 'fog_type_id', 25 | references: { model: 'FogTypes', key: 'id' }, 26 | onDelete: 'cascade' 27 | } 28 | }) 29 | }, 30 | down: (queryInterface, Sequelize) => { 31 | return queryInterface.dropTable('CatalogItemImages') 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/data/migrations/20180930194506-create-catalog-item-input-type.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | up: (queryInterface, Sequelize) => { 4 | return queryInterface.createTable('CatalogItemInputTypes', { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | autoIncrement: true, 9 | allowNull: false, 10 | field: 'id' 11 | }, 12 | infoType: { 13 | type: Sequelize.TEXT, 14 | field: 'info_type' 15 | }, 16 | infoFormat: { 17 | type: Sequelize.TEXT, 18 | field: 'info_format' 19 | }, 20 | catalogItemId: { 21 | type: Sequelize.INTEGER, 22 | field: 'catalog_item_id', 23 | references: { model: 'CatalogItems', key: 'id' }, 24 | onDelete: 'cascade' 25 | } 26 | }) 27 | }, 28 | down: (queryInterface, Sequelize) => { 29 | return queryInterface.dropTable('CatalogItemInputTypes') 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/data/migrations/20180930195746-create-catalog-item-output-type.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | up: (queryInterface, Sequelize) => { 4 | return queryInterface.createTable('CatalogItemOutputTypes', { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | autoIncrement: true, 9 | allowNull: false, 10 | field: 'id' 11 | }, 12 | infoType: { 13 | type: Sequelize.TEXT, 14 | field: 'info_type' 15 | }, 16 | infoFormat: { 17 | type: Sequelize.TEXT, 18 | field: 'info_format' 19 | }, 20 | catalogItemId: { 21 | type: Sequelize.INTEGER, 22 | field: 'catalog_item_id', 23 | references: { model: 'CatalogItems', key: 'id' }, 24 | onDelete: 'cascade' 25 | } 26 | }) 27 | }, 28 | down: (queryInterface, Sequelize) => { 29 | return queryInterface.dropTable('CatalogItemOutputTypes') 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/data/migrations/20180930204039-create-email-activation-code.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { convertToInt } = require('../../helpers/app-helper') 4 | 5 | module.exports = { 6 | up: (queryInterface, Sequelize) => { 7 | return queryInterface.createTable('EmailActivationCodes', { 8 | id: { 9 | type: Sequelize.INTEGER, 10 | primaryKey: true, 11 | autoIncrement: true, 12 | allowNull: false, 13 | field: 'id' 14 | }, 15 | activationCode: { 16 | type: Sequelize.TEXT, 17 | field: 'activation_code' 18 | }, 19 | expirationTime: { 20 | type: Sequelize.BIGINT, 21 | get () { 22 | return convertToInt(this.getDataValue('expirationTime')) 23 | }, 24 | field: 'expiration_time' 25 | }, 26 | userId: { 27 | type: Sequelize.INTEGER, 28 | field: 'user_id', 29 | references: { model: 'Users', key: 'id' }, 30 | onDelete: 'cascade' 31 | } 32 | }) 33 | }, 34 | down: (queryInterface, Sequelize) => { 35 | return queryInterface.dropTable('EmailActivationCodes') 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/data/migrations/20180930230219-create-fog-access-token.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { convertToInt } = require('../../helpers/app-helper') 4 | 5 | module.exports = { 6 | up: (queryInterface, Sequelize) => { 7 | return queryInterface.createTable('FogAccessTokens', { 8 | id: { 9 | type: Sequelize.INTEGER, 10 | primaryKey: true, 11 | autoIncrement: true, 12 | allowNull: false, 13 | field: 'id' 14 | }, 15 | expirationTime: { 16 | type: Sequelize.BIGINT, 17 | get () { 18 | return convertToInt(this.getDataValue('expirationTime')) 19 | }, 20 | field: 'expiration_time' 21 | }, 22 | token: { 23 | type: Sequelize.TEXT, 24 | field: 'token' 25 | }, 26 | iofogUuid: { 27 | type: Sequelize.STRING(32), 28 | field: 'iofog_uuid', 29 | references: { model: 'Fogs', key: 'uuid' }, 30 | onDelete: 'cascade' 31 | }, 32 | userId: { 33 | type: Sequelize.INTEGER, 34 | field: 'user_id', 35 | references: { model: 'Users', key: 'id' }, 36 | onDelete: 'cascade' 37 | } 38 | }) 39 | }, 40 | down: (queryInterface, Sequelize) => { 41 | return queryInterface.dropTable('FogAccessTokens') 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/data/migrations/20180930230626-create-fog-provision-key.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { convertToInt } = require('../../helpers/app-helper') 4 | 5 | module.exports = { 6 | up: (queryInterface, Sequelize) => { 7 | return queryInterface.createTable('FogProvisionKeys', { 8 | id: { 9 | type: Sequelize.INTEGER, 10 | primaryKey: true, 11 | autoIncrement: true, 12 | allowNull: false, 13 | field: 'id' 14 | }, 15 | provisionKey: { 16 | /* eslint-disable new-cap */ 17 | type: Sequelize.STRING(100), 18 | field: 'provisioning_string' 19 | }, 20 | expirationTime: { 21 | type: Sequelize.BIGINT, 22 | get () { 23 | return convertToInt(this.getDataValue('expirationTime')) 24 | }, 25 | field: 'expiration_time' 26 | }, 27 | iofogUuid: { 28 | type: Sequelize.STRING(32), 29 | field: 'iofog_uuid', 30 | references: { model: 'Fogs', key: 'uuid' }, 31 | onDelete: 'cascade' 32 | } 33 | }) 34 | }, 35 | down: (queryInterface, Sequelize) => { 36 | return queryInterface.dropTable('FogProvisionKeys') 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/data/migrations/20180930231241-create-fog-version-command.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | up: (queryInterface, Sequelize) => { 4 | return queryInterface.createTable('FogVersionCommands', { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | autoIncrement: true, 9 | field: 'id' 10 | }, 11 | versionCommand: { 12 | /* eslint-disable new-cap */ 13 | type: Sequelize.STRING(100), 14 | field: 'version_command' 15 | }, 16 | iofogUuid: { 17 | type: Sequelize.STRING(32), 18 | field: 'iofog_uuid', 19 | references: { model: 'Fogs', key: 'uuid' }, 20 | onDelete: 'cascade' 21 | } 22 | }) 23 | }, 24 | down: (queryInterface, Sequelize) => { 25 | return queryInterface.dropTable('FogVersionCommands') 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/data/migrations/20180930231536-create-hw-info.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | up: (queryInterface, Sequelize) => { 4 | return queryInterface.createTable('HWInfos', { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | autoIncrement: true, 9 | allowNull: false, 10 | field: 'id' 11 | }, 12 | info: { 13 | type: Sequelize.TEXT, 14 | defaultValue: ' ', 15 | field: 'info' 16 | }, 17 | createdAt: { 18 | allowNull: false, 19 | type: Sequelize.DATE, 20 | field: 'created_at' 21 | }, 22 | updatedAt: { 23 | allowNull: false, 24 | type: Sequelize.DATE, 25 | field: 'updated_at' 26 | }, 27 | iofogUuid: { 28 | type: Sequelize.STRING(32), 29 | field: 'iofog_uuid', 30 | references: { model: 'Fogs', key: 'uuid' }, 31 | onDelete: 'cascade' 32 | } 33 | }) 34 | }, 35 | down: (queryInterface, Sequelize) => { 36 | return queryInterface.dropTable('HWInfos') 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/data/migrations/20180930232242-create-usb-info.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | up: (queryInterface, Sequelize) => { 4 | return queryInterface.createTable('USBInfos', { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | autoIncrement: true, 9 | allowNull: false, 10 | field: 'id' 11 | }, 12 | info: { 13 | type: Sequelize.TEXT, 14 | defaultValue: ' ', 15 | field: 'info' 16 | }, 17 | createdAt: { 18 | allowNull: false, 19 | type: Sequelize.DATE, 20 | field: 'created_at' 21 | }, 22 | updatedAt: { 23 | allowNull: false, 24 | type: Sequelize.DATE, 25 | field: 'updated_at' 26 | }, 27 | iofogUuid: { 28 | type: Sequelize.STRING(32), 29 | field: 'iofog_uuid', 30 | references: { model: 'Fogs', key: 'uuid' }, 31 | onDelete: 'cascade' 32 | } 33 | }) 34 | }, 35 | down: (queryInterface, Sequelize) => { 36 | return queryInterface.dropTable('USBInfos') 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/data/migrations/20180930232508-create-tunnel.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | up: (queryInterface, Sequelize) => { 4 | return queryInterface.createTable('Tunnels', { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | autoIncrement: true, 9 | allowNull: false, 10 | field: 'id' 11 | }, 12 | username: { 13 | type: Sequelize.TEXT, 14 | field: 'username' 15 | }, 16 | password: { 17 | type: Sequelize.TEXT, 18 | field: 'password' 19 | }, 20 | host: { 21 | type: Sequelize.TEXT, 22 | field: 'host' 23 | }, 24 | rport: { 25 | type: Sequelize.INTEGER, 26 | field: 'remote_port' 27 | }, 28 | lport: { 29 | type: Sequelize.INTEGER, 30 | defaultValue: 22, 31 | field: 'local_port' 32 | }, 33 | rsakey: { 34 | type: Sequelize.TEXT, 35 | field: 'rsa_key' 36 | }, 37 | closed: { 38 | type: Sequelize.BOOLEAN, 39 | defaultValue: false, 40 | field: 'closed' 41 | }, 42 | iofogUuid: { 43 | type: Sequelize.STRING(32), 44 | field: 'iofog_uuid', 45 | references: { model: 'Fogs', key: 'uuid' }, 46 | onDelete: 'cascade' 47 | } 48 | }) 49 | }, 50 | down: (queryInterface, Sequelize) => { 51 | return queryInterface.dropTable('Tunnels') 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/data/migrations/20181001071628-create-connector.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | up: (queryInterface, Sequelize) => { 4 | return queryInterface.createTable('Connectors', { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | autoIncrement: true, 9 | allowNull: false, 10 | field: 'id' 11 | }, 12 | name: { 13 | type: Sequelize.TEXT, 14 | field: 'name' 15 | }, 16 | domain: { 17 | type: Sequelize.TEXT, 18 | field: 'domain' 19 | }, 20 | publicIp: { 21 | type: Sequelize.TEXT, 22 | field: 'public_ip' 23 | }, 24 | cert: { 25 | type: Sequelize.TEXT, 26 | field: 'cert' 27 | }, 28 | selfSignedCerts: { 29 | type: Sequelize.BOOLEAN, 30 | field: 'self_signed_certs' 31 | }, 32 | devMode: { 33 | type: Sequelize.BOOLEAN, 34 | field: 'dev_mode' 35 | }, 36 | createdAt: { 37 | allowNull: false, 38 | type: Sequelize.DATE, 39 | field: 'created_at' 40 | }, 41 | updatedAt: { 42 | allowNull: false, 43 | type: Sequelize.DATE, 44 | field: 'updated_at' 45 | } 46 | }) 47 | }, 48 | down: (queryInterface, Sequelize) => { 49 | return queryInterface.dropTable('Connectors') 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/data/migrations/20181001073429-create-strace-diagnostics.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | up: (queryInterface, Sequelize) => { 4 | return queryInterface.createTable('StraceDiagnostics', { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | autoIncrement: true, 9 | allowNull: false, 10 | field: 'id' 11 | }, 12 | straceRun: { 13 | type: Sequelize.BOOLEAN, 14 | field: 'strace_run' 15 | }, 16 | buffer: { 17 | type: Sequelize.TEXT, 18 | field: 'buffer', 19 | defaultValue: '' 20 | }, 21 | microserviceUuid: { 22 | type: Sequelize.STRING(32), 23 | field: 'microservice_uuid', 24 | references: { model: 'Microservices', key: 'uuid' }, 25 | onDelete: 'cascade' 26 | } 27 | }) 28 | }, 29 | down: (queryInterface, Sequelize) => { 30 | return queryInterface.dropTable('StraceDiagnostics') 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/data/migrations/20181003102815-create-volume-mapping.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | up: (queryInterface, Sequelize) => { 4 | return queryInterface.createTable('VolumeMappings', { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | autoIncrement: true, 9 | allowNull: false, 10 | field: 'uuid' 11 | }, 12 | hostDestination: { 13 | type: Sequelize.TEXT, 14 | field: 'host_destination' 15 | }, 16 | containerDestination: { 17 | type: Sequelize.TEXT, 18 | field: 'container_destination' 19 | }, 20 | accessMode: { 21 | type: Sequelize.TEXT, 22 | field: 'access_mode' 23 | }, 24 | microserviceUuid: { 25 | type: Sequelize.STRING(32), 26 | field: 'microservice_uuid', 27 | references: { model: 'Microservices', key: 'uuid' }, 28 | onDelete: 'cascade' 29 | } 30 | }) 31 | }, 32 | down: (queryInterface, Sequelize) => { 33 | return queryInterface.dropTable('VolumeMappings') 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/data/migrations/20181003104606-create-access-token.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { convertToInt } = require('../../helpers/app-helper') 4 | 5 | module.exports = { 6 | up: (queryInterface, Sequelize) => { 7 | return queryInterface.createTable('AccessTokens', { 8 | id: { 9 | type: Sequelize.INTEGER, 10 | primaryKey: true, 11 | autoIncrement: true, 12 | allowNull: false, 13 | field: 'id' 14 | }, 15 | token: { 16 | type: Sequelize.STRING, 17 | field: 'token' 18 | }, 19 | expirationTime: { 20 | type: Sequelize.BIGINT, 21 | get () { 22 | return convertToInt(this.getDataValue('expirationTime')) 23 | }, 24 | field: 'expiration_time' 25 | }, 26 | userId: { 27 | type: Sequelize.INTEGER, 28 | field: 'user_id', 29 | references: { model: 'Users', key: 'id' }, 30 | onDelete: 'cascade' 31 | } 32 | }) 33 | }, 34 | down: (queryInterface, Sequelize) => { 35 | return queryInterface.dropTable('AccessTokens') 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/data/migrations/20181031094923-drop-need-update-col-microservices.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.removeColumn('Microservices', 'need_update') 6 | }, 7 | 8 | down: (queryInterface, Sequelize) => { 9 | return queryInterface.addColumn('Microservices', 10 | 'need_update', 11 | Sequelize.BOOLEAN 12 | ) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/data/migrations/20181102105758-microservice-status-add-missing-time-cols.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('MicroserviceStatuses', 6 | 'operating_duration', 7 | Sequelize.BIGINT 8 | ) 9 | .then(() => queryInterface.addColumn('MicroserviceStatuses', 10 | 'start_time', 11 | Sequelize.BIGINT)) 12 | }, 13 | 14 | down: (queryInterface, Sequelize) => { 15 | return queryInterface.removeColumn('MicroserviceStatuses', 'operating_duration') 16 | .then(() => queryInterface.removeColumn('MicroserviceStatuses', 'start_time')) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/data/migrations/20181102163657-microservice-add-col-remove.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('Microservices', 6 | 'delete', 7 | Sequelize.BOOLEAN 8 | ) 9 | }, 10 | 11 | down: (queryInterface, Sequelize) => { 12 | return queryInterface.removeColumn('Microservices', 'delete') 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/data/migrations/20181105120036-change-tracking-container-to-microservice-renaming.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.renameColumn('ChangeTrackings', 'container_config', 'microservice_config') 6 | .then(() => { 7 | return queryInterface.renameColumn('ChangeTrackings', 'container_list', 'microservice_list') 8 | }) 9 | }, 10 | 11 | down: (queryInterface, Sequelize) => { 12 | return queryInterface.renameColumn('ChangeTrackings', 'microservice_config', 'container_config') 13 | .then(() => { 14 | return queryInterface.renameColumn('ChangeTrackings', 'microservice_list', 'container_list') 15 | }) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/data/migrations/20181109132609-microservice-rename-updatedBy-to-userId.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.renameColumn('Microservices', 'updated_by', 'user_id') 6 | }, 7 | 8 | down: (queryInterface, Sequelize) => { 9 | return queryInterface.renameColumn('Microservices', 'user_id', 'updated_by') 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/data/migrations/20181109132704-microservice-port-rename-updatedBy-to-userId.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.renameColumn('MicroservicePorts', 'updated_by', 'user_id') 6 | }, 7 | 8 | down: (queryInterface, Sequelize) => { 9 | return queryInterface.renameColumn('MicroservicePorts', 'user_id', 'updated_by') 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/data/migrations/20181109132723-flow-remove-updatedBy.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.removeColumn('Flows', 'updated_by') 6 | }, 7 | 8 | down: (queryInterface, Sequelize) => { 9 | return queryInterface.addColumn('Flows', 10 | 'updated_by', 11 | Sequelize.INTEGER 12 | ) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/data/migrations/20190117110458-create-tracking-event.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { convertToInt } = require('../../helpers/app-helper') 4 | 5 | module.exports = { 6 | up: (queryInterface, Sequelize) => { 7 | return queryInterface.createTable('TrackingEvents', { 8 | id: { 9 | type: Sequelize.INTEGER, 10 | primaryKey: true, 11 | autoIncrement: true, 12 | allowNull: false, 13 | field: 'id' 14 | }, 15 | uuid: { 16 | type: Sequelize.TEXT, 17 | allowNull: false, 18 | field: 'uuid' 19 | }, 20 | sourceType: { 21 | type: Sequelize.TEXT, 22 | field: 'source_type' 23 | }, 24 | timestamp: { 25 | type: Sequelize.BIGINT, 26 | get () { 27 | return convertToInt(this.getDataValue('timestamp')) 28 | }, 29 | field: 'timestamp' 30 | }, 31 | type: { 32 | type: Sequelize.TEXT, 33 | field: 'type' 34 | }, 35 | data: { 36 | type: Sequelize.TEXT, 37 | field: 'data' 38 | } 39 | }) 40 | }, 41 | down: (queryInterface, Sequelize) => { 42 | return queryInterface.dropTable('TrackingEvents') 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/data/migrations/20190222135632-create-kubelet-access-token.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { convertToInt } = require('../../helpers/app-helper') 4 | 5 | module.exports = { 6 | up: (queryInterface, Sequelize) => { 7 | return queryInterface.createTable('KubeletAccessTokens', { 8 | id: { 9 | type: Sequelize.INTEGER, 10 | primaryKey: true, 11 | autoIncrement: true, 12 | allowNull: false, 13 | field: 'id' 14 | }, 15 | expirationTime: { 16 | type: Sequelize.BIGINT, 17 | get () { 18 | return convertToInt(this.getDataValue('expirationTime')) 19 | }, 20 | field: 'expiration_time' 21 | }, 22 | token: { 23 | type: Sequelize.TEXT, 24 | field: 'token' 25 | }, 26 | userId: { 27 | type: Sequelize.INTEGER, 28 | field: 'user_id', 29 | references: { model: 'Users', key: 'id' }, 30 | onDelete: 'cascade' 31 | } 32 | }) 33 | }, 34 | down: (queryInterface, Sequelize) => { 35 | return queryInterface.dropTable('KubeletAccessTokens') 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/data/migrations/20190227154512-create-scheduler-access-token.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { convertToInt } = require('../../helpers/app-helper') 4 | 5 | module.exports = { 6 | up: (queryInterface, Sequelize) => { 7 | return queryInterface.createTable('SchedulerAccessTokens', { 8 | id: { 9 | type: Sequelize.INTEGER, 10 | primaryKey: true, 11 | autoIncrement: true, 12 | allowNull: false, 13 | field: 'id' 14 | }, 15 | expirationTime: { 16 | type: Sequelize.BIGINT, 17 | get () { 18 | return convertToInt(this.getDataValue('expirationTime')) 19 | }, 20 | field: 'expiration_time' 21 | }, 22 | token: { 23 | type: Sequelize.TEXT, 24 | field: 'token' 25 | }, 26 | userId: { 27 | type: Sequelize.INTEGER, 28 | field: 'user_id', 29 | references: { model: 'Users', key: 'id' }, 30 | onDelete: 'cascade' 31 | } 32 | }) 33 | }, 34 | down: (queryInterface, Sequelize) => { 35 | return queryInterface.dropTable('SchedulerAccessTokens') 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/data/migrations/20190305142715-add-security-status-fields.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('Fogs', 6 | 'security_status', Sequelize.TEXT 7 | ).then(() => { 8 | return queryInterface.addColumn('Fogs', 9 | 'security_violation_info', Sequelize.TEXT 10 | ) 11 | }) 12 | }, 13 | 14 | down: (queryInterface, Sequelize) => { 15 | return queryInterface.removeColumn('Fogs', 'security_status') 16 | .then(() => { 17 | return queryInterface.removeColumn('Fogs', 'security_violation_info') 18 | }) 19 | // restore constraints. Because Sequelize has problem with Sqlite constraints 20 | .then(() => { 21 | return queryInterface.addConstraint('Fogs', { 22 | fields: ['user_id'], 23 | type: 'foreign key', 24 | name: 'fogs_users_fkey_constraint', 25 | references: { 26 | table: 'Users', 27 | field: 'id' 28 | }, 29 | onDelete: 'cascade' 30 | }) 31 | }).then(() => { 32 | return queryInterface.addConstraint('Fogs', { 33 | fields: ['fog_type_id'], 34 | type: 'foreign key', 35 | name: 'fogs_types_fkey_constraint', 36 | references: { 37 | table: 'FogTypes', 38 | field: 'id' 39 | }, 40 | onDelete: 'set null' 41 | }) 42 | }) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/data/migrations/20190409055710-add-microservices-env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | up: (queryInterface, Sequelize) => { 4 | return queryInterface.createTable('MicroserviceEnvs', { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | autoIncrement: true, 9 | allowNull: false, 10 | field: 'id' 11 | }, 12 | key: { 13 | type: Sequelize.TEXT, 14 | field: 'key' 15 | }, 16 | value: { 17 | type: Sequelize.TEXT, 18 | field: 'value' 19 | }, 20 | microserviceUuid: { 21 | type: Sequelize.STRING(32), 22 | field: 'microservice_uuid', 23 | references: { model: 'Microservices', key: 'uuid' }, 24 | onDelete: 'cascade' 25 | } 26 | }) 27 | }, 28 | down: (queryInterface, Sequelize) => { 29 | return queryInterface.dropTable('MicroserviceEnvs') 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/data/migrations/20190410055710-add-microservices-arg.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | up: (queryInterface, Sequelize) => { 4 | return queryInterface.createTable('MicroserviceArgs', { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | autoIncrement: true, 9 | allowNull: false, 10 | field: 'id' 11 | }, 12 | cmd: { 13 | type: Sequelize.TEXT, 14 | field: 'cmd' 15 | }, 16 | microserviceUuid: { 17 | type: Sequelize.STRING(32), 18 | field: 'microservice_uuid', 19 | references: { model: 'Microservices', key: 'uuid' }, 20 | onDelete: 'cascade' 21 | } 22 | }) 23 | }, 24 | down: (queryInterface, Sequelize) => { 25 | return queryInterface.dropTable('MicroserviceArgs') 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/data/migrations/20190704043715-agent-external-ip.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('Fogs', 6 | 'ip_address_external', Sequelize.TEXT 7 | ) 8 | }, 9 | 10 | down: (queryInterface, Sequelize) => { 11 | return queryInterface.removeColumn('Fogs', 'ip_address_external') 12 | // restore constraints. Because Sequelize has problem with Sqlite constraints 13 | .then(() => { 14 | return queryInterface.addConstraint('Fogs', { 15 | feilds: ['user_id'], 16 | type: 'foreign key', 17 | name: 'fogs_users_fkey_constraint', 18 | references: { 19 | table: 'Users', 20 | field: 'id' 21 | }, 22 | onDelete: 'cascade' 23 | }) 24 | }).then(() => { 25 | return queryInterface.addConstraint('Fogs', { 26 | feilds: ['fog_type_id'], 27 | type: 'foreign key', 28 | name: 'fogs_types_fkey_constraint', 29 | references: { 30 | table: 'FogTypes', 31 | field: 'id' 32 | }, 33 | onDelete: 'set null' 34 | }) 35 | }) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/data/migrations/20190830071324-update catalog item images to be linked to microservice.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('CatalogItemImages', 'microservice_uuid', { 6 | type: Sequelize.STRING(32), 7 | field: 'microservice_uuid', 8 | references: { model: 'Microservices', key: 'uuid' }, 9 | onDelete: 'cascade' 10 | }) 11 | }, 12 | 13 | down: (queryInterface, Sequelize) => { 14 | return queryInterface.removeColumn('CatalogItemImages', 'microservice_uuid') 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/data/migrations/20190916030304-connector-health.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('Connectors', 'healthy', { 6 | type: Sequelize.BOOLEAN, 7 | field: 'healthy', 8 | defaultValue: true 9 | }) 10 | }, 11 | 12 | down: (queryInterface, Sequelize) => { 13 | return queryInterface.removeColumn('Connectors', 'healthy') 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/data/migrations/20190916030532-connector-port-deletion.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('ConnectorPorts', 'moved', { 6 | type: Sequelize.BOOLEAN, 7 | field: 'moved', 8 | defaultValue: false 9 | }) 10 | }, 11 | 12 | down: (queryInterface, Sequelize) => { 13 | return queryInterface.removeColumn('ConnectorPorts', 'moved') 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/data/migrations/20200123000302-system-fog-and-flow.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | /* 6 | Add altering commands here. 7 | Return a promise to correctly handle asynchronicity. 8 | 9 | Example: 10 | return queryInterface.createTable('users', { id: Sequelize.INTEGER }); 11 | */ 12 | return Promise.all([ 13 | queryInterface.addColumn('Fogs', 'is_system', { 14 | type: Sequelize.BOOLEAN, 15 | defaultValue: false, 16 | field: 'is_system' 17 | }), 18 | queryInterface.addColumn('Flows', 'is_system', { 19 | type: Sequelize.BOOLEAN, 20 | defaultValue: false, 21 | field: 'is_system' 22 | }) 23 | ]) 24 | }, 25 | 26 | down: (queryInterface, Sequelize) => { 27 | /* 28 | Add reverting commands here. 29 | Return a promise to correctly handle asynchronicity. 30 | 31 | Example: 32 | return queryInterface.dropTable('users'); 33 | */ 34 | return Promise.all([ 35 | queryInterface.removeColumn('Fogs', 'is_system'), 36 | queryInterface.removeColumn('Flows', 'is_system') 37 | ]) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/data/migrations/20200123205245-router-port-host-agent-config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return Promise.all([ 6 | queryInterface.addColumn('Fogs', 'router_id', { 7 | type: Sequelize.INTEGER, 8 | field: 'router_id' 9 | }) 10 | ]) 11 | }, 12 | 13 | down: (queryInterface, Sequelize) => { 14 | return Promise.all([ 15 | queryInterface.removeColumn('Fogs', 'router_id') 16 | ]) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/data/migrations/20200124040224-router-changed-flag.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | /* 6 | Add altering commands here. 7 | Return a promise to correctly handle asynchronicity. 8 | 9 | Example: 10 | return queryInterface.createTable('users', { id: Sequelize.INTEGER }); 11 | */ 12 | return queryInterface.addColumn('ChangeTrackings', 'router_changed', { 13 | type: Sequelize.BOOLEAN, 14 | defaultValue: false, 15 | field: 'router_changed' 16 | }) 17 | }, 18 | 19 | down: (queryInterface, Sequelize) => { 20 | /* 21 | Add reverting commands here. 22 | Return a promise to correctly handle asynchronicity. 23 | 24 | Example: 25 | return queryInterface.dropTable('users'); 26 | */ 27 | return queryInterface.removeColumn('ChangeTrackings', 'router_changed') 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/data/migrations/20200213033350-create-config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | up: (queryInterface, Sequelize) => { 4 | return queryInterface.createTable('Config', { 5 | id: { 6 | type: Sequelize.INTEGER, 7 | primaryKey: true, 8 | autoIncrement: true, 9 | allowNull: false, 10 | field: 'id' 11 | 12 | }, 13 | key: { 14 | type: Sequelize.TEXT, 15 | field: 'key', 16 | unique: true, 17 | allowNull: false 18 | }, 19 | value: { 20 | type: Sequelize.TEXT, 21 | field: 'value', 22 | allowNull: false 23 | }, 24 | createdAt: { 25 | type: Sequelize.DATE, 26 | allowNull: false, 27 | field: 'created_at' 28 | }, 29 | updatedAt: { 30 | type: Sequelize.DATE, 31 | allowNull: false, 32 | field: 'updated_at' 33 | }, 34 | updatedBy: { 35 | type: Sequelize.INTEGER, 36 | field: 'updated_by', 37 | references: { model: 'Users', key: 'id' }, 38 | onDelete: 'set null' 39 | } 40 | }).then(() => queryInterface.addIndex('Config', ['key'], { indicesType: 'UNIQUE' })) 41 | }, 42 | down: (queryInterface, Sequelize) => { 43 | return queryInterface.dropTable('Config') 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/data/migrations/20200220210224-change-tracking-timestamp.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: async (queryInterface, Sequelize) => { 5 | await queryInterface.addColumn('ChangeTrackings', 'last_updated', { 6 | type: Sequelize.STRING, 7 | defaultValue: false, 8 | field: 'last_updated' 9 | }) 10 | }, 11 | 12 | down: async (queryInterface, Sequelize) => { 13 | await queryInterface.removeColumn('ChangeTrackings', 'last_updated') 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/data/migrations/20200316032240-add-fog-host.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | /* 6 | Add altering commands here. 7 | Return a promise to correctly handle asynchronicity. 8 | 9 | Example: 10 | return queryInterface.createTable('users', { id: Sequelize.INTEGER }); 11 | */ 12 | return queryInterface.addColumn('Fogs', 'host', { 13 | type: Sequelize.TEXT 14 | }) 15 | }, 16 | 17 | down: (queryInterface, Sequelize) => { 18 | /* 19 | Add reverting commands here. 20 | Return a promise to correctly handle asynchronicity. 21 | 22 | Example: 23 | return queryInterface.dropTable('users'); 24 | */ 25 | return queryInterface.removeColumn('Fogs', 'host') 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/data/migrations/20200323050813-fog-update-messagespeed.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { convertToInt } = require('../../helpers/app-helper') 4 | 5 | module.exports = { 6 | up: async (queryInterface, Sequelize) => { 7 | await queryInterface.changeColumn('Fogs', 'message_speed', { 8 | type: Sequelize.FLOAT, 9 | field: 'message_speed' 10 | }) 11 | }, 12 | 13 | down: async (queryInterface, Sequelize) => { 14 | await queryInterface.changeColumn('Fogs', 'message_speed', { 15 | type: Sequelize.BIGINT, 16 | get () { 17 | return convertToInt(this.getDataValue('messageSpeed')) 18 | }, 19 | field: 'message_speed' 20 | }) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/data/migrations/20200423201804-add-volume-mapping-type.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('VolumeMappings', 'type', { 6 | type: Sequelize.TEXT 7 | }) 8 | }, 9 | 10 | down: (queryInterface, Sequelize) => { 11 | return queryInterface.removeColumn('VolumeMappings', 'type') 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/data/migrations/20200506004924-add-route-name.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('Routings', 'name', { 6 | type: Sequelize.TEXT, 7 | allowNull: false, 8 | defaultValue: 'route' 9 | }).then(() => queryInterface.addIndex('Routings', ['name'], { 10 | indicesType: 'UNIQUE' 11 | })) 12 | }, 13 | 14 | down: (queryInterface, Sequelize) => { 15 | return queryInterface.removeColumn('Routings', 'name') 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/data/migrations/20200512044934-rename-flow.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.renameColumn('Microservices', 'flow_id', 'application_id') 6 | }, 7 | 8 | down: (queryInterface, Sequelize) => { 9 | return queryInterface.renameColumn('Microservices', 'application_id', 'flow_id') 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/data/migrations/20200512214530-add-application-to-routing.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('Routings', 'application_id', 6 | { 7 | type: Sequelize.INTEGER, 8 | field: 'application_id', 9 | references: { model: 'Flows', key: 'id' }, 10 | onDelete: 'cascade' 11 | } 12 | ) 13 | }, 14 | 15 | down: (queryInterface, Sequelize) => { 16 | /* 17 | Add reverting commands here. 18 | Return a promise to correctly handle asynchronicity. 19 | 20 | Example: 21 | return queryInterface.dropTable('users'); 22 | */ 23 | return queryInterface.removeColumn('Routings', 'application_id') 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/data/migrations/20200901053246-add-percentage-msvc-status.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('MicroserviceStatuses', 'percentage', { 6 | type: Sequelize.FLOAT, 7 | defaultValue: 0.00 8 | }) 9 | }, 10 | 11 | down: (queryInterface, Sequelize) => { 12 | return queryInterface.removeColumn('MicroserviceStatuses', 'percentage') 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/data/migrations/20201001230303-add-tags-fogs.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: async (queryInterface, Sequelize) => { 5 | await queryInterface.createTable('Tags', { 6 | id: { 7 | type: Sequelize.INTEGER, 8 | primaryKey: true, 9 | autoIncrement: true, 10 | allowNull: false, 11 | field: 'id' 12 | }, 13 | value: { 14 | type: Sequelize.TEXT, 15 | field: 'value', 16 | unique: true, 17 | allowNull: false 18 | } 19 | }) 20 | await queryInterface.createTable('IofogTags', { 21 | id: { 22 | type: Sequelize.INTEGER, 23 | primaryKey: true, 24 | autoIncrement: true, 25 | allowNull: false, 26 | field: 'id' 27 | }, 28 | TagId: { 29 | type: Sequelize.INTEGER, 30 | field: 'tag_id', 31 | references: { model: 'Tags', key: 'id' }, 32 | onDelete: 'cascade' 33 | }, 34 | FogUuid: { 35 | type: Sequelize.TEXT, 36 | field: 'fog_uuid', 37 | references: { model: 'Fogs', key: 'uuid' }, 38 | onDelete: 'cascade' 39 | } 40 | }) 41 | }, 42 | down: async (queryInterface, Sequelize) => { 43 | await queryInterface.dropTable('Tags') 44 | await queryInterface.dropTable('IofogTags') 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/data/migrations/20201105003849-create-edge-resources-agent-flag.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: async (queryInterface, Sequelize) => { 5 | await queryInterface.addColumn('ChangeTrackings', 'linked_edge_resources', { 6 | type: Sequelize.BOOLEAN, 7 | defaultValue: false, 8 | field: 'linked_edge_resources' 9 | }) 10 | }, 11 | 12 | down: async (queryInterface, Sequelize) => { 13 | await queryInterface.removeColumn('ChangeTrackings', 'linked_edge_resources') 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/data/migrations/20201203011708-microservice-status-error-msg.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('MicroserviceStatuses', 'error_message', { 6 | type: Sequelize.TEXT, 7 | defaultValue: '' 8 | }) 9 | }, 10 | 11 | down: (queryInterface, Sequelize) => { 12 | return queryInterface.removeColumn('MicroserviceStatuses', 'error_message') 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/data/migrations/20210104191500-add_custom_to_edge_resources.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('EdgeResources', 'custom', 6 | { 7 | type: Sequelize.TEXT 8 | } 9 | ) 10 | }, 11 | 12 | down: (queryInterface, Sequelize) => { 13 | /* 14 | Add reverting commands here. 15 | Return a promise to correctly handle asynchronicity. 16 | 17 | Example: 18 | return queryInterface.dropTable('users'); 19 | */ 20 | return queryInterface.removeColumn('EdgeResources', 'custom') 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/data/migrations/20210118012712-add_is_udp_to_port.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: async (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('MicroservicePorts', 'is_udp', 6 | { 7 | type: Sequelize.BOOLEAN 8 | } 9 | ) 10 | }, 11 | 12 | down: async (queryInterface, Sequelize) => { 13 | /** 14 | * Add reverting commands here. 15 | * 16 | * Example: 17 | * await queryInterface.dropTable('users'); 18 | */ 19 | return queryInterface.removeColumn('MicroservicePorts', 'is_udp') 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/data/migrations/20211019214923-add-schemes-to-public-ports.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: async (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('MicroservicePublicPorts', 'schemes', 6 | { 7 | type: Sequelize.TEXT, 8 | defaultValue: JSON.stringify(['https']) 9 | } 10 | ) 11 | }, 12 | 13 | down: async (queryInterface, Sequelize) => { 14 | /** 15 | * Add reverting commands here. 16 | * 17 | * Example: 18 | * await queryInterface.dropTable('users'); 19 | */ 20 | return queryInterface.removeColumn('MicroservicePublicPorts', 'schemes') 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/data/migrations/20211020014715-add-index-to-public-ports.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.addConstraint('MicroservicePublicPorts', 6 | { 7 | fields: ['public_port', 'host_id'], 8 | type: 'unique', 9 | name: 'port_host_unique_constraint' 10 | } 11 | ) 12 | }, 13 | 14 | down: (queryInterface, Sequelize) => { 15 | return queryInterface.removeConstraint('MicroservicePublicPorts', 'port_host_unique_constraint') 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/data/migrations/20211022010318-add-unique-constraint-msvc.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | /* 6 | Add altering commands here. 7 | Return a promise to correctly handle asynchronicity. 8 | 9 | Example: 10 | return queryInterface.createTable('users', { id: Sequelize.INTEGER }); 11 | */ 12 | return queryInterface.addConstraint('Microservices', 13 | { 14 | fields: ['application_id', 'name'], 15 | type: 'unique', 16 | name: 'app_name_unique_constraint' 17 | }) 18 | }, 19 | 20 | down: (queryInterface, Sequelize) => { 21 | /* 22 | Add reverting commands here. 23 | Return a promise to correctly handle asynchronicity. 24 | 25 | Example: 26 | return queryInterface.dropTable('users'); 27 | */ 28 | return queryInterface.removeConstraint('Microservices', 'app_name_unique_constraint') 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/data/migrations/20211022013326-add-unique-constraint-route.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | /* 6 | Add altering commands here. 7 | Return a promise to correctly handle asynchronicity. 8 | 9 | Example: 10 | return queryInterface.createTable('users', { id: Sequelize.INTEGER }); 11 | */ 12 | return queryInterface.addConstraint('Routings', 13 | { 14 | fields: ['application_id', 'name'], 15 | type: 'unique', 16 | name: 'routings_app_name_unique_constraint' 17 | }) 18 | }, 19 | 20 | down: (queryInterface, Sequelize) => { 21 | /* 22 | Add reverting commands here. 23 | Return a promise to correctly handle asynchronicity. 24 | 25 | Example: 26 | return queryInterface.dropTable('users'); 27 | */ 28 | return queryInterface.removeConstraint('Routings', 'routings_app_name_unique_constraint') 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/data/migrations/20220405053419-add-time-zone-agent-config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | /* 6 | Add altering commands here. 7 | Return a promise to correctly handle asynchronicity. 8 | 9 | Example: 10 | return queryInterface.createTable('users', { id: Sequelize.INTEGER }); 11 | */ 12 | return queryInterface.addColumn('Fogs', 'time_zone', { 13 | type: Sequelize.TEXT 14 | }) 15 | }, 16 | 17 | down: (queryInterface, Sequelize) => { 18 | /* 19 | Add reverting commands here. 20 | Return a promise to correctly handle asynchronicity. 21 | 22 | Example: 23 | return queryInterface.dropTable('users'); 24 | */ 25 | return queryInterface.removeColumn('Fogs', 'time_zone') 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/data/migrations/20220409021708-drop-table-tracking.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | /* 6 | Add altering commands here. 7 | Return a promise to correctly handle asynchronicity. 8 | 9 | Example: 10 | return queryInterface.createTable('users', { id: Sequelize.INTEGER }); 11 | */ 12 | return queryInterface.dropTable('TrackingEvent') 13 | }, 14 | 15 | down: (queryInterface, Sequelize) => { 16 | /* 17 | Add reverting commands here. 18 | Return a promise to correctly handle asynchronicity. 19 | 20 | Example: 21 | return queryInterface.dropTable('users'); 22 | */ 23 | return queryInterface.createTable('TrackingEvent') 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/data/migrations/20221021102712-add_is_proxy_to_port.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: async (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('MicroservicePorts', 'is_proxy', 6 | { 7 | type: Sequelize.BOOLEAN 8 | } 9 | ) 10 | }, 11 | 12 | down: async (queryInterface, Sequelize) => { 13 | /** 14 | * Add reverting commands here. 15 | * 16 | * Example: 17 | * await queryInterface.dropTable('users'); 18 | */ 19 | return queryInterface.removeColumn('MicroservicePorts', 'is_proxy') 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/data/migrations/20221021152712-add_admin_port_to_proxy_ports.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: async (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('MicroserviceProxyPorts', 'admin_port', 6 | { 7 | type: Sequelize.BOOLEAN 8 | } 9 | ) 10 | }, 11 | 12 | down: async (queryInterface, Sequelize) => { 13 | /** 14 | * Add reverting commands here. 15 | * 16 | * Example: 17 | * await queryInterface.dropTable('users'); 18 | */ 19 | return queryInterface.removeColumn('MicroserviceProxyPorts', 'admin_port') 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/data/migrations/20221031162712-add_tokens_to_proxy_ports.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: async (queryInterface, Sequelize) => { 5 | return queryInterface.addColumn('MicroserviceProxyPorts', 'proxy_token', 6 | { 7 | type: Sequelize.TEXT 8 | } 9 | ) 10 | }, 11 | 12 | down: async (queryInterface, Sequelize) => { 13 | /** 14 | * Add reverting commands here. 15 | * 16 | * Example: 17 | * await queryInterface.dropTable('users'); 18 | */ 19 | return queryInterface.removeColumn('MicroserviceProxyPorts', 'proxy_token') 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/data/migrations/20221110151246-add_port_uuid_to_proxy_ports copy.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: async (queryInterface, Sequelize) => { 5 | await queryInterface.addColumn('MicroserviceProxyPorts', 'port_uuid', 6 | { 7 | type: Sequelize.TEXT 8 | } 9 | ) 10 | await queryInterface.addColumn('MicroserviceProxyPorts', 'server_token', 11 | { 12 | type: Sequelize.TEXT 13 | } 14 | ) 15 | }, 16 | 17 | down: async (queryInterface, Sequelize) => { 18 | /** 19 | * Add reverting commands here. 20 | * 21 | * Example: 22 | * await queryInterface.dropTable('users'); 23 | */ 24 | await queryInterface.removeColumn('MicroserviceProxyPorts', 'port_uuid') 25 | await queryInterface.removeColumn('MicroserviceProxyPorts', 'server_token') 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/data/models/accesstoken.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { convertToInt } = require('../../helpers/app-helper') 4 | 5 | module.exports = (sequelize, DataTypes) => { 6 | const AccessToken = sequelize.define('AccessToken', { 7 | id: { 8 | type: DataTypes.INTEGER, 9 | primaryKey: true, 10 | autoIncrement: true, 11 | allowNull: false, 12 | field: 'id' 13 | }, 14 | token: { 15 | type: DataTypes.STRING, 16 | field: 'token' 17 | }, 18 | expirationTime: { 19 | type: DataTypes.BIGINT, 20 | get () { 21 | return convertToInt(this.getDataValue('expirationTime')) 22 | }, 23 | field: 'expiration_time' 24 | } 25 | }, { 26 | tableName: 'AccessTokens', 27 | timestamps: false, 28 | underscored: true 29 | }) 30 | AccessToken.associate = function (models) { 31 | AccessToken.belongsTo(models.User, { 32 | foreignKey: { 33 | name: 'userId', 34 | field: 'user_id' 35 | }, 36 | as: 'user' 37 | }) 38 | } 39 | return AccessToken 40 | } 41 | -------------------------------------------------------------------------------- /src/data/models/agentEdgeResource.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const AgentEdgeResources = sequelize.define('AgentEdgeResources', {}, { 4 | tableName: 'AgentEdgeResources', 5 | timestamps: false, 6 | underscored: true 7 | }) 8 | return AgentEdgeResources 9 | } 10 | -------------------------------------------------------------------------------- /src/data/models/application.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const Application = sequelize.define('Application', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false, 9 | field: 'id' 10 | 11 | }, 12 | name: { 13 | type: DataTypes.TEXT, 14 | field: 'name', 15 | defaultValue: 'new-application', 16 | unique: true 17 | }, 18 | description: { 19 | type: DataTypes.TEXT, 20 | field: 'description', 21 | defaultValue: '' 22 | }, 23 | isActivated: { 24 | type: DataTypes.BOOLEAN, 25 | field: 'is_activated', 26 | defaultValue: false 27 | }, 28 | isSystem: { 29 | type: DataTypes.BOOLEAN, 30 | field: 'is_system', 31 | defaultValue: false 32 | } 33 | }, { 34 | tableName: 'Flows', 35 | timestamps: true, 36 | underscored: true 37 | }) 38 | Application.associate = function (models) { 39 | Application.belongsTo(models.User, { 40 | foreignKey: { 41 | name: 'userId', 42 | field: 'user_id' 43 | }, 44 | as: 'user', 45 | onDelete: 'cascade' 46 | }) 47 | 48 | Application.hasMany(models.Microservice, { 49 | foreignKey: { 50 | name: 'applicationId', 51 | field: 'application_id' 52 | }, 53 | as: 'microservices' 54 | }) 55 | } 56 | return Application 57 | } 58 | -------------------------------------------------------------------------------- /src/data/models/applicationTemplateVariable.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const ApplicationTemplateVariable = sequelize.define('ApplicationTemplateVariable', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false, 9 | field: 'id' 10 | }, 11 | key: { 12 | type: DataTypes.TEXT, 13 | field: 'key' 14 | }, 15 | description: { 16 | type: DataTypes.TEXT, 17 | field: 'description', 18 | defaultValue: '' 19 | }, 20 | defaultValue: { 21 | type: DataTypes.TEXT, 22 | field: 'default_value' 23 | } 24 | }, { 25 | tableName: 'ApplicationTemplateVariables', 26 | timestamps: true, 27 | underscored: true 28 | }) 29 | ApplicationTemplateVariable.associate = function (models) { 30 | ApplicationTemplateVariable.belongsTo(models.ApplicationTemplate, { 31 | foreignKey: { 32 | name: 'applicationTemplateId', 33 | field: 'application_template_id' 34 | }, 35 | as: 'applicationTemplate', 36 | onDelete: 'cascade' 37 | }) 38 | } 39 | return ApplicationTemplateVariable 40 | } 41 | -------------------------------------------------------------------------------- /src/data/models/catalogitemimage.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const CatalogItemImage = sequelize.define('CatalogItemImage', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false, 9 | field: 'id' 10 | }, 11 | containerImage: { 12 | type: DataTypes.TEXT, 13 | field: 'container_image' 14 | } 15 | }, { 16 | tableName: 'CatalogItemImages', 17 | timestamps: false, 18 | underscored: true 19 | }) 20 | CatalogItemImage.associate = function (models) { 21 | CatalogItemImage.belongsTo(models.CatalogItem, { 22 | foreignKey: { 23 | name: 'catalogItemId', 24 | field: 'catalog_item_id' 25 | }, 26 | as: 'catalogItem', 27 | onDelete: 'cascade' 28 | }) 29 | 30 | CatalogItemImage.belongsTo(models.Microservice, { 31 | foreignKey: { 32 | name: 'microserviceUuid', 33 | field: 'microservice_uuid' 34 | }, 35 | as: 'microservice', 36 | onDelete: 'cascade' 37 | }) 38 | 39 | CatalogItemImage.belongsTo(models.FogType, { 40 | foreignKey: { 41 | name: 'fogTypeId', 42 | field: 'fog_type_id' 43 | }, 44 | as: 'fogType', 45 | onDelete: 'cascade' 46 | }) 47 | } 48 | return CatalogItemImage 49 | } 50 | -------------------------------------------------------------------------------- /src/data/models/catalogiteminputtype.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const CatalogItemInputType = sequelize.define('CatalogItemInputType', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false, 9 | field: 'id' 10 | }, 11 | infoType: { 12 | type: DataTypes.TEXT, 13 | field: 'info_type' 14 | }, 15 | infoFormat: { 16 | type: DataTypes.TEXT, 17 | field: 'info_format' 18 | } 19 | }, { 20 | tableName: 'CatalogItemInputTypes', 21 | timestamps: false, 22 | underscored: true 23 | }) 24 | CatalogItemInputType.associate = function (models) { 25 | CatalogItemInputType.belongsTo(models.CatalogItem, { 26 | foreignKey: { 27 | name: 'catalogItemId', 28 | field: 'catalog_item_id' 29 | }, 30 | as: 'catalogItem' 31 | }) 32 | } 33 | return CatalogItemInputType 34 | } 35 | -------------------------------------------------------------------------------- /src/data/models/catalogitemoutputtype.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const CatalogItemOutputType = sequelize.define('CatalogItemOutputType', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false, 9 | field: 'id' 10 | }, 11 | infoType: { 12 | type: DataTypes.TEXT, 13 | field: 'info_type' 14 | }, 15 | infoFormat: { 16 | type: DataTypes.TEXT, 17 | field: 'info_format' 18 | } 19 | }, { 20 | tableName: 'CatalogItemOutputTypes', 21 | timestamps: false, 22 | underscored: true 23 | }) 24 | CatalogItemOutputType.associate = function (models) { 25 | CatalogItemOutputType.belongsTo(models.CatalogItem, { 26 | foreignKey: { 27 | name: 'catalogItemId', 28 | field: 'catalog_item_id' 29 | }, 30 | as: 'catalogItem' 31 | }) 32 | } 33 | return CatalogItemOutputType 34 | } 35 | -------------------------------------------------------------------------------- /src/data/models/config.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const Config = sequelize.define('Config', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false, 9 | field: 'id' 10 | }, 11 | key: { 12 | type: DataTypes.TEXT, 13 | allowNull: false, 14 | unique: true, 15 | field: 'key' 16 | }, 17 | value: { 18 | type: DataTypes.TEXT, 19 | allowNull: false, 20 | field: 'value' 21 | } 22 | }, { 23 | tableName: 'Config', 24 | timestamps: true, 25 | underscored: true, 26 | indexes: [ 27 | { 28 | unique: true, 29 | fields: ['key'] 30 | } 31 | ] 32 | }) 33 | Config.associate = function (models) { 34 | 35 | } 36 | return Config 37 | } 38 | -------------------------------------------------------------------------------- /src/data/models/edgeResource.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const EdgeResource = sequelize.define('EdgeResource', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false 9 | }, 10 | name: { 11 | type: DataTypes.TEXT, 12 | allowNull: false 13 | }, 14 | version: DataTypes.TEXT, 15 | description: DataTypes.TEXT, 16 | displayName: DataTypes.TEXT, 17 | displayColor: DataTypes.TEXT, 18 | displayIcon: DataTypes.TEXT, 19 | interfaceProtocol: DataTypes.TEXT, 20 | interfaceId: { type: DataTypes.INTEGER, field: 'interface_id' }, // Reference external document depending on the value of interfaceProtocol 21 | custom: DataTypes.TEXT 22 | }, { 23 | tableName: 'EdgeResources', 24 | timestamps: false, 25 | underscored: true 26 | }) 27 | EdgeResource.associate = function (models) { 28 | EdgeResource.belongsToMany(models.Fog, { through: 'AgentEdgeResources', as: 'agents' }) 29 | EdgeResource.belongsToMany(models.Tags, { as: 'orchestrationTags', through: 'EdgeResourceOrchestrationTags' }) 30 | 31 | EdgeResource.belongsTo(models.User, { 32 | foreignKey: { 33 | name: 'userId', 34 | field: 'user_id' 35 | }, 36 | as: 'user', 37 | defaultValue: 0, 38 | onDelete: 'cascade' 39 | }) 40 | } 41 | return EdgeResource 42 | } 43 | -------------------------------------------------------------------------------- /src/data/models/edgeResourceOrchestrationTags.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const EdgeResourceOrchestrationTags = sequelize.define('EdgeResourceOrchestrationTags', {}, { 4 | tableName: 'EdgeResourceOrchestrationTags', 5 | timestamps: false, 6 | underscored: true 7 | }) 8 | return EdgeResourceOrchestrationTags 9 | } 10 | -------------------------------------------------------------------------------- /src/data/models/emailactivationcode.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { convertToInt } = require('../../helpers/app-helper') 4 | 5 | module.exports = (sequelize, DataTypes) => { 6 | const EmailActivationCode = sequelize.define('EmailActivationCode', { 7 | id: { 8 | type: DataTypes.INTEGER, 9 | primaryKey: true, 10 | autoIncrement: true, 11 | allowNull: false, 12 | field: 'id' 13 | }, 14 | activationCode: { 15 | type: DataTypes.TEXT, 16 | field: 'activation_code' 17 | }, 18 | expirationTime: { 19 | type: DataTypes.BIGINT, 20 | get () { 21 | return convertToInt(this.getDataValue('expirationTime')) 22 | }, 23 | field: 'expiration_time' 24 | } 25 | }, { 26 | tableName: 'EmailActivationCodes', 27 | timestamps: false, 28 | underscored: true 29 | }) 30 | EmailActivationCode.associate = function (models) { 31 | EmailActivationCode.belongsTo(models.User, { 32 | foreignKey: { 33 | name: 'userId', 34 | field: 'user_id' 35 | }, 36 | as: 'user', 37 | onDelete: 'cascade' 38 | }) 39 | } 40 | return EmailActivationCode 41 | } 42 | -------------------------------------------------------------------------------- /src/data/models/fogaccesstoken.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { convertToInt } = require('../../helpers/app-helper') 4 | 5 | module.exports = (sequelize, DataTypes) => { 6 | const FogAccessToken = sequelize.define('FogAccessToken', { 7 | id: { 8 | type: DataTypes.INTEGER, 9 | primaryKey: true, 10 | autoIncrement: true, 11 | allowNull: false, 12 | field: 'id' 13 | }, 14 | expirationTime: { 15 | type: DataTypes.BIGINT, 16 | get () { 17 | return convertToInt(this.getDataValue('expirationTime')) 18 | }, 19 | field: 'expiration_time' 20 | }, 21 | token: { 22 | type: DataTypes.TEXT, 23 | field: 'token' 24 | } 25 | }, { 26 | tableName: 'FogAccessTokens', 27 | timestamps: false, 28 | underscored: true 29 | }) 30 | FogAccessToken.associate = function (models) { 31 | FogAccessToken.belongsTo(models.User, { 32 | foreignKey: { 33 | name: 'userId', 34 | field: 'user_id' 35 | }, 36 | as: 'user', 37 | onDelete: 'cascade' 38 | }) 39 | 40 | FogAccessToken.belongsTo(models.Fog, { 41 | foreignKey: { 42 | name: 'iofogUuid', 43 | field: 'iofog_uuid' 44 | }, 45 | as: 'iofog', 46 | onDelete: 'cascade' 47 | }) 48 | } 49 | return FogAccessToken 50 | } 51 | -------------------------------------------------------------------------------- /src/data/models/fogprovisionkey.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { convertToInt } = require('../../helpers/app-helper') 4 | 5 | module.exports = (sequelize, DataTypes) => { 6 | const FogProvisionKey = sequelize.define('FogProvisionKey', { 7 | id: { 8 | type: DataTypes.INTEGER, 9 | primaryKey: true, 10 | autoIncrement: true, 11 | allowNull: false, 12 | field: 'id' 13 | }, 14 | provisionKey: { 15 | /* eslint-disable new-cap */ 16 | type: DataTypes.STRING(100), 17 | field: 'provisioning_string' 18 | }, 19 | expirationTime: { 20 | type: DataTypes.BIGINT, 21 | get () { 22 | return convertToInt(this.getDataValue('expirationTime')) 23 | }, 24 | field: 'expiration_time' 25 | } 26 | }, { 27 | tableName: 'FogProvisionKeys', 28 | timestamps: false, 29 | underscored: true 30 | }) 31 | FogProvisionKey.associate = function (models) { 32 | FogProvisionKey.belongsTo(models.Fog, { 33 | foreignKey: { 34 | name: 'iofogUuid', 35 | field: 'iofog_uuid' 36 | }, 37 | as: 'iofog', 38 | onDelete: 'cascade' 39 | }) 40 | } 41 | return FogProvisionKey 42 | } 43 | -------------------------------------------------------------------------------- /src/data/models/fogtype.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const FogType = sequelize.define('FogType', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false, 9 | field: 'id' 10 | }, 11 | name: { 12 | type: DataTypes.TEXT, 13 | field: 'name' 14 | }, 15 | image: { 16 | type: DataTypes.TEXT, 17 | field: 'image' 18 | }, 19 | description: { 20 | type: DataTypes.TEXT, 21 | field: 'description' 22 | } 23 | }, { 24 | tableName: 'FogTypes', 25 | timestamps: false, 26 | underscored: true 27 | }) 28 | FogType.associate = function (models) { 29 | FogType.belongsTo(models.CatalogItem, { 30 | foreignKey: { 31 | name: 'networkCatalogItemId', 32 | field: 'network_catalog_item_id' 33 | }, 34 | as: 'networkCatalogItem' 35 | }) 36 | 37 | FogType.belongsTo(models.CatalogItem, { 38 | foreignKey: { 39 | name: 'halCatalogItemId', 40 | field: 'hal_catalog_item_id' 41 | }, 42 | as: 'halCatalogItem' 43 | }) 44 | 45 | FogType.belongsTo(models.CatalogItem, { 46 | foreignKey: { 47 | name: 'bluetoothCatalogItemId', 48 | field: 'bluetooth_catalog_item_id' 49 | }, 50 | as: 'bluetoothCatalogItem' 51 | }) 52 | } 53 | return FogType 54 | } 55 | -------------------------------------------------------------------------------- /src/data/models/fogversioncommand.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const FogVersionCommand = sequelize.define('FogVersionCommand', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | field: 'id' 9 | }, 10 | versionCommand: { 11 | /* eslint-disable new-cap */ 12 | type: DataTypes.STRING(100), 13 | field: 'version_command' 14 | } 15 | }, { 16 | tableName: 'FogVersionCommands', 17 | timestamps: false, 18 | underscored: true 19 | }) 20 | FogVersionCommand.associate = function (models) { 21 | FogVersionCommand.belongsTo(models.Fog, { 22 | foreignKey: { 23 | name: 'iofogUuid', 24 | field: 'iofog_uuid' 25 | }, 26 | as: 'iofog', 27 | onDelete: 'cascade' 28 | }) 29 | } 30 | return FogVersionCommand 31 | } 32 | -------------------------------------------------------------------------------- /src/data/models/httpBasedResourceInterface.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const HTTPBasedResourceInterface = sequelize.define('HTTPBasedResourceInterface', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false 9 | } 10 | }, { 11 | tableName: 'HTTPBasedResourceInterfaces', 12 | timestamps: false, 13 | underscored: true 14 | }) 15 | HTTPBasedResourceInterface.associate = function (models) { 16 | HTTPBasedResourceInterface.hasMany(models.HTTPBasedResourceInterfaceEndpoint, { as: 'endpoints', onDelete: 'cascade', foreignKey: { name: 'interfaceId', field: 'interface_id' } }) 17 | HTTPBasedResourceInterface.belongsTo(models.EdgeResource, { foreignKey: { name: 'edgeResourceId', field: 'edge_resource_id' } }) 18 | } 19 | return HTTPBasedResourceInterface 20 | } 21 | -------------------------------------------------------------------------------- /src/data/models/httpResourceInterfaceEndpoint.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const HTTPBasedResourceInterfaceEndpoint = sequelize.define('HTTPBasedResourceInterfaceEndpoint', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false 9 | }, 10 | name: DataTypes.TEXT, 11 | description: DataTypes.TEXT, 12 | method: DataTypes.TEXT, 13 | url: DataTypes.TEXT, 14 | requestType: DataTypes.TEXT, 15 | responseType: DataTypes.TEXT, 16 | requestPayloadExample: DataTypes.TEXT, 17 | responsePayloadExample: DataTypes.TEXT 18 | }, { 19 | tableName: 'HTTPBasedResourceInterfaceEndpoints', 20 | timestamps: false, 21 | underscored: true 22 | }) 23 | HTTPBasedResourceInterfaceEndpoint.associate = function (models) { 24 | HTTPBasedResourceInterfaceEndpoint.belongsTo(models.HTTPBasedResourceInterface, { foreignKey: { name: 'interfaceId', field: 'interface_id' } }) 25 | } 26 | return HTTPBasedResourceInterfaceEndpoint 27 | } 28 | -------------------------------------------------------------------------------- /src/data/models/hwinfo.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const HWInfo = sequelize.define('HWInfo', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false, 9 | field: 'id' 10 | }, 11 | info: { 12 | type: DataTypes.TEXT, 13 | defaultValue: ' ', 14 | field: 'info' 15 | } 16 | }, { 17 | // add the timestamp attributes (updatedAt, createdAt) 18 | tableName: 'HWInfos', 19 | timestamps: true, 20 | underscored: true 21 | }) 22 | HWInfo.associate = function (models) { 23 | HWInfo.belongsTo(models.Fog, { 24 | foreignKey: { 25 | name: 'iofogUuid', 26 | field: 'iofog_uuid' 27 | }, 28 | as: 'iofog', 29 | onDelete: 'cascade' 30 | }) 31 | } 32 | return HWInfo 33 | } 34 | -------------------------------------------------------------------------------- /src/data/models/iofogTags.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const IofogTags = sequelize.define('IofogTags', {}, { 4 | tableName: 'IofogTags', 5 | timestamps: false, 6 | underscored: true 7 | }) 8 | return IofogTags 9 | } 10 | -------------------------------------------------------------------------------- /src/data/models/kubeletaccesstoken.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { convertToInt } = require('../../helpers/app-helper') 4 | 5 | module.exports = (sequelize, DataTypes) => { 6 | const KubeletAccessToken = sequelize.define('KubeletAccessToken', { 7 | id: { 8 | type: DataTypes.INTEGER, 9 | primaryKey: true, 10 | autoIncrement: true, 11 | allowNull: false, 12 | field: 'id' 13 | }, 14 | expirationTime: { 15 | type: DataTypes.BIGINT, 16 | get () { 17 | return convertToInt(this.getDataValue('expirationTime')) 18 | }, 19 | field: 'expiration_time' 20 | }, 21 | token: { 22 | type: DataTypes.TEXT, 23 | field: 'token' 24 | } 25 | }, { 26 | tableName: 'KubeletAccessTokens', 27 | timestamps: false, 28 | underscored: true 29 | }) 30 | KubeletAccessToken.associate = function (models) { 31 | KubeletAccessToken.belongsTo(models.User, { 32 | foreignKey: { 33 | name: 'userId', 34 | field: 'user_id' 35 | }, 36 | as: 'user', 37 | onDelete: 'cascade' 38 | }) 39 | } 40 | return KubeletAccessToken 41 | } 42 | -------------------------------------------------------------------------------- /src/data/models/microservicearg.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const MicroserviceArg = sequelize.define('MicroserviceArg', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false, 9 | field: 'id' 10 | }, 11 | cmd: { 12 | type: DataTypes.TEXT, 13 | field: 'cmd' 14 | } 15 | }, { 16 | tableName: 'MicroserviceArgs', 17 | timestamps: false, 18 | underscored: true 19 | }) 20 | MicroserviceArg.associate = function (models) { 21 | MicroserviceArg.belongsTo(models.Microservice, { 22 | foreignKey: { 23 | name: 'microserviceUuid', 24 | field: 'microservice_uuid' 25 | }, 26 | as: 'microservice', 27 | onDelete: 'cascade' 28 | }) 29 | } 30 | return MicroserviceArg 31 | } 32 | -------------------------------------------------------------------------------- /src/data/models/microserviceenv.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const MicroserviceEnv = sequelize.define('MicroserviceEnv', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false, 9 | field: 'id' 10 | }, 11 | key: { 12 | type: DataTypes.TEXT, 13 | field: 'key' 14 | }, 15 | value: { 16 | type: DataTypes.TEXT, 17 | field: 'value' 18 | } 19 | }, { 20 | tableName: 'MicroserviceEnvs', 21 | timestamps: false, 22 | underscored: true 23 | }) 24 | MicroserviceEnv.associate = function (models) { 25 | MicroserviceEnv.belongsTo(models.Microservice, { 26 | foreignKey: { 27 | name: 'microserviceUuid', 28 | field: 'microservice_uuid' 29 | }, 30 | as: 'microservice', 31 | onDelete: 'cascade' 32 | }) 33 | } 34 | return MicroserviceEnv 35 | } 36 | -------------------------------------------------------------------------------- /src/data/models/registry.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const Registry = sequelize.define('Registry', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false, 9 | field: 'id' 10 | }, 11 | url: { 12 | type: DataTypes.TEXT, 13 | field: 'url' 14 | }, 15 | isPublic: { 16 | type: DataTypes.BOOLEAN, 17 | field: 'is_public' 18 | }, 19 | isSecure: { 20 | type: DataTypes.BOOLEAN, 21 | field: 'secure' 22 | }, 23 | certificate: { 24 | type: DataTypes.TEXT, 25 | field: 'certificate' 26 | }, 27 | requiresCert: { 28 | type: DataTypes.BOOLEAN, 29 | field: 'requires_cert' 30 | }, 31 | username: { 32 | type: DataTypes.TEXT, 33 | field: 'user_name' 34 | }, 35 | password: { 36 | type: DataTypes.TEXT, 37 | field: 'password' 38 | }, 39 | userEmail: { 40 | type: DataTypes.TEXT, 41 | field: 'user_email' 42 | } 43 | }, { 44 | tableName: 'Registries', 45 | timestamps: false, 46 | underscored: true 47 | }) 48 | Registry.associate = function (models) { 49 | Registry.belongsTo(models.User, { 50 | foreignKey: { 51 | name: 'userId', 52 | field: 'user_id' 53 | }, 54 | as: 'user' 55 | }) 56 | } 57 | return Registry 58 | } 59 | -------------------------------------------------------------------------------- /src/data/models/router-connection.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = (sequelize, DataTypes) => { 4 | const RouterConnection = sequelize.define('RouterConnection', { 5 | id: { 6 | type: DataTypes.INTEGER, 7 | primaryKey: true, 8 | autoIncrement: true, 9 | allowNull: false, 10 | field: 'id' 11 | } 12 | }, { 13 | tableName: 'RouterConnections', 14 | timestamps: true, 15 | underscored: true 16 | }) 17 | RouterConnection.associate = function (models) { 18 | RouterConnection.belongsTo(models.Router, { 19 | foreignKey: { 20 | name: 'sourceRouter', 21 | field: 'source_router' 22 | }, 23 | as: 'source', 24 | onDelete: 'cascade' 25 | }) 26 | 27 | RouterConnection.belongsTo(models.Router, { 28 | foreignKey: { 29 | name: 'destRouter', 30 | field: 'dest_router' 31 | }, 32 | as: 'dest', 33 | onDelete: 'cascade' 34 | }) 35 | } 36 | return RouterConnection 37 | } 38 | -------------------------------------------------------------------------------- /src/data/models/scheduleraccesstoken.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const { convertToInt } = require('../../helpers/app-helper') 4 | 5 | module.exports = (sequelize, DataTypes) => { 6 | const SchedulerAccessToken = sequelize.define('SchedulerAccessToken', { 7 | id: { 8 | type: DataTypes.INTEGER, 9 | primaryKey: true, 10 | autoIncrement: true, 11 | allowNull: false, 12 | field: 'id' 13 | }, 14 | expirationTime: { 15 | type: DataTypes.BIGINT, 16 | get () { 17 | return convertToInt(this.getDataValue('expirationTime')) 18 | }, 19 | field: 'expiration_time' 20 | }, 21 | token: { 22 | type: DataTypes.TEXT, 23 | field: 'token' 24 | } 25 | }, { 26 | tableName: 'SchedulerAccessTokens', 27 | timestamps: false, 28 | underscored: true 29 | }) 30 | SchedulerAccessToken.associate = function (models) { 31 | SchedulerAccessToken.belongsTo(models.User, { 32 | foreignKey: { 33 | name: 'userId', 34 | field: 'user_id' 35 | }, 36 | as: 'user', 37 | onDelete: 'cascade' 38 | }) 39 | } 40 | return SchedulerAccessToken 41 | } 42 | -------------------------------------------------------------------------------- /src/data/models/stracediagnostics.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const StraceDiagnostics = sequelize.define('StraceDiagnostics', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false, 9 | field: 'id' 10 | }, 11 | straceRun: { 12 | type: DataTypes.BOOLEAN, 13 | field: 'strace_run' 14 | }, 15 | buffer: { 16 | type: DataTypes.TEXT, 17 | field: 'buffer', 18 | defaultValue: '' 19 | } 20 | }, { 21 | tableName: 'StraceDiagnostics', 22 | timestamps: false, 23 | underscored: true 24 | }) 25 | StraceDiagnostics.associate = function (models) { 26 | StraceDiagnostics.belongsTo(models.Microservice, { 27 | foreignKey: { 28 | name: 'microserviceUuid', 29 | field: 'microservice_uuid' 30 | }, 31 | as: 'microservice', 32 | onDelete: 'cascade' 33 | 34 | }) 35 | } 36 | return StraceDiagnostics 37 | } 38 | -------------------------------------------------------------------------------- /src/data/models/tags.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const Tags = sequelize.define('Tags', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false, 9 | field: 'id' 10 | }, 11 | value: { 12 | type: DataTypes.TEXT, 13 | unique: true, 14 | allowNull: false, 15 | field: 'value' 16 | } 17 | }, { 18 | tableName: 'Tags', 19 | timestamps: false, 20 | underscored: true 21 | }) 22 | Tags.associate = function (models) { 23 | Tags.belongsToMany(models.Fog, { through: 'IofogTags', as: 'iofogs' }) 24 | Tags.belongsToMany(models.EdgeResource, { through: 'EdgeResourceOrchestrationTags', as: 'edgeResources' }) 25 | } 26 | return Tags 27 | } 28 | -------------------------------------------------------------------------------- /src/data/models/tunnel.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const Tunnel = sequelize.define('Tunnel', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false, 9 | field: 'id' 10 | }, 11 | username: { 12 | type: DataTypes.TEXT, 13 | field: 'username' 14 | }, 15 | password: { 16 | type: DataTypes.TEXT, 17 | field: 'password' 18 | }, 19 | host: { 20 | type: DataTypes.TEXT, 21 | field: 'host' 22 | }, 23 | rport: { 24 | type: DataTypes.INTEGER, 25 | field: 'remote_port' 26 | }, 27 | lport: { 28 | type: DataTypes.INTEGER, 29 | defaultValue: 22, 30 | field: 'local_port' 31 | }, 32 | rsakey: { 33 | type: DataTypes.TEXT, 34 | field: 'rsa_key' 35 | }, 36 | closed: { 37 | type: DataTypes.BOOLEAN, 38 | defaultValue: false, 39 | field: 'closed' 40 | } 41 | }, { 42 | tableName: 'Tunnels', 43 | timestamps: false, 44 | underscored: true 45 | }) 46 | Tunnel.associate = function (models) { 47 | Tunnel.belongsTo(models.Fog, { 48 | foreignKey: { 49 | name: 'iofogUuid', 50 | field: 'iofog_uuid' 51 | }, 52 | as: 'iofog', 53 | onDelete: 'cascade' 54 | }) 55 | } 56 | return Tunnel 57 | } 58 | -------------------------------------------------------------------------------- /src/data/models/usbinfo.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const USBInfo = sequelize.define('USBInfo', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false, 9 | field: 'id' 10 | }, 11 | info: { 12 | type: DataTypes.TEXT, 13 | defaultValue: ' ', 14 | field: 'info' 15 | } 16 | }, { 17 | tableName: 'USBInfos', 18 | // add the timestamp attributes (updatedAt, createdAt) 19 | timestamps: true, 20 | underscored: true 21 | }) 22 | USBInfo.associate = function (models) { 23 | USBInfo.belongsTo(models.Fog, { 24 | foreignKey: { 25 | name: 'iofogUuid', 26 | field: 'iofog_uuid' 27 | }, 28 | as: 'iofog', 29 | onDelete: 'cascade' 30 | }) 31 | } 32 | return USBInfo 33 | } 34 | -------------------------------------------------------------------------------- /src/data/models/volumemapping.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = (sequelize, DataTypes) => { 3 | const VolumeMapping = sequelize.define('VolumeMapping', { 4 | id: { 5 | type: DataTypes.INTEGER, 6 | primaryKey: true, 7 | autoIncrement: true, 8 | allowNull: false, 9 | field: 'uuid' 10 | }, 11 | hostDestination: { 12 | type: DataTypes.TEXT, 13 | field: 'host_destination' 14 | }, 15 | containerDestination: { 16 | type: DataTypes.TEXT, 17 | field: 'container_destination' 18 | }, 19 | accessMode: { 20 | type: DataTypes.TEXT, 21 | field: 'access_mode' 22 | }, 23 | type: { 24 | type: DataTypes.TEXT, 25 | field: 'type' 26 | } 27 | }, { 28 | tableName: 'VolumeMappings', 29 | timestamps: false, 30 | underscored: true 31 | }) 32 | VolumeMapping.associate = function (models) { 33 | VolumeMapping.belongsTo(models.Microservice, { 34 | foreignKey: { 35 | name: 'microserviceUuid', 36 | field: 'microservice_uuid' 37 | }, 38 | as: 'microservice', 39 | onDelete: 'cascade' 40 | }) 41 | } 42 | return VolumeMapping 43 | } 44 | -------------------------------------------------------------------------------- /src/data/providers/database-factory.js: -------------------------------------------------------------------------------- 1 | const config = require('../../config') 2 | 3 | function createDatabaseProvider () { 4 | let provider = process.env.DB_PROVIDER || config.get('Database:Provider', 'sqlite') 5 | 6 | if (!provider) { 7 | provider = 'sqlite' 8 | } 9 | 10 | const DatabaseProvider = require(`./${provider}`) 11 | return new DatabaseProvider() 12 | } 13 | 14 | module.exports = createDatabaseProvider() 15 | -------------------------------------------------------------------------------- /src/data/providers/database-provider.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const Sequelize = require('sequelize') 3 | const Umzug = require('umzug') 4 | 5 | class DatabaseProvider { 6 | constructor () { 7 | this.basename = path.basename(__filename) 8 | } 9 | 10 | async initDB () { 11 | throw new Error('Not Implemented') 12 | } 13 | 14 | createUmzug (path) { 15 | if (!this.sequelize) { 16 | throw new Error('Sequelize is not initialized') 17 | } 18 | 19 | return new Umzug({ 20 | storage: 'sequelize', 21 | storageOptions: { 22 | sequelize: this.sequelize 23 | }, 24 | logging: false, 25 | migrations: { 26 | params: [ 27 | this.sequelize.getQueryInterface(), 28 | Sequelize 29 | ], 30 | path, 31 | pattern: /\.js$/ 32 | } 33 | }) 34 | } 35 | } 36 | 37 | module.exports = DatabaseProvider 38 | -------------------------------------------------------------------------------- /src/data/providers/sqlite.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const fs = require('fs') 3 | const Sequelize = require('sequelize') 4 | 5 | const config = require('../../config') 6 | const DatabaseProvider = require(`./database-provider`) 7 | 8 | class SqliteDatabaseProvider extends DatabaseProvider { 9 | constructor () { 10 | super() 11 | 12 | const sqliteConfig = config.get('Database:Config', {}) 13 | sqliteConfig.dialect = 'sqlite' 14 | sqliteConfig.databaseName = process.env.DB_NAME || sqliteConfig.databaseName 15 | if (!sqliteConfig.databaseName.endsWith('.sqlite')) { 16 | sqliteConfig.databaseName += '.sqlite' 17 | } 18 | const storageFolder = path.resolve(__dirname, '../sqlite_files') 19 | sqliteConfig.storage = path.resolve(storageFolder, sqliteConfig.databaseName) 20 | if (!fs.existsSync(storageFolder)) { 21 | fs.mkdirSync(storageFolder) 22 | } 23 | if (config.use_env_variable) { 24 | this.sequelize = new Sequelize(process.env[config.use_env_variable], sqliteConfig) 25 | } else { 26 | this.sequelize = new Sequelize(sqliteConfig) 27 | } 28 | } 29 | 30 | async initDB () { 31 | } 32 | } 33 | 34 | module.exports = SqliteDatabaseProvider 35 | -------------------------------------------------------------------------------- /src/data/seeders/20180928110125-insert-registry.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.bulkInsert('Registries', [ 6 | { 7 | url: 'registry.hub.docker.com', 8 | is_public: true, 9 | secure: true, 10 | certificate: '', 11 | requires_cert: false, 12 | user_name: '', 13 | password: '', 14 | user_email: '', 15 | user_id: null 16 | }, 17 | { 18 | url: 'from_cache', 19 | is_public: true, 20 | secure: true, 21 | certificate: '', 22 | requires_cert: false, 23 | user_name: '', 24 | password: '', 25 | user_email: '', 26 | user_id: null 27 | } 28 | ]) 29 | }, 30 | 31 | down: (queryInterface, Sequelize) => { 32 | return queryInterface.bulkDelete('Registries', null, {}) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/data/seeders/20190130112616-insert-logging-catalog-item.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | up: (queryInterface, Sequelize) => { 5 | return queryInterface.bulkInsert('CatalogItems', [ 6 | { 7 | name: 'Common Logging', 8 | description: 'Container which gathers logs and provides REST API' + 9 | ' for adding and querying logs from containers', 10 | category: 'UTILITIES', 11 | publisher: 'Eclipse ioFog', 12 | disk_required: 0, 13 | ram_required: 0, 14 | picture: 'none.png', 15 | config_example: '{"access_tokens": ["Some_Access_Token"], "cleanfrequency": "1h40m", "ttl": "24h"}', 16 | is_public: false, 17 | registry_id: 1, 18 | user_id: null 19 | }] 20 | ).then(() => { 21 | return queryInterface.bulkInsert('CatalogItemImages', [ 22 | { 23 | catalog_item_id: 13, 24 | fog_type_id: 1, 25 | container_image: 'iofog/common-logging' 26 | }, 27 | { 28 | catalog_item_id: 13, 29 | fog_type_id: 2, 30 | container_image: 'iofog/common-logging-arm' 31 | } 32 | ] 33 | ) 34 | }) 35 | }, 36 | 37 | down: (queryInterface, Sequelize) => { 38 | return queryInterface.bulkDelete('CatalogItems', { ID: 13 }, {}).then(() => { 39 | return queryInterface.bulkDelete('CatalogItemImages', { catalog_item_id: 13 }) 40 | }) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/data/seeders/20190131111441-insert-json-generator-catalog-item.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | up: (queryInterface, Sequelize) => { 3 | return queryInterface.bulkInsert('CatalogItems', [ 4 | { 5 | name: 'JSON Generator', 6 | description: 'Container generates ioMessages with contentdata as complex JSON object.', 7 | category: 'UTILITIES', 8 | publisher: 'Eclipse ioFog', 9 | disk_required: 0, 10 | ram_required: 0, 11 | picture: 'none.png', 12 | config_example: '{}', 13 | is_public: true, 14 | registry_id: 1, 15 | user_id: null 16 | }] 17 | ).then(() => { 18 | return queryInterface.bulkInsert('CatalogItemImages', [ 19 | { 20 | catalog_item_id: 14, 21 | fog_type_id: 1, 22 | container_image: 'iofog/json-generator' 23 | }, 24 | { 25 | catalog_item_id: 14, 26 | fog_type_id: 2, 27 | container_image: 'iofog/json-generator-arm' 28 | } 29 | ]) 30 | }) 31 | }, 32 | 33 | down: (queryInterface, Sequelize) => { 34 | return queryInterface.bulkDelete('CatalogItems', { ID: 14 }, {}).then(() => { 35 | return queryInterface.bulkDelete('CatalogItemImages', { catalog_item_id: 14 }) 36 | }) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/enums/fog-state.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const fogState = { 15 | UNKNOWN: 'UNKNOWN', 16 | RUNNING: 'RUNNING' 17 | } 18 | 19 | module.exports = fogState 20 | -------------------------------------------------------------------------------- /src/enums/microservice-state.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const microserviceState = { 15 | QUEUED: 'QUEUED', 16 | PULLING: 'PULLING', 17 | STARTING: 'STARTING', 18 | RUNNING: 'RUNNING', 19 | STOPPING: 'STOPPING', 20 | DELETING: 'DELETING', 21 | MARKED_FOR_DELETION: 'MARKED_FOR_DELETION', 22 | UPDATING: 'UPDATING', 23 | RESTARTING: 'RESTARTING', 24 | STUCK_IN_RESTART: 'STUCK_IN_RESTART', 25 | UNKNOWN: 'UNKNOWN', 26 | FAILED: 'FAILED', 27 | DELETED: 'DELETED', 28 | EXITING: 'EXITING', 29 | STOPPED: 'STOPPED', 30 | CREATING: 'CREATING' 31 | } 32 | 33 | module.exports = microserviceState 34 | -------------------------------------------------------------------------------- /src/helpers/proxy-broker-client.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios') 2 | 3 | const controllerConfig = require('../config') 4 | 5 | const brokerUrl = process.env.PROXY_BROKER_URL || controllerConfig.get('PublicPorts:ProxyBrokerUrl', '') 6 | const brokerToken = process.env.PROXY_BROKER_TOKEN || controllerConfig.get('PublicPorts:ProxyBrokerToken', '') 7 | 8 | function allocatePort (serverToken) { 9 | var options = { 10 | method: 'POST', 11 | url: `${brokerUrl}/port`, 12 | headers: { 'X-Api-Key': brokerToken }, 13 | data: { token: serverToken } 14 | } 15 | 16 | return axios(options) 17 | .then(response => { 18 | return response.data 19 | }) 20 | .catch(err => { 21 | return err 22 | }) 23 | } 24 | 25 | function deallocatePort (portUUID) { 26 | var options = { 27 | method: 'DELETE', 28 | url: `${brokerUrl}/port/${portUUID}`, 29 | headers: { 'X-Api-Key': brokerToken } 30 | } 31 | 32 | return axios(options) 33 | } 34 | 35 | function revokeServerToken (token) { 36 | var options = { 37 | method: 'DELETE', 38 | url: `${brokerUrl}/server-token/${token}`, 39 | headers: { 'X-Api-Key': brokerToken } 40 | } 41 | 42 | return axios(options) 43 | } 44 | 45 | module.exports = { 46 | allocatePort: allocatePort, 47 | deallocatePort: deallocatePort, 48 | revokeServerToken: revokeServerToken 49 | } 50 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/filters/array.d.ts: -------------------------------------------------------------------------------- 1 | import { FilterImpl } from '../../template/filter/filter-impl'; 2 | import { Scope } from '../../context/scope'; 3 | export declare const join: (v: any[], arg: string) => string; 4 | export declare const last: (v: any) => any; 5 | export declare const first: (v: any) => any; 6 | export declare const reverse: (v: any[]) => any[]; 7 | export declare function sort(this: FilterImpl, arr: T[], property?: string): any[]; 8 | export declare const size: (v: string | any[]) => number; 9 | export declare function map(this: FilterImpl, arr: Scope[], property: string): object[]; 10 | export declare function concat(v: T1[], arg: T2[] | T2): (T1 | T2)[]; 11 | export declare function slice(v: T[], begin: number, length?: number): T[]; 12 | export declare function where(this: FilterImpl, arr: T[], property: string, expected?: any): T[]; 13 | export declare function uniq(arr: T[]): T[]; 14 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/filters/date.d.ts: -------------------------------------------------------------------------------- 1 | export declare function date(v: string | Date, arg: string): string | Date; 2 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/filters/html.d.ts: -------------------------------------------------------------------------------- 1 | export declare function escape(str: string): string; 2 | export declare function escapeOnce(str: string): string; 3 | export declare function newlineToBr(v: string): string; 4 | export declare function stripHtml(v: string): string; 5 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/filters/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './html'; 2 | export * from './math'; 3 | export * from './url'; 4 | export * from './array'; 5 | export * from './date'; 6 | export * from './object'; 7 | export * from './string'; 8 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/filters/math.d.ts: -------------------------------------------------------------------------------- 1 | export declare const abs: (x: number) => number; 2 | export declare const atLeast: (...values: number[]) => number; 3 | export declare const atMost: (...values: number[]) => number; 4 | export declare const ceil: (x: number) => number; 5 | export declare const dividedBy: (v: number, arg: number) => number; 6 | export declare const floor: (x: number) => number; 7 | export declare const minus: (v: number, arg: number) => number; 8 | export declare const modulo: (v: number, arg: number) => number; 9 | export declare const times: (v: number, arg: number) => number; 10 | export declare function round(v: number, arg?: number): number; 11 | export declare function plus(v: number, arg: number): number; 12 | export declare function sortNatural(input: any[], property?: string): any[]; 13 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/filters/object.d.ts: -------------------------------------------------------------------------------- 1 | import { FilterImpl } from '../../template/filter/filter-impl'; 2 | export declare function Default(this: FilterImpl, v: string | T1, arg: T2): string | T1 | T2; 3 | export declare function json(v: any): string; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/filters/string.d.ts: -------------------------------------------------------------------------------- 1 | export declare function append(v: string, arg: string): string; 2 | export declare function prepend(v: string, arg: string): string; 3 | export declare function lstrip(v: string): string; 4 | export declare function downcase(v: string): string; 5 | export declare function upcase(str: string): string; 6 | export declare function remove(v: string, arg: string): string; 7 | export declare function removeFirst(v: string, l: string): string; 8 | export declare function rstrip(str: string): string; 9 | export declare function split(v: string, arg: string): string[]; 10 | export declare function strip(v: string): string; 11 | export declare function stripNewlines(v: string): string; 12 | export declare function capitalize(str: string): string; 13 | export declare function replace(v: string, pattern: string, replacement: string): string; 14 | export declare function replaceFirst(v: string, arg1: string, arg2: string): string; 15 | export declare function truncate(v: string, l?: number, o?: string): string; 16 | export declare function truncatewords(v: string, l?: number, o?: string): string; 17 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/filters/url.d.ts: -------------------------------------------------------------------------------- 1 | export declare const urlDecode: (x: string) => string; 2 | export declare const urlEncode: (x: string) => string; 3 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/assign.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../types'; 2 | declare const _default: TagImplOptions; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/block.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../types'; 2 | declare const _default: TagImplOptions; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/break.d.ts: -------------------------------------------------------------------------------- 1 | import { Emitter, Context } from '../../types'; 2 | declare const _default: { 3 | render: (ctx: Context, emitter: Emitter) => void; 4 | }; 5 | export default _default; 6 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/capture.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../types'; 2 | declare const _default: TagImplOptions; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/case.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../types'; 2 | declare const _default: TagImplOptions; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/comment.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../template/tag/tag-impl-options'; 2 | declare const _default: TagImplOptions; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/continue.d.ts: -------------------------------------------------------------------------------- 1 | import { Emitter, Context } from '../../types'; 2 | declare const _default: { 3 | render: (ctx: Context, emitter: Emitter) => void; 4 | }; 5 | export default _default; 6 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/cycle.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../types'; 2 | declare const _default: TagImplOptions; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/decrement.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../types'; 2 | declare const _default: TagImplOptions; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/for.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../types'; 2 | declare const _default: TagImplOptions; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/if.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../types'; 2 | declare const _default: TagImplOptions; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/include.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../types'; 2 | declare const _default: TagImplOptions; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/increment.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../types'; 2 | declare const _default: TagImplOptions; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/index.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../template/tag/tag-impl-options'; 2 | declare const tags: { 3 | [key: string]: TagImplOptions; 4 | }; 5 | export default tags; 6 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/layout.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../types'; 2 | declare const _default: TagImplOptions; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/raw.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../types'; 2 | declare const _default: TagImplOptions; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/render.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../types'; 2 | declare const _default: TagImplOptions; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/tablerow.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../types'; 2 | declare const _default: TagImplOptions; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/builtin/tags/unless.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from '../../types'; 2 | declare const _default: TagImplOptions; 3 | export default _default; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/cache/cache.d.ts: -------------------------------------------------------------------------------- 1 | export interface Cache { 2 | write(key: string, value: T): void | Promise; 3 | read(key: string): T | undefined | Promise; 4 | } 5 | -------------------------------------------------------------------------------- /src/lib/liquidjs/cache/lru.d.ts: -------------------------------------------------------------------------------- 1 | import { Cache } from './cache'; 2 | export declare class LRU implements Cache { 3 | limit: number; 4 | size: number; 5 | private cache; 6 | private head; 7 | private tail; 8 | constructor(limit: number, size?: number); 9 | write(key: string, value: T): void; 10 | read(key: string): T | undefined; 11 | remove(key: string): void; 12 | clear(): void; 13 | private ensureLimit; 14 | } 15 | -------------------------------------------------------------------------------- /src/lib/liquidjs/context/block-mode.d.ts: -------------------------------------------------------------------------------- 1 | declare enum BlockMode { 2 | OUTPUT = 0, 3 | STORE = 1 4 | } 5 | export default BlockMode; 6 | -------------------------------------------------------------------------------- /src/lib/liquidjs/context/context.d.ts: -------------------------------------------------------------------------------- 1 | import { Drop } from '../drop/drop'; 2 | import { NormalizedFullOptions } from '../liquid-options'; 3 | import { Scope } from './scope'; 4 | export declare class Context { 5 | private scopes; 6 | private registers; 7 | environments: Scope; 8 | globals: Scope; 9 | sync: boolean; 10 | opts: NormalizedFullOptions; 11 | constructor(env?: object, opts?: NormalizedFullOptions, sync?: boolean); 12 | getRegister(key: string, defaultValue?: {}): any; 13 | setRegister(key: string, value: any): any; 14 | saveRegister(...keys: string[]): [string, any][]; 15 | restoreRegister(keyValues: [string, any][]): void; 16 | getAll(): Scope; 17 | get(paths: string[]): object; 18 | getFromScope(scope: object, paths: string[] | string): object; 19 | push(ctx: object): number; 20 | pop(): import("./scope").PlainObject | Drop | undefined; 21 | bottom(): Scope; 22 | private findScope; 23 | } 24 | export declare function readProperty(obj: Scope, key: string): any; 25 | -------------------------------------------------------------------------------- /src/lib/liquidjs/context/scope.d.ts: -------------------------------------------------------------------------------- 1 | import { Drop } from '../drop/drop'; 2 | export interface PlainObject { 3 | [key: string]: any; 4 | toLiquid?: () => any; 5 | } 6 | export declare type Scope = PlainObject | Drop; 7 | -------------------------------------------------------------------------------- /src/lib/liquidjs/drop/blank-drop.d.ts: -------------------------------------------------------------------------------- 1 | import { EmptyDrop } from '../drop/empty-drop'; 2 | export declare class BlankDrop extends EmptyDrop { 3 | equals(value: any): boolean; 4 | } 5 | -------------------------------------------------------------------------------- /src/lib/liquidjs/drop/comparable.d.ts: -------------------------------------------------------------------------------- 1 | export interface Comparable { 2 | equals: (rhs: any) => boolean; 3 | gt: (rhs: any) => boolean; 4 | geq: (rhs: any) => boolean; 5 | lt: (rhs: any) => boolean; 6 | leq: (rhs: any) => boolean; 7 | } 8 | export declare function isComparable(arg: any): arg is Comparable; 9 | -------------------------------------------------------------------------------- /src/lib/liquidjs/drop/drop.d.ts: -------------------------------------------------------------------------------- 1 | export declare abstract class Drop { 2 | valueOf(): any; 3 | liquidMethodMissing(key: string): Promise | string | undefined; 4 | } 5 | -------------------------------------------------------------------------------- /src/lib/liquidjs/drop/empty-drop.d.ts: -------------------------------------------------------------------------------- 1 | import { Drop } from './drop'; 2 | import { Comparable } from './comparable'; 3 | export declare class EmptyDrop extends Drop implements Comparable { 4 | equals(value: any): boolean; 5 | gt(): boolean; 6 | geq(): boolean; 7 | lt(): boolean; 8 | leq(): boolean; 9 | valueOf(): string; 10 | } 11 | -------------------------------------------------------------------------------- /src/lib/liquidjs/drop/forloop-drop.d.ts: -------------------------------------------------------------------------------- 1 | import { Drop } from './drop'; 2 | export declare class ForloopDrop extends Drop { 3 | protected i: number; 4 | length: number; 5 | constructor(length: number); 6 | next(): void; 7 | index0(): number; 8 | index(): number; 9 | first(): boolean; 10 | last(): boolean; 11 | rindex(): number; 12 | rindex0(): number; 13 | valueOf(): string; 14 | } 15 | -------------------------------------------------------------------------------- /src/lib/liquidjs/drop/null-drop.d.ts: -------------------------------------------------------------------------------- 1 | import { Drop } from './drop'; 2 | import { Comparable } from './comparable'; 3 | export declare class NullDrop extends Drop implements Comparable { 4 | equals(value: any): boolean; 5 | gt(): boolean; 6 | geq(): boolean; 7 | lt(): boolean; 8 | leq(): boolean; 9 | valueOf(): null; 10 | } 11 | -------------------------------------------------------------------------------- /src/lib/liquidjs/drop/tablerowloop-drop.d.ts: -------------------------------------------------------------------------------- 1 | import { ForloopDrop } from './forloop-drop'; 2 | export declare class TablerowloopDrop extends ForloopDrop { 3 | private cols; 4 | constructor(length: number, cols: number); 5 | row(): number; 6 | col0(): number; 7 | col(): number; 8 | col_first(): boolean; 9 | col_last(): boolean; 10 | } 11 | -------------------------------------------------------------------------------- /src/lib/liquidjs/fs/browser.d.ts: -------------------------------------------------------------------------------- 1 | export declare function resolve(root: string, filepath: string, ext: string): string; 2 | export declare function readFile(url: string): Promise; 3 | export declare function readFileSync(url: string): string; 4 | export declare function exists(filepath: string): Promise; 5 | export declare function existsSync(filepath: string): boolean; 6 | -------------------------------------------------------------------------------- /src/lib/liquidjs/fs/fs.d.ts: -------------------------------------------------------------------------------- 1 | export interface FS { 2 | exists: (filepath: string) => Promise; 3 | readFile: (filepath: string) => Promise; 4 | existsSync: (filepath: string) => boolean; 5 | readFileSync: (filepath: string) => string; 6 | resolve: (root: string, file: string, ext: string) => string; 7 | fallback?: (file: string) => string | undefined; 8 | } 9 | -------------------------------------------------------------------------------- /src/lib/liquidjs/fs/node.d.ts: -------------------------------------------------------------------------------- 1 | export declare function exists(filepath: string): Promise; 2 | export declare function readFile(filepath: string): Promise; 3 | export declare function existsSync(filepath: string): boolean; 4 | export declare function readFileSync(filepath: string): string; 5 | export declare function resolve(root: string, file: string, ext: string): string; 6 | export declare function fallback(file: string): string | undefined; 7 | -------------------------------------------------------------------------------- /src/lib/liquidjs/parser/filter-arg.d.ts: -------------------------------------------------------------------------------- 1 | import { ValueToken } from '../tokens/value-token'; 2 | declare type KeyValuePair = [string?, ValueToken?]; 3 | export declare type FilterArg = ValueToken | KeyValuePair; 4 | export declare function isKeyValuePair(arr: FilterArg): arr is KeyValuePair; 5 | export {}; 6 | -------------------------------------------------------------------------------- /src/lib/liquidjs/parser/match-operator.d.ts: -------------------------------------------------------------------------------- 1 | export declare function matchOperator(str: string, begin: number, end?: number): number; 2 | -------------------------------------------------------------------------------- /src/lib/liquidjs/parser/parse-stream.d.ts: -------------------------------------------------------------------------------- 1 | import { Token } from '../tokens/token'; 2 | import { Template } from '../template/template'; 3 | import { TopLevelToken } from '../tokens/toplevel-token'; 4 | declare type ParseToken = ((token: T, remainTokens: T[]) => Template); 5 | export declare class ParseStream { 6 | private tokens; 7 | private handlers; 8 | private stopRequested; 9 | private parseToken; 10 | constructor(tokens: T[], parseToken: ParseToken); 11 | on(name: string, cb: (arg: T2) => void): ParseStream; 12 | private trigger; 13 | start(): this; 14 | stop(): this; 15 | } 16 | export {}; 17 | -------------------------------------------------------------------------------- /src/lib/liquidjs/parser/parse-string-literal.d.ts: -------------------------------------------------------------------------------- 1 | export declare function parseStringLiteral(str: string): string; 2 | -------------------------------------------------------------------------------- /src/lib/liquidjs/parser/parser.d.ts: -------------------------------------------------------------------------------- 1 | import { Liquid } from '../liquid'; 2 | import { ParseStream } from './parse-stream'; 3 | import { Tag } from '../template/tag/tag'; 4 | import { Output } from '../template/output'; 5 | import { HTML } from '../template/html'; 6 | import { Template } from '../template/template'; 7 | import { TopLevelToken } from '../tokens/toplevel-token'; 8 | export default class Parser { 9 | private liquid; 10 | constructor(liquid: Liquid); 11 | parse(tokens: TopLevelToken[]): Template[]; 12 | parseToken(token: TopLevelToken, remainTokens: TopLevelToken[]): Tag | Output | HTML; 13 | parseStream(tokens: TopLevelToken[]): ParseStream; 14 | } 15 | -------------------------------------------------------------------------------- /src/lib/liquidjs/parser/token-kind.d.ts: -------------------------------------------------------------------------------- 1 | export declare enum TokenKind { 2 | Number = 1, 3 | Literal = 2, 4 | Tag = 4, 5 | Output = 8, 6 | HTML = 16, 7 | Filter = 32, 8 | Hash = 64, 9 | PropertyAccess = 128, 10 | Word = 256, 11 | Range = 512, 12 | Quoted = 1024, 13 | Operator = 2048, 14 | Delimited = 12 15 | } 16 | -------------------------------------------------------------------------------- /src/lib/liquidjs/parser/whitespace-ctrl.d.ts: -------------------------------------------------------------------------------- 1 | import { Token } from '../tokens/token'; 2 | import { NormalizedFullOptions } from '../liquid-options'; 3 | export declare function whiteSpaceCtrl(tokens: Token[], options: NormalizedFullOptions): void; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/render/boolean.d.ts: -------------------------------------------------------------------------------- 1 | import { Context } from '../context/context'; 2 | export declare function isTruthy(val: any, ctx: Context): boolean; 3 | export declare function isFalsy(val: any, ctx: Context): boolean; 4 | -------------------------------------------------------------------------------- /src/lib/liquidjs/render/emitter.d.ts: -------------------------------------------------------------------------------- 1 | export declare class Emitter { 2 | html: any; 3 | break: boolean; 4 | continue: boolean; 5 | private keepOutputType?; 6 | constructor(keepOutputType: boolean | undefined); 7 | write(html: any): void; 8 | } 9 | -------------------------------------------------------------------------------- /src/lib/liquidjs/render/expression.d.ts: -------------------------------------------------------------------------------- 1 | import { QuotedToken } from '../tokens/quoted-token'; 2 | import { Token } from '../tokens/token'; 3 | import { Context } from '../context/context'; 4 | export declare class Expression { 5 | private operands; 6 | private postfix; 7 | private lenient; 8 | constructor(str: string, lenient?: boolean); 9 | evaluate(ctx: Context): any; 10 | value(ctx: Context): IterableIterator; 11 | } 12 | export declare function evalToken(token: Token | undefined, ctx: Context, lenient?: boolean): any; 13 | export declare function evalQuotedToken(token: QuotedToken): string; 14 | -------------------------------------------------------------------------------- /src/lib/liquidjs/render/operator.d.ts: -------------------------------------------------------------------------------- 1 | import { Context } from '../context/context'; 2 | export declare const operatorImpls: { 3 | [key: string]: (lhs: any, rhs: any, ctx: Context) => boolean; 4 | }; 5 | -------------------------------------------------------------------------------- /src/lib/liquidjs/render/render.d.ts: -------------------------------------------------------------------------------- 1 | import { Context } from '../context/context'; 2 | import { Template } from '../template/template'; 3 | import { Emitter } from './emitter'; 4 | export declare class Render { 5 | renderTemplates(templates: Template[], ctx: Context, emitter: Emitter): IterableIterator; 6 | } 7 | -------------------------------------------------------------------------------- /src/lib/liquidjs/template/filter/filter-impl-options.d.ts: -------------------------------------------------------------------------------- 1 | import { FilterImpl } from './filter-impl'; 2 | export interface FilterImplOptions { 3 | (this: FilterImpl, value: any, ...args: any[]): any; 4 | } 5 | -------------------------------------------------------------------------------- /src/lib/liquidjs/template/filter/filter-impl.d.ts: -------------------------------------------------------------------------------- 1 | import { Context } from '../../context/context'; 2 | import { Liquid } from '../../liquid'; 3 | export interface FilterImpl { 4 | context: Context; 5 | liquid: Liquid; 6 | } 7 | -------------------------------------------------------------------------------- /src/lib/liquidjs/template/filter/filter-map.d.ts: -------------------------------------------------------------------------------- 1 | import { FilterImplOptions } from './filter-impl-options'; 2 | import { Filter } from './filter'; 3 | import { FilterArg } from '../../parser/filter-arg'; 4 | import { Liquid } from '../../liquid'; 5 | export declare class FilterMap { 6 | private readonly strictFilters; 7 | private readonly liquid; 8 | private impls; 9 | constructor(strictFilters: boolean, liquid: Liquid); 10 | get(name: string): FilterImplOptions; 11 | set(name: string, impl: FilterImplOptions): void; 12 | create(name: string, args: FilterArg[]): Filter; 13 | } 14 | -------------------------------------------------------------------------------- /src/lib/liquidjs/template/filter/filter.d.ts: -------------------------------------------------------------------------------- 1 | import { Context } from '../../context/context'; 2 | import { FilterImplOptions } from './filter-impl-options'; 3 | import { FilterArg } from '../../parser/filter-arg'; 4 | import { Liquid } from '../../liquid'; 5 | export declare class Filter { 6 | name: string; 7 | args: FilterArg[]; 8 | private impl; 9 | private liquid; 10 | constructor(name: string, impl: FilterImplOptions, args: FilterArg[], liquid: Liquid); 11 | render(value: any, context: Context): IterableIterator; 12 | } 13 | -------------------------------------------------------------------------------- /src/lib/liquidjs/template/html.d.ts: -------------------------------------------------------------------------------- 1 | import { TemplateImpl } from '../template/template-impl'; 2 | import { Template } from '../template/template'; 3 | import { HTMLToken } from '../tokens/html-token'; 4 | import { Context } from '../context/context'; 5 | import { Emitter } from '../render/emitter'; 6 | export declare class HTML extends TemplateImpl implements Template { 7 | private str; 8 | constructor(token: HTMLToken); 9 | render(ctx: Context, emitter: Emitter): IterableIterator; 10 | } 11 | -------------------------------------------------------------------------------- /src/lib/liquidjs/template/output.d.ts: -------------------------------------------------------------------------------- 1 | import { FilterMap } from './filter/filter-map'; 2 | import { TemplateImpl } from '../template/template-impl'; 3 | import { Template } from '../template/template'; 4 | import { Context } from '../context/context'; 5 | import { Emitter } from '../render/emitter'; 6 | import { OutputToken } from '../tokens/output-token'; 7 | import { Liquid } from '../liquid'; 8 | export declare class Output extends TemplateImpl implements Template { 9 | private value; 10 | constructor(token: OutputToken, filters: FilterMap, liquid: Liquid); 11 | render(ctx: Context, emitter: Emitter): IterableIterator>; 12 | } 13 | -------------------------------------------------------------------------------- /src/lib/liquidjs/template/tag/hash.d.ts: -------------------------------------------------------------------------------- 1 | import { Context } from '../../context/context'; 2 | /** 3 | * Key-Value Pairs Representing Tag Arguments 4 | * Example: 5 | * For the markup `, foo:'bar', coo:2 reversed %}`, 6 | * hash['foo'] === 'bar' 7 | * hash['coo'] === 2 8 | * hash['reversed'] === undefined 9 | */ 10 | export declare class Hash { 11 | hash: { 12 | [key: string]: any; 13 | }; 14 | constructor(markup: string); 15 | render(ctx: Context): IterableIterator; 16 | } 17 | -------------------------------------------------------------------------------- /src/lib/liquidjs/template/tag/tag-impl-options.d.ts: -------------------------------------------------------------------------------- 1 | import { Context } from '../../context/context'; 2 | import { TagToken } from '../../tokens/tag-token'; 3 | import { TopLevelToken } from '../../tokens/toplevel-token'; 4 | import { TagImpl } from './tag-impl'; 5 | import { Hash } from '../../template/tag/hash'; 6 | import { Emitter } from '../../render/emitter'; 7 | export interface TagImplOptions { 8 | parse?: (this: TagImpl, token: TagToken, remainingTokens: TopLevelToken[]) => void; 9 | render: (this: TagImpl, ctx: Context, emitter: Emitter, hash: Hash) => any; 10 | } 11 | -------------------------------------------------------------------------------- /src/lib/liquidjs/template/tag/tag-impl.d.ts: -------------------------------------------------------------------------------- 1 | import { Liquid } from '../../liquid'; 2 | import { TagImplOptions } from './tag-impl-options'; 3 | export interface TagImpl extends TagImplOptions { 4 | liquid: Liquid; 5 | [key: string]: any; 6 | } 7 | -------------------------------------------------------------------------------- /src/lib/liquidjs/template/tag/tag-map.d.ts: -------------------------------------------------------------------------------- 1 | import { TagImplOptions } from './tag-impl-options'; 2 | export declare class TagMap { 3 | private impls; 4 | get(name: string): TagImplOptions; 5 | set(name: string, impl: TagImplOptions): void; 6 | } 7 | -------------------------------------------------------------------------------- /src/lib/liquidjs/template/tag/tag.d.ts: -------------------------------------------------------------------------------- 1 | import { Liquid } from '../../liquid'; 2 | import { TemplateImpl } from '../../template/template-impl'; 3 | import { Emitter, Context, TagToken, Template, TopLevelToken } from '../../types'; 4 | export declare class Tag extends TemplateImpl implements Template { 5 | name: string; 6 | private impl; 7 | constructor(token: TagToken, tokens: TopLevelToken[], liquid: Liquid); 8 | render(ctx: Context, emitter: Emitter): IterableIterator; 9 | } 10 | -------------------------------------------------------------------------------- /src/lib/liquidjs/template/template-impl.d.ts: -------------------------------------------------------------------------------- 1 | export declare abstract class TemplateImpl { 2 | token: T; 3 | constructor(token: T); 4 | } 5 | -------------------------------------------------------------------------------- /src/lib/liquidjs/template/template.d.ts: -------------------------------------------------------------------------------- 1 | import { Context } from '../context/context'; 2 | import { Token } from '../tokens/token'; 3 | import { Emitter } from '../render/emitter'; 4 | export interface Template { 5 | token: Token; 6 | render(ctx: Context, emitter: Emitter): any; 7 | } 8 | -------------------------------------------------------------------------------- /src/lib/liquidjs/template/value.d.ts: -------------------------------------------------------------------------------- 1 | import { FilterMap } from '../template/filter/filter-map'; 2 | import { Filter } from './filter/filter'; 3 | import { Context } from '../context/context'; 4 | import { ValueToken } from '../tokens/value-token'; 5 | import { Liquid } from '../liquid'; 6 | export declare class Value { 7 | private readonly filterMap; 8 | readonly filters: Filter[]; 9 | readonly initial?: ValueToken; 10 | /** 11 | * @param str the value to be valuated, eg.: "foobar" | truncate: 3 12 | */ 13 | constructor(str: string, filterMap: FilterMap, liquid: Liquid); 14 | value(ctx: Context): IterableIterator; 15 | } 16 | -------------------------------------------------------------------------------- /src/lib/liquidjs/tokens/delimited-token.d.ts: -------------------------------------------------------------------------------- 1 | import { Token } from './token'; 2 | import { TokenKind } from '../parser/token-kind'; 3 | export declare abstract class DelimitedToken extends Token { 4 | trimLeft: boolean; 5 | trimRight: boolean; 6 | content: string; 7 | constructor(kind: TokenKind, content: string, input: string, begin: number, end: number, trimLeft: boolean, trimRight: boolean, file?: string); 8 | } 9 | -------------------------------------------------------------------------------- /src/lib/liquidjs/tokens/filter-token.d.ts: -------------------------------------------------------------------------------- 1 | import { Token } from './token'; 2 | import { FilterArg } from '../parser/filter-arg'; 3 | export declare class FilterToken extends Token { 4 | name: string; 5 | args: FilterArg[]; 6 | constructor(name: string, args: FilterArg[], input: string, begin: number, end: number, file?: string); 7 | } 8 | -------------------------------------------------------------------------------- /src/lib/liquidjs/tokens/hash-token.d.ts: -------------------------------------------------------------------------------- 1 | import { Token } from './token'; 2 | import { IdentifierToken } from './identifier-token'; 3 | export declare class HashToken extends Token { 4 | input: string; 5 | begin: number; 6 | end: number; 7 | name: IdentifierToken; 8 | value?: import("./range-token").RangeToken | import("./literal-token").LiteralToken | import("./quoted-token").QuotedToken | import("./property-access-token").PropertyAccessToken | undefined; 9 | file?: string | undefined; 10 | constructor(input: string, begin: number, end: number, name: IdentifierToken, value?: import("./range-token").RangeToken | import("./literal-token").LiteralToken | import("./quoted-token").QuotedToken | import("./property-access-token").PropertyAccessToken | undefined, file?: string | undefined); 11 | } 12 | -------------------------------------------------------------------------------- /src/lib/liquidjs/tokens/html-token.d.ts: -------------------------------------------------------------------------------- 1 | import { Token } from './token'; 2 | export declare class HTMLToken extends Token { 3 | input: string; 4 | begin: number; 5 | end: number; 6 | file?: string | undefined; 7 | trimLeft: number; 8 | trimRight: number; 9 | constructor(input: string, begin: number, end: number, file?: string | undefined); 10 | getContent(): string; 11 | } 12 | -------------------------------------------------------------------------------- /src/lib/liquidjs/tokens/identifier-token.d.ts: -------------------------------------------------------------------------------- 1 | import { Token } from './token'; 2 | export declare class IdentifierToken extends Token { 3 | input: string; 4 | begin: number; 5 | end: number; 6 | file?: string | undefined; 7 | content: string; 8 | constructor(input: string, begin: number, end: number, file?: string | undefined); 9 | isNumber(allowSign?: boolean): boolean; 10 | } 11 | -------------------------------------------------------------------------------- /src/lib/liquidjs/tokens/literal-token.d.ts: -------------------------------------------------------------------------------- 1 | import { Token } from './token'; 2 | export declare class LiteralToken extends Token { 3 | input: string; 4 | begin: number; 5 | end: number; 6 | file?: string | undefined; 7 | literal: string; 8 | constructor(input: string, begin: number, end: number, file?: string | undefined); 9 | } 10 | -------------------------------------------------------------------------------- /src/lib/liquidjs/tokens/number-token.d.ts: -------------------------------------------------------------------------------- 1 | import { Token } from './token'; 2 | import { IdentifierToken } from './identifier-token'; 3 | export declare class NumberToken extends Token { 4 | whole: IdentifierToken; 5 | decimal?: IdentifierToken | undefined; 6 | constructor(whole: IdentifierToken, decimal?: IdentifierToken | undefined); 7 | } 8 | -------------------------------------------------------------------------------- /src/lib/liquidjs/tokens/operator-token.d.ts: -------------------------------------------------------------------------------- 1 | import { Token } from './token'; 2 | export declare const precedence: { 3 | '==': number; 4 | '!=': number; 5 | '>': number; 6 | '<': number; 7 | '>=': number; 8 | '<=': number; 9 | 'contains': number; 10 | 'and': number; 11 | 'or': number; 12 | }; 13 | export declare class OperatorToken extends Token { 14 | input: string; 15 | begin: number; 16 | end: number; 17 | file?: string | undefined; 18 | operator: string; 19 | constructor(input: string, begin: number, end: number, file?: string | undefined); 20 | getPrecedence(): any; 21 | } 22 | -------------------------------------------------------------------------------- /src/lib/liquidjs/tokens/output-token.d.ts: -------------------------------------------------------------------------------- 1 | import { DelimitedToken } from './delimited-token'; 2 | import { NormalizedFullOptions } from '../liquid-options'; 3 | export declare class OutputToken extends DelimitedToken { 4 | constructor(input: string, begin: number, end: number, options: NormalizedFullOptions, file?: string); 5 | } 6 | -------------------------------------------------------------------------------- /src/lib/liquidjs/tokens/property-access-token.d.ts: -------------------------------------------------------------------------------- 1 | import { Token } from './token'; 2 | import { IdentifierToken } from './identifier-token'; 3 | import { QuotedToken } from './quoted-token'; 4 | export declare class PropertyAccessToken extends Token { 5 | variable: IdentifierToken | QuotedToken; 6 | props: (IdentifierToken | QuotedToken | PropertyAccessToken)[]; 7 | constructor(variable: IdentifierToken | QuotedToken, props: (IdentifierToken | QuotedToken | PropertyAccessToken)[], end: number); 8 | getVariableAsText(): string; 9 | } 10 | -------------------------------------------------------------------------------- /src/lib/liquidjs/tokens/quoted-token.d.ts: -------------------------------------------------------------------------------- 1 | import { Token } from './token'; 2 | export declare class QuotedToken extends Token { 3 | input: string; 4 | begin: number; 5 | end: number; 6 | file?: string | undefined; 7 | constructor(input: string, begin: number, end: number, file?: string | undefined); 8 | } 9 | -------------------------------------------------------------------------------- /src/lib/liquidjs/tokens/range-token.d.ts: -------------------------------------------------------------------------------- 1 | import { Token } from './token'; 2 | import { ValueToken } from './value-token'; 3 | export declare class RangeToken extends Token { 4 | input: string; 5 | begin: number; 6 | end: number; 7 | lhs: ValueToken; 8 | rhs: ValueToken; 9 | file?: string | undefined; 10 | constructor(input: string, begin: number, end: number, lhs: ValueToken, rhs: ValueToken, file?: string | undefined); 11 | } 12 | -------------------------------------------------------------------------------- /src/lib/liquidjs/tokens/tag-token.d.ts: -------------------------------------------------------------------------------- 1 | import { DelimitedToken } from './delimited-token'; 2 | import { NormalizedFullOptions } from '../liquid-options'; 3 | export declare class TagToken extends DelimitedToken { 4 | name: string; 5 | args: string; 6 | constructor(input: string, begin: number, end: number, options: NormalizedFullOptions, file?: string); 7 | } 8 | -------------------------------------------------------------------------------- /src/lib/liquidjs/tokens/token.d.ts: -------------------------------------------------------------------------------- 1 | import { TokenKind } from '../parser/token-kind'; 2 | export declare abstract class Token { 3 | kind: TokenKind; 4 | input: string; 5 | begin: number; 6 | end: number; 7 | file?: string | undefined; 8 | constructor(kind: TokenKind, input: string, begin: number, end: number, file?: string | undefined); 9 | getText(): string; 10 | getPosition(): number[]; 11 | size(): number; 12 | } 13 | -------------------------------------------------------------------------------- /src/lib/liquidjs/tokens/toplevel-token.d.ts: -------------------------------------------------------------------------------- 1 | import { TagToken } from './tag-token'; 2 | import { HTMLToken } from './html-token'; 3 | import { OutputToken } from './output-token'; 4 | export declare type TopLevelToken = TagToken | OutputToken | HTMLToken; 5 | -------------------------------------------------------------------------------- /src/lib/liquidjs/tokens/value-token.d.ts: -------------------------------------------------------------------------------- 1 | import { RangeToken } from './range-token'; 2 | import { LiteralToken } from './literal-token'; 3 | import { QuotedToken } from './quoted-token'; 4 | import { PropertyAccessToken } from './property-access-token'; 5 | export declare type ValueToken = RangeToken | LiteralToken | QuotedToken | PropertyAccessToken; 6 | -------------------------------------------------------------------------------- /src/lib/liquidjs/types.d.ts: -------------------------------------------------------------------------------- 1 | import * as TypeGuards from './util/type-guards'; 2 | export { TypeGuards }; 3 | export { ParseError, TokenizationError, AssertionError } from './util/error'; 4 | export { assert } from './util/assert'; 5 | export { Drop } from './drop/drop'; 6 | export { Emitter } from './render/emitter'; 7 | export { Expression } from './render/expression'; 8 | export { isFalsy, isTruthy } from './render/boolean'; 9 | export { TagToken } from './tokens/tag-token'; 10 | export { Context } from './context/context'; 11 | export { Template } from './template/template'; 12 | export { FilterImplOptions } from './template/filter/filter-impl-options'; 13 | export { TagImplOptions } from './template/tag/tag-impl-options'; 14 | export { ParseStream } from './parser/parse-stream'; 15 | export { Token } from './tokens/token'; 16 | export { TopLevelToken } from './tokens/toplevel-token'; 17 | export { Tokenizer } from './parser/tokenizer'; 18 | export { Hash } from './template/tag/hash'; 19 | export { evalToken, evalQuotedToken } from './render/expression'; 20 | export { toPromise, toThenable, toValue } from './util/async'; 21 | -------------------------------------------------------------------------------- /src/lib/liquidjs/util/assert.d.ts: -------------------------------------------------------------------------------- 1 | export declare function assert(predicate: T | null | undefined, message?: () => string): void; 2 | -------------------------------------------------------------------------------- /src/lib/liquidjs/util/async.d.ts: -------------------------------------------------------------------------------- 1 | declare type resolver = (x?: any) => any; 2 | interface Thenable { 3 | then(resolve: resolver, reject?: resolver): Thenable; 4 | catch(reject: resolver): Thenable; 5 | } 6 | export declare function toThenable(val: IterableIterator | Thenable | any): Thenable; 7 | export declare function toPromise(val: IterableIterator | Thenable | any): Promise; 8 | export declare function toValue(val: IterableIterator | Thenable | any): any; 9 | export {}; 10 | -------------------------------------------------------------------------------- /src/lib/liquidjs/util/character.d.ts: -------------------------------------------------------------------------------- 1 | export declare const TYPES: number[]; 2 | export declare const IDENTIFIER = 1; 3 | export declare const OPERATOR = 2; 4 | export declare const BLANK = 4; 5 | export declare const QUOTE = 8; 6 | export declare const INLINE_BLANK = 16; 7 | export declare const NUMBER = 32; 8 | export declare const SIGN = 64; 9 | -------------------------------------------------------------------------------- /src/lib/liquidjs/util/collection.d.ts: -------------------------------------------------------------------------------- 1 | export declare function toEnumerable(val: any): any[]; 2 | export declare function toArray(val: any): any[]; 3 | -------------------------------------------------------------------------------- /src/lib/liquidjs/util/error.d.ts: -------------------------------------------------------------------------------- 1 | import { Token } from '../tokens/token'; 2 | import { Template } from '../template/template'; 3 | declare abstract class LiquidError extends Error { 4 | private token; 5 | private originalError; 6 | constructor(err: Error, token: Token); 7 | protected update(): void; 8 | } 9 | export declare class TokenizationError extends LiquidError { 10 | constructor(message: string, token: Token); 11 | } 12 | export declare class ParseError extends LiquidError { 13 | constructor(err: Error, token: Token); 14 | } 15 | export declare class RenderError extends LiquidError { 16 | constructor(err: Error, tpl: Template); 17 | static is(obj: any): obj is RenderError; 18 | } 19 | export declare class UndefinedVariableError extends LiquidError { 20 | constructor(err: Error, token: Token); 21 | } 22 | export declare class InternalUndefinedVariableError extends Error { 23 | variableName: string; 24 | constructor(variableName: string); 25 | } 26 | export declare class AssertionError extends Error { 27 | constructor(message: string); 28 | } 29 | export {}; 30 | -------------------------------------------------------------------------------- /src/lib/liquidjs/util/literal.d.ts: -------------------------------------------------------------------------------- 1 | import { NullDrop } from '../drop/null-drop'; 2 | import { EmptyDrop } from '../drop/empty-drop'; 3 | import { BlankDrop } from '../drop/blank-drop'; 4 | export declare const literalValues: { 5 | 'true': boolean; 6 | 'false': boolean; 7 | 'nil': NullDrop; 8 | 'null': NullDrop; 9 | 'empty': EmptyDrop; 10 | 'blank': BlankDrop; 11 | }; 12 | -------------------------------------------------------------------------------- /src/lib/liquidjs/util/strftime.d.ts: -------------------------------------------------------------------------------- 1 | export default function (d: Date, formatStr: string): string; 2 | -------------------------------------------------------------------------------- /src/lib/liquidjs/util/type-guards.d.ts: -------------------------------------------------------------------------------- 1 | import { OperatorToken } from '../tokens/operator-token'; 2 | import { DelimitedToken } from '../tokens/delimited-token'; 3 | import { IdentifierToken } from '../tokens/identifier-token'; 4 | import { TagToken } from '../tokens/tag-token'; 5 | import { HTMLToken } from '../tokens/html-token'; 6 | import { OutputToken } from '../tokens/output-token'; 7 | import { PropertyAccessToken } from '../tokens/property-access-token'; 8 | import { LiteralToken } from '../tokens/literal-token'; 9 | import { QuotedToken } from '../tokens/quoted-token'; 10 | import { NumberToken } from '../tokens/number-token'; 11 | import { RangeToken } from '../tokens/range-token'; 12 | export declare function isDelimitedToken(val: any): val is DelimitedToken; 13 | export declare function isOperatorToken(val: any): val is OperatorToken; 14 | export declare function isHTMLToken(val: any): val is HTMLToken; 15 | export declare function isOutputToken(val: any): val is OutputToken; 16 | export declare function isTagToken(val: any): val is TagToken; 17 | export declare function isQuotedToken(val: any): val is QuotedToken; 18 | export declare function isLiteralToken(val: any): val is LiteralToken; 19 | export declare function isNumberToken(val: any): val is NumberToken; 20 | export declare function isPropertyAccessToken(val: any): val is PropertyAccessToken; 21 | export declare function isWordToken(val: any): val is IdentifierToken; 22 | export declare function isRangeToken(val: any): val is RangeToken; 23 | -------------------------------------------------------------------------------- /src/routes/capabilities.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | const logger = require('../logger') 14 | 15 | module.exports = [ 16 | { 17 | method: 'head', 18 | path: '/api/v3/capabilities/edgeResources', 19 | middleware: async (req, res) => { 20 | logger.apiReq(req) 21 | res.sendStatus(204) 22 | } 23 | }, 24 | { 25 | method: 'head', 26 | path: '/api/v3/capabilities/applicationTemplates', 27 | middleware: async (req, res) => { 28 | logger.apiReq(req) 29 | res.sendStatus(204) 30 | } 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /src/schemas/diagnostics.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const straceStateUpdate = { 15 | 'id': '/straceStateUpdate', 16 | 'type': 'object', 17 | 'properties': { 18 | 'enable': { 'type': 'boolean' } 19 | }, 20 | 'required': ['enable'] 21 | } 22 | 23 | const straceGetData = { 24 | 'id': '/straceGetData', 25 | 'type': 'object', 26 | 'properties': { 27 | 'format': { 'enum': ['string', 'file'] } 28 | }, 29 | 'required': ['format'] 30 | } 31 | 32 | const stracePostToFtp = { 33 | 'id': '/stracePostToFtp', 34 | 'type': 'object', 35 | 'properties': { 36 | 'ftpHost': { 'type': 'string' }, 37 | 'ftpPort': { 'type': 'integer', 'minimum': 0 }, 38 | 'ftpUser': { 'type': 'string' }, 39 | 'ftpPass': { 'type': 'string' }, 40 | 'ftpDestDir': { 'type': 'string' } 41 | }, 42 | 'required': ['ftpHost', 'ftpPort', 'ftpUser', 'ftpPass', 'ftpDestDir'] 43 | } 44 | 45 | module.exports = { 46 | mainSchemas: [straceStateUpdate, straceGetData, stracePostToFtp], 47 | innerSchemas: [] 48 | } 49 | -------------------------------------------------------------------------------- /src/schemas/tunnel.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const tunnelCreate = { 15 | 'id': '/tunnelCreate', 16 | 'type': 'object', 17 | 'properties': { 18 | 'iofogUuid': { 'type': 'string' }, 19 | 'username': { 'type': 'string', 'minLength': 1 }, 20 | 'password': { 'type': 'string' }, 21 | 'rsakey': { 'type': 'string' }, 22 | 'lport': { 'type': 'integer', 'minimum': 0, 'maximum': 65535 }, 23 | 'rport': { 'type': 'integer', 'minimum': 0, 'maximum': 65535 } 24 | }, 25 | 'required': ['iofogUuid', 'username', 'password', 'lport', 'rport'] 26 | } 27 | 28 | module.exports = { 29 | mainSchemas: [tunnelCreate] 30 | } 31 | -------------------------------------------------------------------------------- /src/schemas/utils/utils.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-useless-escape */ 2 | module.exports = { 3 | nameRegex: '^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$', 4 | // Supports hex, rgb, and rgba 5 | colorRegex: '^(#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{8}))|(rgb\(\s*(?:(\d{1,3})\s*,?){3}\))|(rgba\(\s*(?:(\d{1,3})\s*,?){4}\))|$', 6 | // https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string 7 | // https://regex101.com/r/vkijKf/380 8 | versionRegex: '^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:[+]([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$' 9 | } 10 | -------------------------------------------------------------------------------- /src/services/access-token-service.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const AccessTokenManager = require('../data/managers/access-token-manager') 15 | 16 | const createAccessToken = async function (accessToken, transaction) { 17 | return AccessTokenManager.create(accessToken, transaction) 18 | } 19 | 20 | const removeAccessTokenByUserId = async function (userId, transaction) { 21 | return AccessTokenManager.delete({ 22 | userId: userId 23 | }, transaction) 24 | } 25 | 26 | module.exports = { 27 | createAccessToken: createAccessToken, 28 | removeAccessTokenByUserId: removeAccessTokenByUserId 29 | } 30 | -------------------------------------------------------------------------------- /src/services/microservice-ports/factory.js: -------------------------------------------------------------------------------- 1 | /* 2 | * ******************************************************************************* 3 | * * Copyright (c) 2020 Edgeworx, Inc. 4 | * * 5 | * * This program and the accompanying materials are made available under the 6 | * * terms of the Eclipse Public License v. 2.0 which is available at 7 | * * http://www.eclipse.org/legal/epl-2.0 8 | * * 9 | * * SPDX-License-Identifier: EPL-2.0 10 | * ******************************************************************************* 11 | * 12 | */ 13 | 14 | const config = require('../../config') 15 | 16 | function createMicroservicePortProvider () { 17 | let provider = process.env.MSVC_PORT_PROVIDER || config.get('PublicPorts:Provider', 'default') 18 | 19 | return require(`./${provider}`) 20 | } 21 | 22 | module.exports = createMicroservicePortProvider() 23 | -------------------------------------------------------------------------------- /test/mocha.opts: -------------------------------------------------------------------------------- 1 | --require test/support/setup.js 2 | --ui bdd-lazy-var/global 3 | --recursive -------------------------------------------------------------------------------- /test/src/template/simple.yml: -------------------------------------------------------------------------------- 1 | 2 | --- 3 | apiVersion: iofog.org/v2 4 | kind: Application 5 | metadata: 6 | name: edai-smartbuilding-rules-engine 7 | spec: 8 | microservices: 9 | - name: rulesengine 10 | container: 11 | rootHostAccess: false 12 | volumes: [] 13 | ports: 14 | - internal: 1881 15 | external: "{{ external-port | toNumber }}" 16 | env: 17 | - key: selfname 18 | value: "{{ self.metadata.name }}" 19 | - key: selfnameU 20 | value: "{{ self.metadata.name | upcase }}" 21 | - key: selfnameA 22 | value: "{{ microservices | first | findMicroserviceAgent | map: \"host\" | first }}" 23 | -------------------------------------------------------------------------------- /test/support/setup.js: -------------------------------------------------------------------------------- 1 | const chai = require('chai') 2 | const chaiAsPromised = require('chai-as-promised') 3 | const chaiHttp = require('chai-http') 4 | const sinonChai = require('sinon-chai') 5 | 6 | process.env.NODE_ENV = 'test' 7 | process.on('unhandledRejection', () => {}) 8 | process.on('rejectionHandled', () => {}) 9 | 10 | MAIN: { 11 | chai.should() 12 | chai.use(chaiAsPromised) 13 | chai.use(chaiHttp) 14 | chai.use(sinonChai) 15 | } 16 | --------------------------------------------------------------------------------