@swell/cli 2.0.1-alpha.12 → 2.0.1-alpha.16
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/dist/commands/app/install.d.ts +5 -2
- package/dist/commands/app/install.js +41 -38
- package/dist/commands/app/push.d.ts +3 -3
- package/dist/commands/app/push.js +46 -49
- package/dist/commands/app/version.js +3 -3
- package/dist/commands/create/app.d.ts +8 -8
- package/dist/commands/create/app.js +74 -71
- package/dist/commands/create/content.d.ts +2 -2
- package/dist/commands/create/content.js +10 -10
- package/dist/commands/create/function.d.ts +1 -1
- package/dist/commands/create/function.js +20 -20
- package/dist/commands/create/model.d.ts +2 -2
- package/dist/commands/create/model.js +11 -11
- package/dist/commands/create/notification.d.ts +2 -2
- package/dist/commands/create/notification.js +36 -38
- package/dist/commands/login.d.ts +1 -1
- package/dist/commands/login.js +8 -7
- package/dist/commands/logs.js +2 -0
- package/dist/create-collection-command.d.ts +6 -6
- package/dist/create-collection-command.js +19 -19
- package/dist/create-command.js +6 -4
- package/dist/lib/api.d.ts +3 -2
- package/dist/lib/api.js +11 -8
- package/dist/lib/app-config.d.ts +1 -0
- package/dist/lib/app-config.js +5 -3
- package/dist/lib/apps/index.d.ts +1 -1
- package/dist/lib/apps/index.js +1 -1
- package/dist/lib/apps/paths.d.ts +1 -1
- package/dist/lib/apps/paths.js +1 -1
- package/dist/lib/bundle.js +15 -3
- package/dist/lib/constants.js +2 -3
- package/dist/lib/create/content.d.ts +1 -1
- package/dist/lib/create/content.js +1 -1
- package/dist/lib/create/function.d.ts +2 -2
- package/dist/lib/create/function.js +2 -2
- package/dist/lib/create/index.d.ts +1 -1
- package/dist/lib/create/index.js +6 -6
- package/dist/lib/create/model.d.ts +2 -2
- package/dist/lib/create/notification.d.ts +2 -2
- package/dist/lib/logs/index.js +1 -1
- package/dist/lib/sessions.js +2 -2
- package/dist/lib/stores.d.ts +4 -1
- package/dist/lib/stores.js +6 -3
- package/dist/lib/swell-function-wrapper.d.ts +40 -1
- package/dist/lib/swell-function-wrapper.js +107 -22
- package/dist/remote-app-command.d.ts +2 -2
- package/dist/remote-app-command.js +18 -18
- package/oclif.manifest.json +60 -57
- package/package.json +2 -1
package/dist/create-command.js
CHANGED
|
@@ -44,14 +44,16 @@ export class CreateCommand extends AppCommand {
|
|
|
44
44
|
async getCollectionOptions() {
|
|
45
45
|
const models = await this.api.post({ adminPath: `/data/$get/:models` }, {
|
|
46
46
|
body: {
|
|
47
|
-
limit: 1000,
|
|
48
|
-
client_id: null,
|
|
49
|
-
app_id: null,
|
|
50
47
|
abstract: { $ne: true },
|
|
48
|
+
// eslint-disable-next-line camelcase
|
|
49
|
+
app_id: null,
|
|
50
|
+
// eslint-disable-next-line camelcase
|
|
51
|
+
client_id: null,
|
|
51
52
|
deprecated: { $ne: true },
|
|
53
|
+
fields: 'name, namespace',
|
|
54
|
+
limit: 1000,
|
|
52
55
|
name: { $nin: ['events', 'notifications', 'settings'] },
|
|
53
56
|
sort: 'namespace asc, name asc',
|
|
54
|
-
fields: 'name, namespace',
|
|
55
57
|
},
|
|
56
58
|
});
|
|
57
59
|
return (models?.results?.map((model) => model.namespace ? `${model.namespace}/${model.name}` : model.name) || []);
|
package/dist/lib/api.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
export default class Api {
|
|
2
|
+
private envId;
|
|
2
3
|
private secretKey;
|
|
3
4
|
private storeId;
|
|
4
|
-
private envId;
|
|
5
5
|
constructor(storeId?: string, envId?: string, secretKey?: string);
|
|
6
|
-
setStoreEnv(storeId: string, envId?: string): void;
|
|
7
6
|
api(pathOpts: Api.Paths, options: Api.RequestOptions): Promise<any>;
|
|
8
7
|
delete(pathOpts: Api.Paths, options?: Api.RequestOptions): Promise<any>;
|
|
9
8
|
get(pathOpts: Api.Paths, options?: Api.RequestOptions): Promise<any>;
|
|
10
9
|
isAdmin(): boolean;
|
|
11
10
|
post(pathOpts: Api.Paths, options?: Api.RequestOptions): Promise<any>;
|
|
12
11
|
put(pathOpts: Api.Paths, options?: Api.RequestOptions): Promise<any>;
|
|
12
|
+
setStoreEnv(storeId: string, envId?: string): void;
|
|
13
|
+
truncatePath(path: string | undefined): string | undefined;
|
|
13
14
|
}
|
package/dist/lib/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fetch from 'node-fetch';
|
|
2
2
|
import config from './config.js';
|
|
3
|
-
import {
|
|
3
|
+
import { API_BASE_URL, getAdminApiBaseUrl } from './constants.js';
|
|
4
4
|
const defaultHeaders = (opts) => ({
|
|
5
5
|
'Content-Type': 'application/json',
|
|
6
6
|
...opts,
|
|
@@ -23,18 +23,14 @@ const authenticatedHeaders = (storeId, opts = {}) => {
|
|
|
23
23
|
return defaultHeaders(moreOpts);
|
|
24
24
|
};
|
|
25
25
|
export default class Api {
|
|
26
|
+
envId;
|
|
26
27
|
secretKey;
|
|
27
28
|
storeId;
|
|
28
|
-
envId;
|
|
29
29
|
constructor(storeId, envId, secretKey) {
|
|
30
30
|
this.storeId = storeId;
|
|
31
31
|
this.envId = envId;
|
|
32
32
|
this.secretKey = secretKey;
|
|
33
33
|
}
|
|
34
|
-
setStoreEnv(storeId, envId) {
|
|
35
|
-
this.storeId = storeId;
|
|
36
|
-
this.envId = envId;
|
|
37
|
-
}
|
|
38
34
|
async api(pathOpts, options) {
|
|
39
35
|
const storeId = this.storeId || config.getDefaultStore();
|
|
40
36
|
let path;
|
|
@@ -51,8 +47,8 @@ export default class Api {
|
|
|
51
47
|
},
|
|
52
48
|
};
|
|
53
49
|
path = this.isAdmin()
|
|
54
|
-
? `${getAdminApiBaseUrl(storeId)}/${pathOpts.adminPath}`
|
|
55
|
-
: `${API_BASE_URL}/${pathOpts.backendPath}`;
|
|
50
|
+
? `${getAdminApiBaseUrl(storeId)}/${this.truncatePath(pathOpts.adminPath)}`
|
|
51
|
+
: `${API_BASE_URL}/${this.truncatePath(pathOpts.backendPath)}`;
|
|
56
52
|
if (options.query) {
|
|
57
53
|
const query = new URLSearchParams(options.query);
|
|
58
54
|
path += `?${query.toString()}`;
|
|
@@ -123,4 +119,11 @@ export default class Api {
|
|
|
123
119
|
...options,
|
|
124
120
|
});
|
|
125
121
|
}
|
|
122
|
+
setStoreEnv(storeId, envId) {
|
|
123
|
+
this.storeId = storeId;
|
|
124
|
+
this.envId = envId;
|
|
125
|
+
}
|
|
126
|
+
truncatePath(path) {
|
|
127
|
+
return path?.startsWith('/') ? path.slice(1) : path;
|
|
128
|
+
}
|
|
126
129
|
}
|
package/dist/lib/app-config.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ declare function config(configDirPath?: string): LocalApp;
|
|
|
23
23
|
/**
|
|
24
24
|
* Returns a new configuration instance in the current working directory only.
|
|
25
25
|
*
|
|
26
|
+
* @param path Path of the current working directory
|
|
26
27
|
* @returns Conf
|
|
27
28
|
*/
|
|
28
29
|
declare function newConfig(path?: string): any;
|
package/dist/lib/app-config.js
CHANGED
|
@@ -5,12 +5,13 @@ import Conf from 'conf';
|
|
|
5
5
|
import * as fs from 'node:fs';
|
|
6
6
|
import * as path from 'node:path';
|
|
7
7
|
const schema = {
|
|
8
|
+
description: { type: 'string' },
|
|
8
9
|
id: { type: 'string' },
|
|
9
|
-
|
|
10
|
+
integrations: { type: 'array' },
|
|
10
11
|
name: { type: 'string' },
|
|
11
|
-
description: { type: 'string' },
|
|
12
|
-
type: { type: 'string' },
|
|
13
12
|
permissions: { type: 'array' },
|
|
13
|
+
type: { type: 'string' },
|
|
14
|
+
version: { type: 'string' },
|
|
14
15
|
};
|
|
15
16
|
const APP_FILE_NAME = 'swell';
|
|
16
17
|
const APP_FILE_EXT = 'json';
|
|
@@ -115,6 +116,7 @@ function config(configDirPath = '') {
|
|
|
115
116
|
/**
|
|
116
117
|
* Returns a new configuration instance in the current working directory only.
|
|
117
118
|
*
|
|
119
|
+
* @param path Path of the current working directory
|
|
118
120
|
* @returns Conf
|
|
119
121
|
*/
|
|
120
122
|
function newConfig(path) {
|
package/dist/lib/apps/index.d.ts
CHANGED
|
@@ -64,4 +64,4 @@ declare function findAppConfig(app: App, file: string, configType: ConfigType):
|
|
|
64
64
|
declare function batchAppConfigsByType(appConfigs: AppConfig[]): Array<any>;
|
|
65
65
|
export { App, AppVersion, ConfigInputFields, ConfigPaths, ConfigPathsType, ConfigType, appConfigFromFile, appLogoIcon, batchAppConfigsByType, fileExists, findAppConfig, getConfigTypeFromPath, getConfigTypeKeyFromValue, hasAllowedFileExtension, isAppLogoIcon, writeFile, writeJsonFile, };
|
|
66
66
|
export { AppConfig, FunctionProcessingError, IgnoringFileError, } from './app-config.js';
|
|
67
|
-
export { allConfigDirsPaths, allConfigFilesPaths, allConfigFilesPathsByType,
|
|
67
|
+
export { allConfigDirsPaths, allConfigFilesPaths, allConfigFilesPathsByType, configFilePath, getAllConfigPaths, } from './paths.js';
|
package/dist/lib/apps/index.js
CHANGED
|
@@ -164,4 +164,4 @@ export { ConfigInputFields, ConfigPaths, ConfigType,
|
|
|
164
164
|
// functions
|
|
165
165
|
appConfigFromFile, appLogoIcon, batchAppConfigsByType, fileExists, findAppConfig, getConfigTypeFromPath, getConfigTypeKeyFromValue, hasAllowedFileExtension, isAppLogoIcon, writeFile, writeJsonFile, };
|
|
166
166
|
export { AppConfig, FunctionProcessingError, IgnoringFileError, } from './app-config.js';
|
|
167
|
-
export { allConfigDirsPaths, allConfigFilesPaths, allConfigFilesPathsByType,
|
|
167
|
+
export { allConfigDirsPaths, allConfigFilesPaths, allConfigFilesPathsByType, configFilePath, getAllConfigPaths, } from './paths.js';
|
package/dist/lib/apps/paths.d.ts
CHANGED
|
@@ -15,4 +15,4 @@ declare function allConfigFilesPathsByType(appPath: string, configTypeKey: strin
|
|
|
15
15
|
}, void, unknown>;
|
|
16
16
|
declare function configFilePath(appPath: string, config: AppConfig): string;
|
|
17
17
|
declare function getAllConfigPaths(): Array<string>;
|
|
18
|
-
export { allConfigDirsPaths, allConfigFilesPaths, allConfigFilesPathsByType,
|
|
18
|
+
export { allConfigDirsPaths, allConfigFilesPaths, allConfigFilesPathsByType, configFilePath, getAllConfigPaths, };
|
package/dist/lib/apps/paths.js
CHANGED
|
@@ -51,4 +51,4 @@ function getAllConfigPaths() {
|
|
|
51
51
|
}
|
|
52
52
|
return configPaths;
|
|
53
53
|
}
|
|
54
|
-
export { allConfigDirsPaths, allConfigFilesPaths, allConfigFilesPathsByType,
|
|
54
|
+
export { allConfigDirsPaths, allConfigFilesPaths, allConfigFilesPathsByType, configFilePath, getAllConfigPaths, };
|
package/dist/lib/bundle.js
CHANGED
|
@@ -24,15 +24,14 @@ export async function bundleFunction(filePath) {
|
|
|
24
24
|
.join('\n');
|
|
25
25
|
// Remove comments with to get a unique hash in the API
|
|
26
26
|
// Because esbuild puts the file name as a comment
|
|
27
|
-
code = code.
|
|
27
|
+
code = code.replaceAll(/^\n?\/\/.*/gm, '');
|
|
28
28
|
// eslint-disable-next-line no-new-func
|
|
29
29
|
const evalFn = new Function(`${code}\nreturn { ...moduleExports }`);
|
|
30
30
|
const { config, ...moduleExports } = evalFn();
|
|
31
|
-
code
|
|
31
|
+
code = await minifyCode(code + getSwellFunctionWrapper());
|
|
32
32
|
return { code, config, dependencies, moduleExports };
|
|
33
33
|
}
|
|
34
34
|
catch (error) {
|
|
35
|
-
console.log(error);
|
|
36
35
|
throw new Error(`Unable to compile function ${filePath}: ${error.message}`);
|
|
37
36
|
}
|
|
38
37
|
}
|
|
@@ -41,3 +40,16 @@ function getSwellFunctionWrapper() {
|
|
|
41
40
|
const __dirname = path.dirname(__filename);
|
|
42
41
|
return fs.readFileSync(path.join(__dirname, './swell-function-wrapper.js'), 'utf8');
|
|
43
42
|
}
|
|
43
|
+
async function minifyCode(code) {
|
|
44
|
+
try {
|
|
45
|
+
const result = await esbuild.transform(code, {
|
|
46
|
+
minifyIdentifiers: false,
|
|
47
|
+
minifySyntax: false,
|
|
48
|
+
minifyWhitespace: true,
|
|
49
|
+
});
|
|
50
|
+
return result.code;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw new Error('Compilation error:', error.message);
|
|
54
|
+
}
|
|
55
|
+
}
|
package/dist/lib/constants.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
/* eslint-disable no-template-curly-in-string */
|
|
1
2
|
import { env } from './config.js';
|
|
2
3
|
// note: env values stored in ~/.swell/env.json
|
|
3
4
|
// url for backend api calls
|
|
4
5
|
export const API_BASE_URL = env.get('API_BASE_URL') || 'https://api.swell.store';
|
|
5
6
|
// url for admin api calls
|
|
6
|
-
export const ADMIN_API_BASE_URL =
|
|
7
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
8
|
-
env.get('ADMIN_API_BASE_URL') || 'https://${STORE_ID}.swell.store/admin/api';
|
|
7
|
+
export const ADMIN_API_BASE_URL = env.get('ADMIN_API_BASE_URL') || 'https://${STORE_ID}.swell.store/admin/api';
|
|
9
8
|
// url host for admin login
|
|
10
9
|
export const LOGIN_HOST = env.get('LOGIN_HOST') || 'https://${STORE_ID}.swell.store';
|
|
11
10
|
// helpers to get constants with replacements
|
|
@@ -7,11 +7,11 @@ interface CreateFunctionArgs {
|
|
|
7
7
|
interface WriteFunctionFileParams {
|
|
8
8
|
description: string;
|
|
9
9
|
events: string;
|
|
10
|
-
route: string;
|
|
11
10
|
functionName: string;
|
|
12
11
|
language: FunctionLanguage;
|
|
12
|
+
route: string;
|
|
13
13
|
schedule: string;
|
|
14
14
|
trigger: FunctionType;
|
|
15
15
|
}
|
|
16
|
-
declare const getFunctionTemplate: ({ description, events, route, schedule,
|
|
16
|
+
declare const getFunctionTemplate: ({ description, events, language, route, schedule, trigger, }: WriteFunctionFileParams) => string;
|
|
17
17
|
export { CreateFunctionArgs, FunctionLanguage, FunctionType, WriteFunctionFileParams, getFunctionTemplate, };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const getFunctionTemplate = ({ description, events, route, schedule,
|
|
1
|
+
const getFunctionTemplate = ({ description, events, language, route, schedule, trigger, }) => {
|
|
2
2
|
let typeAppend = ``;
|
|
3
3
|
if (trigger === 'model') {
|
|
4
4
|
const eventsList = events
|
|
5
5
|
.split(/\s*,\s*/g)
|
|
6
|
-
.filter(
|
|
6
|
+
.filter(Boolean)
|
|
7
7
|
.map((eventName) => `'${eventName}'`)
|
|
8
8
|
.join(', ');
|
|
9
9
|
typeAppend = `,
|
|
@@ -10,4 +10,4 @@ declare const toFunctionFileName: (value: string) => string;
|
|
|
10
10
|
declare const toCollectionName: (value: string) => string;
|
|
11
11
|
declare const toCollectionLabel: (value: string) => string;
|
|
12
12
|
declare const toNotificationLabel: (value: string) => string;
|
|
13
|
-
export { CreateFileParams,
|
|
13
|
+
export { CreateFileParams, toAppId, toAppName, toCollectionLabel, toCollectionName, toFileName, toFunctionFileName, toNotificationLabel, };
|
package/dist/lib/create/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { dasherize, pluralize,
|
|
1
|
+
import { dasherize, pluralize, titleize, underscore } from 'inflection';
|
|
2
2
|
// Example: 'My Thing' => 'my-thing'
|
|
3
3
|
const toFileName = (value) => dasherize(underscore(value.split('.')[0].replace(' ', '_'))).toLowerCase();
|
|
4
4
|
// Example: 'my-things' => 'My Things'
|
|
5
5
|
const toAppName = (value) => pluralize(titleize(value).replace('-', ' '));
|
|
6
6
|
// Example: 'My App' => 'my_app'
|
|
7
7
|
const toAppId = (value) => String(value || '')
|
|
8
|
-
.
|
|
9
|
-
.
|
|
10
|
-
.
|
|
11
|
-
.
|
|
8
|
+
.replaceAll(/[^\s\w./:-]/g, '')
|
|
9
|
+
.replaceAll(/[_\s-:./]+/g, '_')
|
|
10
|
+
.replaceAll(/^_+|_+$/g, '')
|
|
11
|
+
.replaceAll(/([a-z])([A-Z])/g, '$1_$2')
|
|
12
12
|
.toLowerCase();
|
|
13
13
|
// Example: 'My Thing' => 'my-thing'
|
|
14
14
|
// And: 'myThing' => 'myThing'
|
|
@@ -19,4 +19,4 @@ const toCollectionName = (value) => pluralize(value.replaceAll(/[^A-Za-z]/g, '-'
|
|
|
19
19
|
const toCollectionLabel = (value) => pluralize(titleize(value).replace('-', ' '));
|
|
20
20
|
// Example: 'order-receipt' => 'Order Receipt'
|
|
21
21
|
const toNotificationLabel = (value) => titleize(value).replace('-', ' ');
|
|
22
|
-
export {
|
|
22
|
+
export { toAppId, toAppName, toCollectionLabel, toCollectionName, toFileName, toFunctionFileName, toNotificationLabel, };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
interface CreateModelFileBody {
|
|
2
|
-
label?: string;
|
|
3
2
|
collection?: string;
|
|
4
3
|
description?: string;
|
|
5
|
-
fields?: ModelFieldResponse;
|
|
6
4
|
events?: ModelEventObject;
|
|
5
|
+
fields?: ModelFieldResponse;
|
|
6
|
+
label?: string;
|
|
7
7
|
}
|
|
8
8
|
interface ModelEventObject {
|
|
9
9
|
types?: ModelEvent[];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
interface WriteNotificationsFileParams {
|
|
2
|
+
admin?: boolean;
|
|
2
3
|
description: string;
|
|
3
4
|
event: string;
|
|
4
5
|
model: string;
|
|
5
6
|
name: string;
|
|
6
|
-
subject: string;
|
|
7
|
-
admin?: boolean;
|
|
8
7
|
once?: boolean;
|
|
8
|
+
subject: string;
|
|
9
9
|
}
|
|
10
10
|
interface CreateNotificationFileBody {
|
|
11
11
|
admin?: boolean;
|
package/dist/lib/logs/index.js
CHANGED
|
@@ -83,6 +83,6 @@ export class LoggedItem {
|
|
|
83
83
|
}
|
|
84
84
|
})
|
|
85
85
|
.join('\n');
|
|
86
|
-
return `Function ${event ? `${event.type} >` : ''} ${style.logMethod(method.toUpperCase())} /${name} ${logLines ? `\n${logLines}` : ''}`;
|
|
86
|
+
return `Function ${event ? `${event.hook ? `${event.hook}:` : ''}${event.type} >` : ''} ${style.logMethod(method.toUpperCase())} /${name} ${logLines ? `\n${logLines}` : ''}`;
|
|
87
87
|
}
|
|
88
88
|
}
|
package/dist/lib/sessions.js
CHANGED
|
@@ -20,7 +20,6 @@ function createServer(onSessionId, storeId) {
|
|
|
20
20
|
// the spinner is used to show progress while waiting for the browser
|
|
21
21
|
const spinner = ux.action;
|
|
22
22
|
serverForLogin({
|
|
23
|
-
storeId,
|
|
24
23
|
onPost(req) {
|
|
25
24
|
// we received the session id from the browser so we can move on
|
|
26
25
|
const sessionId = req.headers['x-session'];
|
|
@@ -37,6 +36,7 @@ function createServer(onSessionId, storeId) {
|
|
|
37
36
|
].join(' '));
|
|
38
37
|
await open(loginUrl);
|
|
39
38
|
},
|
|
39
|
+
storeId,
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
@@ -52,7 +52,7 @@ function createServer(onSessionId, storeId) {
|
|
|
52
52
|
* from the browser
|
|
53
53
|
* @returns void
|
|
54
54
|
*/
|
|
55
|
-
function serverForLogin({
|
|
55
|
+
function serverForLogin({ onPost, onStart, storeId, }) {
|
|
56
56
|
// flag to track if the POST and GET requests have been handled
|
|
57
57
|
// we only want to handle them once
|
|
58
58
|
let postHandled = false;
|
package/dist/lib/stores.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ declare function selectStoreId({ authorizations, currentStoreId, force, }: {
|
|
|
35
35
|
* Select the store to switch to from a CLI prompt from the list of
|
|
36
36
|
* already logged in stores.
|
|
37
37
|
*
|
|
38
|
+
* @param message Store selection message
|
|
38
39
|
* @returns The store ID to switch to
|
|
39
40
|
* @throws CLIError - If there are no stores to switch to
|
|
40
41
|
*/
|
|
@@ -42,6 +43,8 @@ declare function selectLoggedInStoreId(message?: string): Promise<string>;
|
|
|
42
43
|
/**
|
|
43
44
|
* Select an environment.
|
|
44
45
|
*
|
|
46
|
+
* @param message Environment selection message
|
|
47
|
+
* @returns Environment to switch to
|
|
45
48
|
* @throws CLIError - If there are no stores to switch to
|
|
46
49
|
*/
|
|
47
50
|
declare function selectEnvironmentId(message?: string): Promise<string>;
|
|
@@ -60,4 +63,4 @@ declare function modifyDefaultStore({ currentStoreId, storeId, }: {
|
|
|
60
63
|
currentStoreId: string;
|
|
61
64
|
storeId: string;
|
|
62
65
|
}): Promise<void>;
|
|
63
|
-
export { modifyDefaultStore, selectLoggedInStoreId, selectStoreId,
|
|
66
|
+
export { modifyDefaultStore, selectEnvironmentId, selectLoggedInStoreId, selectStoreId, showStores, };
|
package/dist/lib/stores.js
CHANGED
|
@@ -101,6 +101,7 @@ async function selectStoreId({ authorizations, currentStoreId, force = false, })
|
|
|
101
101
|
* Select the store to switch to from a CLI prompt from the list of
|
|
102
102
|
* already logged in stores.
|
|
103
103
|
*
|
|
104
|
+
* @param message Store selection message
|
|
104
105
|
* @returns The store ID to switch to
|
|
105
106
|
* @throws CLIError - If there are no stores to switch to
|
|
106
107
|
*/
|
|
@@ -123,14 +124,16 @@ async function selectLoggedInStoreId(message) {
|
|
|
123
124
|
new Separator(),
|
|
124
125
|
{ name: 'Login to another account', value: '' },
|
|
125
126
|
],
|
|
127
|
+
loop: false,
|
|
126
128
|
message: message || 'Which store do you want to switch to?',
|
|
127
129
|
pageSize: 25,
|
|
128
|
-
loop: false,
|
|
129
130
|
});
|
|
130
131
|
}
|
|
131
132
|
/**
|
|
132
133
|
* Select an environment.
|
|
133
134
|
*
|
|
135
|
+
* @param message Environment selection message
|
|
136
|
+
* @returns Environment to switch to
|
|
134
137
|
* @throws CLIError - If there are no stores to switch to
|
|
135
138
|
*/
|
|
136
139
|
async function selectEnvironmentId(message) {
|
|
@@ -145,7 +148,7 @@ async function selectEnvironmentId(message) {
|
|
|
145
148
|
value: 'test',
|
|
146
149
|
},
|
|
147
150
|
],
|
|
148
|
-
message: message || 'Which
|
|
151
|
+
message: message || 'Which environment?',
|
|
149
152
|
});
|
|
150
153
|
}
|
|
151
154
|
/**
|
|
@@ -170,4 +173,4 @@ async function modifyDefaultStore({ currentStoreId, storeId, }) {
|
|
|
170
173
|
config.setDefaultStore(storeId);
|
|
171
174
|
}
|
|
172
175
|
}
|
|
173
|
-
export { modifyDefaultStore, selectLoggedInStoreId, selectStoreId,
|
|
176
|
+
export { modifyDefaultStore, selectEnvironmentId, selectLoggedInStoreId, selectStoreId, showStores, };
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Handle a function request.
|
|
3
|
+
* @param {Request} originalRequest from cloudflare
|
|
4
|
+
* @param {*} _env cloudflare environment vars
|
|
5
|
+
* @param {*} context cloudflare conttext
|
|
6
|
+
* @returns {Promise<SwellResponse>}
|
|
7
|
+
*/
|
|
8
|
+
declare function request(originalRequest: Request, _env: any, context: any): Promise<SwellResponse>;
|
|
2
9
|
/**
|
|
3
10
|
* Invokes one of the function types that are available.
|
|
4
11
|
*
|
|
@@ -35,10 +42,19 @@ declare function handleRequest(originalRequest: any, _env: any, context: any): P
|
|
|
35
42
|
* @param {Event} context
|
|
36
43
|
*/
|
|
37
44
|
declare function executeModuleHandler(req: SwellRequest, context: Event): Promise<any>;
|
|
45
|
+
/**
|
|
46
|
+
* Helper to determine if a value is an ordinary object.
|
|
47
|
+
* @param {any} obj
|
|
48
|
+
* @returns {boolean}
|
|
49
|
+
*/
|
|
50
|
+
declare function isOrdinaryObject(val: any): boolean;
|
|
38
51
|
declare const origialConsoleLog: {
|
|
39
52
|
(...data: any[]): void;
|
|
40
53
|
(message?: any, ...optionalParams: any[]): void;
|
|
41
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Class representing a Swell request.
|
|
57
|
+
*/
|
|
42
58
|
declare class SwellRequest {
|
|
43
59
|
constructor(req: any, context: any);
|
|
44
60
|
originalRequest: any;
|
|
@@ -62,8 +78,21 @@ declare class SwellRequest {
|
|
|
62
78
|
url: URL | undefined;
|
|
63
79
|
parseJson(input: any): any;
|
|
64
80
|
log(level: any, ...line: any[]): void;
|
|
81
|
+
getIngestableLogs(response: any): {
|
|
82
|
+
params: any;
|
|
83
|
+
} | undefined;
|
|
65
84
|
ingestLogs(response: any): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Merge values into app data for the current request.
|
|
87
|
+
* @param {object|string} idOrValues string to indicate app ID, or values to merge
|
|
88
|
+
* @param {object|undefined} values values to merge into app data
|
|
89
|
+
* @returns {object|undefined} existing app data merged with values if passed
|
|
90
|
+
*/
|
|
91
|
+
appValues(idOrValues: object | string, values?: object | undefined): object | undefined;
|
|
66
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Class representing the Swell backend API.
|
|
95
|
+
*/
|
|
67
96
|
declare class SwellAPI {
|
|
68
97
|
constructor(req: any, context: any);
|
|
69
98
|
request: any;
|
|
@@ -79,10 +108,20 @@ declare class SwellAPI {
|
|
|
79
108
|
delete(url: any, data: any): Promise<any>;
|
|
80
109
|
settings(id?: any): Promise<any>;
|
|
81
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Class representing a Swell error.
|
|
113
|
+
*/
|
|
82
114
|
declare class SwellError extends Error {
|
|
83
115
|
constructor(message: any, options?: {});
|
|
84
116
|
status: any;
|
|
85
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Class representing a Swell response.
|
|
120
|
+
*/
|
|
86
121
|
declare class SwellResponse extends Response {
|
|
122
|
+
static _respond(req: any, response: any, context: any): any;
|
|
123
|
+
static _respondWithLogs(response: any, req: any): SwellResponse;
|
|
87
124
|
constructor(data: any, options?: {});
|
|
125
|
+
_swellData: any;
|
|
126
|
+
_swellOptions: {};
|
|
88
127
|
}
|