@seeka-labs/cli-apps 2.0.16-alpha.0 → 2.0.20-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.
- package/LICENSE +19 -19
- package/dist/index.js +2 -2
- package/dist/index.js.map +2 -2
- package/dist/init-template/.gitlab-ci.yml +46 -46
- package/dist/init-template/.yarnrc.yml +8 -0
- package/dist/init-template/README.md +6 -6
- package/dist/init-template/app/browser/jest.config.js +11 -11
- package/dist/init-template/app/browser/package.json +40 -40
- package/dist/init-template/app/browser/scripts/esbuild/build-browser-plugin.mjs +110 -110
- package/dist/init-template/app/browser/scripts/esbuild/plugins/importAsGlobals.mjs +38 -38
- package/dist/init-template/app/browser/src/browser.ts +12 -12
- package/dist/init-template/app/browser/src/plugin/index.test.ts +6 -6
- package/dist/init-template/app/browser/src/plugin/index.ts +47 -47
- package/dist/init-template/app/browser/tsconfig.json +34 -34
- package/dist/init-template/app/server-azure-function/.eslintrc.cjs +10 -10
- package/dist/init-template/app/server-azure-function/.funcignore +21 -21
- package/dist/init-template/app/server-azure-function/README.md +104 -104
- package/dist/init-template/app/server-azure-function/host.json +19 -19
- package/dist/init-template/app/server-azure-function/local.settings.example.json +25 -25
- package/dist/init-template/app/server-azure-function/package.json +52 -52
- package/dist/init-template/app/server-azure-function/scripts/ngrok.js +27 -27
- package/dist/init-template/app/server-azure-function/src/functions/healthCheck.ts +13 -13
- package/dist/init-template/app/server-azure-function/src/functions/pollingExample.ts +39 -39
- package/dist/init-template/app/server-azure-function/src/functions/queueExample.ts +66 -66
- package/dist/init-template/app/server-azure-function/src/functions/seekaAppWebhook.ts +235 -235
- package/dist/init-template/app/server-azure-function/src/lib/browser/index.ts +54 -54
- package/dist/init-template/app/server-azure-function/src/lib/jobs/index.ts +95 -95
- package/dist/init-template/app/server-azure-function/src/lib/logging/index.ts +92 -92
- package/dist/init-template/app/server-azure-function/src/lib/models/index.ts +6 -6
- package/dist/init-template/app/server-azure-function/src/lib/services/index.ts +40 -40
- package/dist/init-template/app/server-azure-function/src/lib/state/redis/index.ts +96 -96
- package/dist/init-template/app/server-azure-function/src/lib/state/seeka/installations.ts +64 -64
- package/dist/init-template/app/server-azure-function/tsconfig.json +17 -17
- package/dist/init-template/tsconfig.json +25 -25
- package/package.json +2 -2
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import type { Logger } from 'winston';
|
|
2
|
-
|
|
3
|
-
import { getList, remove, set, tryGet } from '../redis';
|
|
4
|
-
|
|
5
|
-
export interface SeekaAppInstallState {
|
|
6
|
-
/** ID of the organisation that installed the app */
|
|
7
|
-
organisationId: string;
|
|
8
|
-
/** ID of the brand that installed the app */
|
|
9
|
-
organisationBrandId: string;
|
|
10
|
-
/** ID of the installation of the app */
|
|
11
|
-
applicationInstallId: string;
|
|
12
|
-
// Installation settings provided by the user installing the app
|
|
13
|
-
installationSettings: SampleAppInstallSettings
|
|
14
|
-
// State relating to the app and installation of the app
|
|
15
|
-
installationState: SampleAppInstallState;
|
|
16
|
-
|
|
17
|
-
// When the app was installed
|
|
18
|
-
installedAt: string; // new Date().toISOString()
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface SampleAppInstallState {
|
|
22
|
-
grantedPermissions?: string[]
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type SampleAppInstallSettings = { [key: string]: any; } | {
|
|
26
|
-
myAppInstallSetting1: string | number | undefined;
|
|
27
|
-
myAppInstallSetting2: string | number | undefined;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const stateType = 'install'
|
|
31
|
-
|
|
32
|
-
export const tryGetInstallation = async (applicationInstallId: string, throwWhenNotFound: boolean, logger: Logger): Promise<SeekaAppInstallState | null> => {
|
|
33
|
-
const installation = await tryGet<SeekaAppInstallState>(stateType, applicationInstallId);
|
|
34
|
-
if (installation == null && throwWhenNotFound) {
|
|
35
|
-
throw new Error(`Seeka installation ${applicationInstallId} not found`);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return installation;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const listInstallations = async (logger: Logger): Promise<SeekaAppInstallState[]> => {
|
|
42
|
-
const installations = await getList<SeekaAppInstallState>(stateType);
|
|
43
|
-
|
|
44
|
-
return installations;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
export const createOrUpdateInstallation = async (state: SeekaAppInstallState, logger: Logger): Promise<SeekaAppInstallState> => {
|
|
49
|
-
if (!state.installationState) state.installationState = {};
|
|
50
|
-
if (!state.installedAt) state.installedAt = new Date().toISOString();
|
|
51
|
-
|
|
52
|
-
const creating = (await tryGetInstallation(state.applicationInstallId, false, logger)) === null;
|
|
53
|
-
|
|
54
|
-
await set(stateType, state.applicationInstallId, state);
|
|
55
|
-
|
|
56
|
-
logger.info(creating ? 'Created installation state' : 'Updated installation state', { applicationInstallId: state.applicationInstallId, organisationId: state.organisationId, organisationBrandId: state.organisationBrandId });
|
|
57
|
-
|
|
58
|
-
return state;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export const deleteInstallation = async (applicationInstallId: string, logger: Logger): Promise<void> => {
|
|
62
|
-
await remove(stateType, applicationInstallId);
|
|
63
|
-
|
|
64
|
-
logger.info('Deleted installation state', { applicationInstallId });
|
|
1
|
+
import type { Logger } from 'winston';
|
|
2
|
+
|
|
3
|
+
import { getList, remove, set, tryGet } from '../redis';
|
|
4
|
+
|
|
5
|
+
export interface SeekaAppInstallState {
|
|
6
|
+
/** ID of the organisation that installed the app */
|
|
7
|
+
organisationId: string;
|
|
8
|
+
/** ID of the brand that installed the app */
|
|
9
|
+
organisationBrandId: string;
|
|
10
|
+
/** ID of the installation of the app */
|
|
11
|
+
applicationInstallId: string;
|
|
12
|
+
// Installation settings provided by the user installing the app
|
|
13
|
+
installationSettings: SampleAppInstallSettings
|
|
14
|
+
// State relating to the app and installation of the app
|
|
15
|
+
installationState: SampleAppInstallState;
|
|
16
|
+
|
|
17
|
+
// When the app was installed
|
|
18
|
+
installedAt: string; // new Date().toISOString()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface SampleAppInstallState {
|
|
22
|
+
grantedPermissions?: string[]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type SampleAppInstallSettings = { [key: string]: any; } | {
|
|
26
|
+
myAppInstallSetting1: string | number | undefined;
|
|
27
|
+
myAppInstallSetting2: string | number | undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const stateType = 'install'
|
|
31
|
+
|
|
32
|
+
export const tryGetInstallation = async (applicationInstallId: string, throwWhenNotFound: boolean, logger: Logger): Promise<SeekaAppInstallState | null> => {
|
|
33
|
+
const installation = await tryGet<SeekaAppInstallState>(stateType, applicationInstallId);
|
|
34
|
+
if (installation == null && throwWhenNotFound) {
|
|
35
|
+
throw new Error(`Seeka installation ${applicationInstallId} not found`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return installation;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const listInstallations = async (logger: Logger): Promise<SeekaAppInstallState[]> => {
|
|
42
|
+
const installations = await getList<SeekaAppInstallState>(stateType);
|
|
43
|
+
|
|
44
|
+
return installations;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
export const createOrUpdateInstallation = async (state: SeekaAppInstallState, logger: Logger): Promise<SeekaAppInstallState> => {
|
|
49
|
+
if (!state.installationState) state.installationState = {};
|
|
50
|
+
if (!state.installedAt) state.installedAt = new Date().toISOString();
|
|
51
|
+
|
|
52
|
+
const creating = (await tryGetInstallation(state.applicationInstallId, false, logger)) === null;
|
|
53
|
+
|
|
54
|
+
await set(stateType, state.applicationInstallId, state);
|
|
55
|
+
|
|
56
|
+
logger.info(creating ? 'Created installation state' : 'Updated installation state', { applicationInstallId: state.applicationInstallId, organisationId: state.organisationId, organisationBrandId: state.organisationBrandId });
|
|
57
|
+
|
|
58
|
+
return state;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const deleteInstallation = async (applicationInstallId: string, logger: Logger): Promise<void> => {
|
|
62
|
+
await remove(stateType, applicationInstallId);
|
|
63
|
+
|
|
64
|
+
logger.info('Deleted installation state', { applicationInstallId });
|
|
65
65
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"allowJs": true,
|
|
4
|
-
"skipLibCheck": true,
|
|
5
|
-
"strict": false,
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"outDir": "dist",
|
|
8
|
-
"rootDir": ".",
|
|
9
|
-
"sourceMap": true,
|
|
10
|
-
"module": "CommonJS",
|
|
11
|
-
"target": "ES6",
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"isolatedModules": false,
|
|
14
|
-
},
|
|
15
|
-
"include": [
|
|
16
|
-
"src/functions/*.ts"
|
|
17
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": true,
|
|
4
|
+
"skipLibCheck": true,
|
|
5
|
+
"strict": false,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"rootDir": ".",
|
|
9
|
+
"sourceMap": true,
|
|
10
|
+
"module": "CommonJS",
|
|
11
|
+
"target": "ES6",
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": false,
|
|
14
|
+
},
|
|
15
|
+
"include": [
|
|
16
|
+
"src/functions/*.ts"
|
|
17
|
+
]
|
|
18
18
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"allowJs": true,
|
|
4
|
-
"skipLibCheck": true,
|
|
5
|
-
"strict": false,
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"sourceMap": true,
|
|
8
|
-
"module": "CommonJS",
|
|
9
|
-
"target": "ES6",
|
|
10
|
-
"resolveJsonModule": true,
|
|
11
|
-
"isolatedModules": false,
|
|
12
|
-
"baseUrl": ".",
|
|
13
|
-
"paths": {
|
|
14
|
-
"@seeka-app-example-name/*": ["app/*/src"]
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"references": [
|
|
18
|
-
{ "path": "app/server-azure-function" },
|
|
19
|
-
{ "path": "app/browser" }
|
|
20
|
-
],
|
|
21
|
-
"exclude": [
|
|
22
|
-
"node_modules",
|
|
23
|
-
"**/dist"
|
|
24
|
-
]
|
|
25
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": true,
|
|
4
|
+
"skipLibCheck": true,
|
|
5
|
+
"strict": false,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"sourceMap": true,
|
|
8
|
+
"module": "CommonJS",
|
|
9
|
+
"target": "ES6",
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"isolatedModules": false,
|
|
12
|
+
"baseUrl": ".",
|
|
13
|
+
"paths": {
|
|
14
|
+
"@seeka-app-example-name/*": ["app/*/src"]
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"references": [
|
|
18
|
+
{ "path": "app/server-azure-function" },
|
|
19
|
+
{ "path": "app/browser" }
|
|
20
|
+
],
|
|
21
|
+
"exclude": [
|
|
22
|
+
"node_modules",
|
|
23
|
+
"**/dist"
|
|
24
|
+
]
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seeka-labs/cli-apps",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.20-alpha.0",
|
|
4
4
|
"description": "Seeka - Apps CLI",
|
|
5
5
|
"author": "SEEKA <platform@seeka.co>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"ts-jest": "^29.3.4",
|
|
46
46
|
"typescript": "^5.8.3"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "ff4ab77f42330ca62adeb55c9cf4de01f5e08d77",
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"lodash-es": "^4.17.21",
|
|
51
51
|
"source-map-support": "^0.5.21"
|