@appsemble/utils 0.29.4 → 0.29.5
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/api/components/schemas/AppDefinition.js +12 -0
- package/api/components/schemas/ContainerDefinition.d.ts +2 -0
- package/api/components/schemas/ContainerDefinition.js +52 -0
- package/api/components/schemas/index.d.ts +1 -0
- package/api/components/schemas/index.js +1 -0
- package/api/paths/action.js +21 -0
- package/api/paths/apps.js +4 -0
- package/examples.js +6 -0
- package/package.json +2 -2
- package/reference-schemas/remappers/data.js +19 -0
- package/remap.js +10 -0
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#  Appsemble Utilities
|
|
2
2
|
|
|
3
3
|
> Internal utility functions used across multiple Appsemble projects.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@appsemble/utils)
|
|
6
|
-
[](https://gitlab.com/appsemble/appsemble/-/releases/0.29.5)
|
|
7
7
|
[](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.
|
|
29
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.29.5/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,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
|
|
@@ -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';
|
package/api/paths/action.js
CHANGED
|
@@ -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
package/examples.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsemble/utils",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.5",
|
|
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.
|
|
40
|
+
"@appsemble/types": "0.29.5",
|
|
41
41
|
"axios": "^1.0.0",
|
|
42
42
|
"cron-parser": "^4.0.0",
|
|
43
43
|
"date-fns": "^2.0.0",
|
|
@@ -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
|
},
|
package/remap.js
CHANGED
|
@@ -415,5 +415,15 @@ 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
|
+
const namespace = 'companion-containers';
|
|
420
|
+
const appName = context.appUrl.split('.')[0].replace(/^https?:\/\//, '');
|
|
421
|
+
const endpoint = property.split('/').slice(1).join('/');
|
|
422
|
+
const containerName = `${property.split('/')[0]}-${appName}-${context.appId}`
|
|
423
|
+
.replaceAll(' ', '-')
|
|
424
|
+
.toLowerCase();
|
|
425
|
+
const url = `http://${containerName}.${namespace}.svc.cluster.local/${endpoint}`;
|
|
426
|
+
return url;
|
|
427
|
+
},
|
|
418
428
|
};
|
|
419
429
|
//# sourceMappingURL=remap.js.map
|