@contentful/app-scripts 1.13.4 → 1.15.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/lib/types.d.ts
CHANGED
|
@@ -10,11 +10,12 @@ export interface FunctionAppAction {
|
|
|
10
10
|
allowNetworks?: string[];
|
|
11
11
|
entryFile?: string;
|
|
12
12
|
}
|
|
13
|
-
export interface
|
|
13
|
+
export interface ContentfulFunction {
|
|
14
14
|
id: string;
|
|
15
15
|
name: string;
|
|
16
16
|
description: string;
|
|
17
17
|
path: string;
|
|
18
|
+
accepts: string[];
|
|
18
19
|
allowNetworks?: string[];
|
|
19
20
|
entryFile?: string;
|
|
20
21
|
}
|
|
@@ -69,5 +70,5 @@ export interface UploadSettings {
|
|
|
69
70
|
userAgentApplication?: string;
|
|
70
71
|
host?: string;
|
|
71
72
|
actions?: FunctionAppAction[];
|
|
72
|
-
|
|
73
|
+
functions?: ContentfulFunction[];
|
|
73
74
|
}
|
|
@@ -7,7 +7,7 @@ const utils_1 = require("../utils");
|
|
|
7
7
|
const constants_1 = require("../constants");
|
|
8
8
|
async function buildAppUploadSettings(options) {
|
|
9
9
|
const actionsManifest = (0, utils_1.getEntityFromManifest)('actions');
|
|
10
|
-
const
|
|
10
|
+
const functionManifest = (0, utils_1.getEntityFromManifest)('functions');
|
|
11
11
|
const prompts = [];
|
|
12
12
|
const { bundleDir, comment, skipActivation, host } = options;
|
|
13
13
|
if (!bundleDir) {
|
|
@@ -47,7 +47,7 @@ async function buildAppUploadSettings(options) {
|
|
|
47
47
|
comment,
|
|
48
48
|
host,
|
|
49
49
|
actions: actionsManifest,
|
|
50
|
-
|
|
50
|
+
functions: functionManifest,
|
|
51
51
|
...appUploadSettings,
|
|
52
52
|
...appInfo,
|
|
53
53
|
};
|
|
@@ -10,7 +10,7 @@ const utils_1 = require("../utils");
|
|
|
10
10
|
const contentful_management_1 = require("contentful-management");
|
|
11
11
|
const create_app_upload_1 = require("./create-app-upload");
|
|
12
12
|
async function createAppBundleFromUpload(settings, appUploadId) {
|
|
13
|
-
const { accessToken, host, userAgentApplication, comment, actions,
|
|
13
|
+
const { accessToken, host, userAgentApplication, comment, actions, functions } = settings;
|
|
14
14
|
const clientSpinner = (0, ora_1.default)('Verifying your upload...').start();
|
|
15
15
|
const client = (0, contentful_management_1.createClient)({
|
|
16
16
|
accessToken,
|
|
@@ -27,7 +27,7 @@ async function createAppBundleFromUpload(settings, appUploadId) {
|
|
|
27
27
|
appUploadId,
|
|
28
28
|
comment: comment && comment.length > 0 ? comment : undefined,
|
|
29
29
|
actions,
|
|
30
|
-
|
|
30
|
+
functions,
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
catch (err) {
|
|
@@ -18,7 +18,7 @@ const requiredOptions = {
|
|
|
18
18
|
async function getUploadSettingsArgs(options) {
|
|
19
19
|
const validateSpinner = (0, ora_1.default)('Validating your input...').start();
|
|
20
20
|
const actionsManifest = (0, utils_1.getEntityFromManifest)('actions');
|
|
21
|
-
const
|
|
21
|
+
const functionManifest = (0, utils_1.getEntityFromManifest)('functions');
|
|
22
22
|
const { bundleDir, comment, skipActivation, host, userAgentApplication } = options;
|
|
23
23
|
try {
|
|
24
24
|
(0, validate_arguments_1.validateArguments)(requiredOptions, options, 'upload');
|
|
@@ -31,7 +31,7 @@ async function getUploadSettingsArgs(options) {
|
|
|
31
31
|
host,
|
|
32
32
|
userAgentApplication,
|
|
33
33
|
actions: actionsManifest,
|
|
34
|
-
|
|
34
|
+
functions: functionManifest,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
catch (err) {
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Definition } from './definition-api';
|
|
2
2
|
import { Organization } from './organization-api';
|
|
3
|
-
import {
|
|
3
|
+
import { ContentfulFunction, FunctionAppAction } from './types';
|
|
4
4
|
export declare const throwValidationException: (subject: string, message?: string, details?: string) => never;
|
|
5
5
|
export declare const isValidNetwork: (address: string) => boolean;
|
|
6
6
|
export declare const stripProtocol: (url: string) => string;
|
|
7
7
|
export declare const showCreationError: (subject: string, message: string) => void;
|
|
8
8
|
export declare const throwError: (err: Error, message: string) => never;
|
|
9
9
|
export declare const selectFromList: <T extends Definition | Organization>(list: T[], message: string, cachedOptionEnvVar: string) => Promise<T>;
|
|
10
|
-
type Entities<Type> = Type extends 'actions' ? Omit<FunctionAppAction, 'entryFile'>[] : Omit<
|
|
11
|
-
export declare function getEntityFromManifest<Type extends 'actions' | '
|
|
10
|
+
type Entities<Type> = Type extends 'actions' ? Omit<FunctionAppAction, 'entryFile'>[] : Omit<ContentfulFunction, 'entryFile'>[];
|
|
11
|
+
export declare function getEntityFromManifest<Type extends 'actions' | 'functions'>(type: Type): Entities<Type> | undefined;
|
|
12
12
|
export {};
|
package/lib/utils.js
CHANGED
|
@@ -86,22 +86,32 @@ function getEntityFromManifest(type) {
|
|
|
86
86
|
if (!Array.isArray(manifest[type]) || manifest[type].length === 0) {
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
logProgress(`${type === 'actions' ? 'App Actions' : '
|
|
89
|
+
logProgress(`${type === 'actions' ? 'App Actions' : 'functions'} found in ${chalk_1.default.bold(DEFAULT_MANIFEST_PATH)}.`);
|
|
90
|
+
const fieldMappingEvent = "graphql.field.mapping";
|
|
91
|
+
const queryEvent = "graphql.query";
|
|
90
92
|
const items = manifest[type].map((item) => {
|
|
91
93
|
const allowNetworks = Array.isArray(item.allowNetworks)
|
|
92
94
|
? item.allowNetworks.map(exports.stripProtocol)
|
|
93
95
|
: [];
|
|
96
|
+
const accepts = 'accepts' in item && Array.isArray(item.accepts) ? item.accepts : undefined;
|
|
97
|
+
const hasInvalidEvent = accepts?.some((event) => ![fieldMappingEvent, queryEvent].includes(event));
|
|
94
98
|
const hasInvalidNetwork = allowNetworks.find((netWork) => !(0, exports.isValidNetwork)(netWork));
|
|
95
99
|
if (hasInvalidNetwork) {
|
|
96
100
|
console.log(`${chalk_1.default.red('Error:')} Invalid IP address ${hasInvalidNetwork} found in the allowNetworks array for ${type} "${item.name}".`);
|
|
97
101
|
// eslint-disable-next-line no-process-exit
|
|
98
102
|
process.exit(1);
|
|
99
103
|
}
|
|
104
|
+
if (hasInvalidEvent) {
|
|
105
|
+
console.log(`${chalk_1.default.red('Error:')} Invalid events ${hasInvalidEvent} found in the accepts array for ${type} "${item.name}".`);
|
|
106
|
+
// eslint-disable-next-line no-process-exit
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
100
109
|
// EntryFile is not used but we do want to strip it
|
|
101
110
|
// eslint-disable-next-line no-unused-vars
|
|
102
111
|
const { entryFile: _, ...itemWithoutEntryFile } = item;
|
|
103
112
|
return {
|
|
104
113
|
...itemWithoutEntryFile,
|
|
114
|
+
...(accepts && { accepts }),
|
|
105
115
|
allowNetworks,
|
|
106
116
|
};
|
|
107
117
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/app-scripts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "A collection of scripts for building Contentful Apps",
|
|
5
5
|
"author": "Contentful GmbH",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,16 +51,16 @@
|
|
|
51
51
|
"adm-zip": "0.5.10",
|
|
52
52
|
"bottleneck": "2.19.5",
|
|
53
53
|
"chalk": "4.1.2",
|
|
54
|
-
"commander": "
|
|
55
|
-
"contentful-management": "11.
|
|
56
|
-
"dotenv": "16.4.
|
|
57
|
-
"ignore": "5.3.
|
|
54
|
+
"commander": "12.0.0",
|
|
55
|
+
"contentful-management": "11.16.0",
|
|
56
|
+
"dotenv": "16.4.4",
|
|
57
|
+
"ignore": "5.3.1",
|
|
58
58
|
"inquirer": "8.2.6",
|
|
59
59
|
"lodash": "4.17.21",
|
|
60
60
|
"open": "8.4.2",
|
|
61
61
|
"ora": "5.4.1"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "ca1260e5b969a8b5a1ff1104fbb2431cbf420ca3",
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@tsconfig/node18": "18.2.2",
|
|
66
66
|
"@types/adm-zip": "0.5.5",
|