@appsemble/node-utils 0.36.5 → 0.36.6-test.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/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.36.5/config/assets/logo.svg) Appsemble Node Utilities
1
+ # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.36.6-test.0/config/assets/logo.svg) Appsemble Node Utilities
2
2
 
3
3
  > NodeJS utilities used by Appsemble internally.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@appsemble/node-utils)](https://www.npmjs.com/package/@appsemble/node-utils)
6
- [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.36.5/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.36.5)
6
+ [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.36.6-test.0/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.36.6-test.0)
7
7
  [![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)
8
8
 
9
9
  ## Table of Contents
@@ -26,5 +26,5 @@ compatibility is not guaranteed.
26
26
 
27
27
  ## License
28
28
 
29
- [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.36.5/LICENSE.md) ©
29
+ [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.36.6-test.0/LICENSE.md) ©
30
30
  [Appsemble](https://appsemble.com)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/node-utils",
3
- "version": "0.36.5",
3
+ "version": "0.36.6-test.0",
4
4
  "description": "NodeJS utilities used by Appsemble internally.",
5
5
  "keywords": [
6
6
  "app",
@@ -40,9 +40,9 @@
40
40
  "test": "vitest"
41
41
  },
42
42
  "dependencies": {
43
- "@appsemble/lang-sdk": "0.36.5",
44
- "@appsemble/types": "0.36.5",
45
- "@appsemble/utils": "0.36.5",
43
+ "@appsemble/lang-sdk": "0.36.6-test.0",
44
+ "@appsemble/types": "0.36.6-test.0",
45
+ "@appsemble/utils": "0.36.6-test.0",
46
46
  "@formatjs/fast-memoize": "^2.0.0",
47
47
  "@fortawesome/fontawesome-free": "^6.0.0",
48
48
  "@kubernetes/client-node": "1.4.0",
@@ -6,6 +6,7 @@ export function createBlockAssetHandler({ getBlockAsset }) {
6
6
  params: { filename, name, version }, } = ctx;
7
7
  const blockAsset = await getBlockAsset({ filename, name, version, context: ctx });
8
8
  assertKoaCondition(blockAsset != null, ctx, 404, 'Block asset not found');
9
+ ctx.set('Cache-Control', 'max-age=31536000,immutable');
9
10
  ctx.body = blockAsset.content;
10
11
  ctx.type = blockAsset.mime;
11
12
  };
@@ -35,7 +35,7 @@ export function createAppRouter(options) {
35
35
  },
36
36
  {
37
37
  route: '/service-worker.js',
38
- get: createServiceWorkerHandler(options),
38
+ get: createServiceWorkerHandler(),
39
39
  },
40
40
  {
41
41
  route: /^\/icon-(?<size>\d+)\.png$/,
@@ -1,3 +1,2 @@
1
- import { type Options } from '@appsemble/node-utils';
2
1
  import { type Middleware } from 'koa';
3
- export declare function createServiceWorkerHandler({ getApp, getBlocksAssetsPaths }: Options): Middleware;
2
+ export declare function createServiceWorkerHandler(): Middleware;
@@ -1,22 +1,12 @@
1
1
  import { readFile } from 'node:fs/promises';
2
- import { getAppBlocks } from '@appsemble/lang-sdk';
3
- import { assertKoaCondition } from '@appsemble/node-utils';
4
- export function createServiceWorkerHandler({ getApp, getBlocksAssetsPaths }) {
2
+ export function createServiceWorkerHandler() {
5
3
  return async (ctx) => {
6
4
  const production = process.env.NODE_ENV === 'production';
7
5
  const filename = production ? '/service-worker.js' : '/app/service-worker.js';
8
6
  const serviceWorker = await (production
9
7
  ? readFile(new URL('../../../../../dist/app/service-worker.js', import.meta.url), 'utf8')
10
8
  : ctx.fs.promises.readFile(filename, 'utf8'));
11
- const app = await getApp({
12
- context: ctx,
13
- query: { attributes: ['id', 'definition'] },
14
- });
15
- assertKoaCondition(app != null, ctx, 404, 'App does not exist.');
16
- const identifiableBlocks = getAppBlocks(app.definition);
17
- const blocksAssetsPaths = await getBlocksAssetsPaths({ identifiableBlocks, context: ctx });
18
- // App.version is a virtual column and comes from App.AppSnapshots
19
- ctx.body = `const appVersion = ${app.version};const blockAssets=${JSON.stringify(blocksAssetsPaths)};${serviceWorker}`;
9
+ ctx.body = serviceWorker;
20
10
  ctx.type = 'application/javascript';
21
11
  };
22
12
  }