@seeka-labs/cli-apps 2.0.7-rc.1 → 2.0.10-alpha.0

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.
@@ -1,47 +1,47 @@
1
- stages:
2
- - deploy
3
-
4
- variables:
5
- AZURE_FUNC_RESOURCE_NAME: seeka-app-example-name
6
- CI_DEBUG_TRACE: "true"
7
-
8
- workflow:
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
- variables:
14
- # AZURE_FUNC_SLOT: ""
15
- # AZURE_FUNC_SLOT: "production"?????
16
- HOSTING_REGION_NAME: auea
17
- HOSTING_ENV_NAME: prod
18
- when: always
19
- - if: '$CI_COMMIT_BRANCH == "staging" && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "web")'
20
- variables:
21
- # AZURE_FUNC_SLOT: staging
22
- HOSTING_REGION_NAME: auea
23
- HOSTING_ENV_NAME: stag
24
- when: always
25
-
26
- deploy:
27
- stage: deploy
28
- image: node:20
29
- environment:
30
- name: $HOSTING_REGION_NAME/$HOSTING_ENV_NAME/apps
31
- before_script:
32
- - echo "installing azure cli"
33
- - curl -sL https://aka.ms/InstallAzureCLIDeb | bash
34
- - az --version
35
- - echo "logging in to azure"
36
- - az login --service-principal --username "$AZURE_SERVICEPRINCIPAL_CLIENTID" --password "$AZURE_SERVICEPRINCIPAL_SECRET" --tenant "$AZURE_TENANT_ID"
37
- - az account set --subscription "$AZURE_SUBSCRIPTION_ID"
38
- - corepack enable
39
- script:
40
- - echo "deploying azure func $AZURE_FUNC_RESOURCE_NAME to slot $AZURE_FUNC_SLOT from branch $CI_COMMIT_BRANCH"
41
- - yarn install --immutable
42
- - yarn clean && yarn build
43
- - cd app/server-azure-function
44
- - yarn func azure functionapp publish $AZURE_FUNC_RESOURCE_NAME --no-build --javascript
45
- only:
46
- - main
1
+ stages:
2
+ - deploy
3
+
4
+ variables:
5
+ AZURE_FUNC_RESOURCE_NAME: seeka-app-example-name
6
+ CI_DEBUG_TRACE: "true"
7
+
8
+ workflow:
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
+ variables:
14
+ # AZURE_FUNC_SLOT: ""
15
+ # AZURE_FUNC_SLOT: "production"?????
16
+ HOSTING_REGION_NAME: auea
17
+ HOSTING_ENV_NAME: prod
18
+ when: always
19
+ - if: '$CI_COMMIT_BRANCH == "staging" && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "web")'
20
+ variables:
21
+ # AZURE_FUNC_SLOT: staging
22
+ HOSTING_REGION_NAME: auea
23
+ HOSTING_ENV_NAME: stag
24
+ when: always
25
+
26
+ deploy:
27
+ stage: deploy
28
+ image: node:20
29
+ environment:
30
+ name: $HOSTING_REGION_NAME/$HOSTING_ENV_NAME/apps
31
+ before_script:
32
+ - echo "installing azure cli"
33
+ - curl -sL https://aka.ms/InstallAzureCLIDeb | bash
34
+ - az --version
35
+ - echo "logging in to azure"
36
+ - az login --service-principal --username "$AZURE_SERVICEPRINCIPAL_CLIENTID" --password "$AZURE_SERVICEPRINCIPAL_SECRET" --tenant "$AZURE_TENANT_ID"
37
+ - az account set --subscription "$AZURE_SUBSCRIPTION_ID"
38
+ - corepack enable
39
+ script:
40
+ - echo "deploying azure func $AZURE_FUNC_RESOURCE_NAME to slot $AZURE_FUNC_SLOT from branch $CI_COMMIT_BRANCH"
41
+ - yarn install --immutable
42
+ - yarn clean && yarn build
43
+ - cd app/server-azure-function
44
+ - yarn func azure functionapp publish $AZURE_FUNC_RESOURCE_NAME --no-build --javascript
45
+ only:
46
+ - main
47
47
  - staging
@@ -1,7 +1,7 @@
1
- # Seeka app
2
-
3
- # updating all deps
4
- ```
5
- cd repo root
6
- npx npm-check-updates@latest -i --target minor --workspaces && npx npm-check-updates@latest -i --target latest --workspaces
1
+ # Seeka app
2
+
3
+ # updating all deps
4
+ ```
5
+ cd repo root
6
+ npx npm-check-updates@latest -i --target minor --workspaces && npx npm-check-updates@latest -i --target latest --workspaces
7
7
  ```
@@ -1,40 +1,40 @@
1
- {
2
- "name": "@seeka-app-example-name/browser",
3
- "version": "2.0.7-rc.1",
4
- "description": "Seeka browser app seeka-app-example-name-browser",
5
- "author": "Seeka company <support@seeka.co>",
6
- "license": "MIT",
7
- "files": [
8
- "dist/"
9
- ],
10
- "scripts": {
11
- "lint": "eslint --fix src/ --ext .ts",
12
- "test:ci": "jest --collectCoverage --coverageDirectory=\"./coverage\" --ci --reporters=default --reporters=jest-junit --watchAll=false",
13
- "test": "jest --watch",
14
- "clean": "rimraf dist build package",
15
- "build": "yarn clean && node ./scripts/esbuild/build-browser-plugin.mjs seeka-app-example-name SampleAppConvergeSdkPlugin",
16
- "build:dev": "yarn clean && node ./scripts/esbuild/build-browser-plugin.mjs seeka-app-example-name SampleAppConvergeSdkPlugin dev",
17
- "watch": "yarn clean && node ./scripts/esbuild/build-browser-plugin.mjs seeka-app-example-name SampleAppConvergeSdkPlugin dev watch"
18
- },
19
- "dependencies": {
20
- "@seeka-labs/converge": "^1.8.64"
21
- },
22
- "devDependencies": {
23
- "@jest/globals": "^29.7.0",
24
- "@jgoz/esbuild-plugin-typecheck": "^4.0.3",
25
- "@types/jest": "^29.5.14",
26
- "@types/lodash-es": "^4.17.12",
27
- "@typescript-eslint/eslint-plugin": "^8.32.1",
28
- "@typescript-eslint/parser": "^8.32.1",
29
- "esbuild": "^0.25.5",
30
- "eslint": "^9",
31
- "eslint-plugin-unused-imports": "^4.1.4",
32
- "jest": "^29.7.0",
33
- "jest-junit": "^16.0.0",
34
- "rimraf": "^6.0.1",
35
- "ts-jest": "^29.3.4",
36
- "typescript": "^5.8.3",
37
- "watch": "^1.0.2"
38
- },
39
- "stableVersion": "2.0.6"
40
- }
1
+ {
2
+ "name": "@seeka-app-example-name/browser",
3
+ "version": "2.0.7-rc.2",
4
+ "description": "Seeka browser app seeka-app-example-name-browser",
5
+ "author": "Seeka company <support@seeka.co>",
6
+ "license": "MIT",
7
+ "files": [
8
+ "dist/"
9
+ ],
10
+ "scripts": {
11
+ "lint": "eslint --fix src/ --ext .ts",
12
+ "test:ci": "jest --collectCoverage --coverageDirectory=\"./coverage\" --ci --reporters=default --reporters=jest-junit --watchAll=false",
13
+ "test": "jest --watch",
14
+ "clean": "rimraf dist build package",
15
+ "build": "yarn clean && node ./scripts/esbuild/build-browser-plugin.mjs seeka-app-example-name SampleAppConvergeSdkPlugin",
16
+ "build:dev": "yarn clean && node ./scripts/esbuild/build-browser-plugin.mjs seeka-app-example-name SampleAppConvergeSdkPlugin dev",
17
+ "watch": "yarn clean && node ./scripts/esbuild/build-browser-plugin.mjs seeka-app-example-name SampleAppConvergeSdkPlugin dev watch"
18
+ },
19
+ "dependencies": {
20
+ "@seeka-labs/converge": "^1.8.64"
21
+ },
22
+ "devDependencies": {
23
+ "@jest/globals": "^29.7.0",
24
+ "@jgoz/esbuild-plugin-typecheck": "^4.0.3",
25
+ "@types/jest": "^29.5.14",
26
+ "@types/lodash-es": "^4.17.12",
27
+ "@typescript-eslint/eslint-plugin": "^8.32.1",
28
+ "@typescript-eslint/parser": "^8.32.1",
29
+ "esbuild": "^0.25.5",
30
+ "eslint": "^9",
31
+ "eslint-plugin-unused-imports": "^4.1.4",
32
+ "jest": "^29.7.0",
33
+ "jest-junit": "^16.0.0",
34
+ "rimraf": "^6.0.1",
35
+ "ts-jest": "^29.3.4",
36
+ "typescript": "^5.8.3",
37
+ "watch": "^1.0.2"
38
+ },
39
+ "stableVersion": "2.0.6"
40
+ }
@@ -1,11 +1,11 @@
1
- /* eslint-env node */
2
- module.exports = {
3
- extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
4
- parser: '@typescript-eslint/parser',
5
- plugins: ['@typescript-eslint'],
6
- root: true,
7
- rules: {
8
- "@typescript-eslint/no-unused-vars": "warn",
9
- "@typescript-eslint/no-empty-function": "warn",
10
- }
1
+ /* eslint-env node */
2
+ module.exports = {
3
+ extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
4
+ parser: '@typescript-eslint/parser',
5
+ plugins: ['@typescript-eslint'],
6
+ root: true,
7
+ rules: {
8
+ "@typescript-eslint/no-unused-vars": "warn",
9
+ "@typescript-eslint/no-empty-function": "warn",
10
+ }
11
11
  };
@@ -1,22 +1,22 @@
1
- *.ts
2
- local.settings.json
3
- test
4
- scripts/
5
- src/
6
- README.md
7
- tsconfig.json
8
- .eslintrc.cjs
9
-
10
- node_modules/@jest/globals/
11
- node_modules/@types/
12
- node_modules/@typescript-eslint/eslint-plugin/
13
- node_modules/@typescript-eslint/parser/
14
- node_modules/azure-functions-core-tools/
15
- node_modules/eslint/
16
- node_modules/jest/
17
- node_modules/ngrok/
18
- node_modules/rimraf/
19
- node_modules/ts-jest/
20
- node_modules/typescript/
21
-
1
+ *.ts
2
+ local.settings.json
3
+ test
4
+ scripts/
5
+ src/
6
+ README.md
7
+ tsconfig.json
8
+ .eslintrc.cjs
9
+
10
+ node_modules/@jest/globals/
11
+ node_modules/@types/
12
+ node_modules/@typescript-eslint/eslint-plugin/
13
+ node_modules/@typescript-eslint/parser/
14
+ node_modules/azure-functions-core-tools/
15
+ node_modules/eslint/
16
+ node_modules/jest/
17
+ node_modules/ngrok/
18
+ node_modules/rimraf/
19
+ node_modules/ts-jest/
20
+ node_modules/typescript/
21
+
22
22
  .gitignore
@@ -1,20 +1,20 @@
1
- {
2
- "version": "2.0",
3
- "logging": {
4
- "applicationInsights": {
5
- "samplingSettings": {
6
- "isEnabled": true,
7
- "excludedTypes": "Request"
8
- }
9
- }
10
- },
11
- "functionTimeout": "00:10:00",
12
- "extensionBundle": {
13
- "id": "Microsoft.Azure.Functions.ExtensionBundle",
14
- "version": "[4.*, 5.0.0)"
15
- },
16
- "concurrency": {
17
- "dynamicConcurrencyEnabled": true,
18
- "snapshotPersistenceEnabled": true
19
- }
1
+ {
2
+ "version": "2.0",
3
+ "logging": {
4
+ "applicationInsights": {
5
+ "samplingSettings": {
6
+ "isEnabled": true,
7
+ "excludedTypes": "Request"
8
+ }
9
+ }
10
+ },
11
+ "functionTimeout": "00:10:00",
12
+ "extensionBundle": {
13
+ "id": "Microsoft.Azure.Functions.ExtensionBundle",
14
+ "version": "[4.*, 5.0.0)"
15
+ },
16
+ "concurrency": {
17
+ "dynamicConcurrencyEnabled": true,
18
+ "snapshotPersistenceEnabled": true
19
+ }
20
20
  }
@@ -1,26 +1,26 @@
1
- {
2
- "IsEncrypted": false,
3
- "Host": {
4
- "CORS": "*"
5
- },
6
- "Values": {
7
- "FUNCTIONS_WORKER_RUNTIME": "node",
8
- "FUNCTIONS_EXTENSION_VERSION": "~4",
9
- "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
10
- "AzureWebJobsStorage": "UseDevelopmentStorage=true",
11
- "SEEKA_APP_ID": "",
12
- "SEEKA_APP_SECRET": "",
13
- "SEEKA_DEBUG_ENABLED": "true",
14
- "SEEKA_INGEST_URL": "",
15
- "SEEKA_ISSUER_URL": "",
16
- "NODE_TLS_REJECT_UNAUTHORIZED": "1",
17
- "REDIS_CONNECTION_USER": "default",
18
- "REDIS_CONNECTION_PASSWORD": "",
19
- "REDIS_CONNECTION_TLS": "true",
20
- "REDIS_CONNECTION_HOST": "",
21
- "REDIS_CONNECTION_PORT": "",
22
- "LOGGING_SEQ_SERVERURL": "",
23
- "LOGGING_SEQ_APIKEY": "",
24
- "LOGGING_LEVEL": "silly"
25
- }
1
+ {
2
+ "IsEncrypted": false,
3
+ "Host": {
4
+ "CORS": "*"
5
+ },
6
+ "Values": {
7
+ "FUNCTIONS_WORKER_RUNTIME": "node",
8
+ "FUNCTIONS_EXTENSION_VERSION": "~4",
9
+ "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
10
+ "AzureWebJobsStorage": "UseDevelopmentStorage=true",
11
+ "SEEKA_APP_ID": "",
12
+ "SEEKA_APP_SECRET": "",
13
+ "SEEKA_DEBUG_ENABLED": "true",
14
+ "SEEKA_INGEST_URL": "",
15
+ "SEEKA_ISSUER_URL": "",
16
+ "NODE_TLS_REJECT_UNAUTHORIZED": "1",
17
+ "REDIS_CONNECTION_USER": "default",
18
+ "REDIS_CONNECTION_PASSWORD": "",
19
+ "REDIS_CONNECTION_TLS": "true",
20
+ "REDIS_CONNECTION_HOST": "",
21
+ "REDIS_CONNECTION_PORT": "",
22
+ "LOGGING_SEQ_SERVERURL": "",
23
+ "LOGGING_SEQ_APIKEY": "",
24
+ "LOGGING_LEVEL": "silly"
25
+ }
26
26
  }
@@ -1,52 +1,52 @@
1
- {
2
- "name": "@seeka-app-example-name/server-azure-function",
3
- "version": "2.0.7-rc.1",
4
- "description": "Seeka example app with hosting on Azure serverless functions",
5
- "author": "Seeka <platform@seeka.co>",
6
- "license": "MIT",
7
- "main": "dist/src/functions/*.js",
8
- "private": true,
9
- "engines": {
10
- "node": ">=20"
11
- },
12
- "scripts": {
13
- "lint": "eslint",
14
- "build": "tsc",
15
- "watch": "tsc -w",
16
- "clean": "rimraf dist",
17
- "prestart": "<packageManagerRunPrefix> clean && yarn build",
18
- "dev": "func start --port 7072",
19
- "tunnel": "node scripts/ngrok.js seeka-app-example-name-localdev",
20
- "deploy": "yarn func azure functionapp publish seeka-app-example-name --no-build --javascript",
21
- "dev:queue:create": "node scripts/dev-queue-setup.js sample-queue-name"
22
- },
23
- "dependencies": {
24
- "@azure/functions": "^4.7.2",
25
- "@azure/storage-queue": "^12.26.0",
26
- "@datalust/winston-seq": "^2.0.0",
27
- "@redis/client": "^5.1.0",
28
- "@redis/json": "^5.1.0",
29
- "@seeka-labs/sdk-apps-server": "2.0.7-rc.1",
30
- "axios": "^1.9.0",
31
- "lodash": "^4.17.21",
32
- "redis": "^5.1.0",
33
- "winston": "^3.17.0"
34
- },
35
- "devDependencies": {
36
- "@jest/globals": "^29.7.0",
37
- "@types/jest": "^29.5.14",
38
- "@types/lodash": "^4.17.17",
39
- "@types/lodash-es": "^4.17.12",
40
- "@types/node": "^20",
41
- "@typescript-eslint/eslint-plugin": "^8.32.1",
42
- "@typescript-eslint/parser": "^8.32.1",
43
- "azure-functions-core-tools": "*",
44
- "eslint": "^9",
45
- "jest": "^29.7.0",
46
- "ngrok": "^5.0.0-beta.2",
47
- "rimraf": "^6.0.1",
48
- "ts-jest": "^29.3.4",
49
- "typescript": "^5.8.3"
50
- },
51
- "stableVersion": "2.0.6"
52
- }
1
+ {
2
+ "name": "@seeka-app-example-name/server-azure-function",
3
+ "version": "2.0.7-rc.2",
4
+ "description": "Seeka example app with hosting on Azure serverless functions",
5
+ "author": "Seeka <platform@seeka.co>",
6
+ "license": "MIT",
7
+ "main": "dist/src/functions/*.js",
8
+ "private": true,
9
+ "engines": {
10
+ "node": ">=20"
11
+ },
12
+ "scripts": {
13
+ "lint": "eslint",
14
+ "build": "tsc",
15
+ "watch": "tsc -w",
16
+ "clean": "rimraf dist",
17
+ "prestart": "<packageManagerRunPrefix> clean && yarn build",
18
+ "dev": "func start --port 7072",
19
+ "tunnel": "node scripts/ngrok.js seeka-app-example-name-localdev",
20
+ "deploy": "yarn func azure functionapp publish seeka-app-example-name --no-build --javascript",
21
+ "dev:queue:create": "node scripts/dev-queue-setup.js sample-queue-name"
22
+ },
23
+ "dependencies": {
24
+ "@azure/functions": "^4.7.2",
25
+ "@azure/storage-queue": "^12.26.0",
26
+ "@datalust/winston-seq": "^2.0.0",
27
+ "@redis/client": "^5.1.0",
28
+ "@redis/json": "^5.1.0",
29
+ "@seeka-labs/sdk-apps-server": "2.0.7-rc.2",
30
+ "axios": "^1.9.0",
31
+ "lodash": "^4.17.21",
32
+ "redis": "^5.1.0",
33
+ "winston": "^3.17.0"
34
+ },
35
+ "devDependencies": {
36
+ "@jest/globals": "^29.7.0",
37
+ "@types/jest": "^29.5.14",
38
+ "@types/lodash": "^4.17.17",
39
+ "@types/lodash-es": "^4.17.12",
40
+ "@types/node": "^20",
41
+ "@typescript-eslint/eslint-plugin": "^8.32.1",
42
+ "@typescript-eslint/parser": "^8.32.1",
43
+ "azure-functions-core-tools": "*",
44
+ "eslint": "^9",
45
+ "jest": "^29.7.0",
46
+ "ngrok": "^5.0.0-beta.2",
47
+ "rimraf": "^6.0.1",
48
+ "ts-jest": "^29.3.4",
49
+ "typescript": "^5.8.3"
50
+ },
51
+ "stableVersion": "2.0.6"
52
+ }
@@ -1,28 +1,28 @@
1
- /* eslint-disable no-undef */
2
- // eslint-disable-next-line @typescript-eslint/no-var-requires
3
- const ngrok = require('ngrok');
4
- (async function () {
5
- const url = await ngrok.connect({
6
- proto: 'http',
7
- web_addr: 'localhost:4040',
8
- addr: 7072,
9
- subdomain: process.argv[2],
10
- onLogEvent: (event) => {
11
- console.log('Ngrok - ', event);
12
- }
13
- });
14
-
15
- console.log('')
16
- console.log('')
17
- console.log('------------------------------------------')
18
- console.log('')
19
- console.info(`Public URL for Seeka app is exposed by Ngrok`)
20
- console.log('')
21
- console.info(`${url}/api/webhook/seeka/app`)
22
- console.log('')
23
- console.info(`Use this URL in your Seeka app configuration for testing`)
24
- console.log('')
25
- console.log('------------------------------------------')
26
- console.log('')
27
- console.log('')
1
+ /* eslint-disable no-undef */
2
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
3
+ const ngrok = require('ngrok');
4
+ (async function () {
5
+ const url = await ngrok.connect({
6
+ proto: 'http',
7
+ web_addr: 'localhost:4040',
8
+ addr: 7072,
9
+ subdomain: process.argv[2],
10
+ onLogEvent: (event) => {
11
+ console.log('Ngrok - ', event);
12
+ }
13
+ });
14
+
15
+ console.log('')
16
+ console.log('')
17
+ console.log('------------------------------------------')
18
+ console.log('')
19
+ console.info(`Public URL for Seeka app is exposed by Ngrok`)
20
+ console.log('')
21
+ console.info(`${url}/api/webhook/seeka/app`)
22
+ console.log('')
23
+ console.info(`Use this URL in your Seeka app configuration for testing`)
24
+ console.log('')
25
+ console.log('------------------------------------------')
26
+ console.log('')
27
+ console.log('')
28
28
  })();
@@ -1,14 +1,14 @@
1
- import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions';
2
-
3
- app.http('healthCheck', {
4
- methods: ['GET', 'HEAD'],
5
- authLevel: 'anonymous',
6
- route: 'health',
7
- handler: healthCheck
8
- });
9
-
10
- export async function healthCheck(req: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> {
11
- return {
12
- status: 200
13
- }
1
+ import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions';
2
+
3
+ app.http('healthCheck', {
4
+ methods: ['GET', 'HEAD'],
5
+ authLevel: 'anonymous',
6
+ route: 'health',
7
+ handler: healthCheck
8
+ });
9
+
10
+ export async function healthCheck(req: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> {
11
+ return {
12
+ status: 200
13
+ }
14
14
  }
@@ -1,39 +1,39 @@
1
- import winston from 'winston';
2
-
3
- import { app, InvocationContext, Timer } from '@azure/functions';
4
- import { QueueClient } from '@azure/storage-queue';
5
-
6
- import { jobNames, queueNames, triggerBackgroundJobWithQueue } from '../lib/jobs';
7
- import { backgroundJobLogger } from '../lib/logging';
8
- import { startServices } from '../lib/services';
9
- import { listInstallations } from '../lib/state/seeka/installations';
10
-
11
- // https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=python-v2%2Cisolated-process%2Cnodejs-v4&pivots=programming-language-typescript
12
- app.timer('pollingExample', {
13
- schedule: '0 0 * * * *', // every 1 hour
14
- handler: pollingExample
15
- });
16
-
17
- export async function pollingExample(myTimer: Timer, context: InvocationContext): Promise<void> {
18
- const logger = backgroundJobLogger(jobNames.pollingExample, undefined, context);
19
-
20
- logger.profile(`job.${jobNames.pollingExample}`)
21
- logger.debug('Received request to trigger scheduled job');
22
-
23
- await startServices(logger);
24
-
25
- const allInstallations = await listInstallations(logger);
26
- logger.verbose(`Triggering background job for ${allInstallations.length} installations`)
27
-
28
- const queueClient = new QueueClient(process.env.AzureWebJobsStorage as string, queueNames.queueItemExampleQueueName);
29
- const promises = allInstallations.map(installation => triggerBackgroundJobWithQueue(queueClient, { ...installation, causationId: context.invocationId, correlationId: context.invocationId }, logger))
30
-
31
- try {
32
- await Promise.all(promises);
33
- }
34
- catch (err) {
35
- logger.error('Error triggering background jobs', { ex: winston.exceptions.getAllInfo(err) })
36
- }
37
-
38
- logger.profile(`job.${jobNames.pollingExample}`)
39
- }
1
+ import winston from 'winston';
2
+
3
+ import { app, InvocationContext, Timer } from '@azure/functions';
4
+ import { QueueClient } from '@azure/storage-queue';
5
+
6
+ import { jobNames, queueNames, triggerBackgroundJobWithQueue } from '../lib/jobs';
7
+ import { backgroundJobLogger } from '../lib/logging';
8
+ import { startServices } from '../lib/services';
9
+ import { listInstallations } from '../lib/state/seeka/installations';
10
+
11
+ // https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=python-v2%2Cisolated-process%2Cnodejs-v4&pivots=programming-language-typescript
12
+ app.timer('pollingExample', {
13
+ schedule: '0 0 * * * *', // every 1 hour
14
+ handler: pollingExample
15
+ });
16
+
17
+ export async function pollingExample(myTimer: Timer, context: InvocationContext): Promise<void> {
18
+ const logger = backgroundJobLogger(jobNames.pollingExample, undefined, context);
19
+
20
+ logger.profile(`job.${jobNames.pollingExample}`)
21
+ logger.debug('Received request to trigger scheduled job');
22
+
23
+ await startServices(logger);
24
+
25
+ const allInstallations = await listInstallations(logger);
26
+ logger.verbose(`Triggering background job for ${allInstallations.length} installations`)
27
+
28
+ const queueClient = new QueueClient(process.env.AzureWebJobsStorage as string, queueNames.queueItemExampleQueueName);
29
+ const promises = allInstallations.map(installation => triggerBackgroundJobWithQueue(queueClient, { ...installation, causationId: context.invocationId, correlationId: context.invocationId }, logger))
30
+
31
+ try {
32
+ await Promise.all(promises);
33
+ }
34
+ catch (err) {
35
+ logger.error('Error triggering background jobs', { ex: winston.exceptions.getAllInfo(err) })
36
+ }
37
+
38
+ logger.profile(`job.${jobNames.pollingExample}`)
39
+ }