@limetech/n8n-nodes-lime 0.4.0 → 2.3.1-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/lint.yml +3 -1
- package/.github/workflows/release.yml +2 -49
- package/.github/workflows/test-and-build.yml +1 -1
- package/.prettierignore +3 -1
- package/.releaserc.json +2 -1
- package/CHANGELOG.md +215 -0
- package/README.md +2 -9
- package/credentials/LimeCrmApi.credentials.ts +44 -7
- package/credentials/index.ts +2 -0
- package/eslint.config.mjs +2 -1
- package/knip.json +9 -0
- package/nodes/fortnox/Fortnox.node.ts +3 -3
- package/nodes/fortnox/FortnoxTrigger.node.ts +2 -2
- package/nodes/fortnox/index.ts +6 -0
- package/nodes/fortnox/resources/customers/index.ts +18 -22
- package/nodes/fortnox/resources/customers/operations/create.operation.ts +12 -8
- package/nodes/fortnox/resources/customers/operations/delete.operation.ts +10 -15
- package/nodes/fortnox/resources/customers/operations/get.operation.ts +10 -15
- package/nodes/fortnox/resources/customers/operations/getAll.operation.ts +1 -2
- package/nodes/fortnox/resources/customers/operations/index.ts +5 -0
- package/nodes/fortnox/resources/customers/operations/update.operation.ts +30 -30
- package/nodes/fortnox/resources/invoice/index.ts +16 -18
- package/nodes/fortnox/resources/invoice/model.ts +0 -4
- package/nodes/fortnox/resources/invoice/operations/create.operation.ts +1 -2
- package/nodes/fortnox/resources/invoice/operations/get.operation.ts +10 -15
- package/nodes/fortnox/resources/invoice/operations/getAll.operation.ts +1 -2
- package/nodes/fortnox/resources/invoice/operations/index.ts +4 -0
- package/nodes/fortnox/resources/invoice/operations/update.operation.ts +11 -16
- package/nodes/fortnox/transport/index.ts +14 -11
- package/nodes/index.ts +4 -0
- package/nodes/lime-crm/LimeCrmNode.node.ts +126 -69
- package/nodes/lime-crm/LimeCrmTrigger.node.ts +86 -53
- package/nodes/lime-crm/index.ts +9 -0
- package/nodes/lime-crm/methods/getLimetypeProperties.ts +110 -0
- package/nodes/lime-crm/methods/getLimetypes.ts +26 -0
- package/nodes/lime-crm/methods/index.ts +7 -3
- package/nodes/lime-crm/models/constants.ts +73 -0
- package/nodes/lime-crm/models/index.ts +21 -0
- package/nodes/lime-crm/models/limeobject.ts +13 -0
- package/nodes/lime-crm/models/limetype.ts +47 -0
- package/nodes/lime-crm/models/propertyTypes.ts +13 -0
- package/nodes/lime-crm/models/users.ts +46 -0
- package/nodes/lime-crm/models/webhook.ts +61 -0
- package/nodes/lime-crm/resources/admin/index.ts +89 -0
- package/nodes/lime-crm/resources/admin/operations/getManyUsers.operation.ts +166 -0
- package/nodes/lime-crm/resources/admin/operations/getSingleUser.operation.ts +113 -0
- package/nodes/lime-crm/resources/admin/operations/index.ts +8 -0
- package/nodes/lime-crm/resources/data/index.ts +117 -0
- package/nodes/lime-crm/resources/data/operations/createSingleObject.operation.ts +231 -0
- package/nodes/lime-crm/resources/data/operations/deleteSingleObject.operation.ts +83 -0
- package/nodes/lime-crm/resources/data/operations/getManyObjects.operation.ts +499 -0
- package/nodes/lime-crm/resources/data/operations/getSingleFile.operation.ts +162 -0
- package/nodes/lime-crm/resources/data/operations/getSingleObject.operation.ts +116 -0
- package/nodes/lime-crm/resources/data/operations/index.ts +24 -0
- package/nodes/lime-crm/resources/{limeObject/operations/update.operation.ts → data/operations/updateSingleObject.operation.ts} +91 -25
- package/nodes/lime-crm/resources/metadata/index.ts +97 -0
- package/nodes/lime-crm/resources/metadata/operations/getAllLimetypes.operation.ts +28 -0
- package/nodes/lime-crm/resources/metadata/operations/getSingleFileMetadata.operation.ts +147 -0
- package/nodes/lime-crm/resources/metadata/operations/getSingleLimetype.operation.ts +58 -0
- package/nodes/lime-crm/resources/metadata/operations/index.ts +12 -0
- package/nodes/lime-crm/transport/commons.ts +97 -27
- package/nodes/lime-crm/transport/files.ts +220 -0
- package/nodes/lime-crm/transport/index.ts +38 -13
- package/nodes/lime-crm/transport/limeQuery.ts +44 -10
- package/nodes/lime-crm/transport/limeobjects.ts +126 -168
- package/nodes/lime-crm/transport/limetypes.ts +169 -57
- package/nodes/lime-crm/transport/users.ts +264 -0
- package/nodes/lime-crm/transport/webhooks.ts +96 -37
- package/nodes/lime-crm/utils/files.ts +198 -0
- package/nodes/lime-crm/utils/hmac.ts +35 -0
- package/nodes/lime-crm/utils/index.ts +10 -0
- package/nodes/lime-crm/utils/propertyAdapters.ts +75 -0
- package/nodes/lime-crm/utils/webhook.ts +81 -0
- package/nodes/modules.ts +44 -0
- package/nodes/response.ts +16 -0
- package/package.json +21 -29
- package/restore_script/README +42 -0
- package/restore_script/api_key_download.txt +0 -0
- package/restore_script/api_key_upload.txt +0 -0
- package/restore_script/cli.py +73 -0
- package/restore_script/download.py +73 -0
- package/restore_script/main.py +19 -0
- package/restore_script/poetry.lock +162 -0
- package/restore_script/pyproject.toml +15 -0
- package/restore_script/transfer.py +41 -0
- package/restore_script/upload.py +66 -0
- package/restore_script/utils.py +42 -0
- package/tests/nodes/lime-crm/utils.spec.ts +238 -0
- package/typedoc.css +9 -0
- package/typedoc.json +19 -0
- package/.dockerignore +0 -1
- package/Dockerfile +0 -21
- package/dist/credentials/FortnoxApi.credentials.d.ts +0 -9
- package/dist/credentials/FortnoxApi.credentials.js +0 -57
- package/dist/credentials/FortnoxApi.credentials.js.map +0 -1
- package/dist/credentials/LimeCrmApi.credentials.d.ts +0 -9
- package/dist/credentials/LimeCrmApi.credentials.js +0 -66
- package/dist/credentials/LimeCrmApi.credentials.js.map +0 -1
- package/dist/nodes/fortnox/Fortnox.node.d.ts +0 -5
- package/dist/nodes/fortnox/Fortnox.node.js +0 -95
- package/dist/nodes/fortnox/Fortnox.node.js.map +0 -1
- package/dist/nodes/fortnox/Fortnox.node.json +0 -18
- package/dist/nodes/fortnox/FortnoxTrigger.node.d.ts +0 -5
- package/dist/nodes/fortnox/FortnoxTrigger.node.js +0 -155
- package/dist/nodes/fortnox/FortnoxTrigger.node.js.map +0 -1
- package/dist/nodes/fortnox/FortnoxTrigger.node.json +0 -18
- package/dist/nodes/fortnox/commons.d.ts +0 -25
- package/dist/nodes/fortnox/commons.js +0 -44
- package/dist/nodes/fortnox/commons.js.map +0 -1
- package/dist/nodes/fortnox/fortnoxLogo.svg +0 -15
- package/dist/nodes/fortnox/model.d.ts +0 -20
- package/dist/nodes/fortnox/model.js +0 -3
- package/dist/nodes/fortnox/model.js.map +0 -1
- package/dist/nodes/fortnox/resources/customers/filterParameters.d.ts +0 -2
- package/dist/nodes/fortnox/resources/customers/filterParameters.js +0 -31
- package/dist/nodes/fortnox/resources/customers/filterParameters.js.map +0 -1
- package/dist/nodes/fortnox/resources/customers/index.d.ts +0 -20
- package/dist/nodes/fortnox/resources/customers/index.js +0 -87
- package/dist/nodes/fortnox/resources/customers/index.js.map +0 -1
- package/dist/nodes/fortnox/resources/customers/model.d.ts +0 -99
- package/dist/nodes/fortnox/resources/customers/model.js +0 -3
- package/dist/nodes/fortnox/resources/customers/model.js.map +0 -1
- package/dist/nodes/fortnox/resources/customers/operations/create.operation.d.ts +0 -12
- package/dist/nodes/fortnox/resources/customers/operations/create.operation.js +0 -283
- package/dist/nodes/fortnox/resources/customers/operations/create.operation.js.map +0 -1
- package/dist/nodes/fortnox/resources/customers/operations/delete.operation.d.ts +0 -10
- package/dist/nodes/fortnox/resources/customers/operations/delete.operation.js +0 -45
- package/dist/nodes/fortnox/resources/customers/operations/delete.operation.js.map +0 -1
- package/dist/nodes/fortnox/resources/customers/operations/get.operation.d.ts +0 -11
- package/dist/nodes/fortnox/resources/customers/operations/get.operation.js +0 -45
- package/dist/nodes/fortnox/resources/customers/operations/get.operation.js.map +0 -1
- package/dist/nodes/fortnox/resources/customers/operations/getAll.operation.d.ts +0 -11
- package/dist/nodes/fortnox/resources/customers/operations/getAll.operation.js +0 -68
- package/dist/nodes/fortnox/resources/customers/operations/getAll.operation.js.map +0 -1
- package/dist/nodes/fortnox/resources/customers/operations/update.operation.d.ts +0 -12
- package/dist/nodes/fortnox/resources/customers/operations/update.operation.js +0 -276
- package/dist/nodes/fortnox/resources/customers/operations/update.operation.js.map +0 -1
- package/dist/nodes/fortnox/resources/customers/sortParameters.d.ts +0 -2
- package/dist/nodes/fortnox/resources/customers/sortParameters.js +0 -30
- package/dist/nodes/fortnox/resources/customers/sortParameters.js.map +0 -1
- package/dist/nodes/fortnox/resources/invoice/filterParameters.d.ts +0 -2
- package/dist/nodes/fortnox/resources/invoice/filterParameters.js +0 -72
- package/dist/nodes/fortnox/resources/invoice/filterParameters.js.map +0 -1
- package/dist/nodes/fortnox/resources/invoice/index.d.ts +0 -20
- package/dist/nodes/fortnox/resources/invoice/index.js +0 -81
- package/dist/nodes/fortnox/resources/invoice/index.js.map +0 -1
- package/dist/nodes/fortnox/resources/invoice/invoiceParameters.d.ts +0 -2
- package/dist/nodes/fortnox/resources/invoice/invoiceParameters.js +0 -193
- package/dist/nodes/fortnox/resources/invoice/invoiceParameters.js.map +0 -1
- package/dist/nodes/fortnox/resources/invoice/model.d.ts +0 -150
- package/dist/nodes/fortnox/resources/invoice/model.js +0 -3
- package/dist/nodes/fortnox/resources/invoice/model.js.map +0 -1
- package/dist/nodes/fortnox/resources/invoice/operations/create.operation.d.ts +0 -11
- package/dist/nodes/fortnox/resources/invoice/operations/create.operation.js +0 -64
- package/dist/nodes/fortnox/resources/invoice/operations/create.operation.js.map +0 -1
- package/dist/nodes/fortnox/resources/invoice/operations/get.operation.d.ts +0 -11
- package/dist/nodes/fortnox/resources/invoice/operations/get.operation.js +0 -44
- package/dist/nodes/fortnox/resources/invoice/operations/get.operation.js.map +0 -1
- package/dist/nodes/fortnox/resources/invoice/operations/getAll.operation.d.ts +0 -11
- package/dist/nodes/fortnox/resources/invoice/operations/getAll.operation.js +0 -92
- package/dist/nodes/fortnox/resources/invoice/operations/getAll.operation.js.map +0 -1
- package/dist/nodes/fortnox/resources/invoice/operations/update.operation.d.ts +0 -11
- package/dist/nodes/fortnox/resources/invoice/operations/update.operation.js +0 -71
- package/dist/nodes/fortnox/resources/invoice/operations/update.operation.js.map +0 -1
- package/dist/nodes/fortnox/transport/errorCodes.d.ts +0 -1
- package/dist/nodes/fortnox/transport/errorCodes.js +0 -50
- package/dist/nodes/fortnox/transport/errorCodes.js.map +0 -1
- package/dist/nodes/fortnox/transport/index.d.ts +0 -4
- package/dist/nodes/fortnox/transport/index.js +0 -77
- package/dist/nodes/fortnox/transport/index.js.map +0 -1
- package/dist/nodes/lime-crm/LimeCrm.node.json +0 -18
- package/dist/nodes/lime-crm/LimeCrmNode.node.d.ts +0 -14
- package/dist/nodes/lime-crm/LimeCrmNode.node.js +0 -126
- package/dist/nodes/lime-crm/LimeCrmNode.node.js.map +0 -1
- package/dist/nodes/lime-crm/LimeCrmTrigger.node.d.ts +0 -18
- package/dist/nodes/lime-crm/LimeCrmTrigger.node.js +0 -215
- package/dist/nodes/lime-crm/LimeCrmTrigger.node.js.map +0 -1
- package/dist/nodes/lime-crm/assets/lime-crm.svg +0 -1
- package/dist/nodes/lime-crm/commons/constants.d.ts +0 -5
- package/dist/nodes/lime-crm/commons/constants.js +0 -9
- package/dist/nodes/lime-crm/commons/constants.js.map +0 -1
- package/dist/nodes/lime-crm/commons/hmac.d.ts +0 -1
- package/dist/nodes/lime-crm/commons/hmac.js +0 -11
- package/dist/nodes/lime-crm/commons/hmac.js.map +0 -1
- package/dist/nodes/lime-crm/commons/index.d.ts +0 -3
- package/dist/nodes/lime-crm/commons/index.js +0 -12
- package/dist/nodes/lime-crm/commons/index.js.map +0 -1
- package/dist/nodes/lime-crm/commons/limetype.d.ts +0 -10
- package/dist/nodes/lime-crm/commons/limetype.js +0 -3
- package/dist/nodes/lime-crm/commons/limetype.js.map +0 -1
- package/dist/nodes/lime-crm/commons/task.d.ts +0 -14
- package/dist/nodes/lime-crm/commons/task.js +0 -48
- package/dist/nodes/lime-crm/commons/task.js.map +0 -1
- package/dist/nodes/lime-crm/commons/webhook.d.ts +0 -20
- package/dist/nodes/lime-crm/commons/webhook.js +0 -30
- package/dist/nodes/lime-crm/commons/webhook.js.map +0 -1
- package/dist/nodes/lime-crm/methods/getEntitiesForErpSystem.d.ts +0 -5
- package/dist/nodes/lime-crm/methods/getEntitiesForErpSystem.js +0 -11
- package/dist/nodes/lime-crm/methods/getEntitiesForErpSystem.js.map +0 -1
- package/dist/nodes/lime-crm/methods/getLimeTypeProperties.d.ts +0 -2
- package/dist/nodes/lime-crm/methods/getLimeTypeProperties.js +0 -20
- package/dist/nodes/lime-crm/methods/getLimeTypeProperties.js.map +0 -1
- package/dist/nodes/lime-crm/methods/getLimeTypes.d.ts +0 -2
- package/dist/nodes/lime-crm/methods/getLimeTypes.js +0 -20
- package/dist/nodes/lime-crm/methods/getLimeTypes.js.map +0 -1
- package/dist/nodes/lime-crm/methods/index.d.ts +0 -3
- package/dist/nodes/lime-crm/methods/index.js +0 -10
- package/dist/nodes/lime-crm/methods/index.js.map +0 -1
- package/dist/nodes/lime-crm/resources/erpConnector/index.d.ts +0 -23
- package/dist/nodes/lime-crm/resources/erpConnector/index.js +0 -67
- package/dist/nodes/lime-crm/resources/erpConnector/index.js.map +0 -1
- package/dist/nodes/lime-crm/resources/erpConnector/operations/createOrUpdateObjects.operation.d.ts +0 -26
- package/dist/nodes/lime-crm/resources/erpConnector/operations/createOrUpdateObjects.operation.js +0 -65
- package/dist/nodes/lime-crm/resources/erpConnector/operations/createOrUpdateObjects.operation.js.map +0 -1
- package/dist/nodes/lime-crm/resources/erpConnector/operations/transform.operation.d.ts +0 -9
- package/dist/nodes/lime-crm/resources/erpConnector/operations/transform.operation.js +0 -220
- package/dist/nodes/lime-crm/resources/erpConnector/operations/transform.operation.js.map +0 -1
- package/dist/nodes/lime-crm/resources/erpConnector/transform.d.ts +0 -15
- package/dist/nodes/lime-crm/resources/erpConnector/transform.js +0 -11
- package/dist/nodes/lime-crm/resources/erpConnector/transform.js.map +0 -1
- package/dist/nodes/lime-crm/resources/erpConnector/transformers/baseTransformer.d.ts +0 -4
- package/dist/nodes/lime-crm/resources/erpConnector/transformers/baseTransformer.js +0 -7
- package/dist/nodes/lime-crm/resources/erpConnector/transformers/baseTransformer.js.map +0 -1
- package/dist/nodes/lime-crm/resources/erpConnector/transformers/fortnox.d.ts +0 -37
- package/dist/nodes/lime-crm/resources/erpConnector/transformers/fortnox.js +0 -124
- package/dist/nodes/lime-crm/resources/erpConnector/transformers/fortnox.js.map +0 -1
- package/dist/nodes/lime-crm/resources/erpConnector/transformers/index.d.ts +0 -1
- package/dist/nodes/lime-crm/resources/erpConnector/transformers/index.js +0 -6
- package/dist/nodes/lime-crm/resources/erpConnector/transformers/index.js.map +0 -1
- package/dist/nodes/lime-crm/resources/limeObject/index.d.ts +0 -14
- package/dist/nodes/lime-crm/resources/limeObject/index.js +0 -88
- package/dist/nodes/lime-crm/resources/limeObject/index.js.map +0 -1
- package/dist/nodes/lime-crm/resources/limeObject/operations/create.operation.d.ts +0 -9
- package/dist/nodes/lime-crm/resources/limeObject/operations/create.operation.js +0 -139
- package/dist/nodes/lime-crm/resources/limeObject/operations/create.operation.js.map +0 -1
- package/dist/nodes/lime-crm/resources/limeObject/operations/delete.operation.d.ts +0 -9
- package/dist/nodes/lime-crm/resources/limeObject/operations/delete.operation.js +0 -51
- package/dist/nodes/lime-crm/resources/limeObject/operations/delete.operation.js.map +0 -1
- package/dist/nodes/lime-crm/resources/limeObject/operations/fetchMany.operation.d.ts +0 -9
- package/dist/nodes/lime-crm/resources/limeObject/operations/fetchMany.operation.js +0 -103
- package/dist/nodes/lime-crm/resources/limeObject/operations/fetchMany.operation.js.map +0 -1
- package/dist/nodes/lime-crm/resources/limeObject/operations/get.operation.d.ts +0 -9
- package/dist/nodes/lime-crm/resources/limeObject/operations/get.operation.js +0 -51
- package/dist/nodes/lime-crm/resources/limeObject/operations/get.operation.js.map +0 -1
- package/dist/nodes/lime-crm/resources/limeObject/operations/search.operation.d.ts +0 -9
- package/dist/nodes/lime-crm/resources/limeObject/operations/search.operation.js +0 -103
- package/dist/nodes/lime-crm/resources/limeObject/operations/search.operation.js.map +0 -1
- package/dist/nodes/lime-crm/resources/limeObject/operations/update.operation.d.ts +0 -9
- package/dist/nodes/lime-crm/resources/limeObject/operations/update.operation.js +0 -149
- package/dist/nodes/lime-crm/resources/limeObject/operations/update.operation.js.map +0 -1
- package/dist/nodes/lime-crm/resources/limeQuery/index.d.ts +0 -6
- package/dist/nodes/lime-crm/resources/limeQuery/index.js +0 -66
- package/dist/nodes/lime-crm/resources/limeQuery/index.js.map +0 -1
- package/dist/nodes/lime-crm/resources/limeQuery/operations/query.operation.d.ts +0 -9
- package/dist/nodes/lime-crm/resources/limeQuery/operations/query.operation.js +0 -191
- package/dist/nodes/lime-crm/resources/limeQuery/operations/query.operation.js.map +0 -1
- package/dist/nodes/lime-crm/resources/limeType/index.d.ts +0 -20
- package/dist/nodes/lime-crm/resources/limeType/index.js +0 -81
- package/dist/nodes/lime-crm/resources/limeType/index.js.map +0 -1
- package/dist/nodes/lime-crm/resources/limeType/operations/getProperties.operation.d.ts +0 -11
- package/dist/nodes/lime-crm/resources/limeType/operations/getProperties.operation.js +0 -36
- package/dist/nodes/lime-crm/resources/limeType/operations/getProperties.operation.js.map +0 -1
- package/dist/nodes/lime-crm/resources/limeType/operations/getType.operation.d.ts +0 -9
- package/dist/nodes/lime-crm/resources/limeType/operations/getType.operation.js +0 -36
- package/dist/nodes/lime-crm/resources/limeType/operations/getType.operation.js.map +0 -1
- package/dist/nodes/lime-crm/resources/limeType/operations/listTypes.operation.d.ts +0 -10
- package/dist/nodes/lime-crm/resources/limeType/operations/listTypes.operation.js +0 -15
- package/dist/nodes/lime-crm/resources/limeType/operations/listTypes.operation.js.map +0 -1
- package/dist/nodes/lime-crm/transport/commons.d.ts +0 -5
- package/dist/nodes/lime-crm/transport/commons.js +0 -33
- package/dist/nodes/lime-crm/transport/commons.js.map +0 -1
- package/dist/nodes/lime-crm/transport/erpConnector.d.ts +0 -9
- package/dist/nodes/lime-crm/transport/erpConnector.js +0 -11
- package/dist/nodes/lime-crm/transport/erpConnector.js.map +0 -1
- package/dist/nodes/lime-crm/transport/index.d.ts +0 -6
- package/dist/nodes/lime-crm/transport/index.js +0 -24
- package/dist/nodes/lime-crm/transport/index.js.map +0 -1
- package/dist/nodes/lime-crm/transport/limeQuery.d.ts +0 -10
- package/dist/nodes/lime-crm/transport/limeQuery.js +0 -15
- package/dist/nodes/lime-crm/transport/limeQuery.js.map +0 -1
- package/dist/nodes/lime-crm/transport/limeobjects.d.ts +0 -7
- package/dist/nodes/lime-crm/transport/limeobjects.js +0 -134
- package/dist/nodes/lime-crm/transport/limeobjects.js.map +0 -1
- package/dist/nodes/lime-crm/transport/limetypes.d.ts +0 -6
- package/dist/nodes/lime-crm/transport/limetypes.js +0 -54
- package/dist/nodes/lime-crm/transport/limetypes.js.map +0 -1
- package/dist/nodes/lime-crm/transport/task.d.ts +0 -13
- package/dist/nodes/lime-crm/transport/task.js +0 -13
- package/dist/nodes/lime-crm/transport/task.js.map +0 -1
- package/dist/nodes/lime-crm/transport/webhooks.d.ts +0 -16
- package/dist/nodes/lime-crm/transport/webhooks.js +0 -43
- package/dist/nodes/lime-crm/transport/webhooks.js.map +0 -1
- package/dist/nodes/nodeResponse.d.ts +0 -12
- package/dist/nodes/nodeResponse.js +0 -3
- package/dist/nodes/nodeResponse.js.map +0 -1
- package/dist/package.json +0 -75
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/docker-compose.yml +0 -46
- package/nodes/lime-crm/commons/constants.ts +0 -10
- package/nodes/lime-crm/commons/hmac.ts +0 -13
- package/nodes/lime-crm/commons/index.ts +0 -10
- package/nodes/lime-crm/commons/limetype.ts +0 -11
- package/nodes/lime-crm/commons/task.ts +0 -55
- package/nodes/lime-crm/commons/webhook.ts +0 -56
- package/nodes/lime-crm/methods/getEntitiesForErpSystem.ts +0 -11
- package/nodes/lime-crm/methods/getLimeTypeProperties.ts +0 -27
- package/nodes/lime-crm/methods/getLimeTypes.ts +0 -23
- package/nodes/lime-crm/resources/erpConnector/index.ts +0 -43
- package/nodes/lime-crm/resources/erpConnector/operations/createOrUpdateObjects.operation.ts +0 -69
- package/nodes/lime-crm/resources/erpConnector/operations/transform.operation.ts +0 -274
- package/nodes/lime-crm/resources/erpConnector/transform.ts +0 -49
- package/nodes/lime-crm/resources/erpConnector/transformers/baseTransformer.ts +0 -18
- package/nodes/lime-crm/resources/erpConnector/transformers/fortnox.ts +0 -201
- package/nodes/lime-crm/resources/erpConnector/transformers/index.ts +0 -1
- package/nodes/lime-crm/resources/limeObject/index.ts +0 -64
- package/nodes/lime-crm/resources/limeObject/operations/create.operation.ts +0 -152
- package/nodes/lime-crm/resources/limeObject/operations/delete.operation.ts +0 -55
- package/nodes/lime-crm/resources/limeObject/operations/fetchMany.operation.ts +0 -112
- package/nodes/lime-crm/resources/limeObject/operations/get.operation.ts +0 -54
- package/nodes/lime-crm/resources/limeQuery/index.ts +0 -40
- package/nodes/lime-crm/resources/limeQuery/operations/query.operation.ts +0 -222
- package/nodes/lime-crm/resources/limeType/index.ts +0 -58
- package/nodes/lime-crm/resources/limeType/operations/getProperties.operation.ts +0 -42
- package/nodes/lime-crm/resources/limeType/operations/getType.operation.ts +0 -36
- package/nodes/lime-crm/resources/limeType/operations/listTypes.operation.ts +0 -18
- package/nodes/lime-crm/transport/erpConnector.ts +0 -21
- package/nodes/lime-crm/transport/task.ts +0 -32
- package/nodes/nodeResponse.ts +0 -13
- package/tests/fixtures/fortnox.ts +0 -182
- package/tests/transform.spec.ts +0 -187
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { callLimeApi } from './commons';
|
|
2
|
+
import {
|
|
3
|
+
IAllExecuteFunctions,
|
|
4
|
+
LoggerProxy as Logger,
|
|
5
|
+
NodeOperationError,
|
|
6
|
+
} from 'n8n-workflow';
|
|
7
|
+
import {
|
|
8
|
+
User,
|
|
9
|
+
UserType,
|
|
10
|
+
DEFAULT_API_OBJECT_LIMIT,
|
|
11
|
+
NullOptionType,
|
|
12
|
+
Limetype,
|
|
13
|
+
} from '../models';
|
|
14
|
+
import { getLimetypesFromApi } from './limetypes';
|
|
15
|
+
import { queryLimeobjects, QueryResponse } from './limeQuery';
|
|
16
|
+
import { getLimeobject } from './limeobjects';
|
|
17
|
+
|
|
18
|
+
const USERS_URL = 'api/v1/admin/users/';
|
|
19
|
+
|
|
20
|
+
type UserQueryParameters = {
|
|
21
|
+
active?: boolean;
|
|
22
|
+
user_type?: UserType;
|
|
23
|
+
_limit: number;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Finds limetype that has a property of type 'user'.
|
|
28
|
+
* There should only be one such limetype in the system.
|
|
29
|
+
*
|
|
30
|
+
* @param limetypes - Array of limetype objects to search through
|
|
31
|
+
* @returns The first limetype with a 'user' property, or undefined if not found
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
function findCoworkerLimetype(limetypes: Limetype[]): Limetype | undefined {
|
|
35
|
+
for (const limetype of limetypes) {
|
|
36
|
+
for (const property of limetype.properties) {
|
|
37
|
+
if (property.type === 'user') {
|
|
38
|
+
Logger.info('Found coworker limetype');
|
|
39
|
+
return limetype;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
Logger.warn('No coworker limetype found');
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the coworker limetype from the API.
|
|
49
|
+
*
|
|
50
|
+
* @param nodeContext - The n8n execution context
|
|
51
|
+
* @returns The coworker limetype object
|
|
52
|
+
* @throws NodeOperationError if no coworker limetype is found
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
async function findCoworker(
|
|
56
|
+
nodeContext: IAllExecuteFunctions
|
|
57
|
+
): Promise<Limetype> {
|
|
58
|
+
const response = await getLimetypesFromApi(nodeContext);
|
|
59
|
+
const coworker = findCoworkerLimetype(response);
|
|
60
|
+
if (!coworker) {
|
|
61
|
+
throw new NodeOperationError(
|
|
62
|
+
nodeContext.getNode(),
|
|
63
|
+
`No limetype with 'user' property found to get coworker`
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
return coworker;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Fetches coworker data for a given user.
|
|
71
|
+
*
|
|
72
|
+
* @param nodeContext - The n8n execution context
|
|
73
|
+
* @param coworker - The limetype definition for the coworker
|
|
74
|
+
* @param userId - The ID of the user whose coworker data is to be fetched
|
|
75
|
+
* @returns The coworker data response from the Lime Query API
|
|
76
|
+
* @throws NodeOperationError if no 'user' property is found in the coworker limetype
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
async function getCoworker(
|
|
80
|
+
nodeContext: IAllExecuteFunctions,
|
|
81
|
+
coworker: Limetype,
|
|
82
|
+
userId: string | number
|
|
83
|
+
): Promise<QueryResponse> {
|
|
84
|
+
// 'hasmany' properties are not supported in the response format of Lime Query API
|
|
85
|
+
const properties = Object.fromEntries(
|
|
86
|
+
coworker.properties
|
|
87
|
+
.filter((prop) => prop.type !== 'hasmany')
|
|
88
|
+
.map((prop) => [prop.name, ''])
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const userProperty = coworker.properties.find(
|
|
92
|
+
(prop) => prop.type === 'user'
|
|
93
|
+
);
|
|
94
|
+
if (!userProperty) {
|
|
95
|
+
throw new NodeOperationError(
|
|
96
|
+
nodeContext.getNode(),
|
|
97
|
+
`No property of type 'user' found in ${coworker.name} limetype`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const responseFormat = {
|
|
102
|
+
object: properties,
|
|
103
|
+
};
|
|
104
|
+
const filter = {
|
|
105
|
+
key: userProperty.name,
|
|
106
|
+
op: '=',
|
|
107
|
+
exp: userId,
|
|
108
|
+
};
|
|
109
|
+
const q = JSON.stringify({
|
|
110
|
+
limetype: coworker.name,
|
|
111
|
+
responseFormat: responseFormat,
|
|
112
|
+
filter: filter,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
return await queryLimeobjects(nodeContext, q);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Fetch the Lime CRM users with given parameters.
|
|
120
|
+
*
|
|
121
|
+
* @param nodeContext - The n8n execution context
|
|
122
|
+
* @param active - flag used to filtering by active or inactive users
|
|
123
|
+
* @param userType - a type of a user defined in the {@link UserType} class
|
|
124
|
+
* @param limit - max number of users returned by the API call, default is 50
|
|
125
|
+
* @param withCoworker - whether to include coworker data linked to the user
|
|
126
|
+
*
|
|
127
|
+
* @returns List of {@link User} objects
|
|
128
|
+
* @public
|
|
129
|
+
* @group Transport
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
export async function fetchManyUsers(
|
|
133
|
+
nodeContext: IAllExecuteFunctions,
|
|
134
|
+
active: boolean | NullOptionType = '',
|
|
135
|
+
userType: UserType | NullOptionType = '',
|
|
136
|
+
limit: number = DEFAULT_API_OBJECT_LIMIT,
|
|
137
|
+
withCoworker: boolean = false
|
|
138
|
+
): Promise<User[]> {
|
|
139
|
+
const queryParams: UserQueryParameters = {
|
|
140
|
+
_limit: limit,
|
|
141
|
+
};
|
|
142
|
+
if (active !== '') {
|
|
143
|
+
queryParams.active = active;
|
|
144
|
+
}
|
|
145
|
+
if (userType !== '') {
|
|
146
|
+
queryParams.user_type = userType;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const response = await callLimeApi<User[]>(nodeContext, {
|
|
150
|
+
method: 'GET',
|
|
151
|
+
url: USERS_URL,
|
|
152
|
+
requestOptions: {
|
|
153
|
+
qs: queryParams,
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
if (!withCoworker) return response;
|
|
158
|
+
const coworker = await findCoworker(nodeContext);
|
|
159
|
+
|
|
160
|
+
const usersWithCoworkers: User[] = [];
|
|
161
|
+
for (const user of response) {
|
|
162
|
+
const coworkerResponse = await getCoworker(
|
|
163
|
+
nodeContext,
|
|
164
|
+
coworker,
|
|
165
|
+
user.id
|
|
166
|
+
);
|
|
167
|
+
usersWithCoworkers.push({
|
|
168
|
+
...user,
|
|
169
|
+
[coworker.name]: coworkerResponse.objects[0] || null,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return usersWithCoworkers;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Fetch the single Lime CRM User by ID.
|
|
178
|
+
*
|
|
179
|
+
* @param nodeContext - The n8n execution context
|
|
180
|
+
* @param id - Lime CRM user's ID
|
|
181
|
+
* @param withCoworker - whether to include coworker data linked to the user
|
|
182
|
+
*
|
|
183
|
+
* @returns A {@link User} object
|
|
184
|
+
* @public
|
|
185
|
+
* @group Transport
|
|
186
|
+
*/
|
|
187
|
+
|
|
188
|
+
export async function fetchSingleUserById(
|
|
189
|
+
nodeContext: IAllExecuteFunctions,
|
|
190
|
+
id: string,
|
|
191
|
+
withCoworker: boolean = false
|
|
192
|
+
): Promise<User> {
|
|
193
|
+
const url = `${USERS_URL}${id}`;
|
|
194
|
+
const userResponse = await callLimeApi<User>(nodeContext, {
|
|
195
|
+
method: 'GET',
|
|
196
|
+
url: url,
|
|
197
|
+
errorMetadata: {
|
|
198
|
+
user_id: id,
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
if (!withCoworker) return userResponse;
|
|
203
|
+
const coworker = await findCoworker(nodeContext);
|
|
204
|
+
const coworkerResponse = await getCoworker(nodeContext, coworker, id);
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
...userResponse,
|
|
208
|
+
[coworker.name]: coworkerResponse.objects[0] || null,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Fetch a single Lime CRM User by the related limeobject ID.
|
|
214
|
+
*
|
|
215
|
+
* This function retrieves a user based on the ID of a related limeobject.
|
|
216
|
+
* It could be only one object related to the user in the system, most often it is the
|
|
217
|
+
* 'coworker' limetype. The corresponding limetype is determined automatically.
|
|
218
|
+
*
|
|
219
|
+
* @param nodeContext - The n8n execution context
|
|
220
|
+
* @param id - The ID of the coworker limeobject
|
|
221
|
+
* @param withCoworker - Whether to include coworker data linked to the user (default: false)
|
|
222
|
+
*
|
|
223
|
+
* @returns A {@link User} object, optionally with coworker data
|
|
224
|
+
* @public
|
|
225
|
+
* @group Transport
|
|
226
|
+
*/
|
|
227
|
+
export async function fetchSingleUserByLimeobjectId(
|
|
228
|
+
nodeContext: IAllExecuteFunctions,
|
|
229
|
+
id: string,
|
|
230
|
+
withCoworker: boolean = false
|
|
231
|
+
): Promise<User> {
|
|
232
|
+
const coworker = await findCoworker(nodeContext);
|
|
233
|
+
const coworkerResponse = await getLimeobject(
|
|
234
|
+
nodeContext,
|
|
235
|
+
coworker.name,
|
|
236
|
+
id
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
const userProperty = coworker.properties.find(
|
|
240
|
+
(prop) => prop.type === 'user'
|
|
241
|
+
);
|
|
242
|
+
if (!userProperty) {
|
|
243
|
+
throw new NodeOperationError(
|
|
244
|
+
nodeContext.getNode(),
|
|
245
|
+
`No property of type 'user' found in ${coworker.name} limetype`
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const url = `${USERS_URL}${coworkerResponse[userProperty.name]}`;
|
|
250
|
+
const userResponse = await callLimeApi<User>(nodeContext, {
|
|
251
|
+
method: 'GET',
|
|
252
|
+
url: url,
|
|
253
|
+
errorMetadata: {
|
|
254
|
+
user_id: id,
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
if (!withCoworker) return userResponse;
|
|
259
|
+
|
|
260
|
+
return {
|
|
261
|
+
...userResponse,
|
|
262
|
+
[coworker.name]: coworkerResponse || null,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
import { Webhook } from '../commons';
|
|
2
1
|
import { callLimeApi } from '.';
|
|
3
2
|
import { IAllExecuteFunctions } from 'n8n-workflow';
|
|
4
|
-
import {
|
|
5
|
-
import { CreateWebhook } from '../commons/webhook';
|
|
3
|
+
import { CreateWebhook, Webhook } from '../models';
|
|
6
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Endpoint path for Lime CRM Subscription API.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
* @group Transport
|
|
10
|
+
*/
|
|
7
11
|
const SUBSCRIPTION_URL = 'api/v1/subscription/';
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Representation of response format for a Lime CRM webhook subscription.
|
|
15
|
+
*
|
|
16
|
+
* @property {string} id - Unique identifier of the subscription
|
|
17
|
+
* @property {string} name - Name of the subscription
|
|
18
|
+
* @property {boolean} enabled - Whether the subscription is currently enabled
|
|
19
|
+
* @property {string[]} events - List of events the subscription is listening for
|
|
20
|
+
* @property {string} target_url - Target URL for the webhook
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
* @group Transport
|
|
24
|
+
*/
|
|
25
|
+
export interface ApiResponseWebhook {
|
|
10
26
|
id: string;
|
|
11
27
|
name: string;
|
|
12
28
|
enabled: boolean;
|
|
@@ -14,61 +30,104 @@ interface ApiResponseWebhook {
|
|
|
14
30
|
target_url: string;
|
|
15
31
|
}
|
|
16
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Retrieve details of a specific subscription from Lime CRM.
|
|
35
|
+
*
|
|
36
|
+
* @param nodeContext - The n8n node execution context
|
|
37
|
+
* @param webhook - The webhook object containing subscription details
|
|
38
|
+
*
|
|
39
|
+
* @returns The subscription information from Lime CRM.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
* @group Transport
|
|
43
|
+
*/
|
|
17
44
|
export async function getSubscription(
|
|
18
45
|
nodeContext: IAllExecuteFunctions,
|
|
19
46
|
webhook: Webhook
|
|
20
|
-
): Promise<
|
|
21
|
-
return await callLimeApi(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
);
|
|
47
|
+
): Promise<ApiResponseWebhook> {
|
|
48
|
+
return await callLimeApi(nodeContext, {
|
|
49
|
+
method: 'GET',
|
|
50
|
+
url: `${SUBSCRIPTION_URL}${webhook.data.webhookId}`,
|
|
51
|
+
});
|
|
26
52
|
}
|
|
27
53
|
|
|
54
|
+
/**
|
|
55
|
+
* List all active subscriptions that match the given webhook events and target URL.
|
|
56
|
+
*
|
|
57
|
+
* @param nodeContext - The n8n node execution context
|
|
58
|
+
* @param webhook - The webhook instance containing event and URL information
|
|
59
|
+
*
|
|
60
|
+
* @returns Array of subscription objects from Lime CRM.
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
* @group Transport
|
|
64
|
+
*/
|
|
28
65
|
export async function listSubscriptionsWithExistingData(
|
|
29
66
|
nodeContext: IAllExecuteFunctions,
|
|
30
67
|
webhook: Webhook
|
|
31
|
-
): Promise<
|
|
32
|
-
return await callLimeApi(nodeContext,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
68
|
+
): Promise<ApiResponseWebhook[]> {
|
|
69
|
+
return await callLimeApi(nodeContext, {
|
|
70
|
+
method: 'GET',
|
|
71
|
+
url: SUBSCRIPTION_URL,
|
|
72
|
+
requestOptions: {
|
|
73
|
+
qs: {
|
|
74
|
+
events: webhook.events.join(','),
|
|
75
|
+
target_url: webhook.url,
|
|
76
|
+
enabled: true,
|
|
77
|
+
},
|
|
37
78
|
},
|
|
38
79
|
});
|
|
39
80
|
}
|
|
40
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Creates a new webhook subscription in Lime CRM.
|
|
84
|
+
*
|
|
85
|
+
* @param nodeContext - The n8n node execution context.
|
|
86
|
+
* @param webhook - The webhook configuration to create.
|
|
87
|
+
*
|
|
88
|
+
* @returns The newly created subscription object.
|
|
89
|
+
*
|
|
90
|
+
* @public
|
|
91
|
+
* @group Transport
|
|
92
|
+
*/
|
|
41
93
|
export async function createSubscription(
|
|
42
94
|
nodeContext: IAllExecuteFunctions,
|
|
43
95
|
webhook: CreateWebhook
|
|
44
|
-
): Promise<
|
|
45
|
-
return await callLimeApi(nodeContext,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
96
|
+
): Promise<ApiResponseWebhook> {
|
|
97
|
+
return await callLimeApi(nodeContext, {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
url: SUBSCRIPTION_URL,
|
|
100
|
+
requestOptions: {
|
|
101
|
+
body: {
|
|
102
|
+
events: webhook.events,
|
|
103
|
+
target_url: webhook.url,
|
|
104
|
+
name: webhook.name,
|
|
105
|
+
secret: webhook.secret,
|
|
106
|
+
},
|
|
51
107
|
},
|
|
52
108
|
});
|
|
53
109
|
}
|
|
54
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Delete a webhook subscription from Lime CRM.
|
|
113
|
+
*
|
|
114
|
+
* @param nodeContext - The n8n node execution context
|
|
115
|
+
* @param webhook - The webhook object identifying the subscription to delete
|
|
116
|
+
*
|
|
117
|
+
* @returns Response indicating success or failure of the deletion.
|
|
118
|
+
*
|
|
119
|
+
* @public
|
|
120
|
+
* @group Transport
|
|
121
|
+
*/
|
|
55
122
|
export async function deleteSubscription(
|
|
56
123
|
nodeContext: IAllExecuteFunctions,
|
|
57
124
|
webhook: Webhook
|
|
58
|
-
): Promise<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
if (response.success) return response;
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
...response,
|
|
69
|
-
metadata: {
|
|
70
|
-
...response.metadata,
|
|
125
|
+
): Promise<void> {
|
|
126
|
+
return await callLimeApi(nodeContext, {
|
|
127
|
+
method: 'DELETE',
|
|
128
|
+
url: `${SUBSCRIPTION_URL}${webhook.data.webhookId}/`,
|
|
129
|
+
errorMetadata: {
|
|
71
130
|
id: webhook.data.webhookId,
|
|
72
131
|
},
|
|
73
|
-
};
|
|
132
|
+
});
|
|
74
133
|
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IBinaryData,
|
|
3
|
+
IDataObject,
|
|
4
|
+
IExecuteFunctions,
|
|
5
|
+
LoggerProxy as Logger,
|
|
6
|
+
} from 'n8n-workflow';
|
|
7
|
+
import { createFile, getFileContent, getFileMetadata } from '../transport';
|
|
8
|
+
import { FileResponse } from '../../response';
|
|
9
|
+
import { LimetypeProperty } from '../models';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Set a default file name if missing.
|
|
13
|
+
*
|
|
14
|
+
* @param preparedBinaryData - The binary data object
|
|
15
|
+
* @param responseFileName -The fallback file name to assign if the binary data has no name
|
|
16
|
+
*
|
|
17
|
+
* @returns Set filename
|
|
18
|
+
* @public
|
|
19
|
+
* @group Utils
|
|
20
|
+
*/
|
|
21
|
+
export const setFilename = (
|
|
22
|
+
preparedBinaryData: IBinaryData,
|
|
23
|
+
responseFileName: string
|
|
24
|
+
) => {
|
|
25
|
+
if (!preparedBinaryData.fileName && preparedBinaryData.fileExtension) {
|
|
26
|
+
return responseFileName;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return preparedBinaryData.fileName;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Extract a filename from the `Content-Disposition` HTTP header.
|
|
34
|
+
*
|
|
35
|
+
* @param headers - An object containing HTTP headers, where the key may be either
|
|
36
|
+
* `'content-disposition'` or `'Content-Disposition'`
|
|
37
|
+
*
|
|
38
|
+
* @returns Filename or `null` if the header does not contain one
|
|
39
|
+
* @public
|
|
40
|
+
* @group Utils
|
|
41
|
+
*/
|
|
42
|
+
export function getFilenameFromHeader(
|
|
43
|
+
headers: Record<string, string | string[] | undefined>
|
|
44
|
+
): string | null {
|
|
45
|
+
let contentDisposition =
|
|
46
|
+
headers['content-disposition'] || headers['Content-Disposition'];
|
|
47
|
+
if (!contentDisposition) return null;
|
|
48
|
+
|
|
49
|
+
if (Array.isArray(contentDisposition)) {
|
|
50
|
+
contentDisposition = contentDisposition[0];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Try RFC 5987 filename* format
|
|
54
|
+
const filenameStarMatch = /filename\*\s*=\s*UTF-8''([^;]+)/i.exec(
|
|
55
|
+
contentDisposition
|
|
56
|
+
);
|
|
57
|
+
if (filenameStarMatch) {
|
|
58
|
+
try {
|
|
59
|
+
return decodeURIComponent(filenameStarMatch[1]);
|
|
60
|
+
} catch {
|
|
61
|
+
return filenameStarMatch[1];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Try regular filename="..." or filename=...
|
|
66
|
+
const filenameMatch =
|
|
67
|
+
/filename\s*=\s*"([^"]+)"|filename\s*=\s*([^;]+)/i.exec(
|
|
68
|
+
contentDisposition
|
|
69
|
+
);
|
|
70
|
+
if (filenameMatch) {
|
|
71
|
+
return filenameMatch[1] || filenameMatch[2];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Retrieve all file properties names for a given Limetype
|
|
79
|
+
* and optionally filter by a set of allowed property names.
|
|
80
|
+
*
|
|
81
|
+
* @param properties - the {@link LimeTypeProperty} object array fetched from Lime CRM
|
|
82
|
+
* @param allowedProperties - An optional set of property names to include in the result
|
|
83
|
+
*
|
|
84
|
+
* @returns A set containing the names of all matching file-type properties.
|
|
85
|
+
* @public
|
|
86
|
+
* @group Utils
|
|
87
|
+
*/
|
|
88
|
+
export function getFilePropertiesNames(
|
|
89
|
+
properties: LimetypeProperty[],
|
|
90
|
+
allowedProperties?: Set<string>
|
|
91
|
+
): Set<string> {
|
|
92
|
+
return new Set(
|
|
93
|
+
properties
|
|
94
|
+
.filter(
|
|
95
|
+
(property) =>
|
|
96
|
+
property.type === 'file' &&
|
|
97
|
+
(!allowedProperties || allowedProperties.has(property.name))
|
|
98
|
+
)
|
|
99
|
+
.map((property) => property.name)
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Iterate through all file properties, checks whether
|
|
105
|
+
* the corresponding values represent valid binary data, and uploads them.
|
|
106
|
+
* When a file is successfully uploaded, its property value is replaced with the returned file ID.
|
|
107
|
+
*
|
|
108
|
+
* @param context - The n8n node execution context
|
|
109
|
+
* @param i - The index of the current item being processed
|
|
110
|
+
* @param fileProperties - A set of Limeobject property names that are of type `'file'`
|
|
111
|
+
* @param definedProperties - An object containing property values
|
|
112
|
+
*
|
|
113
|
+
* @returns A response object indicating whether the operation succeeded and containing
|
|
114
|
+
* the updated properties.
|
|
115
|
+
*
|
|
116
|
+
* @public
|
|
117
|
+
* @group Utils
|
|
118
|
+
*/
|
|
119
|
+
export async function setFileProperties(
|
|
120
|
+
context: IExecuteFunctions,
|
|
121
|
+
i: number,
|
|
122
|
+
fileProperties: Set<string>,
|
|
123
|
+
definedProperties: IDataObject
|
|
124
|
+
): Promise<IDataObject> {
|
|
125
|
+
for (const fileProperty of fileProperties) {
|
|
126
|
+
if (!(fileProperty in definedProperties)) continue;
|
|
127
|
+
let binaryData: IBinaryData;
|
|
128
|
+
try {
|
|
129
|
+
Logger.info(
|
|
130
|
+
`Checking whether "${definedProperties[fileProperty]}" is a valid binary object for property "${fileProperty}"...`
|
|
131
|
+
);
|
|
132
|
+
binaryData = context.helpers.assertBinaryData(
|
|
133
|
+
i,
|
|
134
|
+
definedProperties[fileProperty] as string
|
|
135
|
+
);
|
|
136
|
+
} catch {
|
|
137
|
+
Logger.info(
|
|
138
|
+
`Invalid or missing binary data for "${fileProperty}". Using original value instead.`
|
|
139
|
+
);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const response = await createFile(
|
|
144
|
+
context,
|
|
145
|
+
binaryData,
|
|
146
|
+
definedProperties[fileProperty] as string
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
definedProperties[fileProperty] = response.id;
|
|
150
|
+
}
|
|
151
|
+
return definedProperties;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Update file properties with a file metadata and optionally retrieves file content.
|
|
156
|
+
*
|
|
157
|
+
* @param nodeContext - The n8n node execution context
|
|
158
|
+
* @param fileProperties - A set of file property names to process
|
|
159
|
+
* @param data - The record data containing property values to process
|
|
160
|
+
* @param includeFileContent - Whether to include the actual file content in the response. Defaults to `false`
|
|
161
|
+
*
|
|
162
|
+
* @returns A {@link FileResponse} object containing updated JSON data and, if requested, the associated binary files.
|
|
163
|
+
*
|
|
164
|
+
* @public
|
|
165
|
+
* @group Utils
|
|
166
|
+
*/
|
|
167
|
+
export async function processFileResponse<T extends Record<string, unknown>>(
|
|
168
|
+
nodeContext: IExecuteFunctions,
|
|
169
|
+
fileProperties: Set<string>,
|
|
170
|
+
data: T,
|
|
171
|
+
includeFileContent: boolean = false
|
|
172
|
+
): Promise<FileResponse<T>> {
|
|
173
|
+
let updatedData = { ...data };
|
|
174
|
+
const binaryData: Record<string, IBinaryData> = {};
|
|
175
|
+
for (const fileProperty of fileProperties) {
|
|
176
|
+
if (!data[fileProperty]) continue;
|
|
177
|
+
const fileMetadataResponse = await getFileMetadata(
|
|
178
|
+
nodeContext,
|
|
179
|
+
data[fileProperty] as string
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
updatedData = {
|
|
183
|
+
...updatedData,
|
|
184
|
+
[fileProperty]: fileMetadataResponse,
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
if (includeFileContent) {
|
|
188
|
+
binaryData[fileProperty] = await getFileContent(
|
|
189
|
+
nodeContext,
|
|
190
|
+
fileMetadataResponse.id
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
json: updatedData,
|
|
196
|
+
binary: binaryData,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createHmac } from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generate an HMAC SHA-256 hash for the given data using the provided key.
|
|
5
|
+
*
|
|
6
|
+
* @param key - The secret key used to generate the HMAC
|
|
7
|
+
* @param data - The data to hash
|
|
8
|
+
* @returns The generated HMAC string in the format `sha256=<digest>`.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
* @group Utils
|
|
12
|
+
*/
|
|
13
|
+
function generateHmac(key: string, data: Buffer): string {
|
|
14
|
+
return 'sha256=' + createHmac('sha256', key).update(data).digest('hex');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Verify that a given HMAC matches the expected value for the provided data and key.
|
|
19
|
+
*
|
|
20
|
+
* @param key - The secret key used to generate the HMAC
|
|
21
|
+
* @param data - The data to verify against
|
|
22
|
+
* @param comparedHmac - The HMAC value to compare with
|
|
23
|
+
*
|
|
24
|
+
* @returns `true` if the HMAC matches, otherwise `false`.
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
* @group Utils
|
|
28
|
+
*/
|
|
29
|
+
export function verifyHmac(
|
|
30
|
+
key: string,
|
|
31
|
+
data: Buffer,
|
|
32
|
+
comparedHmac: string
|
|
33
|
+
): boolean {
|
|
34
|
+
return generateHmac(key, data) === comparedHmac;
|
|
35
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export {
|
|
2
|
+
setFilename,
|
|
3
|
+
getFilenameFromHeader,
|
|
4
|
+
getFilePropertiesNames,
|
|
5
|
+
processFileResponse,
|
|
6
|
+
setFileProperties,
|
|
7
|
+
} from './files';
|
|
8
|
+
export { verifyHmac } from './hmac';
|
|
9
|
+
export { getWebhook } from './webhook';
|
|
10
|
+
export { adaptProperty, getPropertyType } from './propertyAdapters';
|