@seeka-labs/cli-apps 1.1.24 → 1.1.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/LICENSE +19 -19
  2. package/dist/index.js +10 -10
  3. package/dist/index.js.map +4 -4
  4. package/dist/init-templates/aws-lambda/.example.gitignore +48 -48
  5. package/dist/init-templates/aws-lambda/.gitlab-ci.yml +23 -23
  6. package/dist/init-templates/aws-lambda/.nvmrc +1 -1
  7. package/dist/init-templates/aws-lambda/README.md +76 -76
  8. package/dist/init-templates/aws-lambda/jest.config.js +4 -4
  9. package/dist/init-templates/aws-lambda/package.json +51 -54
  10. package/dist/init-templates/aws-lambda/src/index.test.ts +6 -6
  11. package/dist/init-templates/aws-lambda/src/lib/logging/index.ts +87 -87
  12. package/dist/init-templates/aws-lambda/src/lib/state/redis/index.ts +64 -64
  13. package/dist/init-templates/aws-lambda/src/lib/state/seeka/installations.ts +66 -66
  14. package/dist/init-templates/aws-lambda/src/routes/seekaAppWebhook.ts +193 -193
  15. package/dist/init-templates/azure-function/.example.gitignore +47 -47
  16. package/dist/init-templates/azure-function/README.md +107 -107
  17. package/dist/init-templates/azure-function/jest.config.js +4 -4
  18. package/dist/init-templates/azure-function/package.json +45 -48
  19. package/dist/init-templates/azure-function/scripts/dev-queue-setup.js +29 -29
  20. package/dist/init-templates/azure-function/src/functions/healthCheck.ts +13 -13
  21. package/dist/init-templates/azure-function/src/functions/pollingExample.ts +39 -39
  22. package/dist/init-templates/azure-function/src/functions/queueExample.ts +66 -66
  23. package/dist/init-templates/azure-function/src/functions/seekaAppWebhook.ts +236 -236
  24. package/dist/init-templates/azure-function/src/index.test.ts +6 -6
  25. package/dist/init-templates/azure-function/src/lib/browser/index.ts +54 -54
  26. package/dist/init-templates/azure-function/src/lib/browser/models/index.ts +6 -6
  27. package/dist/init-templates/azure-function/src/lib/jobs/index.ts +95 -95
  28. package/dist/init-templates/azure-function/src/lib/logging/index.ts +92 -92
  29. package/dist/init-templates/azure-function/src/lib/state/redis/index.ts +64 -64
  30. package/dist/init-templates/azure-function/src/lib/state/seeka/installations.ts +66 -66
  31. package/dist/init-templates/browser/.editorconfig +14 -14
  32. package/dist/init-templates/browser/.eslintrc.cjs +1 -1
  33. package/dist/init-templates/browser/.yarnrc +1 -1
  34. package/dist/init-templates/browser/jest.config.js +11 -11
  35. package/dist/init-templates/browser/package.json +3 -3
  36. package/dist/init-templates/browser/scripts/esbuild/build-browser-plugin.mjs +110 -110
  37. package/dist/init-templates/browser/scripts/esbuild/plugins/importAsGlobals.mjs +38 -38
  38. package/dist/init-templates/browser/src/browser.ts +12 -12
  39. package/dist/init-templates/browser/src/plugin/index.test.ts +6 -6
  40. package/dist/init-templates/browser/src/plugin/index.ts +49 -49
  41. package/dist/init-templates/browser/tsconfig.json +34 -34
  42. package/dist/init-templates/netlify-function/.env.example +17 -17
  43. package/dist/init-templates/netlify-function/.example.gitignore +36 -36
  44. package/dist/init-templates/netlify-function/.nvmrc +1 -1
  45. package/dist/init-templates/netlify-function/.vscode/launch.json +44 -44
  46. package/dist/init-templates/netlify-function/README.md +61 -61
  47. package/dist/init-templates/netlify-function/jest.config.js +4 -4
  48. package/dist/init-templates/netlify-function/netlify.toml +6 -6
  49. package/dist/init-templates/netlify-function/package.json +11 -14
  50. package/dist/init-templates/netlify-function/src/api/example-job-background/index.ts +51 -51
  51. package/dist/init-templates/netlify-function/src/api/polling-example-job-scheduled/index.ts +45 -45
  52. package/dist/init-templates/netlify-function/src/api/seeka-app-webhook/index.ts +216 -216
  53. package/dist/init-templates/netlify-function/src/index.test.ts +6 -6
  54. package/dist/init-templates/netlify-function/src/lib/jobs/index.ts +67 -67
  55. package/dist/init-templates/netlify-function/src/lib/logging/index.ts +90 -90
  56. package/dist/init-templates/netlify-function/src/lib/state/redis/index.ts +64 -64
  57. package/dist/init-templates/netlify-function/src/lib/state/seeka/installations.ts +66 -66
  58. package/package.json +7 -7
@@ -1,49 +1,49 @@
1
- bin
2
- obj
3
- csx
4
- .vs
5
- edge
6
- Publish
7
- deploy.zip
8
-
9
- *.user
10
- *.suo
11
- *.cscfg
12
- *.Cache
13
- project.lock.json
14
-
15
- /packages
16
- /TestResults
17
-
18
- /tools/NuGet.exe
19
- /App_Data
20
- /secrets
21
- /data
22
- .secrets
23
- appsettings.json
24
- local.settings.json
25
-
26
- node_modules
27
- dist
28
-
29
- # Local python packages
30
- .python_packages/
31
-
32
- # Python Environments
33
- .env
34
- .venv
35
- env/
36
- venv/
37
- ENV/
38
- env.bak/
39
- venv.bak/
40
-
41
- # Byte-compiled / optimized / DLL files
42
- __pycache__/
43
- *.py[cod]
44
- *$py.class
45
-
46
- # Azurite artifacts
47
- __blobstorage__
48
- __queuestorage__
1
+ bin
2
+ obj
3
+ csx
4
+ .vs
5
+ edge
6
+ Publish
7
+ deploy.zip
8
+
9
+ *.user
10
+ *.suo
11
+ *.cscfg
12
+ *.Cache
13
+ project.lock.json
14
+
15
+ /packages
16
+ /TestResults
17
+
18
+ /tools/NuGet.exe
19
+ /App_Data
20
+ /secrets
21
+ /data
22
+ .secrets
23
+ appsettings.json
24
+ local.settings.json
25
+
26
+ node_modules
27
+ dist
28
+
29
+ # Local python packages
30
+ .python_packages/
31
+
32
+ # Python Environments
33
+ .env
34
+ .venv
35
+ env/
36
+ venv/
37
+ ENV/
38
+ env.bak/
39
+ venv.bak/
40
+
41
+ # Byte-compiled / optimized / DLL files
42
+ __pycache__/
43
+ *.py[cod]
44
+ *$py.class
45
+
46
+ # Azurite artifacts
47
+ __blobstorage__
48
+ __queuestorage__
49
49
  __azurite_db*__.json
@@ -1,5 +1,5 @@
1
1
  stages:
2
- - deploy
2
+ - deploy
3
3
 
4
4
  variables:
5
5
  LAMBDA_FUNC_RESOURCE_NAME: seeka-app-example-name
@@ -7,31 +7,31 @@ variables:
7
7
 
8
8
  workflow:
9
9
  rules:
10
- - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
11
- when: never
12
- - if: '$CI_COMMIT_BRANCH == "main" && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "web")'
13
- when: always
14
- - if: '$CI_COMMIT_BRANCH == "staging" && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "web")'
15
- when: always
10
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
11
+ when: never
12
+ - if: '$CI_COMMIT_BRANCH == "main" && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "web")'
13
+ when: always
14
+ - if: '$CI_COMMIT_BRANCH == "staging" && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "web")'
15
+ when: always
16
16
 
17
17
  deploy:
18
18
  stage: deploy
19
- image: node:18-bullseye
19
+ image: node:20-bullseye
20
20
  before_script:
21
- - echo "installing aws cli"
22
- - curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
23
- - unzip awscliv2.zip
24
- - ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update
25
- - ls -l /usr/local/bin/aws
26
- - aws --version
27
- - echo "using environment variables AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION for accessing the AWS CLI"
28
- - echo "installing zip"
29
- - apt-get update
30
- - apt-get install zip
21
+ - echo "installing aws cli"
22
+ - curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
23
+ - unzip awscliv2.zip
24
+ - ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update
25
+ - ls -l /usr/local/bin/aws
26
+ - aws --version
27
+ - echo "using environment variables AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION for accessing the AWS CLI"
28
+ - echo "installing zip"
29
+ - apt-get update
30
+ - apt-get install zip
31
31
  script:
32
- - echo "deploying AWS lambda func $LAMBDA_FUNC_RESOURCE_NAME from branch $CI_COMMIT_BRANCH"
33
- - yarn install --production=false
34
- - yarn deploy
32
+ - echo "deploying AWS lambda func $LAMBDA_FUNC_RESOURCE_NAME from branch $CI_COMMIT_BRANCH"
33
+ - yarn install --production=false
34
+ - yarn deploy
35
35
  only:
36
- - main
37
- - staging
36
+ - main
37
+ - staging
@@ -1 +1 @@
1
- v18
1
+ v20
@@ -1,77 +1,77 @@
1
- # Seeka app - AWS lambda
2
-
3
- ## Development
4
- - `yarn install`
5
- - `yarn watch:debug` or use VsCode debugging for "Debug Seeka App" configuration
6
-
7
- ### Debugging
8
- Supports VSCode debugging via the debugger and utilisation of breakpoints.
9
- Use "Debug Seeka App" configuration to compile, watch and start app.
10
- This is only tested on Linux but may work on Windows.
11
- If using Windows, WSL coupled with an Ubuntu distro will provide support for attaching the VS code debugger.
12
-
13
- ### Live urls
14
- You can expose your app locally to the internet via Ngrok to test your app before deploying.
15
-
16
- #### Setup
17
- 1. Sign up for a Ngrok account
18
- 2. Get your auth token
19
- 3. `yarn ngrok config add-authtoken [auth token here]` replacing `[auth token]` with the auth token retrieved from your Ngrok dashboard
20
-
21
- #### Running
22
- 1. `yarn start` OR start debugging in VSCode
23
- 2. In separate terminal window run `yarn tunnel` and observe the log entry that starts with `Live url exposed`.
24
- 3. Input the URL into your Seeka app configuration as the "Webook URL" via the Seeka UI.
25
-
26
- ## Logging
27
- Centralised logging handled by [Winston](https://www.npmjs.com/package/winston). Winston is installed in this template and is also used in the Seeka SDK NPM packages.
28
-
29
- [Seq](https://datalust.co/seq) Winston transport is installed in this template (optional).
30
-
31
- To configure Seq options, see `_SEQ_` environment variables.
32
-
33
- To install Seq on your development machine
34
- 1. Run `docker run --name seq -d --restart=always -e ACCEPT_EULA=Y -p 5341:80 datalust/seq:2024.2`
35
- 2. Update your `LOGGING_SEQ_SERVERURL` environment variable to `http://localhost:5341` or `http://[YOUR MACHINE NAME].local:5341` if using WSL.
36
-
37
- If creating an API key for Seq, only permission that is required is `Ingest`.
38
-
39
-
40
- ## State management
41
- Installations of your app and other state required for your app to function is stored in Redis. Another state provider can be swapped out for Redis, see `src/lib/state/seeka/installations.ts` for the file that manages the state of the installations.
42
-
43
- ### Upstash (optional)
44
- If you dont want to use Upstash for Redis then you can swap out the connection strings with your Redis instance.
45
-
46
- > If using Upstash then create a database before following the below guide to deploying your AWS lambda function.
47
-
48
- > When choosing a region, consider the AWS region that the lambda function is running from to reduce latency between the function and the Redis database.
49
-
50
- ## Deployment
51
- 1. [Install the aws lambda CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html#getting-started-install-instructions)
52
- 1. Create a function via the AWS console with following settings
53
- - Mode: Author from scratch
54
- - function name: `seeka-app-example-name`
55
- - runtime: `Node.js 18.x`
56
- - architecture: `arm64`
57
- - Advanced settings:
58
- - Enable code signing: unchecked
59
- - Enable function URL: checked
60
- - Auth type: `NONE` - Calls to your function from Seeka will be verified by SHA256 signatures
61
- - Invoke mode: Buffered
62
- - Configure cross-origin resource sharing: unchecked
63
- - Enable VPC: unchecked
64
- - All other settings leave as defaults
65
- 3. Add environment variables to the function in AWS by clicking 'Configuration' and then 'Environment varables'. Use the `.env` file in this project as a reference to what variables are required by to be set in the AWS Lambda.
66
- 4. [Authenticate the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-authentication-short-term.html)
67
- 2. `yarn deploy`
68
-
69
- > At this point you may wish to [configure concurrency](https://docs.aws.amazon.com/lambda/latest/dg/scaling-behavior.html) of the AWS lambda function depending on the amount of concurrent requests you forecast your function handling.
70
-
71
- 6. Update your `Webhook URL` in you Seeka app configuration to point to the AWS Lambda function URL. This URL can be found in your viewing your Lambda via the AWS console and copying the "Function URL". It should look something like `https://prragnghaaupodlqte6hkvo446acc.lambda-url.ap-southeast-2.on.aws/`. Ensure to append `api/webhook/seeka/app` onto this URL so the complete example to update your Seeka app configuration with will look like `https://prragnghaaupodlqte6hkvo446acc.lambda-url.ap-southeast-2.on.aws/api/webhook/seeka/app`
72
-
73
- ### Continuous delivery
74
- This template includes a GitLab CD pipeline that can be used to trigger deployments of your app when changes are pushed to your Git repository.
75
-
76
- ## References
1
+ # Seeka app - AWS lambda
2
+
3
+ ## Development
4
+ - `yarn install`
5
+ - `yarn watch:debug` or use VsCode debugging for "Debug Seeka App" configuration
6
+
7
+ ### Debugging
8
+ Supports VSCode debugging via the debugger and utilisation of breakpoints.
9
+ Use "Debug Seeka App" configuration to compile, watch and start app.
10
+ This is only tested on Linux but may work on Windows.
11
+ If using Windows, WSL coupled with an Ubuntu distro will provide support for attaching the VS code debugger.
12
+
13
+ ### Live urls
14
+ You can expose your app locally to the internet via Ngrok to test your app before deploying.
15
+
16
+ #### Setup
17
+ 1. Sign up for a Ngrok account
18
+ 2. Get your auth token
19
+ 3. `yarn ngrok config add-authtoken [auth token here]` replacing `[auth token]` with the auth token retrieved from your Ngrok dashboard
20
+
21
+ #### Running
22
+ 1. `yarn start` OR start debugging in VSCode
23
+ 2. In separate terminal window run `yarn tunnel` and observe the log entry that starts with `Live url exposed`.
24
+ 3. Input the URL into your Seeka app configuration as the "Webook URL" via the Seeka UI.
25
+
26
+ ## Logging
27
+ Centralised logging handled by [Winston](https://www.npmjs.com/package/winston). Winston is installed in this template and is also used in the Seeka SDK NPM packages.
28
+
29
+ [Seq](https://datalust.co/seq) Winston transport is installed in this template (optional).
30
+
31
+ To configure Seq options, see `_SEQ_` environment variables.
32
+
33
+ To install Seq on your development machine
34
+ 1. Run `docker run --name seq -d --restart=always -e ACCEPT_EULA=Y -p 5341:80 datalust/seq:2024.2`
35
+ 2. Update your `LOGGING_SEQ_SERVERURL` environment variable to `http://localhost:5341` or `http://[YOUR MACHINE NAME].local:5341` if using WSL.
36
+
37
+ If creating an API key for Seq, only permission that is required is `Ingest`.
38
+
39
+
40
+ ## State management
41
+ Installations of your app and other state required for your app to function is stored in Redis. Another state provider can be swapped out for Redis, see `src/lib/state/seeka/installations.ts` for the file that manages the state of the installations.
42
+
43
+ ### Upstash (optional)
44
+ If you dont want to use Upstash for Redis then you can swap out the connection strings with your Redis instance.
45
+
46
+ > If using Upstash then create a database before following the below guide to deploying your AWS lambda function.
47
+
48
+ > When choosing a region, consider the AWS region that the lambda function is running from to reduce latency between the function and the Redis database.
49
+
50
+ ## Deployment
51
+ 1. [Install the aws lambda CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html#getting-started-install-instructions)
52
+ 1. Create a function via the AWS console with following settings
53
+ - Mode: Author from scratch
54
+ - function name: `seeka-app-example-name`
55
+ - runtime: `Node.js 18.x`
56
+ - architecture: `arm64`
57
+ - Advanced settings:
58
+ - Enable code signing: unchecked
59
+ - Enable function URL: checked
60
+ - Auth type: `NONE` - Calls to your function from Seeka will be verified by SHA256 signatures
61
+ - Invoke mode: Buffered
62
+ - Configure cross-origin resource sharing: unchecked
63
+ - Enable VPC: unchecked
64
+ - All other settings leave as defaults
65
+ 3. Add environment variables to the function in AWS by clicking 'Configuration' and then 'Environment varables'. Use the `.env` file in this project as a reference to what variables are required by to be set in the AWS Lambda.
66
+ 4. [Authenticate the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-authentication-short-term.html)
67
+ 2. `yarn deploy`
68
+
69
+ > At this point you may wish to [configure concurrency](https://docs.aws.amazon.com/lambda/latest/dg/scaling-behavior.html) of the AWS lambda function depending on the amount of concurrent requests you forecast your function handling.
70
+
71
+ 6. Update your `Webhook URL` in you Seeka app configuration to point to the AWS Lambda function URL. This URL can be found in your viewing your Lambda via the AWS console and copying the "Function URL". It should look something like `https://prragnghaaupodlqte6hkvo446acc.lambda-url.ap-southeast-2.on.aws/`. Ensure to append `api/webhook/seeka/app` onto this URL so the complete example to update your Seeka app configuration with will look like `https://prragnghaaupodlqte6hkvo446acc.lambda-url.ap-southeast-2.on.aws/api/webhook/seeka/app`
72
+
73
+ ### Continuous delivery
74
+ This template includes a GitLab CD pipeline that can be used to trigger deployments of your app when changes are pushed to your Git repository.
75
+
76
+ ## References
77
77
  - https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lambda/index.html#available-commands
@@ -1,5 +1,5 @@
1
- /** @type {import('ts-jest').JestConfigWithTsJest} */
2
- module.exports = {
3
- preset: 'ts-jest',
4
- testEnvironment: 'node',
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ preset: 'ts-jest',
4
+ testEnvironment: 'node',
5
5
  };
@@ -1,55 +1,52 @@
1
- {
2
- "name": "seeka-app-example-name",
3
- "version": "0.0.1",
4
- "description": "Seeka example app for hosting on AWS lambda functions",
5
- "author": "Seeka <platform@seeka.co>",
6
- "license": "MIT",
7
- "main": "./index.js",
8
- "private": true,
9
- "engines": {
10
- "node": ">=18.14.0"
11
- },
12
- "scripts": {
13
- "lint": "eslint",
14
- "build": "esbuild src/index.ts --bundle --minify --sourcemap --platform=node --target=node18 --outfile=dist/index.js",
15
- "watch": "tsc -w",
16
- "test": "yarn jest",
17
- "clean": "<packageManagerRunPrefix> rimraf dist && <packageManagerRunPrefix> rimraf deploy.zip",
18
- "start": "node --require dotenv/config dist/index.js",
19
- "dev": "<packageManagerRunPrefix> clean && <packageManagerRunPrefix> build && node --require dotenv/config dist/index.js",
20
- "tunnel": "node scripts/ngrok.js seeka-app-example-name-localdev",
21
- "build:aws": "<packageManagerRunPrefix> clean && <packageManagerRunPrefix> build && cd dist && zip -r ../deploy.zip . && cd ..",
22
- "deploy": "<packageManagerRunPrefix> build:aws && aws lambda update-function-code --function-name seeka-app-example-name --zip-file fileb://deploy.zip && rm deploy.zip",
23
- "watch:debug": "nodemon --inspect=5858 -e ts --exec node -r ts-node/register --require dotenv/config ./src/index.ts"
24
- },
25
- "dependencies": {
26
- "@datalust/winston-seq": "^2.0.0",
27
- "@seeka-labs/sdk-apps-server": "^1.1.7",
28
- "axios": "^1.6.7",
29
- "express": "^4.18.2",
30
- "lodash-es": "^4.17.21",
31
- "openid-client": "^5.6.4",
32
- "redis": "^4.6.12",
33
- "serverless-http": "^3.2.0",
34
- "winston": "^3.11.0"
35
- },
36
- "devDependencies": {
37
- "@jest/globals": "^29.7.0",
38
- "@types/aws-lambda": "^8.10.133",
39
- "@types/express": "^4.17.21",
40
- "@types/lodash-es": "^4.17.12",
41
- "@types/node": "^18",
42
- "@typescript-eslint/eslint-plugin": "^6.19.1",
43
- "@typescript-eslint/parser": "^6.19.1",
44
- "dotenv": "^16.4.4",
45
- "esbuild": "^0.24.0",
46
- "eslint": "^8",
47
- "jest": "^29.7.0",
48
- "ts-jest": "^29.1.5",
49
- "ngrok": "^5.0.0-beta.2",
50
- "nodemon": "^3.0.3",
51
- "rimraf": "^5.0.0",
52
- "ts-node": "^10.9.2",
53
- "typescript": "^5.4.2"
54
- }
1
+ {
2
+ "name": "seeka-app-example-name",
3
+ "version": "0.0.1",
4
+ "description": "Seeka example app for hosting on AWS lambda functions",
5
+ "author": "Seeka <platform@seeka.co>",
6
+ "license": "MIT",
7
+ "main": "./index.js",
8
+ "private": true,
9
+ "engines": {
10
+ "node": ">=20"
11
+ },
12
+ "scripts": {
13
+ "lint": "eslint",
14
+ "build": "esbuild src/index.ts --bundle --minify --sourcemap --platform=node --target=node18 --outfile=dist/index.js",
15
+ "watch": "tsc -w",
16
+ "test": "yarn jest",
17
+ "clean": "<packageManagerRunPrefix> rimraf dist && <packageManagerRunPrefix> rimraf deploy.zip",
18
+ "start": "node --require dotenv/config dist/index.js",
19
+ "dev": "<packageManagerRunPrefix> clean && <packageManagerRunPrefix> build && node --require dotenv/config dist/index.js",
20
+ "tunnel": "node scripts/ngrok.js seeka-app-example-name-localdev",
21
+ "build:aws": "<packageManagerRunPrefix> clean && <packageManagerRunPrefix> build && cd dist && zip -r ../deploy.zip . && cd ..",
22
+ "deploy": "<packageManagerRunPrefix> build:aws && aws lambda update-function-code --function-name seeka-app-example-name --zip-file fileb://deploy.zip && rm deploy.zip",
23
+ "watch:debug": "nodemon --inspect=5858 -e ts --exec node -r ts-node/register --require dotenv/config ./src/index.ts"
24
+ },
25
+ "dependencies": {
26
+ "@datalust/winston-seq": "^2.0.0",
27
+ "@seeka-labs/sdk-apps-server": "^1.1.24",
28
+ "express": "^4.21.1",
29
+ "lodash-es": "^4.17.21",
30
+ "redis": "^4.7.0",
31
+ "serverless-http": "^3.2.0"
32
+ },
33
+ "devDependencies": {
34
+ "@jest/globals": "^29.7.0",
35
+ "@types/aws-lambda": "^8.10.146",
36
+ "@types/express": "^5.0.0",
37
+ "@types/lodash-es": "^4.17.12",
38
+ "@types/node": "^20",
39
+ "@typescript-eslint/eslint-plugin": "^8.17.0",
40
+ "@typescript-eslint/parser": "^8.17.0",
41
+ "dotenv": "^16.4.7",
42
+ "esbuild": "^0.24.0",
43
+ "eslint": "^9",
44
+ "jest": "^29.7.0",
45
+ "ts-jest": "^29.2.5",
46
+ "ngrok": "^5.0.0-beta.2",
47
+ "nodemon": "^3.1.7",
48
+ "rimraf": "^5.0.0",
49
+ "ts-node": "^10.9.2",
50
+ "typescript": "^5.7.2"
51
+ }
55
52
  }
@@ -1,7 +1,7 @@
1
- import { describe, expect, test } from '@jest/globals';
2
-
3
- describe('test example module', () => {
4
- test('should be false', () => {
5
- expect(false).toBeFalsy();
6
- });
1
+ import { describe, expect, test } from '@jest/globals';
2
+
3
+ describe('test example module', () => {
4
+ test('should be false', () => {
5
+ expect(false).toBeFalsy();
6
+ });
7
7
  });
@@ -1,88 +1,88 @@
1
- import { Context } from 'aws-lambda';
2
- import * as winston from 'winston';
3
-
4
- import { SeqTransport } from '@datalust/winston-seq';
5
-
6
- import * as packageJson from '../../../package.json';
7
-
8
- import type {
9
- SeekaWebhookPayload, SeekaWebhookPayloadOfSeekaAppWebhookContext
10
- } from '@seeka-labs/sdk-apps-server';
11
-
12
- const loggerTransports: winston.transport[] = [
13
- new winston.transports.Console({
14
- level: process.env.LOGGING_LEVEL,
15
- format: winston.format.combine(
16
- winston.format.errors({ stack: true }),
17
- winston.format.cli(),
18
- winston.format.splat(),
19
- ),
20
- handleExceptions: true,
21
- handleRejections: true,
22
- }),
23
- ]
24
- if (process.env.LOGGING_SEQ_SERVERURL) {
25
- loggerTransports.push(
26
- new SeqTransport({
27
- level: process.env.LOGGING_LEVEL,
28
- serverUrl: process.env.LOGGING_SEQ_SERVERURL,
29
- apiKey: process.env.LOGGING_SEQ_APIKEY,
30
- onError: ((e: any) => { console.error('Failed to configure Seq logging transport', e) }),
31
- format: winston.format.combine(
32
- winston.format.errors({ stack: true }),
33
- winston.format.json(),
34
- ),
35
- handleExceptions: true,
36
- handleRejections: true,
37
- })
38
- )
39
- }
40
-
41
- let logger: winston.Logger | null = null;
42
-
43
- const createLogger = () => winston.createLogger({
44
- level: process.env.LOGGING_LEVEL,
45
- defaultMeta: {
46
- seekaAppId: process.env.SEEKA_APP_ID,
47
- Hosting_Provider: 'aws',
48
- Release_Version: `v${packageJson.version}`,
49
- Hosting_Region: process.env.AWS_REGION,
50
- Aws_Xray_TraceId: process.env._X_AMZN_TRACE_ID,
51
- Aws_Lambda_FunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
52
- Service: `app/${packageJson.name}`,
53
- },
54
- transports: loggerTransports,
55
- exitOnError: false,
56
- });
57
-
58
- export const getLogger = () => {
59
- if (!logger || logger.closed) {
60
- // If the AWS lambda host is reused then the logger will be closed and we need to recreate it
61
- logger = createLogger();
62
- }
63
-
64
- return logger;
65
- };
66
-
67
- export const childLogger = (meta: object) => getLogger().child(meta);
68
-
69
- export const webhookLogger = (payload: SeekaWebhookPayload, functionContext: Context) => {
70
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
71
- const meta: any = {
72
- seekaWebhookType: payload.type,
73
- seekaWebhookIsTest: payload.isTest,
74
- RequestId: payload.requestId,
75
- AwsLambda_RequestId: functionContext.awsRequestId,
76
- CausationId: payload.causationId,
77
- CorrelationId: payload.causationId,
78
- }
79
-
80
- const context = (payload as SeekaWebhookPayloadOfSeekaAppWebhookContext).context;
81
- if (context) {
82
- meta.seekaAppInstallId = context.applicationInstallId;
83
- meta.seekaAppInstallOrganisationBrandId = context.organisationBrandId;
84
- meta.seekaAppInstallOrganisationId = context.organisationId;
85
- }
86
-
87
- return childLogger(meta)
1
+ import { Context } from 'aws-lambda';
2
+ import * as winston from 'winston';
3
+
4
+ import { SeqTransport } from '@datalust/winston-seq';
5
+
6
+ import * as packageJson from '../../../package.json';
7
+
8
+ import type {
9
+ SeekaWebhookPayload, SeekaWebhookPayloadOfSeekaAppWebhookContext
10
+ } from '@seeka-labs/sdk-apps-server';
11
+
12
+ const loggerTransports: winston.transport[] = [
13
+ new winston.transports.Console({
14
+ level: process.env.LOGGING_LEVEL,
15
+ format: winston.format.combine(
16
+ winston.format.errors({ stack: true }),
17
+ winston.format.cli(),
18
+ winston.format.splat(),
19
+ ),
20
+ handleExceptions: true,
21
+ handleRejections: true,
22
+ }),
23
+ ]
24
+ if (process.env.LOGGING_SEQ_SERVERURL) {
25
+ loggerTransports.push(
26
+ new SeqTransport({
27
+ level: process.env.LOGGING_LEVEL,
28
+ serverUrl: process.env.LOGGING_SEQ_SERVERURL,
29
+ apiKey: process.env.LOGGING_SEQ_APIKEY,
30
+ onError: ((e: any) => { console.error('Failed to configure Seq logging transport', e) }),
31
+ format: winston.format.combine(
32
+ winston.format.errors({ stack: true }),
33
+ winston.format.json(),
34
+ ),
35
+ handleExceptions: true,
36
+ handleRejections: true,
37
+ })
38
+ )
39
+ }
40
+
41
+ let logger: winston.Logger | null = null;
42
+
43
+ const createLogger = () => winston.createLogger({
44
+ level: process.env.LOGGING_LEVEL,
45
+ defaultMeta: {
46
+ seekaAppId: process.env.SEEKA_APP_ID,
47
+ Hosting_Provider: 'aws',
48
+ Release_Version: `v${packageJson.version}`,
49
+ Hosting_Region: process.env.AWS_REGION,
50
+ Aws_Xray_TraceId: process.env._X_AMZN_TRACE_ID,
51
+ Aws_Lambda_FunctionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
52
+ Service: `app/${packageJson.name}`,
53
+ },
54
+ transports: loggerTransports,
55
+ exitOnError: false,
56
+ });
57
+
58
+ export const getLogger = () => {
59
+ if (!logger || logger.closed) {
60
+ // If the AWS lambda host is reused then the logger will be closed and we need to recreate it
61
+ logger = createLogger();
62
+ }
63
+
64
+ return logger;
65
+ };
66
+
67
+ export const childLogger = (meta: object) => getLogger().child(meta);
68
+
69
+ export const webhookLogger = (payload: SeekaWebhookPayload, functionContext: Context) => {
70
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
71
+ const meta: any = {
72
+ seekaWebhookType: payload.type,
73
+ seekaWebhookIsTest: payload.isTest,
74
+ RequestId: payload.requestId,
75
+ AwsLambda_RequestId: functionContext.awsRequestId,
76
+ CausationId: payload.causationId,
77
+ CorrelationId: payload.causationId,
78
+ }
79
+
80
+ const context = (payload as SeekaWebhookPayloadOfSeekaAppWebhookContext).context;
81
+ if (context) {
82
+ meta.seekaAppInstallId = context.applicationInstallId;
83
+ meta.seekaAppInstallOrganisationBrandId = context.organisationBrandId;
84
+ meta.seekaAppInstallOrganisationId = context.organisationId;
85
+ }
86
+
87
+ return childLogger(meta)
88
88
  }