@appsemble/utils 0.25.2 → 0.27.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 +3 -3
- package/api/components/schemas/App.js +0 -4
- package/api/components/schemas/ResourceDefinition.js +0 -4
- package/api/paths/appCollections.js +1 -1
- package/api/paths/apps.js +6 -6
- package/api/paths/assets.js +60 -0
- package/api/paths/oauth2Login.js +1 -1
- package/api/paths/resources.js +74 -0
- package/examples.d.ts +24 -0
- package/examples.js +668 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +4 -4
- package/reference-schemas/remappers/arrays.js +8 -147
- package/reference-schemas/remappers/conditionals.js +9 -53
- package/reference-schemas/remappers/data.js +8 -66
- package/reference-schemas/remappers/dates.js +7 -42
- package/reference-schemas/remappers/objects.js +4 -66
- package/reference-schemas/remappers/strings.js +4 -32
- package/reference-schemas/remappers/unsorted.js +2 -24
- package/remap.test.js +8 -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.27.0)
|
|
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
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.27.0/LICENSE.md) ©
|
|
30
30
|
[Appsemble](https://appsemble.com)
|
|
@@ -72,10 +72,6 @@ This doesn’t affect whether or not the app can be accessed on its own domain.
|
|
|
72
72
|
type: 'boolean',
|
|
73
73
|
description: 'Determines whether this app should be used in demo mode.',
|
|
74
74
|
},
|
|
75
|
-
seed: {
|
|
76
|
-
type: 'boolean',
|
|
77
|
-
description: 'Determines whether this app should be seeded in demo mode.',
|
|
78
|
-
},
|
|
79
75
|
longDescription: {
|
|
80
76
|
type: 'string',
|
|
81
77
|
description: `
|
|
@@ -67,10 +67,6 @@ Example: 1d 8h 30m
|
|
|
67
67
|
type: 'boolean',
|
|
68
68
|
description: 'Whether the resource should be able to be transferred when cloning the app it belongs to',
|
|
69
69
|
},
|
|
70
|
-
ephemeral: {
|
|
71
|
-
type: 'boolean',
|
|
72
|
-
description: 'Whether the resource should be cleaned up regularly.',
|
|
73
|
-
},
|
|
74
70
|
schema: {
|
|
75
71
|
$ref: '#/components/schemas/JSONSchemaRoot',
|
|
76
72
|
description: 'JSON schema definitions that may be used by the app.',
|
|
@@ -349,7 +349,7 @@ export const paths = {
|
|
|
349
349
|
description: 'The app was added to the app collection',
|
|
350
350
|
},
|
|
351
351
|
},
|
|
352
|
-
security: [{ studio: [] }],
|
|
352
|
+
security: [{ studio: [] }, { cli: ['apps:write'] }],
|
|
353
353
|
},
|
|
354
354
|
},
|
|
355
355
|
'/api/appCollections/{appCollectionId}/apps/{appId}': {
|
package/api/paths/apps.js
CHANGED
|
@@ -35,9 +35,6 @@ export const paths = {
|
|
|
35
35
|
demoMode: {
|
|
36
36
|
$ref: '#/components/schemas/App/properties/demoMode',
|
|
37
37
|
},
|
|
38
|
-
seed: {
|
|
39
|
-
$ref: '#/components/schemas/App/properties/seed',
|
|
40
|
-
},
|
|
41
38
|
longDescription: {
|
|
42
39
|
$ref: '#/components/schemas/App/properties/longDescription',
|
|
43
40
|
},
|
|
@@ -187,9 +184,6 @@ export const paths = {
|
|
|
187
184
|
demoMode: {
|
|
188
185
|
$ref: '#/components/schemas/App/properties/demoMode',
|
|
189
186
|
},
|
|
190
|
-
seed: {
|
|
191
|
-
$ref: '#/components/schemas/App/properties/seed',
|
|
192
|
-
},
|
|
193
187
|
longDescription: {
|
|
194
188
|
$ref: '#/components/schemas/App/properties/longDescription',
|
|
195
189
|
},
|
|
@@ -345,6 +339,12 @@ export const paths = {
|
|
|
345
339
|
description: 'Whether to include resources for an app.',
|
|
346
340
|
in: 'query',
|
|
347
341
|
},
|
|
342
|
+
{
|
|
343
|
+
name: 'assets',
|
|
344
|
+
schema: { type: 'boolean' },
|
|
345
|
+
description: 'Whether to include assets in the export file',
|
|
346
|
+
in: 'query',
|
|
347
|
+
},
|
|
348
348
|
],
|
|
349
349
|
responses: {
|
|
350
350
|
200: {
|
package/api/paths/assets.js
CHANGED
|
@@ -1,5 +1,65 @@
|
|
|
1
1
|
import { normalized } from '../../constants/index.js';
|
|
2
2
|
export const paths = {
|
|
3
|
+
'/api/apps/{appId}/seed-assets': {
|
|
4
|
+
parameters: [{ $ref: '#/components/parameters/appId' }],
|
|
5
|
+
post: {
|
|
6
|
+
tags: ['asset'],
|
|
7
|
+
description: 'Upload a new seed asset.',
|
|
8
|
+
operationId: 'seedAsset',
|
|
9
|
+
requestBody: {
|
|
10
|
+
description: 'The asset to upload.',
|
|
11
|
+
content: {
|
|
12
|
+
'multipart/form-data': {
|
|
13
|
+
schema: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
description: 'The request body for creating an asset.',
|
|
16
|
+
additionalProperties: false,
|
|
17
|
+
required: ['file'],
|
|
18
|
+
properties: {
|
|
19
|
+
file: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
format: 'binary',
|
|
22
|
+
writeOnly: true,
|
|
23
|
+
description: 'The binary data of the asset. This may include a filename.',
|
|
24
|
+
},
|
|
25
|
+
name: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
pattern: normalized.source,
|
|
28
|
+
description: 'The given name of the asset. Assets may be referenced by their name or ID in the API.',
|
|
29
|
+
},
|
|
30
|
+
clonable: {
|
|
31
|
+
type: 'boolean',
|
|
32
|
+
description: 'Whether the asset should be transferable when cloning the app they are in.',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
responses: {
|
|
40
|
+
201: {
|
|
41
|
+
description: 'The asset that was created.',
|
|
42
|
+
content: {
|
|
43
|
+
'application/json': {
|
|
44
|
+
schema: { $ref: '#/components/schemas/Asset' },
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
security: [{ studio: [] }, {}, { cli: ['assets:write'] }],
|
|
50
|
+
},
|
|
51
|
+
delete: {
|
|
52
|
+
tags: ['asset'],
|
|
53
|
+
description: 'Delete all app seed assets.',
|
|
54
|
+
operationId: 'deleteSeedAssets',
|
|
55
|
+
responses: {
|
|
56
|
+
204: {
|
|
57
|
+
description: 'The app assets have been deleted successfully.',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
security: [{ studio: [] }, { app: ['resources:manage'] }, { cli: ['resources:write'] }, {}],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
3
63
|
'/api/apps/{appId}/assets': {
|
|
4
64
|
parameters: [{ $ref: '#/components/parameters/appId' }],
|
|
5
65
|
get: {
|
package/api/paths/oauth2Login.js
CHANGED
package/api/paths/resources.js
CHANGED
|
@@ -1,4 +1,78 @@
|
|
|
1
1
|
export const paths = {
|
|
2
|
+
'/api/apps/{appId}/seed-resources/{resourceType}': {
|
|
3
|
+
parameters: [
|
|
4
|
+
{ $ref: '#/components/parameters/appId' },
|
|
5
|
+
{ $ref: '#/components/parameters/resourceType' },
|
|
6
|
+
],
|
|
7
|
+
post: {
|
|
8
|
+
tags: ['resource'],
|
|
9
|
+
description: 'Create a new seed resource for this app.',
|
|
10
|
+
operationId: 'seedResource',
|
|
11
|
+
requestBody: {
|
|
12
|
+
required: true,
|
|
13
|
+
description: 'The resource to create',
|
|
14
|
+
content: {
|
|
15
|
+
'application/json': {
|
|
16
|
+
schema: {
|
|
17
|
+
anyOf: [
|
|
18
|
+
{ $ref: '#/components/schemas/Resource' },
|
|
19
|
+
{ type: 'array', items: { $ref: '#/components/schemas/Resource' } },
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
'multipart/form-data': {
|
|
24
|
+
schema: {
|
|
25
|
+
type: 'object',
|
|
26
|
+
required: ['resource'],
|
|
27
|
+
description: 'A `multipart/form-data` representation of a resource.',
|
|
28
|
+
additionalProperties: false,
|
|
29
|
+
properties: {
|
|
30
|
+
resource: {
|
|
31
|
+
type: 'array',
|
|
32
|
+
items: { $ref: '#/components/schemas/Resource' },
|
|
33
|
+
},
|
|
34
|
+
assets: {
|
|
35
|
+
type: 'array',
|
|
36
|
+
description: 'A list of assets that should be linked to the resource.',
|
|
37
|
+
items: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
format: 'binary',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
'text/csv': {
|
|
46
|
+
schema: {
|
|
47
|
+
type: 'array',
|
|
48
|
+
items: { type: 'object', additionalProperties: { type: 'string' } },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
responses: {
|
|
54
|
+
201: {
|
|
55
|
+
description: 'The resource that was created.',
|
|
56
|
+
$ref: '#/components/responses/resource',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
security: [{ studio: [] }, { app: ['resources:manage'] }, { cli: ['resources:write'] }, {}],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
'/api/apps/{appId}/seed-resources': {
|
|
63
|
+
parameters: [{ $ref: '#/components/parameters/appId' }],
|
|
64
|
+
delete: {
|
|
65
|
+
tags: ['resource'],
|
|
66
|
+
description: 'Delete all app seed resources.',
|
|
67
|
+
operationId: 'deleteSeedResources',
|
|
68
|
+
responses: {
|
|
69
|
+
204: {
|
|
70
|
+
description: 'The app seed resources have been deleted successfully.',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
security: [{ cli: ['resources:write'] }, {}],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
2
76
|
'/api/apps/{appId}/resources/{resourceType}': {
|
|
3
77
|
parameters: [
|
|
4
78
|
{ $ref: '#/components/parameters/appId' },
|
package/examples.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { type Remappers, type UserInfo } from '@appsemble/types';
|
|
3
|
+
import { type RemapperContext } from './remap.js';
|
|
4
|
+
export interface RemapperExample {
|
|
5
|
+
input: unknown;
|
|
6
|
+
remapper: unknown;
|
|
7
|
+
result: unknown;
|
|
8
|
+
skip?: boolean;
|
|
9
|
+
}
|
|
10
|
+
type CustomRemapperKeys = 'app.id' | 'app.locale' | 'app.url' | 'array.map.1' | 'if.else' | 'if.then' | 'None';
|
|
11
|
+
export type RemapperExampleKeys = CustomRemapperKeys | Exclude<keyof Remappers, 'app' | 'if'>;
|
|
12
|
+
export declare const examples: Record<RemapperExampleKeys, RemapperExample>;
|
|
13
|
+
/**
|
|
14
|
+
* @param remapper The remapper example to use.
|
|
15
|
+
* @param options The options specifying how to display the example.
|
|
16
|
+
* @returns Example based on the input options.
|
|
17
|
+
*/
|
|
18
|
+
export declare function schemaExample(remapper: keyof typeof examples, options?: {
|
|
19
|
+
input?: 'inline' | 'pretty';
|
|
20
|
+
result?: 'inline' | 'pretty';
|
|
21
|
+
exclude?: ('input' | 'remapper' | 'result')[];
|
|
22
|
+
}): string;
|
|
23
|
+
export declare function createExampleContext(url: URL, lang: string, userInfo?: UserInfo, history?: []): RemapperContext;
|
|
24
|
+
export {};
|