@appsemble/utils 0.29.4 → 0.29.6

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.29.4/config/assets/logo.svg) Appsemble Utilities
1
+ # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.29.6/config/assets/logo.svg) Appsemble Utilities
2
2
 
3
3
  > Internal utility functions used across multiple Appsemble projects.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@appsemble/utils)](https://www.npmjs.com/package/@appsemble/utils)
6
- [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.29.4/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.29.4)
6
+ [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.29.6/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.29.6)
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 @@ not guaranteed.
26
26
 
27
27
  ## License
28
28
 
29
- [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.29.4/LICENSE.md) ©
29
+ [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.29.6/LICENSE.md) ©
30
30
  [Appsemble](https://appsemble.com)
@@ -114,6 +114,18 @@ The most basic resource has a \`schema\` property and defines the minimal securi
114
114
  description: 'Helper property that can be used to store YAML anchors.',
115
115
  items: {},
116
116
  },
117
+ containers: {
118
+ type: 'array',
119
+ minItems: 1,
120
+ additionalProperties: false,
121
+ description: 'Definition of the companion containers to be created.',
122
+ items: { $ref: '#/components/schemas/ContainerDefinition' },
123
+ },
124
+ registry: {
125
+ type: 'string',
126
+ default: null,
127
+ description: 'The default registry used to pull images for companion containers.',
128
+ },
117
129
  },
118
130
  };
119
131
  //# sourceMappingURL=AppDefinition.js.map
@@ -0,0 +1,2 @@
1
+ import { type OpenAPIV3 } from 'openapi-types';
2
+ export declare const ContainerDefinition: OpenAPIV3.NonArraySchemaObject;
@@ -0,0 +1,52 @@
1
+ export const ContainerDefinition = {
2
+ type: 'object',
3
+ additionalProperties: false,
4
+ description: 'An object describing a companion container',
5
+ required: ['name', 'image', 'port'],
6
+ properties: {
7
+ name: {
8
+ type: 'string',
9
+ description: 'Alias used to reference the container',
10
+ },
11
+ image: {
12
+ type: 'string',
13
+ description: 'Name of the image used for the container',
14
+ },
15
+ port: {
16
+ type: 'number',
17
+ description: 'Port used by the image provided',
18
+ },
19
+ resources: {
20
+ type: 'object',
21
+ additionalProperties: true,
22
+ description: 'Maximum amount of resources the container can use. Deafult: 1 CPU and 512Mi memory',
23
+ },
24
+ env: {
25
+ type: 'array',
26
+ description: 'Environment variables that will be used within the container',
27
+ items: {
28
+ type: 'object',
29
+ additionalProperties: false,
30
+ description: 'Each item is an environment variable. `useValueFromSecret` property determines whether the value is taken literally or from and existing secret',
31
+ required: ['name', 'value'],
32
+ properties: {
33
+ name: { type: 'string', description: 'Name of the environment variable' },
34
+ useValueFromSecret: {
35
+ type: 'boolean',
36
+ description: 'If set to true, will retrieve the value from the Kubernetes secret, the value property will refer to the secret key. If false, will take the value literally',
37
+ },
38
+ value: {
39
+ type: 'string',
40
+ description: "The value of the environment variable. If `useValueFromSecret` is true, this property will refer to the Kubernetes secret's key",
41
+ },
42
+ },
43
+ },
44
+ },
45
+ metadata: {
46
+ type: 'object',
47
+ additionalProperties: true,
48
+ description: 'Metadata including labels and annotations to be added to the container',
49
+ },
50
+ },
51
+ };
52
+ //# sourceMappingURL=ContainerDefinition.js.map
@@ -14,7 +14,7 @@ The following values are allowed:
14
14
  - \`organization\`: Every authenticated user gets the default role if they are in the same organization as the app.
15
15
  - \`invite\`: The user has to manually get a role assigned.
16
16
 
17
- > **Important**: When [OAuth2](../03-guide/oauth2) or [SAML2.0](../03-guide/saml) is used in the
17
+ > **Important**: When [OAuth2](../02-guides/oauth2) or [SAML2.0](../02-guides/saml) is used in the
18
18
  > app, you must set the policy to \`everyone\`. This will specifically allow every configured
19
19
  > authentication method on the secrets page to be used as login method. If you do not want other
20
20
  > Appsemble user accounts to be able to log in, you must \`disable\` the \`appsemble login\` options
@@ -19,6 +19,7 @@ export * from './BlockDefinition.js';
19
19
  export * from './BlockVersion.js';
20
20
  export * from './ConditionActionDefinition.js';
21
21
  export * from './CronDefinition.js';
22
+ export * from './ContainerDefinition.js';
22
23
  export * from './CustomFontDefinition.js';
23
24
  export * from './DialogActionDefinition.js';
24
25
  export * from './DialogErrorActionDefinition.js';
@@ -19,6 +19,7 @@ export * from './BlockDefinition.js';
19
19
  export * from './BlockVersion.js';
20
20
  export * from './ConditionActionDefinition.js';
21
21
  export * from './CronDefinition.js';
22
+ export * from './ContainerDefinition.js';
22
23
  export * from './CustomFontDefinition.js';
23
24
  export * from './DialogActionDefinition.js';
24
25
  export * from './DialogErrorActionDefinition.js';
@@ -15,6 +15,27 @@ function proxy(method, body) {
15
15
  description: 'The data that was passed to the action',
16
16
  required: true,
17
17
  content: {
18
+ 'multipart/form-data': {
19
+ schema: {
20
+ type: 'object',
21
+ description: 'A `multipart/form-data` representation of a resource.',
22
+ additionalProperties: true,
23
+ properties: {
24
+ resource: {
25
+ type: 'array',
26
+ items: { $ref: '#/components/schemas/Resource' },
27
+ },
28
+ assets: {
29
+ type: 'array',
30
+ description: 'A list of assets that should be linked to the resource.',
31
+ items: {
32
+ type: 'string',
33
+ format: 'binary',
34
+ },
35
+ },
36
+ },
37
+ },
38
+ },
18
39
  '*/*': {},
19
40
  },
20
41
  };
package/api/paths/apps.js CHANGED
@@ -279,6 +279,10 @@ export const paths = {
279
279
  type: 'boolean',
280
280
  description: 'Whether TLS is being used.',
281
281
  },
282
+ containers: {
283
+ type: 'array',
284
+ items: { $ref: '#/components/schemas/ContainerDefinition' },
285
+ },
282
286
  },
283
287
  },
284
288
  encoding: {
@@ -0,0 +1,2 @@
1
+ import { type OpenAPIV3 } from 'openapi-types';
2
+ export declare const paths: OpenAPIV3.PathsObject;
@@ -0,0 +1,38 @@
1
+ export const paths = {
2
+ '/api/containers/{appId}/logs/{container}': {
3
+ get: {
4
+ tags: ['container'],
5
+ description: 'Retrieve the logs related to a companion container',
6
+ operationId: 'getContainerLogs',
7
+ parameters: [
8
+ {
9
+ name: 'appId',
10
+ schema: { type: 'number' },
11
+ description: 'Id of the app which defines the companion container',
12
+ in: 'path',
13
+ },
14
+ {
15
+ name: 'container',
16
+ schema: { type: 'string' },
17
+ description: 'Name of the companion container to fetch the logs for',
18
+ in: 'path',
19
+ },
20
+ ],
21
+ responses: {
22
+ 200: {
23
+ description: 'Logs of the container running in a specific app',
24
+ content: {
25
+ 'application/json': {
26
+ schema: {
27
+ type: 'array',
28
+ items: {},
29
+ },
30
+ },
31
+ },
32
+ },
33
+ },
34
+ security: [{ studio: [] }],
35
+ },
36
+ },
37
+ };
38
+ //# sourceMappingURL=containerLogs.js.map
@@ -13,6 +13,7 @@ import { paths as appSSLSecrets } from './appSSLSecrets.js';
13
13
  import { paths as appVariables } from './appVariables.js';
14
14
  import { paths as assets } from './assets.js';
15
15
  import { paths as blocks } from './blocks.js';
16
+ import { paths as containerLogs } from './containerLogs.js';
16
17
  import { paths as emails } from './emails.js';
17
18
  import { paths as health } from './health.js';
18
19
  import { paths as invite } from './invite.js';
@@ -55,5 +56,6 @@ export const paths = {
55
56
  ...appServiceSecrets,
56
57
  ...user,
57
58
  ...trainings,
59
+ ...containerLogs,
58
60
  };
59
61
  //# sourceMappingURL=index.js.map
package/examples.js CHANGED
@@ -655,6 +655,12 @@ export const examples = {
655
655
  result: {},
656
656
  skip: true,
657
657
  },
658
+ container: {
659
+ input: null,
660
+ remapper: {},
661
+ result: {},
662
+ skip: true,
663
+ },
658
664
  };
659
665
  /**
660
666
  * @param remapper The remapper example to use.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/utils",
3
- "version": "0.29.4",
3
+ "version": "0.29.6",
4
4
  "description": "Utility functions used in Appsemble internally",
5
5
  "keywords": [
6
6
  "app",
@@ -37,7 +37,7 @@
37
37
  "test": "vitest"
38
38
  },
39
39
  "dependencies": {
40
- "@appsemble/types": "0.29.4",
40
+ "@appsemble/types": "0.29.6",
41
41
  "axios": "^1.0.0",
42
42
  "cron-parser": "^4.0.0",
43
43
  "date-fns": "^2.0.0",
@@ -61,7 +61,7 @@ Clicking on the first item would log \`0\`, the second item \`1\` and so on.
61
61
  },
62
62
  history: {
63
63
  type: 'integer',
64
- description: `> **Note:** This remapper is explained more in depth in the [History](/docs/remapper/history) page
64
+ description: `> **Note:** This remapper is explained more in depth in the [History](/docs/04-remappers/05-history) page
65
65
 
66
66
  Gives the data at the history entry at the specified history index. The history at specified index
67
67
  is the data that is passed to that action.
@@ -166,7 +166,7 @@ Example:
166
166
  \`\`\`
167
167
 
168
168
  The page data only works in the context of a flow page. Let’s say you have a
169
- [“FlowPage”](/docs/reference/app#-flow-page-definition) type with multiple subpages. Whenever you
169
+ [“FlowPage”](/docs/05-reference/app#-flow-page-definition) type with multiple subpages. Whenever you
170
170
  navigate to the next page it adds the data from that page to the flow page’s data. The page remapper
171
171
  allows you to access this cumulative data.
172
172
 
@@ -281,7 +281,7 @@ ${schemaExample('static', { exclude: ['input'] })}
281
281
  },
282
282
  translate: {
283
283
  type: 'string',
284
- description: `> **Note:** This is explained much more in depth at [Translating](/docs/03-guide/translating)
284
+ description: `> **Note:** This is explained much more in depth at [Translating](/docs/02-guides/translating)
285
285
 
286
286
  This remapper allows you to easily add translations to your app. To make this remapper work, replace
287
287
  any static text with \`translate: {name}\`. Then, in your app’s Translations page pick the language
@@ -349,6 +349,7 @@ Provides some fields of the appMember object.
349
349
  - \`primary_email\`: User’s **primary** email address.
350
350
  - \`name\`: The user’s name.
351
351
  - \`role\`: User's role in the context of the app.
352
+
352
353
  Example:
353
354
 
354
355
  \`\`\`json
@@ -359,6 +360,24 @@ Example:
359
360
  "role": "Medewerker",
360
361
  "userId": "5c6270e2-ad31-414f-bcab-6752a2c4dcfd"
361
362
  }
363
+ \`\`\`
364
+ `,
365
+ },
366
+ container: {
367
+ type: 'string',
368
+ description: `
369
+ > **Note:** For this remapper to work, the application needs to define a companion container.
370
+
371
+ This remapper provides a short way to access a companion container for the purpose of making http requests.
372
+ When using the 'request' action, the url can be provided by using the 'container' remapper, and providing a string.
373
+ The string should contain the name of the companion container, followed by the API endpoint path.
374
+
375
+ Example:
376
+ \`\`\`yaml
377
+ type: request
378
+ url: { container: my-container/api/endpoint }
379
+ proxy: true
380
+ method: get
362
381
  \`\`\`
363
382
  `,
364
383
  },
@@ -2,7 +2,7 @@ export const unsortedRemappers = {
2
2
  ics: {
3
3
  type: 'object',
4
4
  description: `Create a calendar event. This event can be downloaded as an \`.ics\` file and
5
- uploaded to your agenda using the [download](../reference/action#download) action.
5
+ uploaded to your agenda using the [download](../05-reference/action#download) action.
6
6
 
7
7
  For example, the following input:
8
8
  \`\`\`yaml
@@ -160,12 +160,12 @@ The options represent the level of logging that will show in the console.
160
160
  - \`appId\`: ID of the application,
161
161
  - \`url\`: Absolute URL of the page where the remapper was fired,
162
162
  - \`appUrl\`: Base URL of the application,
163
- - \`pageData\`: Current page data of a FlowPage (See [page remapper](./data#page)),
164
- - \`userInfo\`: User's information if they are logged in (See [user remapper](./data#user)),
163
+ - \`pageData\`: Current page data of a FlowPage (See [page remapper](./04-data#page)),
164
+ - \`userInfo\`: User's information if they are logged in (See [user remapper](./04-data#user)),
165
165
  - \`context\`: Internal context
166
- - \`history\`: Complete list of this remapper’s history (See [history remapper](./history))
166
+ - \`history\`: Complete list of this remapper’s history (See [history remapper](./05-history))
167
167
  - \`locale\`: The user’s locale,
168
- - \`stepRef\`: In a loop page, gives the properties from the loop’s current data index (See [step remapper](./data#step))
168
+ - \`stepRef\`: In a loop page, gives the properties from the loop’s current data index (See [step remapper](./04-data#step))
169
169
 
170
170
  For example:
171
171
 
package/remap.js CHANGED
@@ -415,5 +415,17 @@ const mapperImplementations = {
415
415
  },
416
416
  user: (property, input, context) => { var _a; return (_a = context.userInfo) === null || _a === void 0 ? void 0 : _a[property]; },
417
417
  appMember: (property, input, context) => { var _a, _b; return (_b = (_a = context.userInfo) === null || _a === void 0 ? void 0 : _a.appMember) === null || _b === void 0 ? void 0 : _b[property]; },
418
+ container(property, input, context) {
419
+ // This value is replaced when the request is made
420
+ // By using the value of the release name
421
+ const namespace = 'companion-containers-appsemble';
422
+ const appName = context.appUrl.split('.')[0].replace(/^https?:\/\//, '');
423
+ const endpoint = property.split('/').slice(1).join('/');
424
+ const containerName = `${property.split('/')[0]}-${appName}-${context.appId}`
425
+ .replaceAll(' ', '-')
426
+ .toLowerCase();
427
+ const url = `http://${containerName}.${namespace}.svc.cluster.local/${endpoint}`;
428
+ return url;
429
+ },
418
430
  };
419
431
  //# sourceMappingURL=remap.js.map