@trycourier/cli 2.7.2 → 3.1.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 +21 -92
- package/bin/.gitkeep +0 -0
- package/install.js +115 -0
- package/package.json +22 -87
- package/LICENSE +0 -21
- package/dist/bulk.d.ts +0 -15
- package/dist/bulk.js +0 -53
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -24
- package/dist/commands/AudienceSearch.d.ts +0 -3
- package/dist/commands/AudienceSearch.js +0 -113
- package/dist/commands/AutomationInvokeBulk.d.ts +0 -3
- package/dist/commands/AutomationInvokeBulk.js +0 -139
- package/dist/commands/Config.d.ts +0 -4
- package/dist/commands/Config.js +0 -45
- package/dist/commands/DigestFlush.d.ts +0 -5
- package/dist/commands/DigestFlush.js +0 -28
- package/dist/commands/Help.d.ts +0 -16
- package/dist/commands/Help.js +0 -38
- package/dist/commands/Inbox/ArchiveAll.d.ts +0 -8
- package/dist/commands/Inbox/ArchiveAll.js +0 -180
- package/dist/commands/Inbox/ArchiveAllBulk.d.ts +0 -5
- package/dist/commands/Inbox/ArchiveAllBulk.js +0 -99
- package/dist/commands/Inbox/MarkAllRead.d.ts +0 -5
- package/dist/commands/Inbox/MarkAllRead.js +0 -110
- package/dist/commands/MessagesSearch.d.ts +0 -3
- package/dist/commands/MessagesSearch.js +0 -120
- package/dist/commands/NotYetImplemented.d.ts +0 -3
- package/dist/commands/NotYetImplemented.js +0 -5
- package/dist/commands/Send.d.ts +0 -5
- package/dist/commands/Send.js +0 -144
- package/dist/commands/Templates/List.d.ts +0 -3
- package/dist/commands/Templates/List.js +0 -114
- package/dist/commands/TenantsBulk.d.ts +0 -3
- package/dist/commands/TenantsBulk.js +0 -171
- package/dist/commands/TenantsGetMembership.d.ts +0 -3
- package/dist/commands/TenantsGetMembership.js +0 -127
- package/dist/commands/TenantsMembershipBulk.d.ts +0 -3
- package/dist/commands/TenantsMembershipBulk.js +0 -203
- package/dist/commands/Track.d.ts +0 -5
- package/dist/commands/Track.js +0 -40
- package/dist/commands/TrackBulk.d.ts +0 -3
- package/dist/commands/TrackBulk.js +0 -89
- package/dist/commands/TranslationsDownload.d.ts +0 -10
- package/dist/commands/TranslationsDownload.js +0 -30
- package/dist/commands/TranslationsUpload.d.ts +0 -9
- package/dist/commands/TranslationsUpload.js +0 -37
- package/dist/commands/Upgrade.d.ts +0 -3
- package/dist/commands/Upgrade.js +0 -38
- package/dist/commands/UserToken.d.ts +0 -3
- package/dist/commands/UserToken.js +0 -96
- package/dist/commands/UsersBulk.d.ts +0 -3
- package/dist/commands/UsersBulk.js +0 -205
- package/dist/commands/UsersGet.d.ts +0 -5
- package/dist/commands/UsersGet.js +0 -37
- package/dist/commands/UsersPreferences.d.ts +0 -3
- package/dist/commands/UsersPreferences.js +0 -73
- package/dist/commands/UsersSet.d.ts +0 -5
- package/dist/commands/UsersSet.js +0 -34
- package/dist/commands/UsersTokensBulk.d.ts +0 -3
- package/dist/commands/UsersTokensBulk.js +0 -215
- package/dist/commands/WhoAmI.d.ts +0 -3
- package/dist/commands/WhoAmI.js +0 -27
- package/dist/components/Context.d.ts +0 -55
- package/dist/components/Context.js +0 -94
- package/dist/components/Elemental.d.ts +0 -13
- package/dist/components/Elemental.js +0 -23
- package/dist/components/KVP.d.ts +0 -11
- package/dist/components/KVP.js +0 -12
- package/dist/components/Request.d.ts +0 -23
- package/dist/components/Request.js +0 -17
- package/dist/components/Response.d.ts +0 -16
- package/dist/components/Response.js +0 -29
- package/dist/components/Router.d.ts +0 -4
- package/dist/components/Router.js +0 -60
- package/dist/components/SdkResponse.d.ts +0 -9
- package/dist/components/SdkResponse.js +0 -21
- package/dist/components/Spinner.d.ts +0 -6
- package/dist/components/Spinner.js +0 -41
- package/dist/components/Table.d.ts +0 -19
- package/dist/components/Table.js +0 -62
- package/dist/components/UhOh.d.ts +0 -5
- package/dist/components/UhOh.js +0 -10
- package/dist/components/Version.d.ts +0 -3
- package/dist/components/Version.js +0 -53
- package/dist/constants.d.ts +0 -8
- package/dist/constants.js +0 -8
- package/dist/lib/api.d.ts +0 -17
- package/dist/lib/api.js +0 -39
- package/dist/lib/args.d.ts +0 -2
- package/dist/lib/args.js +0 -13
- package/dist/lib/courier.d.ts +0 -3
- package/dist/lib/courier.js +0 -7
- package/dist/lib/delay.d.ts +0 -2
- package/dist/lib/delay.js +0 -7
- package/dist/lib/load-env.d.ts +0 -2
- package/dist/lib/load-env.js +0 -16
- package/dist/lib/uuid.d.ts +0 -2
- package/dist/lib/uuid.js +0 -4
- package/dist/mappings.d.ts +0 -6
- package/dist/mappings.js +0 -565
- package/dist/version.d.ts +0 -2
- package/dist/version.js +0 -2
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { Box, Text } from 'ink';
|
|
3
|
-
import spinners from 'cli-spinners';
|
|
4
|
-
import constants from '../constants.js';
|
|
5
|
-
/*
|
|
6
|
-
some of my favorites:
|
|
7
|
-
- spinners.dots
|
|
8
|
-
- spinners.triangle
|
|
9
|
-
- spinners.binary
|
|
10
|
-
- spinners.arc
|
|
11
|
-
- spinners.arrow
|
|
12
|
-
- spinners.bouncingBar
|
|
13
|
-
- spinners.pong
|
|
14
|
-
- spinners.aesthetic
|
|
15
|
-
*/
|
|
16
|
-
const spinner = spinners.aesthetic;
|
|
17
|
-
const spinnerColor = constants.colors.primary;
|
|
18
|
-
const textColor = 'white';
|
|
19
|
-
export default ({ text }) => {
|
|
20
|
-
const [index, setIndex] = useState(0);
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
const timer = setInterval(() => {
|
|
23
|
-
setIndex(i => {
|
|
24
|
-
if (i + 1 >= spinner.frames.length) {
|
|
25
|
-
return 0;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
return i + 1;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}, spinner.interval);
|
|
32
|
-
return () => {
|
|
33
|
-
clearInterval(timer);
|
|
34
|
-
};
|
|
35
|
-
}, []);
|
|
36
|
-
return (React.createElement(Box, { borderStyle: "classic", borderColor: "gray" },
|
|
37
|
-
React.createElement(Text, { bold: true, color: spinnerColor }, spinner.frames[index]),
|
|
38
|
-
text?.length ? React.createElement(Text, { color: textColor },
|
|
39
|
-
" ",
|
|
40
|
-
text) : React.createElement(React.Fragment, null)));
|
|
41
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { TextProps } from 'ink';
|
|
3
|
-
type Scalar = string | number | boolean | null | undefined;
|
|
4
|
-
type ScalarDict = {
|
|
5
|
-
[key: string]: Scalar;
|
|
6
|
-
};
|
|
7
|
-
type TableProps = {
|
|
8
|
-
data: ScalarDict[];
|
|
9
|
-
showHeaders?: boolean;
|
|
10
|
-
headerLabels?: {
|
|
11
|
-
[key: string]: string;
|
|
12
|
-
};
|
|
13
|
-
disableRowSeparators?: boolean;
|
|
14
|
-
disableBorders?: boolean;
|
|
15
|
-
headerStyles?: TextProps;
|
|
16
|
-
rowStyles?: TextProps;
|
|
17
|
-
};
|
|
18
|
-
declare const Table: ({ data, disableBorders, disableRowSeparators, headerStyles, headerLabels, rowStyles, showHeaders, }: TableProps) => React.JSX.Element;
|
|
19
|
-
export default Table;
|
package/dist/components/Table.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
// Table.tsx
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Box, Text } from 'ink';
|
|
4
|
-
const Table = ({ data, disableBorders, disableRowSeparators, headerStyles, headerLabels, rowStyles, showHeaders = true, }) => {
|
|
5
|
-
// Determine columns and their widths
|
|
6
|
-
const columns = getColumns(data, headerLabels);
|
|
7
|
-
return (React.createElement(Box, { flexDirection: "column", width: "100%" },
|
|
8
|
-
!disableBorders && renderHeaderSeparators(columns),
|
|
9
|
-
showHeaders && (React.createElement(React.Fragment, null,
|
|
10
|
-
renderRow(columns.reduce((p, v) => {
|
|
11
|
-
p[v.key] = v.label || v.key;
|
|
12
|
-
return p;
|
|
13
|
-
}, {}), columns, disableBorders, {
|
|
14
|
-
color: 'blue',
|
|
15
|
-
bold: true,
|
|
16
|
-
...headerStyles,
|
|
17
|
-
}),
|
|
18
|
-
!disableRowSeparators ? renderRowSeparators(columns) : null)),
|
|
19
|
-
data.map((row, index) => (React.createElement(React.Fragment, { key: `row-${index}` },
|
|
20
|
-
index !== 0 && !disableRowSeparators && renderRowSeparators(columns),
|
|
21
|
-
renderRow(row, columns, disableBorders, rowStyles)))),
|
|
22
|
-
!disableBorders && renderFooterSeparators(columns)));
|
|
23
|
-
};
|
|
24
|
-
// Helper function to determine columns and their widths
|
|
25
|
-
function getColumns(data, headerLabels) {
|
|
26
|
-
let columnWidths = {};
|
|
27
|
-
data.forEach(row => {
|
|
28
|
-
Object.keys(row).forEach(key => {
|
|
29
|
-
const valueLength = row[key]?.toString().length || 0;
|
|
30
|
-
columnWidths[key] = Math.max(columnWidths[key] || key.length, valueLength);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
return Object.keys(columnWidths).map(key => ({
|
|
34
|
-
key: key,
|
|
35
|
-
label: headerLabels?.[key] || key,
|
|
36
|
-
width: (columnWidths[key] ?? 0) + 2, // adding padding
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
// Helper function to render a row with separators
|
|
40
|
-
function renderRow(row, columns, disableBorders, textStyles) {
|
|
41
|
-
return (React.createElement(Box, { flexDirection: "row" },
|
|
42
|
-
!disableBorders && React.createElement(Text, null, "\u2502"),
|
|
43
|
-
columns.map((column, index) => (React.createElement(React.Fragment, { key: column.key },
|
|
44
|
-
index !== 0 && !disableBorders && React.createElement(Text, null, "\u2502"),
|
|
45
|
-
React.createElement(Box, { width: column.width, justifyContent: "flex-start" },
|
|
46
|
-
React.createElement(Text, { ...textStyles }, row[column.key]?.toString() || ''))))),
|
|
47
|
-
!disableBorders && React.createElement(Text, null, "\u2502")));
|
|
48
|
-
}
|
|
49
|
-
function renderHeaderSeparators(columns) {
|
|
50
|
-
return renderRowSeparators(columns, '┌', '┬', '┐');
|
|
51
|
-
}
|
|
52
|
-
function renderFooterSeparators(columns) {
|
|
53
|
-
return renderRowSeparators(columns, '└', '┴', '┘');
|
|
54
|
-
}
|
|
55
|
-
function renderRowSeparators(columns, leftChar = '├', midChar = '┼', rightChar = '┤') {
|
|
56
|
-
return (React.createElement(Box, { flexDirection: "row" },
|
|
57
|
-
React.createElement(Text, null, leftChar),
|
|
58
|
-
columns.map((column, index) => (React.createElement(React.Fragment, { key: column.key },
|
|
59
|
-
React.createElement(Text, null, '─'.repeat(column.width)),
|
|
60
|
-
index < columns.length - 1 ? (React.createElement(Text, null, midChar)) : (React.createElement(Text, null, rightChar)))))));
|
|
61
|
-
}
|
|
62
|
-
export default Table;
|
package/dist/components/UhOh.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { execa } from 'execa';
|
|
2
|
-
import { Box, Text } from 'ink';
|
|
3
|
-
import _ from 'lodash';
|
|
4
|
-
import React, { useEffect } from 'react';
|
|
5
|
-
import { useCliContext } from './Context.js';
|
|
6
|
-
import constants from '../constants.js';
|
|
7
|
-
const Version = () => {
|
|
8
|
-
const { version, setVersion, map, parsedParams } = useCliContext();
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
getVersion();
|
|
11
|
-
}, []);
|
|
12
|
-
const getVersion = async () => {
|
|
13
|
-
try {
|
|
14
|
-
const exc = await execa('npm', ['-g', 'outdated', constants.package_name, '--json'], {
|
|
15
|
-
shell: true,
|
|
16
|
-
reject: false,
|
|
17
|
-
});
|
|
18
|
-
const stdout = JSON.parse(exc.stdout);
|
|
19
|
-
setVersion(v => ({
|
|
20
|
-
...v,
|
|
21
|
-
latest: _.get(stdout, [constants.package_name, 'latest']),
|
|
22
|
-
}));
|
|
23
|
-
}
|
|
24
|
-
catch (e) {
|
|
25
|
-
console.log(e);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
const version_text = version.latest && version.current !== version.latest
|
|
29
|
-
? `Upgrade available (${version.current} > ${version.latest}), run courier upgrade`
|
|
30
|
-
: undefined;
|
|
31
|
-
if (version_text?.length) {
|
|
32
|
-
if (map === 'upgrade' || _.get(parsedParams, ['quiet'], false)) {
|
|
33
|
-
return React.createElement(React.Fragment, null);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
return (React.createElement(Box, { flexDirection: "column", marginY: 1, flexShrink: 1, width: version_text.length + 2, borderColor: "gray", borderStyle: 'single' },
|
|
37
|
-
React.createElement(Text, null,
|
|
38
|
-
"Upgrade available (",
|
|
39
|
-
version.current,
|
|
40
|
-
" ",
|
|
41
|
-
'>',
|
|
42
|
-
" ",
|
|
43
|
-
version.latest,
|
|
44
|
-
"), run",
|
|
45
|
-
' ',
|
|
46
|
-
React.createElement(Text, { color: "green" }, "courier upgrade"))));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
return React.createElement(React.Fragment, null);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
export default Version;
|
package/dist/constants.d.ts
DELETED
package/dist/constants.js
DELETED
package/dist/lib/api.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
interface IRequest {
|
|
2
|
-
url: string;
|
|
3
|
-
method: string;
|
|
4
|
-
body?: object | string;
|
|
5
|
-
headers?: {
|
|
6
|
-
[key: string]: string;
|
|
7
|
-
};
|
|
8
|
-
options?: RequestInit;
|
|
9
|
-
}
|
|
10
|
-
interface IResponse {
|
|
11
|
-
res: Response;
|
|
12
|
-
json?: any;
|
|
13
|
-
text?: string;
|
|
14
|
-
err?: Error;
|
|
15
|
-
}
|
|
16
|
-
declare const _default: (request: IRequest, baseUrl: string, apikey: string) => Promise<IResponse>;
|
|
17
|
-
export default _default;
|
package/dist/lib/api.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import VERSION from "../version.js";
|
|
2
|
-
const isString = (s) => {
|
|
3
|
-
return typeof s === 'string' || s instanceof String;
|
|
4
|
-
};
|
|
5
|
-
export default async (request, baseUrl, apikey) => {
|
|
6
|
-
const req = {
|
|
7
|
-
method: request.method,
|
|
8
|
-
headers: {
|
|
9
|
-
Authorization: `Bearer ${apikey}`,
|
|
10
|
-
'Content-Type': 'application/json',
|
|
11
|
-
'User-Agent': `courier-cli/${VERSION}`,
|
|
12
|
-
'X-Courier-CLI-Version': VERSION,
|
|
13
|
-
...request.headers,
|
|
14
|
-
},
|
|
15
|
-
body: request.body && !isString(request.body)
|
|
16
|
-
? JSON.stringify(request.body)
|
|
17
|
-
: request.body?.toString(),
|
|
18
|
-
...request.options,
|
|
19
|
-
};
|
|
20
|
-
return fetch(`${baseUrl}${request.url}`, req).then(res => {
|
|
21
|
-
if (res.status > 400) {
|
|
22
|
-
return {
|
|
23
|
-
res,
|
|
24
|
-
err: new Error(`${res.status}: ${res.statusText}`),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
else if (res.status === 204) {
|
|
28
|
-
return { res };
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
if (res.headers.get('Content-Type')?.includes('application/json')) {
|
|
32
|
-
return res.json().then(json => ({ res, json }));
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return res.text().then(text => ({ res, text }));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
};
|
package/dist/lib/args.d.ts
DELETED
package/dist/lib/args.js
DELETED
package/dist/lib/courier.d.ts
DELETED
package/dist/lib/courier.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CourierClient } from "@trycourier/courier";
|
|
2
|
-
const getClient = (environment = 'production') => {
|
|
3
|
-
return new CourierClient({
|
|
4
|
-
authorizationToken: environment ? process.env['COURIER_AUTH_TOKEN'] : process.env['COURIER_AUTH_TOKEN_TEST'],
|
|
5
|
-
});
|
|
6
|
-
};
|
|
7
|
-
export default getClient;
|
package/dist/lib/delay.d.ts
DELETED
package/dist/lib/delay.js
DELETED
package/dist/lib/load-env.d.ts
DELETED
package/dist/lib/load-env.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import os from 'os';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import dotenv from 'dotenv';
|
|
4
|
-
export default async () => {
|
|
5
|
-
const paths = [
|
|
6
|
-
`${process.cwd()}/.courier`, // current working directory
|
|
7
|
-
`${os.homedir()}/.courier`, // user home directory
|
|
8
|
-
];
|
|
9
|
-
for (const path of paths) {
|
|
10
|
-
if (fs.existsSync(path)) {
|
|
11
|
-
dotenv.config({ path });
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return false;
|
|
16
|
-
};
|
package/dist/lib/uuid.d.ts
DELETED
package/dist/lib/uuid.js
DELETED