@appsemble/cli 0.30.14-test.6 → 0.32.1-test.15
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/README.md +3 -3
- package/commands/app/create.js +9 -4
- package/commands/app/delete.js +1 -1
- package/commands/app/export.js +1 -1
- package/commands/app/patch.d.ts +2 -0
- package/commands/app/patch.js +8 -0
- package/commands/app/update.js +1 -1
- package/commands/asset/publish.js +1 -1
- package/commands/cleanupSoftDeletedRecords.d.ts +6 -0
- package/commands/cleanupSoftDeletedRecords.js +40 -0
- package/commands/config/get.js +6 -2
- package/commands/config/set.js +6 -1
- package/commands/migrate.js +19 -0
- package/commands/serve.js +5 -1
- package/commands/start.js +19 -0
- package/commands/synchronizeTrainings.d.ts +6 -0
- package/commands/synchronizeTrainings.js +40 -0
- package/index.js +5 -0
- package/lib/app.d.ts +8 -0
- package/lib/app.js +59 -17
- package/lib/asset.d.ts +1 -1
- package/lib/authentication.js +4 -4
- package/lib/block.js +15 -6
- package/lib/coercers.js +1 -0
- package/lib/config.js +26 -18
- package/lib/createServers.js +3 -1
- package/lib/group.d.ts +1 -1
- package/lib/group.js +7 -6
- package/lib/output.js +3 -1
- package/lib/processCss.js +1 -1
- package/lib/project.js +3 -2
- package/lib/serverImport.d.ts +1 -1
- package/lib/serverImport.js +1 -1
- package/package.json +19 -16
- package/server/db/methods.js +3 -0
- package/server/options/createAppAsset.d.ts +1 -1
- package/server/options/createAppAsset.js +5 -6
- package/server/options/createAppResourcesWithAssets.js +4 -6
- package/server/options/createSettings.js +1 -1
- package/server/options/createTheme.js +2 -0
- package/server/options/getAppAsset.js +5 -10
- package/server/options/getAppAssets.js +5 -9
- package/server/options/getAppScreenshots.js +3 -3
- package/server/options/getBlockAsset.js +3 -0
- package/server/options/getTheme.js +1 -0
- package/server/options/options.js +2 -0
- package/templates/apps/empty/app-definition.yaml +2 -2
- package/templates/blocks/mini-jsx/package.json +4 -1
- package/templates/blocks/mini-jsx/src/index.tsx +1 -1
- package/templates/blocks/preact/package.json +5 -2
- package/templates/blocks/vanilla/package.json +4 -1
- package/vitest.setup.js +11 -2
- package/lib/app.test.d.ts +0 -1
- package/lib/app.test.js +0 -2212
- package/lib/asset.test.d.ts +0 -1
- package/lib/asset.test.js +0 -105
- package/lib/block.test.d.ts +0 -1
- package/lib/block.test.js +0 -235
- package/lib/coercers.test.d.ts +0 -1
- package/lib/coercers.test.js +0 -27
- package/lib/config.test.d.ts +0 -1
- package/lib/config.test.js +0 -239
- package/lib/group.test.d.ts +0 -1
- package/lib/group.test.js +0 -616
- package/lib/organization.test.d.ts +0 -1
- package/lib/organization.test.js +0 -222
- package/lib/resource.test.d.ts +0 -1
- package/lib/resource.test.js +0 -393
- package/server/db/methods.test.d.ts +0 -1
- package/server/db/methods.test.js +0 -366
- package/server/options/parseQuery.test.d.ts +0 -1
- package/server/options/parseQuery.test.js +0 -46
package/lib/authentication.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { hostname } from 'node:os';
|
|
2
|
-
import { AppsembleError,
|
|
2
|
+
import { AppsembleError, assertKoaCondition, getKeytar, getService, logger, throwKoaError, } from '@appsemble/node-utils';
|
|
3
3
|
import inquirer from 'inquirer';
|
|
4
4
|
import Koa from 'koa';
|
|
5
5
|
import open from 'open';
|
|
@@ -24,14 +24,14 @@ function waitForCredentials(url) {
|
|
|
24
24
|
ctx.assert(ctx.path === '/', 404);
|
|
25
25
|
ctx.assert(ctx.method === 'POST', 405);
|
|
26
26
|
ctx.assert(ctx.is('json'), 415);
|
|
27
|
-
let credentials;
|
|
27
|
+
let credentials = '';
|
|
28
28
|
try {
|
|
29
29
|
({ credentials } = JSON.parse(await raw(ctx.req, { encoding: 'utf8' })));
|
|
30
30
|
}
|
|
31
31
|
catch {
|
|
32
32
|
throwKoaError(ctx, 400, 'Invalid JSON');
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
assertKoaCondition(!(typeof credentials === 'string' && !validate(credentials)), ctx, 400, 'Invalid client credentials');
|
|
35
35
|
ctx.status = 204;
|
|
36
36
|
server.close();
|
|
37
37
|
resolve(credentials);
|
|
@@ -47,7 +47,7 @@ export async function login({ clientCredentials, remote }) {
|
|
|
47
47
|
const url = new URL('/settings/client-credentials', remote);
|
|
48
48
|
let credentials = clientCredentials;
|
|
49
49
|
if (credentials) {
|
|
50
|
-
if (!validate(clientCredentials)) {
|
|
50
|
+
if (!validate(clientCredentials ?? '')) {
|
|
51
51
|
throw new AppsembleError(`Invalid client credentials. Client credentials can be registered on ${url}`);
|
|
52
52
|
}
|
|
53
53
|
credentials = clientCredentials;
|
package/lib/block.js
CHANGED
|
@@ -20,10 +20,17 @@ import { processCss } from './processCss.js';
|
|
|
20
20
|
* @returns The Webpack stats object.
|
|
21
21
|
*/
|
|
22
22
|
export async function buildBlock(buildConfig, env) {
|
|
23
|
-
const conf = await getProjectWebpackConfig(buildConfig, env || 'production',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const conf = await getProjectWebpackConfig(buildConfig, env || 'production',
|
|
24
|
+
// @ts-expect-error 2345 argument of type is not assignable to parameter of type
|
|
25
|
+
// (strictNullChecks)
|
|
26
|
+
join(buildConfig.dir, buildConfig.output));
|
|
27
|
+
// @ts-expect-error 2345 argument of type is not assignable to parameter of type
|
|
28
|
+
// (strictNullChecks)
|
|
29
|
+
if (existsSync(conf.output?.path)) {
|
|
30
|
+
logger.warn(`Removing ${conf.output?.path}`);
|
|
31
|
+
// @ts-expect-error 2345 argument of type is not assignable to parameter of type
|
|
32
|
+
// (strictNullChecks)
|
|
33
|
+
await rm(conf.output?.path, { force: true, recursive: true });
|
|
27
34
|
}
|
|
28
35
|
logger.info(`Building ${buildConfig.name}@${buildConfig.version} 🔨`);
|
|
29
36
|
const compiler = webpack(conf);
|
|
@@ -32,11 +39,13 @@ export async function buildBlock(buildConfig, env) {
|
|
|
32
39
|
if (err) {
|
|
33
40
|
reject(err);
|
|
34
41
|
}
|
|
35
|
-
else if (stats
|
|
42
|
+
else if (stats?.hasErrors()) {
|
|
36
43
|
reject(new AppsembleError(stats.toString({ colors: true })));
|
|
37
44
|
}
|
|
38
45
|
else {
|
|
39
|
-
logger.verbose(stats
|
|
46
|
+
logger.verbose(stats?.toString({ colors: true }));
|
|
47
|
+
// @ts-expect-error 2345 argument of type is not assignable to parameter of type
|
|
48
|
+
// (strictNullChecks)
|
|
40
49
|
resolve(stats);
|
|
41
50
|
}
|
|
42
51
|
};
|
package/lib/coercers.js
CHANGED
package/lib/config.js
CHANGED
|
@@ -17,15 +17,11 @@ import { createFormatter, createParser, SchemaGenerator, ts } from 'ts-json-sche
|
|
|
17
17
|
*/
|
|
18
18
|
export async function getProjectBuildConfig(dir) {
|
|
19
19
|
const explorer = cosmiconfig('appsemble', { stopDir: dir });
|
|
20
|
-
const found = await explorer.search(dir);
|
|
21
|
-
let foundInParent;
|
|
20
|
+
const found = (await explorer.search(dir)) ?? (await explorer.search(dirname(dir)));
|
|
22
21
|
if (!found) {
|
|
23
|
-
|
|
24
|
-
if (!foundInParent) {
|
|
25
|
-
throw new AppsembleError(`No Appsemble configuration file found searching ${dir}`);
|
|
26
|
-
}
|
|
22
|
+
throw new AppsembleError(`No Appsemble configuration file found searching ${dir}`);
|
|
27
23
|
}
|
|
28
|
-
const { config, filepath } = found
|
|
24
|
+
const { config, filepath } = found;
|
|
29
25
|
logger.info(`Found configuration file: ${filepath}`);
|
|
30
26
|
const [pkg] = await readData(join(dir, 'package.json'));
|
|
31
27
|
if (!pkg.private) {
|
|
@@ -61,7 +57,7 @@ export async function getProjectsBuildConfigs(root) {
|
|
|
61
57
|
.map((path) => getProjectBuildConfig(path))
|
|
62
58
|
// Ignore non-project workspaces.
|
|
63
59
|
.map((p) => p.catch(() => null)));
|
|
64
|
-
return projectBuildConfigs.filter(
|
|
60
|
+
return projectBuildConfigs.filter((x) => x != null);
|
|
65
61
|
}
|
|
66
62
|
/**
|
|
67
63
|
* Get the TypeScript program for a given path.
|
|
@@ -76,6 +72,8 @@ function getProgram(path) {
|
|
|
76
72
|
getCanonicalFileName: (x) => x,
|
|
77
73
|
};
|
|
78
74
|
const tsConfigPath = ts.findConfigFile(path, ts.sys.fileExists);
|
|
75
|
+
// @ts-expect-error 2345 argument of type is not assignable to parameter of type
|
|
76
|
+
// (strictNullChecks)
|
|
79
77
|
const { config, error } = ts.readConfigFile(tsConfigPath, ts.sys.readFile);
|
|
80
78
|
if (error) {
|
|
81
79
|
throw new AppsembleError(ts.formatDiagnostic(error, diagnosticHost));
|
|
@@ -111,6 +109,8 @@ function getProgram(path) {
|
|
|
111
109
|
* @returns The tsdoc comment as a string, if present.
|
|
112
110
|
*/
|
|
113
111
|
function getNodeComments(checker, node) {
|
|
112
|
+
// @ts-expect-error 2345 argument of type is not assignable to parameter of type
|
|
113
|
+
// (strictNullChecks)
|
|
114
114
|
const symbol = checker.getSymbolAtLocation(node.name);
|
|
115
115
|
if (!symbol) {
|
|
116
116
|
return;
|
|
@@ -239,6 +239,7 @@ function processParameters(program, iface) {
|
|
|
239
239
|
* @returns The action manifest to upload.
|
|
240
240
|
*/
|
|
241
241
|
function processMessages(iface, checker) {
|
|
242
|
+
// @ts-expect-error 2322 null is not assignable to type (strictNullChecks)
|
|
242
243
|
return processInterface(iface, checker, (name, description) => [name, { description }]);
|
|
243
244
|
}
|
|
244
245
|
/**
|
|
@@ -276,6 +277,8 @@ export function getProjectImplementations(buildConfig) {
|
|
|
276
277
|
if (mod.name.text !== '@appsemble/sdk') {
|
|
277
278
|
return;
|
|
278
279
|
}
|
|
280
|
+
// @ts-expect-error 2345 argument of type is not assignable to parameter of type
|
|
281
|
+
// (strictNullChecks)
|
|
279
282
|
ts.forEachChild(mod.body, (iface) => {
|
|
280
283
|
// Appsemble only uses module interface augmentation.
|
|
281
284
|
if (!ts.isInterfaceDeclaration(iface)) {
|
|
@@ -324,16 +327,21 @@ export function getProjectImplementations(buildConfig) {
|
|
|
324
327
|
});
|
|
325
328
|
}
|
|
326
329
|
return {
|
|
327
|
-
actions:
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
330
|
+
actions:
|
|
331
|
+
// @ts-expect-error 2454 Variable used before it was assigned
|
|
332
|
+
'actions' in buildConfig ? buildConfig.actions : processActions(actionInterface, checker),
|
|
333
|
+
events:
|
|
334
|
+
// @ts-expect-error 2454 Variable used before it was assigned
|
|
335
|
+
// eslint-disable-next-line prettier/prettier
|
|
336
|
+
'events' in buildConfig ? buildConfig.events : processEvents(eventListenerInterface, eventEmitterInterface, checker),
|
|
337
|
+
parameters:
|
|
338
|
+
// @ts-expect-error 2454 Variable used before it was assigned
|
|
339
|
+
// eslint-disable-next-line prettier/prettier
|
|
340
|
+
'parameters' in buildConfig ? buildConfig.parameters : processParameters(program, parametersInterface),
|
|
341
|
+
messages:
|
|
342
|
+
// @ts-expect-error 2454 Variable used before it was assigned
|
|
343
|
+
// eslint-disable-next-line prettier/prettier
|
|
344
|
+
'messages' in buildConfig ? buildConfig.messages : processMessages(messagesInterface, checker),
|
|
337
345
|
};
|
|
338
346
|
}
|
|
339
347
|
/**
|
package/lib/createServers.js
CHANGED
|
@@ -20,7 +20,9 @@ export async function createStaticServer({ context, webpackConfigs, }) {
|
|
|
20
20
|
if (process.env.NODE_ENV === 'production') {
|
|
21
21
|
app.use(compress());
|
|
22
22
|
}
|
|
23
|
-
if (!['test', 'production'].includes(process.env.NODE_ENV)) {
|
|
23
|
+
if (!['test', 'production'].includes(process.env.NODE_ENV ?? '')) {
|
|
24
|
+
// @ts-expect-error 2345 argument of type is not assignable to parameter of type
|
|
25
|
+
// (strictNullChecks)
|
|
24
26
|
app.use(await frontend(webpackConfigs, argv));
|
|
25
27
|
}
|
|
26
28
|
app.use(appRouter);
|
package/lib/group.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ interface CreateGroupParams extends SharedGroupParams {
|
|
|
57
57
|
*/
|
|
58
58
|
annotations?: string[];
|
|
59
59
|
}
|
|
60
|
-
export declare function resolveAnnotations(annotations: string[]): Record<string, string
|
|
60
|
+
export declare function resolveAnnotations(annotations: string[]): Record<string, string> | undefined;
|
|
61
61
|
export declare function createGroup({ annotations, appId, clientCredentials, name, remote, }: CreateGroupParams): Promise<void>;
|
|
62
62
|
export declare function deleteGroup({ clientCredentials, id, remote, }: SharedExistingGroupParams): Promise<void>;
|
|
63
63
|
export declare function updateGroup({ annotations, id, name, remote, }: UpdateGroupParams): Promise<void>;
|
package/lib/group.js
CHANGED
|
@@ -2,15 +2,16 @@ import { AppsembleError, authenticate, logger } from '@appsemble/node-utils';
|
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
export function resolveAnnotations(annotations) {
|
|
4
4
|
const annotationRegex = /^\w+=.+$/;
|
|
5
|
+
if (!annotations.length) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
5
8
|
if (annotations.some((a) => !annotationRegex.test(a))) {
|
|
6
9
|
throw new AppsembleError('One of the annotations did not follow the pattern of key=value');
|
|
7
10
|
}
|
|
8
|
-
return annotations.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}))
|
|
13
|
-
: undefined;
|
|
11
|
+
return Object.fromEntries(annotations.map((annotation) => {
|
|
12
|
+
const [key, ...value] = annotation.split('=');
|
|
13
|
+
return [key, value.join('=')];
|
|
14
|
+
}));
|
|
14
15
|
}
|
|
15
16
|
export async function createGroup({ annotations = [], appId, clientCredentials, name, remote, }) {
|
|
16
17
|
logger.info(`Creating group ${name}`);
|
package/lib/output.js
CHANGED
|
@@ -7,7 +7,9 @@ export function printAxiosError(filename, yaml, errors) {
|
|
|
7
7
|
const node = doc.getIn(error.path, true);
|
|
8
8
|
let result = filename;
|
|
9
9
|
if (isNode(node)) {
|
|
10
|
-
|
|
10
|
+
// @ts-expect-error 2345 argument of type is not assignable to parameter of type
|
|
11
|
+
// (strictNullChecks)
|
|
12
|
+
const { col, line } = lineCounter.linePos(node.range?.[0]);
|
|
11
13
|
result += `:${line}:${col}`;
|
|
12
14
|
}
|
|
13
15
|
return `${result} ${error.message}`;
|
package/lib/processCss.js
CHANGED
|
@@ -15,7 +15,7 @@ export async function processCss(path) {
|
|
|
15
15
|
const postCss = postcss(postcssConfig.plugins);
|
|
16
16
|
postCss.use(postcssUrl({ url: 'inline' }));
|
|
17
17
|
postCss.use(postcssImport({ plugins: postCss.plugins }));
|
|
18
|
-
const { css } = await postCss.process(data, { from: path, to:
|
|
18
|
+
const { css } = await postCss.process(data, { from: path, to: undefined });
|
|
19
19
|
return css;
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=processCss.js.map
|
package/lib/project.js
CHANGED
|
@@ -10,9 +10,10 @@ import FormData from 'form-data';
|
|
|
10
10
|
import { getProjectImplementations } from './config.js';
|
|
11
11
|
export async function buildProject(config) {
|
|
12
12
|
const buildOptions = {
|
|
13
|
-
entryPoints: ['index
|
|
13
|
+
entryPoints: ['./src/index'],
|
|
14
14
|
bundle: true,
|
|
15
15
|
write: false,
|
|
16
|
+
outdir: 'dist',
|
|
16
17
|
absWorkingDir: join(config.dir),
|
|
17
18
|
loader: {
|
|
18
19
|
'.png': 'dataurl',
|
|
@@ -135,7 +136,7 @@ export async function publishProject(buildConfig, url, ignoreConflict) {
|
|
|
135
136
|
logger.info(`Successfully published ${buildConfig.name}@${buildConfig.version} 🎉`);
|
|
136
137
|
}
|
|
137
138
|
catch (err) {
|
|
138
|
-
if (ignoreConflict && axios.isAxiosError(err) && err.response
|
|
139
|
+
if (ignoreConflict && axios.isAxiosError(err) && err.response?.status === 409) {
|
|
139
140
|
logger.warn(`${buildConfig.name}@${buildConfig.version} was already published.`);
|
|
140
141
|
return;
|
|
141
142
|
}
|
package/lib/serverImport.d.ts
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @param members The names of the exported member to import.
|
|
5
5
|
* @returns The exported member.
|
|
6
6
|
*/
|
|
7
|
-
export declare function serverImport<T extends 'checkDownMigrations' | 'checkMigrations' | 'cleanupDemoAppMembers' | 'cleanupResourcesAndAssets' | 'fuzzMigrations' | 'migrate' | 'migrateAppDefinitions' | 'runCronJobs' | 'scaleContainers' | 'setArgv' | 'start'>(...members: T[]): Promise<Record<T, any>>;
|
|
7
|
+
export declare function serverImport<T extends 'checkDownMigrations' | 'checkMigrations' | 'cleanupDemoAppMembers' | 'cleanupResourcesAndAssets' | 'cleanupSoftDeletedRecords' | 'fuzzMigrations' | 'migrate' | 'migrateAppDefinitions' | 'runCronJobs' | 'scaleContainers' | 'setArgv' | 'start' | 'synchronizeTrainings'>(...members: T[]): Promise<Record<T, any>>;
|
package/lib/serverImport.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AppsembleError } from '@appsemble/node-utils';
|
|
2
2
|
import { has } from '@appsemble/utils';
|
|
3
3
|
const PROMPT = process.platform === 'win32' ? '>' : '$';
|
|
4
|
-
const COMMAND = /yarn/.test(process.env.npm_execpath)
|
|
4
|
+
const COMMAND = /yarn/.test(process.env.npm_execpath ?? '')
|
|
5
5
|
? 'yarn add --dev --ignore-workspace-root-check'
|
|
6
6
|
: 'npm install --save-dev';
|
|
7
7
|
const INSTALL_MESSAGE = `This command requires the Appsemble server to be installed. It can be installed by running the following command:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsemble/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.1-test.15",
|
|
4
4
|
"description": "The CLI for developing with Appsemble apps and blocks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"author": "Appsemble <info@appsemble.com> (https://appsemble.com)",
|
|
23
23
|
"type": "module",
|
|
24
24
|
"exports": {
|
|
25
|
-
".":
|
|
26
|
-
"./index.
|
|
27
|
-
"./index.
|
|
28
|
-
|
|
25
|
+
".": {
|
|
26
|
+
"ts-source": "./index.ts",
|
|
27
|
+
"default": "./index.js"
|
|
28
|
+
},
|
|
29
29
|
"./README.md": "./README.md"
|
|
30
30
|
},
|
|
31
31
|
"bin": {
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
"**/*.d.ts",
|
|
36
36
|
"**/*.js",
|
|
37
37
|
"!*.config.js",
|
|
38
|
+
"!**/*.test.js",
|
|
39
|
+
"!**/*.test.d.ts",
|
|
38
40
|
"templates"
|
|
39
41
|
],
|
|
40
42
|
"scripts": {
|
|
@@ -42,23 +44,23 @@
|
|
|
42
44
|
"test": "vitest"
|
|
43
45
|
},
|
|
44
46
|
"dependencies": {
|
|
45
|
-
"@appsemble/node-utils": "0.
|
|
46
|
-
"@appsemble/types": "0.
|
|
47
|
-
"@appsemble/utils": "0.
|
|
47
|
+
"@appsemble/node-utils": "0.32.1-test.15",
|
|
48
|
+
"@appsemble/types": "0.32.1-test.15",
|
|
49
|
+
"@appsemble/utils": "0.32.1-test.15",
|
|
48
50
|
"@fortawesome/fontawesome-common-types": "^6.0.0",
|
|
49
|
-
"@koa/cors": "^
|
|
51
|
+
"@koa/cors": "^5.0.0",
|
|
50
52
|
"@odata/parser": "^0.2.0",
|
|
51
53
|
"axios": "^1.0.0",
|
|
52
54
|
"chalk": "^5.0.0",
|
|
53
55
|
"comment-parser": "^1.0.0",
|
|
54
56
|
"cosmiconfig": "^7.0.0",
|
|
55
57
|
"csvtojson": "^2.0.0",
|
|
56
|
-
"esbuild": "^0.
|
|
58
|
+
"esbuild": "^0.21.5",
|
|
57
59
|
"fast-glob": "^3.0.0",
|
|
58
60
|
"form-data": "^4.0.0",
|
|
59
61
|
"global-cache-dir": "^6.0.0",
|
|
60
62
|
"inquirer": "^9.0.0",
|
|
61
|
-
"jsonschema": "
|
|
63
|
+
"jsonschema": "~1.4.1",
|
|
62
64
|
"koa": "^2.0.0",
|
|
63
65
|
"koa-compose": "^4.0.0",
|
|
64
66
|
"koa-compress": "^5.0.0",
|
|
@@ -87,20 +89,21 @@
|
|
|
87
89
|
"yargs": "^17.0.0"
|
|
88
90
|
},
|
|
89
91
|
"devDependencies": {
|
|
90
|
-
"@appsemble/types": "0.
|
|
91
|
-
"@appsemble/server": "0.
|
|
92
|
+
"@appsemble/types": "0.32.1-test.15",
|
|
93
|
+
"@appsemble/server": "0.32.1-test.15",
|
|
92
94
|
"bcrypt": "^5.0.0",
|
|
93
95
|
"axios-test-instance": "^7.0.0",
|
|
94
96
|
"@types/concat-stream": "^2.0.0",
|
|
95
97
|
"@types/inquirer": "^9.0.0",
|
|
98
|
+
"@types/koa__cors": "^5.0.0",
|
|
96
99
|
"@types/normalize-path": "^3.0.0",
|
|
97
100
|
"@types/postcss-import": "^14.0.0",
|
|
98
101
|
"@types/postcss-url": "^10.0.0",
|
|
99
102
|
"concat-stream": "^2.0.0",
|
|
100
|
-
"vitest": "^
|
|
101
|
-
"sequelize": "^6.0.0"
|
|
103
|
+
"vitest": "^2.0.0",
|
|
104
|
+
"sequelize": "^6.0.0",
|
|
105
|
+
"minio": "^8.0.3"
|
|
102
106
|
},
|
|
103
|
-
"peerDependencies": {},
|
|
104
107
|
"optionalDependencies": {
|
|
105
108
|
"keytar": "^7.0.0"
|
|
106
109
|
},
|
package/server/db/methods.js
CHANGED
|
@@ -216,9 +216,11 @@ export const Methods = {
|
|
|
216
216
|
const entityIndex = await db.getIndex(modelDir, id);
|
|
217
217
|
const existing = await this.findById(id, modelDir);
|
|
218
218
|
await db.push(`${modelDir}[${entityIndex}]`, { ...existing, ...values }, true);
|
|
219
|
+
// @ts-expect-error 2322 null is not assignable to type (strictNullChecks)
|
|
219
220
|
return this.findOne({ where: values }, modelDir);
|
|
220
221
|
}
|
|
221
222
|
catch {
|
|
223
|
+
// @ts-expect-error 2322 null is not assignable to type (strictNullChecks)
|
|
222
224
|
return null;
|
|
223
225
|
}
|
|
224
226
|
},
|
|
@@ -229,6 +231,7 @@ export const Methods = {
|
|
|
229
231
|
return await db.delete(`${modelDir}[${entityIndex}]`);
|
|
230
232
|
}
|
|
231
233
|
catch {
|
|
234
|
+
// @ts-expect-error 2322 null is not assignable to type (strictNullChecks)
|
|
232
235
|
return null;
|
|
233
236
|
}
|
|
234
237
|
},
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type AppAsset, type CreateAppAssetParams } from '@appsemble/node-utils';
|
|
2
|
-
export declare function createAppAsset({ context, payload
|
|
2
|
+
export declare function createAppAsset({ context, payload }: CreateAppAssetParams): Promise<AppAsset>;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
const {
|
|
1
|
+
import { createReadStream } from 'node:fs';
|
|
2
|
+
export function createAppAsset({ context, payload }) {
|
|
3
|
+
const { filename, mime, name, path } = payload;
|
|
4
4
|
const asset = {
|
|
5
5
|
id: name,
|
|
6
|
-
data,
|
|
7
6
|
mime,
|
|
8
7
|
name,
|
|
9
8
|
filename,
|
|
9
|
+
stream: createReadStream(path),
|
|
10
10
|
};
|
|
11
11
|
context.appAssets.push(asset);
|
|
12
|
-
|
|
13
|
-
return asset;
|
|
12
|
+
return Promise.resolve(asset);
|
|
14
13
|
}
|
|
15
14
|
//# sourceMappingURL=createAppAsset.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createReadStream } from 'node:fs';
|
|
2
2
|
import { Resource } from '../models/Resource.js';
|
|
3
3
|
export async function createAppResourcesWithAssets({ app, context, preparedAssets, resourceType, resources, }) {
|
|
4
4
|
const existingResources = await Resource.findAll({}, resourceType);
|
|
@@ -8,11 +8,9 @@ export async function createAppResourcesWithAssets({ app, context, preparedAsset
|
|
|
8
8
|
AppId: app.id,
|
|
9
9
|
...resource,
|
|
10
10
|
})), resourceType);
|
|
11
|
-
const
|
|
12
|
-
context.appAssets.push(asset);
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
-
await Promise.all(assetPromises);
|
|
11
|
+
for (const asset of preparedAssets) {
|
|
12
|
+
context.appAssets.push({ ...asset, stream: createReadStream(asset.path) });
|
|
13
|
+
}
|
|
16
14
|
return createdResources;
|
|
17
15
|
}
|
|
18
16
|
//# sourceMappingURL=createAppResourcesWithAssets.js.map
|
|
@@ -12,7 +12,7 @@ export async function createSettings({ context, host, languages, }) {
|
|
|
12
12
|
const controllerBuildConfig = await getProjectBuildConfig(controllerPath);
|
|
13
13
|
const controllerBuildResult = await buildProject(controllerBuildConfig);
|
|
14
14
|
[, controllerImplementations] = await makeProjectPayload(controllerBuildConfig);
|
|
15
|
-
controllerCode = controllerBuildResult.outputFiles[0].text;
|
|
15
|
+
controllerCode = controllerBuildResult.outputFiles?.[0].text;
|
|
16
16
|
}
|
|
17
17
|
return createUtilsSettings({
|
|
18
18
|
apiUrl: host,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Theme } from '../models/Theme.js';
|
|
2
2
|
export function createTheme({ css, ...theme }) {
|
|
3
|
+
// @ts-expect-error 2345 argument of type is not assignable to parameter of type
|
|
4
|
+
// (strictNullChecks)
|
|
3
5
|
return Theme.create({ ...theme, css });
|
|
4
6
|
}
|
|
5
7
|
//# sourceMappingURL=createTheme.js.map
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createReadStream } from 'node:fs';
|
|
2
2
|
export function getAppAsset({ context, id: filename }) {
|
|
3
|
-
const assetFound = context.appAssets.find((asset) => asset.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
...assetFound,
|
|
8
|
-
data,
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
return Promise.resolve(assetPromise());
|
|
3
|
+
const assetFound = context.appAssets.find((asset) => asset.name === filename);
|
|
4
|
+
// @ts-expect-error 2345 argument of type is not assignable to parameter of type
|
|
5
|
+
// (strictNullChecks)
|
|
6
|
+
return Promise.resolve({ ...assetFound, stream: createReadStream(assetFound.filename) });
|
|
12
7
|
}
|
|
13
8
|
//# sourceMappingURL=getAppAsset.js.map
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createReadStream } from 'node:fs';
|
|
2
2
|
export function getAppAssets({ context }) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
data,
|
|
8
|
-
};
|
|
9
|
-
});
|
|
10
|
-
return Promise.all(assetPromises);
|
|
3
|
+
return Promise.resolve(
|
|
4
|
+
// @ts-expect-error 2345 argument of type is not assignable to parameter of type
|
|
5
|
+
// (strictNullChecks)
|
|
6
|
+
context.appAssets.map((asset) => ({ ...asset, stream: createReadStream(asset.filename) })));
|
|
11
7
|
}
|
|
12
8
|
//# sourceMappingURL=getAppAssets.js.map
|
|
@@ -2,11 +2,11 @@ import { readFile } from 'node:fs/promises';
|
|
|
2
2
|
import { lookup } from 'mime-types';
|
|
3
3
|
import sharp from 'sharp';
|
|
4
4
|
export function getAppScreenshots({ app, }) {
|
|
5
|
-
const appScreenshotsPromises = app.screenshotUrls
|
|
5
|
+
const appScreenshotsPromises = app.screenshotUrls?.map(async (screenshotUrl, index) => {
|
|
6
6
|
const screenshot = await readFile(`${app.path}/screenshots/${screenshotUrl}`);
|
|
7
7
|
const img = sharp(screenshot);
|
|
8
8
|
const { format, height, width } = await img.metadata();
|
|
9
|
-
const mime = lookup(format);
|
|
9
|
+
const mime = lookup(format ?? '');
|
|
10
10
|
return {
|
|
11
11
|
id: index,
|
|
12
12
|
width,
|
|
@@ -15,6 +15,6 @@ export function getAppScreenshots({ app, }) {
|
|
|
15
15
|
screenshot,
|
|
16
16
|
};
|
|
17
17
|
});
|
|
18
|
-
return Promise.all(appScreenshotsPromises);
|
|
18
|
+
return Promise.all(appScreenshotsPromises ?? []);
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=getAppScreenshots.js.map
|
|
@@ -6,9 +6,12 @@ import globalCacheDir from 'global-cache-dir';
|
|
|
6
6
|
import { lookup } from 'mime-types';
|
|
7
7
|
export async function getBlockAsset({ context, filename, name, version, }) {
|
|
8
8
|
const { blockConfigs } = context;
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
10
|
+
// @ts-ignore 2488 [...] | undefined must have a '[Symbol.iterator]()'
|
|
9
11
|
const [organisation, blockName] = parseBlockName(name);
|
|
10
12
|
if (existsSync(join(process.cwd(), 'blocks', blockName))) {
|
|
11
13
|
const blockConfig = blockConfigs.find((block) => block.name === name);
|
|
14
|
+
// @ts-expect-error 18048 variable is possibly undefined (strictNullChecks)
|
|
12
15
|
const asset = await readFile(`${blockConfig.dir}/${blockConfig.output}/${filename}`);
|
|
13
16
|
const mime = lookup(filename) || '';
|
|
14
17
|
return {
|
|
@@ -2,6 +2,7 @@ import { Theme } from '../models/Theme.js';
|
|
|
2
2
|
export async function getTheme({ theme }) {
|
|
3
3
|
const persistedTheme = await Theme.findOne({ where: theme });
|
|
4
4
|
return {
|
|
5
|
+
// @ts-expect-error 2322 null is not assignable to type (strictNullChecks)
|
|
5
6
|
css: persistedTheme ? persistedTheme.css : null,
|
|
6
7
|
};
|
|
7
8
|
}
|
|
@@ -6,7 +6,7 @@ pages:
|
|
|
6
6
|
- name: Example Page A
|
|
7
7
|
blocks:
|
|
8
8
|
- type: action-button
|
|
9
|
-
version: 0.
|
|
9
|
+
version: 0.32.1-test.15
|
|
10
10
|
parameters:
|
|
11
11
|
icon: arrow-right
|
|
12
12
|
actions:
|
|
@@ -17,7 +17,7 @@ pages:
|
|
|
17
17
|
- name: Example Page B
|
|
18
18
|
blocks:
|
|
19
19
|
- type: action-button
|
|
20
|
-
version: 0.
|
|
20
|
+
version: 0.32.1-test.15
|
|
21
21
|
parameters:
|
|
22
22
|
icon: arrow-left
|
|
23
23
|
actions:
|
|
@@ -36,7 +36,7 @@ bootstrap(({ events, parameters: { fields }, utils: { fa, formatMessage, remap }
|
|
|
36
36
|
wrapper.append(
|
|
37
37
|
...fields.map(({ icon, label, value }) => {
|
|
38
38
|
// The remap utility is a powerful tool to transform user data. A full reference is found
|
|
39
|
-
// on https://appsemble.app/docs/
|
|
39
|
+
// on https://appsemble.app/docs/remappers. However, for the block all that
|
|
40
40
|
// matters is we can pass in a user defined remapper and a value, and get the value the
|
|
41
41
|
// user wants to use.
|
|
42
42
|
const remappedLabel = remap(label, data) as string;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": true,
|
|
3
3
|
"type": "module",
|
|
4
|
+
"sideEffects": [
|
|
5
|
+
"*.css"
|
|
6
|
+
],
|
|
4
7
|
"dependencies": {
|
|
5
|
-
"@appsemble/preact": "0.
|
|
6
|
-
"@appsemble/sdk": "0.
|
|
8
|
+
"@appsemble/preact": "0.32.1-test.15",
|
|
9
|
+
"@appsemble/sdk": "0.32.1-test.15",
|
|
7
10
|
"preact": "^10.0.0"
|
|
8
11
|
}
|
|
9
12
|
}
|