@appsemble/node-utils 0.30.3 → 0.30.9

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.30.3/config/assets/logo.svg) Appsemble Node Utilities
1
+ # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.30.9/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.30.3/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.30.3)
6
+ [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.30.9/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.30.9)
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.30.3/LICENSE.md) ©
29
+ [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.30.9/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.30.3",
3
+ "version": "0.30.9",
4
4
  "description": "NodeJS utilities used by Appsemble internally.",
5
5
  "keywords": [
6
6
  "app",
@@ -38,8 +38,8 @@
38
38
  "test": "vitest"
39
39
  },
40
40
  "dependencies": {
41
- "@appsemble/types": "0.30.3",
42
- "@appsemble/utils": "0.30.3",
41
+ "@appsemble/types": "0.30.9",
42
+ "@appsemble/utils": "0.30.9",
43
43
  "@formatjs/fast-memoize": "^2.0.0",
44
44
  "@fortawesome/fontawesome-free": "^6.0.0",
45
45
  "@kubernetes/client-node": "0.21.0",
@@ -0,0 +1,3 @@
1
+ import { type Middleware } from 'koa';
2
+ import { type Options } from '../../../../../types.js';
3
+ export declare function createGetCurrentAppMemberGroupsController({ getApp, getCurrentAppMemberGroups, }: Options): Middleware;
@@ -0,0 +1,8 @@
1
+ export function createGetCurrentAppMemberGroupsController({ getApp, getCurrentAppMemberGroups, }) {
2
+ return async (ctx) => {
3
+ const { pathParams: { appId }, } = ctx;
4
+ const app = await getApp({ context: ctx, query: { where: { id: appId }, attributes: ['id'] } });
5
+ ctx.body = await getCurrentAppMemberGroups({ context: ctx, app });
6
+ };
7
+ }
8
+ //# sourceMappingURL=createGetCurrentAppMemberGroupsController.js.map
@@ -0,0 +1 @@
1
+ export * from './createGetCurrentAppMemberGroupsController.js';
@@ -0,0 +1,2 @@
1
+ export * from './createGetCurrentAppMemberGroupsController.js';
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1,2 @@
1
1
  export { createGetCurrentAppMemberController } from './createGetCurrentAppMemberController.js';
2
+ export { createGetCurrentAppMemberGroupsController } from './groups/index.js';
@@ -1,2 +1,3 @@
1
1
  export { createGetCurrentAppMemberController } from './createGetCurrentAppMemberController.js';
2
+ export { createGetCurrentAppMemberGroupsController } from './groups/index.js';
2
3
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,3 @@
1
1
  import { type Middleware } from 'koa';
2
2
  import { type Options } from '../../../../types.js';
3
- export declare function createGetAppAssetByIdController({ getApp, getAppAssets }: Options): Middleware;
3
+ export declare function createGetAppAssetByIdController({ getApp, getAppAsset }: Options): Middleware;
@@ -1,14 +1,11 @@
1
1
  import { extension } from 'mime-types';
2
2
  import { assertKoaError } from '../../../../../koa.js';
3
- export function createGetAppAssetByIdController({ getApp, getAppAssets }) {
3
+ export function createGetAppAssetByIdController({ getApp, getAppAsset }) {
4
4
  return async (ctx) => {
5
5
  const { pathParams: { appId, assetId }, } = ctx;
6
6
  const app = await getApp({ context: ctx, query: { where: { id: appId } } });
7
7
  assertKoaError(!app, ctx, 404, 'App not found');
8
- const assets = await getAppAssets({ app, context: ctx });
9
- // Pick asset id over asset name
10
- const asset = assets.find((a) => a.id === assetId) || assets.find((a) => a.name === assetId);
11
- assertKoaError(!asset, ctx, 404, 'Asset not found');
8
+ const asset = await getAppAsset({ app, context: ctx, id: assetId });
12
9
  if (assetId !== asset.id) {
13
10
  // Redirect to asset using current asset ID
14
11
  ctx.status = 302;
@@ -14,6 +14,7 @@ export function createCountAppResourcesController(options) {
14
14
  });
15
15
  const { where } = generateResourceQuery(ctx, options);
16
16
  const findOptions = {
17
+ attributes: ['id'],
17
18
  where: {
18
19
  and: [
19
20
  where || {},
package/server/types.d.ts CHANGED
@@ -97,7 +97,7 @@ declare module 'koas-parameters' {
97
97
  assets: boolean;
98
98
  screenshots: boolean;
99
99
  readmes: boolean;
100
- roles: string[] | string;
100
+ roles?: string;
101
101
  includeMessages: boolean;
102
102
  demo: boolean;
103
103
  selectedGroupId: number;
@@ -202,6 +202,10 @@ export interface GetCspParams {
202
202
  export interface GetCurrentAppMemberParams {
203
203
  context: ParameterizedContext<DefaultState, DefaultContextInterface, any>;
204
204
  }
205
+ export interface GetCurrentAppMemberGroupsParams {
206
+ context: ParameterizedContext<DefaultState, DefaultContextInterface, any>;
207
+ app: App;
208
+ }
205
209
  export type ResourceAction = 'create' | 'delete' | 'update';
206
210
  export type Action = ResourceAction | 'count' | 'get' | 'patch' | 'query';
207
211
  export interface ApplyAppServiceSecretsParams {
@@ -244,6 +248,9 @@ export interface GetAppResourceParams extends GetAppSubEntityParams {
244
248
  type: string;
245
249
  id: number | string;
246
250
  }
251
+ export interface GetAppAssetParams extends GetAppSubEntityParams {
252
+ id: string;
253
+ }
247
254
  export interface GetAppResourcesParams extends GetAppSubEntityParams {
248
255
  findOptions: FindOptions;
249
256
  type: string;
@@ -343,6 +350,7 @@ export interface ParsedQuery {
343
350
  export type ContentSecurityPolicy = Record<string, (string | false)[]>;
344
351
  export interface Options {
345
352
  getCurrentAppMember: (params: GetCurrentAppMemberParams) => Promise<AppMemberInfo>;
353
+ getCurrentAppMemberGroups: (params: GetCurrentAppMemberGroupsParams) => Promise<Group[]>;
346
354
  getApp: (params: GetAppParams) => Promise<App>;
347
355
  getAppDetails: (params: GetAppParams) => Promise<AppDetails>;
348
356
  getAppMessages: (params: GetAppMessagesParams) => Promise<AppMessages[]>;
@@ -374,7 +382,8 @@ export interface Options {
374
382
  createAppResourcesWithAssets: (params: CreateAppResourcesWithAssetsParams) => Promise<Resource[]>;
375
383
  updateAppResource: (params: UpdateAppResourceParams) => Promise<Resource | null>;
376
384
  deleteAppResource: (params: DeleteAppResourceParams) => Promise<void>;
377
- getAppAssets: (params: GetAppSubEntityParams) => Promise<AppAsset[]>;
385
+ getAppAssets: (params: GetAppSubEntityParams) => Promise<Asset[]>;
386
+ getAppAsset: (params: GetAppAssetParams) => Promise<AppAsset>;
378
387
  createAppAsset: (params: CreateAppAssetParams) => Promise<AppAsset>;
379
388
  deleteAppAsset: (params: DeleteAppAssetParams) => Promise<number>;
380
389
  email: (params: EmailParams) => Promise<void>;
@@ -26,6 +26,7 @@ export async function deleteResourcesRecursively(type, app, options, context) {
26
26
  await deleteResourcesRecursively(referencingResourceType, app, options, context);
27
27
  }
28
28
  const resourcesToDeleteFindOptions = {
29
+ attributes: ['id'],
29
30
  where: {
30
31
  type,
31
32
  AppId: app.id,