@trycourier/cli 2.7.1 → 3.1.4

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.
Files changed (103) hide show
  1. package/bin/.gitkeep +0 -0
  2. package/install.js +115 -0
  3. package/package.json +22 -87
  4. package/LICENSE +0 -21
  5. package/README.md +0 -105
  6. package/dist/bulk.d.ts +0 -15
  7. package/dist/bulk.js +0 -53
  8. package/dist/cli.d.ts +0 -2
  9. package/dist/cli.js +0 -24
  10. package/dist/commands/AudienceSearch.d.ts +0 -3
  11. package/dist/commands/AudienceSearch.js +0 -113
  12. package/dist/commands/AutomationInvokeBulk.d.ts +0 -3
  13. package/dist/commands/AutomationInvokeBulk.js +0 -139
  14. package/dist/commands/Config.d.ts +0 -4
  15. package/dist/commands/Config.js +0 -45
  16. package/dist/commands/DigestFlush.d.ts +0 -5
  17. package/dist/commands/DigestFlush.js +0 -28
  18. package/dist/commands/Help.d.ts +0 -16
  19. package/dist/commands/Help.js +0 -38
  20. package/dist/commands/Inbox/ArchiveAll.d.ts +0 -8
  21. package/dist/commands/Inbox/ArchiveAll.js +0 -180
  22. package/dist/commands/Inbox/ArchiveAllBulk.d.ts +0 -5
  23. package/dist/commands/Inbox/ArchiveAllBulk.js +0 -99
  24. package/dist/commands/Inbox/MarkAllRead.d.ts +0 -5
  25. package/dist/commands/Inbox/MarkAllRead.js +0 -110
  26. package/dist/commands/MessagesSearch.d.ts +0 -3
  27. package/dist/commands/MessagesSearch.js +0 -120
  28. package/dist/commands/NotYetImplemented.d.ts +0 -3
  29. package/dist/commands/NotYetImplemented.js +0 -5
  30. package/dist/commands/Send.d.ts +0 -5
  31. package/dist/commands/Send.js +0 -144
  32. package/dist/commands/Templates/List.d.ts +0 -3
  33. package/dist/commands/Templates/List.js +0 -114
  34. package/dist/commands/TenantsBulk.d.ts +0 -3
  35. package/dist/commands/TenantsBulk.js +0 -171
  36. package/dist/commands/TenantsGetMembership.d.ts +0 -3
  37. package/dist/commands/TenantsGetMembership.js +0 -127
  38. package/dist/commands/TenantsMembershipBulk.d.ts +0 -3
  39. package/dist/commands/TenantsMembershipBulk.js +0 -203
  40. package/dist/commands/Track.d.ts +0 -5
  41. package/dist/commands/Track.js +0 -40
  42. package/dist/commands/TrackBulk.d.ts +0 -3
  43. package/dist/commands/TrackBulk.js +0 -89
  44. package/dist/commands/TranslationsDownload.d.ts +0 -10
  45. package/dist/commands/TranslationsDownload.js +0 -30
  46. package/dist/commands/TranslationsUpload.d.ts +0 -9
  47. package/dist/commands/TranslationsUpload.js +0 -37
  48. package/dist/commands/Upgrade.d.ts +0 -3
  49. package/dist/commands/Upgrade.js +0 -38
  50. package/dist/commands/UserToken.d.ts +0 -3
  51. package/dist/commands/UserToken.js +0 -78
  52. package/dist/commands/UsersBulk.d.ts +0 -3
  53. package/dist/commands/UsersBulk.js +0 -205
  54. package/dist/commands/UsersGet.d.ts +0 -5
  55. package/dist/commands/UsersGet.js +0 -37
  56. package/dist/commands/UsersPreferences.d.ts +0 -3
  57. package/dist/commands/UsersPreferences.js +0 -73
  58. package/dist/commands/UsersSet.d.ts +0 -5
  59. package/dist/commands/UsersSet.js +0 -34
  60. package/dist/commands/UsersTokensBulk.d.ts +0 -3
  61. package/dist/commands/UsersTokensBulk.js +0 -215
  62. package/dist/commands/WhoAmI.d.ts +0 -3
  63. package/dist/commands/WhoAmI.js +0 -27
  64. package/dist/components/Context.d.ts +0 -55
  65. package/dist/components/Context.js +0 -94
  66. package/dist/components/Elemental.d.ts +0 -13
  67. package/dist/components/Elemental.js +0 -23
  68. package/dist/components/KVP.d.ts +0 -11
  69. package/dist/components/KVP.js +0 -12
  70. package/dist/components/Request.d.ts +0 -23
  71. package/dist/components/Request.js +0 -17
  72. package/dist/components/Response.d.ts +0 -16
  73. package/dist/components/Response.js +0 -29
  74. package/dist/components/Router.d.ts +0 -4
  75. package/dist/components/Router.js +0 -60
  76. package/dist/components/SdkResponse.d.ts +0 -9
  77. package/dist/components/SdkResponse.js +0 -21
  78. package/dist/components/Spinner.d.ts +0 -6
  79. package/dist/components/Spinner.js +0 -41
  80. package/dist/components/Table.d.ts +0 -19
  81. package/dist/components/Table.js +0 -62
  82. package/dist/components/UhOh.d.ts +0 -5
  83. package/dist/components/UhOh.js +0 -10
  84. package/dist/components/Version.d.ts +0 -3
  85. package/dist/components/Version.js +0 -53
  86. package/dist/constants.d.ts +0 -8
  87. package/dist/constants.js +0 -8
  88. package/dist/lib/api.d.ts +0 -17
  89. package/dist/lib/api.js +0 -39
  90. package/dist/lib/args.d.ts +0 -2
  91. package/dist/lib/args.js +0 -13
  92. package/dist/lib/courier.d.ts +0 -3
  93. package/dist/lib/courier.js +0 -7
  94. package/dist/lib/delay.d.ts +0 -2
  95. package/dist/lib/delay.js +0 -7
  96. package/dist/lib/load-env.d.ts +0 -2
  97. package/dist/lib/load-env.js +0 -16
  98. package/dist/lib/uuid.d.ts +0 -2
  99. package/dist/lib/uuid.js +0 -4
  100. package/dist/mappings.d.ts +0 -6
  101. package/dist/mappings.js +0 -559
  102. package/dist/version.d.ts +0 -2
  103. package/dist/version.js +0 -2
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- declare const TenantsGetMembership: () => React.JSX.Element;
3
- export default TenantsGetMembership;
@@ -1,127 +0,0 @@
1
- import { Alert } from '@inkjs/ui';
2
- import { stringify } from 'csv-stringify/sync';
3
- import fs from 'fs/promises';
4
- import _ from 'lodash';
5
- import { DateTime } from 'luxon';
6
- import React, { useEffect, useState } from 'react';
7
- import { useBoolean, useCounter } from 'usehooks-ts';
8
- import { useCliContext } from '../components/Context.js';
9
- import Spinner from '../components/Spinner.js';
10
- import UhOh from '../components/UhOh.js';
11
- const FILENAME = 'tenent_members';
12
- const TenantsGetMembership = () => {
13
- const { parsedParams, courier } = useCliContext();
14
- const processing = useBoolean(true);
15
- const running = useBoolean(true);
16
- const counter = useCounter(0);
17
- const [members, setMembers] = useState([]);
18
- const [error, setError] = useState();
19
- const { maxPages, json, csv, webhook, filename, _: [tenant_id], } = parsedParams;
20
- const out_file = (filename?.length
21
- ? filename.substring(0, filename.includes('.') ? filename.lastIndexOf('.') : filename.length)
22
- : FILENAME) + (csv ? '.csv' : '.json');
23
- const MAX_PAGES = Number(maxPages) || 100;
24
- useEffect(() => {
25
- if (!processing.value) {
26
- if (json || csv || webhook?.length) {
27
- runExport();
28
- }
29
- else {
30
- running.setFalse();
31
- }
32
- }
33
- }, [processing.value]);
34
- useEffect(() => {
35
- getTenantMemberships();
36
- }, []);
37
- const getTenantMemberships = async (cursor, count = 0) => {
38
- if (!tenant_id) {
39
- setError('No Tenant Specified');
40
- processing.setFalse();
41
- }
42
- else {
43
- counter.increment();
44
- const r = await courier.tenants.getUsersByTenant(tenant_id, {
45
- cursor,
46
- limit: 100,
47
- }, {
48
- maxRetries: 3,
49
- timeoutInSeconds: 10,
50
- });
51
- let items = r.items;
52
- if (items?.length) {
53
- setMembers(previous => {
54
- return [
55
- ...previous,
56
- ...items.map(({ tenant_id, type, ...rest }) => rest),
57
- ];
58
- });
59
- if (r.has_more && count < MAX_PAGES) {
60
- await getTenantMemberships(r.cursor, count + 1);
61
- }
62
- else {
63
- processing.setFalse();
64
- }
65
- }
66
- else {
67
- processing.setFalse();
68
- }
69
- }
70
- };
71
- const runExport = async () => {
72
- const flat = csv ? flattenData(members) : members;
73
- if (csv) {
74
- await fs.writeFile(out_file, stringify(flat, { header: true }));
75
- }
76
- else if (json) {
77
- await fs.writeFile(out_file, JSON.stringify(flat, null, 2), {
78
- encoding: 'utf-8',
79
- });
80
- }
81
- if (webhook?.length) {
82
- try {
83
- await fetch(webhook, {
84
- method: 'POST',
85
- headers: {
86
- 'Content-Type': 'application/json',
87
- },
88
- body: JSON.stringify(flat),
89
- });
90
- }
91
- catch (e) {
92
- setError(e instanceof Error ? e.message : String(e));
93
- }
94
- }
95
- running.setFalse();
96
- };
97
- if (error?.length) {
98
- return React.createElement(UhOh, { text: error });
99
- }
100
- else if (running.value) {
101
- return React.createElement(Spinner, { text: `Fetching tenent_members - page ${counter.count}` });
102
- }
103
- else {
104
- return (React.createElement(React.Fragment, null,
105
- React.createElement(Alert, { variant: "success", title: `Finished ${counter.count} pages` }, csv || json
106
- ? `Output ${members.length} tenent_members to ${out_file}`
107
- : JSON.stringify(members, null, 2))));
108
- }
109
- };
110
- const flattenData = (data) => {
111
- return data.map(row => {
112
- return Object.keys(row).reduce((p, key) => {
113
- const v = _.get(row, [key]);
114
- if (typeof v === 'number') {
115
- p[key] = DateTime.fromMillis(v, { zone: 'utc' }).toISO();
116
- }
117
- else if (typeof v === 'object') {
118
- p[key] = JSON.stringify(v);
119
- }
120
- else if (v) {
121
- p[key] = v;
122
- }
123
- return p;
124
- }, {});
125
- });
126
- };
127
- export default TenantsGetMembership;
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- declare const _default: () => React.JSX.Element;
3
- export default _default;
@@ -1,203 +0,0 @@
1
- import { ProgressBar } from '@inkjs/ui';
2
- import { Box, Text } from 'ink';
3
- import _ from 'lodash';
4
- import fs from 'fs/promises';
5
- import React, { useEffect, useState } from 'react';
6
- import { useBoolean, useCounter } from 'usehooks-ts';
7
- import getDb, { getChunk } from '../bulk.js';
8
- import { useCliContext } from '../components/Context.js';
9
- import Spinner from '../components/Spinner.js';
10
- import UhOh from '../components/UhOh.js';
11
- import delay from '../lib/delay.js';
12
- const DEFAULT_DELAY = 10000;
13
- const DEFAULT_CHUNK_SIZE = 500;
14
- const DEFAULT_TIMEOUT = 10;
15
- const DEFAULT_REQ_OPTIONS = { maxRetries: 5, timeoutInSeconds: DEFAULT_TIMEOUT };
16
- const DEFAULT_ERROR_FILENAME = 'errors.json';
17
- export default () => {
18
- const { parsedParams, courier } = useCliContext();
19
- const [error, setError] = useState();
20
- const processing = useBoolean(true);
21
- const running = useBoolean(true);
22
- const [data, setData] = useState();
23
- const [data_errors, setDataErrors] = useState([]);
24
- const counter = useCounter(0);
25
- const [row_errors, setRowErrors] = useState([]);
26
- const filename = String(_.get(parsedParams, ['_', 0], ''));
27
- const { db, filetype, sql } = getDb(filename);
28
- const delay_between_chunks = Number(parsedParams['delay']) ?? DEFAULT_DELAY;
29
- const chunk_size = parsedParams['chunk_size']
30
- ? Number(parsedParams['chunk_size'])
31
- : DEFAULT_CHUNK_SIZE;
32
- const log_errors = Boolean(parsedParams['errors']);
33
- const remove_membership = Boolean(parsedParams['remove-membership']);
34
- const keep_flat = Boolean(parsedParams['keep-flat']);
35
- const remove_nulls = Boolean(parsedParams['remove-nulls']);
36
- const tenants = String(_.get(parsedParams, ['tenant'], ''))
37
- .split(',')
38
- .map(l => l.trim())
39
- .filter(t => t.length > 0);
40
- useEffect(() => {
41
- if (filetype) {
42
- getData();
43
- }
44
- else {
45
- setError('File type not supported.');
46
- }
47
- }, []);
48
- useEffect(() => {
49
- if (data) {
50
- processData();
51
- }
52
- }, [data]);
53
- useEffect(() => {
54
- if (!processing.value) {
55
- handleErrors();
56
- }
57
- }, [processing.value]);
58
- const getData = () => {
59
- db.all(sql, (err, result) => {
60
- if (err) {
61
- setError(err.message);
62
- }
63
- else {
64
- setData(result);
65
- }
66
- });
67
- };
68
- const processChunkRows = (data, start_index) => {
69
- return data.map((row, i) => {
70
- const curr_index = start_index + i;
71
- let { user_id, tenant_id, ...profile } = row || {};
72
- if (!user_id) {
73
- return Promise.resolve({
74
- success: false,
75
- userId: '__unknown__',
76
- error: `user_id not found in index ${curr_index}`,
77
- index: curr_index,
78
- });
79
- }
80
- else {
81
- Object.entries(profile).forEach(([key, value]) => {
82
- if (filetype === 'csv' && !keep_flat) {
83
- _.unset(profile, key);
84
- _.set(profile, key, value);
85
- }
86
- if (value === null && remove_nulls) {
87
- _.unset(profile, key);
88
- }
89
- });
90
- return processRow(String(user_id), profile, curr_index, tenant_id?.length ? String(tenant_id) : undefined);
91
- }
92
- });
93
- };
94
- const processRow = async (userId, profile, index, tenant_id) => {
95
- return new Promise(async (resolve) => {
96
- let promises = [];
97
- try {
98
- if (!remove_membership) {
99
- if (tenants.length) {
100
- promises.push(courier.users.tenants.addMultple(userId, {
101
- tenants: tenants.map(t => ({ tenant_id: t, profile })),
102
- }, DEFAULT_REQ_OPTIONS));
103
- }
104
- else if (tenant_id) {
105
- promises.push(courier.users.tenants.add(userId, tenant_id, { profile }, DEFAULT_REQ_OPTIONS));
106
- }
107
- }
108
- else {
109
- if (tenants.length) {
110
- tenants.forEach(t => {
111
- promises.push(courier.users.tenants.remove(userId, t, DEFAULT_REQ_OPTIONS));
112
- });
113
- }
114
- else if (tenant_id?.length) {
115
- promises.push(courier.users.tenants.remove(userId, tenant_id, DEFAULT_REQ_OPTIONS));
116
- }
117
- }
118
- await Promise.all(promises);
119
- counter.increment();
120
- return resolve({ userId, success: true, index });
121
- }
122
- catch (error) {
123
- counter.increment();
124
- return resolve({
125
- userId,
126
- success: false,
127
- index,
128
- error: (String(error) ??
129
- error?.message ??
130
- error.message ??
131
- 'Unknown Error') + `+ ${userId}`,
132
- });
133
- }
134
- });
135
- };
136
- const processData = async () => {
137
- if (data?.length) {
138
- let data_copy = [...data];
139
- let counter = 0;
140
- let { rows, data: rest } = getChunk(data_copy, chunk_size);
141
- while (rows?.length) {
142
- const chunk = processChunkRows(rows, counter);
143
- const processed_chunks = await Promise.all(chunk);
144
- const errors = processed_chunks.filter(r => !r.success);
145
- if (errors.length) {
146
- setDataErrors(p => [
147
- ...p,
148
- ...errors.map(r => {
149
- return `user_id (${r.userId}) failed to update in index ${r.index}: ${String(r.error)}`;
150
- }),
151
- ]);
152
- setRowErrors(r => [
153
- ...r,
154
- ...errors.map(e => data[e.index]),
155
- ]);
156
- }
157
- if (rest.length > 0) {
158
- await delay(delay_between_chunks);
159
- counter += rows.length;
160
- const next = getChunk(rest, chunk_size);
161
- rows = next.rows;
162
- rest = next.data;
163
- }
164
- else {
165
- processing.setFalse();
166
- break;
167
- }
168
- }
169
- }
170
- };
171
- const handleErrors = async () => {
172
- if (row_errors.length && log_errors) {
173
- await fs.writeFile(DEFAULT_ERROR_FILENAME, JSON.stringify(row_errors, null, 2), {
174
- encoding: 'utf-8',
175
- });
176
- running.setFalse();
177
- }
178
- else {
179
- running.setFalse();
180
- }
181
- };
182
- if (!filename?.length) {
183
- return React.createElement(UhOh, { text: "You must specify a filename." });
184
- }
185
- else if (error?.length) {
186
- return React.createElement(UhOh, { text: error });
187
- }
188
- else if (data && running.value) {
189
- return (React.createElement(React.Fragment, null,
190
- React.createElement(ProgressBar, { value: Math.floor((counter.count / data.length) * 100) }),
191
- React.createElement(Spinner, { text: `Completed Rows: ${counter.count} / ${data.length}` })));
192
- }
193
- else {
194
- return (React.createElement(Box, { flexDirection: "column", marginY: 1 },
195
- React.createElement(Text, { color: 'green' }, `Completed Rows: ${counter.count} / ${data?.length || 0}`),
196
- data_errors.map((err, i) => {
197
- return React.createElement(UhOh, { key: i, text: err });
198
- }),
199
- log_errors && data_errors.length ? (React.createElement(Text, null,
200
- "Errors output to ",
201
- DEFAULT_ERROR_FILENAME)) : (React.createElement(React.Fragment, null))));
202
- }
203
- };
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- declare const _default: ({ params }: {
3
- params: any;
4
- }) => React.JSX.Element;
5
- export default _default;
@@ -1,40 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import UhOh from '../components/UhOh.js';
3
- import Request from '../components/Request.js';
4
- import Response from '../components/Response.js';
5
- import api from '../lib/api.js';
6
- import { useCliContext } from '../components/Context.js';
7
- import uuid from '../lib/uuid.js';
8
- export default ({ params }) => {
9
- const { apikey, url } = useCliContext();
10
- const [resp, setResp] = useState();
11
- const eventId = params?._?.[0];
12
- if (!eventId) {
13
- return React.createElement(UhOh, { text: "You must specify an event ID to trigger." });
14
- }
15
- const userId = params?._?.[1];
16
- if (!userId) {
17
- return React.createElement(UhOh, { text: "You must specify a user ID for the event." });
18
- }
19
- const { _, ...properties } = params;
20
- const payload = {
21
- type: 'track',
22
- event: eventId,
23
- messageId: uuid(),
24
- properties: {
25
- userId,
26
- ...properties,
27
- },
28
- };
29
- const request = {
30
- method: 'POST',
31
- url: '/inbound/courier',
32
- body: payload,
33
- };
34
- useEffect(() => {
35
- api(request, url, apikey).then(res => setResp(res));
36
- }, []);
37
- return (React.createElement(React.Fragment, null,
38
- React.createElement(Request, { request: request, response: resp }),
39
- React.createElement(Response, { response: resp })));
40
- };
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- declare const _default: ({}: {}) => React.JSX.Element;
3
- export default _default;
@@ -1,89 +0,0 @@
1
- import { Alert } from '@inkjs/ui';
2
- import _ from 'lodash';
3
- import React, { useEffect, useState } from 'react';
4
- import { useBoolean, useCounter } from 'usehooks-ts';
5
- import getDb from '../bulk.js';
6
- import { useCliContext } from '../components/Context.js';
7
- import Spinner from '../components/Spinner.js';
8
- import UhOh from '../components/UhOh.js';
9
- import uuid from '../lib/uuid.js';
10
- export default ({}) => {
11
- const { parsedParams, courier } = useCliContext();
12
- const processing = useBoolean(true);
13
- const running = useBoolean(true);
14
- const [data, setData] = useState();
15
- const [data_errors, setDataError] = useState([]);
16
- const counter = useCounter(0);
17
- const { _: [event_name, filename], } = parsedParams;
18
- const { db, filetype, sql } = getDb(filename || '');
19
- useEffect(() => {
20
- if (filetype) {
21
- getData();
22
- }
23
- else {
24
- setDataError(p => [...p, 'File type not supported.']);
25
- }
26
- }, []);
27
- useEffect(() => {
28
- if (data) {
29
- processData();
30
- }
31
- }, [data]);
32
- useEffect(() => {
33
- if (data_errors?.length) {
34
- running.setFalse();
35
- processing.setFalse();
36
- }
37
- }, [data_errors]);
38
- const getData = () => {
39
- db.all(sql, (err, result) => {
40
- if (err) {
41
- setDataError(p => [...p, err.message]);
42
- }
43
- else {
44
- setData(result);
45
- }
46
- });
47
- processing.setFalse();
48
- };
49
- const processData = async () => {
50
- if (data?.length) {
51
- for (let i = 0; i < data.length; i++) {
52
- let { user_id, recipient, ...rest } = data[i] || {};
53
- let body = {
54
- messageId: uuid(),
55
- recipient: `${recipient ?? user_id}`,
56
- event: event_name,
57
- type: 'track',
58
- properties: {},
59
- };
60
- _.keys(rest).forEach(key => {
61
- _.set(body, ['properties', key], rest[key]);
62
- });
63
- const res = await courier.inbound.track(body);
64
- if (res instanceof Error) {
65
- setDataError([res.message]);
66
- }
67
- counter.increment();
68
- }
69
- }
70
- running.setFalse();
71
- };
72
- if (data_errors?.length) {
73
- return React.createElement(UhOh, { text: data_errors.join('\n') });
74
- }
75
- else if (processing.value) {
76
- return React.createElement(Spinner, { text: "Processing data..." });
77
- }
78
- else if (running.value) {
79
- return (React.createElement(Spinner, { text: `Processing ${counter.count} / ${data?.length} records` }));
80
- }
81
- else {
82
- return (React.createElement(React.Fragment, null,
83
- React.createElement(Alert, { variant: !counter.count ? 'info' : 'success', title: `Track complete` },
84
- "Sent ",
85
- counter.count,
86
- " track events to ",
87
- event_name)));
88
- }
89
- };
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- type Params = {
3
- _?: string[];
4
- text?: boolean;
5
- domain?: string;
6
- };
7
- declare const _default: ({ params }: {
8
- params: Params;
9
- }) => React.JSX.Element;
10
- export default _default;
@@ -1,30 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { Box, Text } from 'ink';
3
- import UhOh from '../components/UhOh.js';
4
- import Request from '../components/Request.js';
5
- import Response from '../components/Response.js';
6
- import api from '../lib/api.js';
7
- import { useCliContext } from '../components/Context.js';
8
- export default ({ params }) => {
9
- const { apikey, url } = useCliContext();
10
- const [resp, setResp] = useState();
11
- const locale = params?._?.[0];
12
- if (!locale) {
13
- return React.createElement(UhOh, { text: "You must specify a locale, e.g. en-US." });
14
- }
15
- const isText = params.text || false;
16
- const request = {
17
- method: 'GET',
18
- url: `/translations/${params.domain || 'default'}/${locale}`,
19
- };
20
- useEffect(() => {
21
- api(request, url, apikey).then(res => {
22
- res.res.headers.get('content-type');
23
- setResp(res);
24
- });
25
- }, []);
26
- return isText ? (React.createElement(Box, null,
27
- React.createElement(Text, null, resp?.text))) : (React.createElement(React.Fragment, null,
28
- React.createElement(Request, { request: request, response: resp }),
29
- React.createElement(Response, { response: resp })));
30
- };
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- type Params = {
3
- _?: string[];
4
- domain?: string;
5
- };
6
- declare const _default: ({ params }: {
7
- params: Params;
8
- }) => React.JSX.Element;
9
- export default _default;
@@ -1,37 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import fs from 'fs';
3
- import UhOh from '../components/UhOh.js';
4
- import Request from '../components/Request.js';
5
- import Response from '../components/Response.js';
6
- import api from '../lib/api.js';
7
- import { useCliContext } from '../components/Context.js';
8
- export default ({ params }) => {
9
- const { apikey, url } = useCliContext();
10
- const [resp, setResp] = useState();
11
- const locale = params?._?.[0];
12
- if (!locale) {
13
- return React.createElement(UhOh, { text: "You must specify a locale, e.g. en-US." });
14
- }
15
- const filepath = params?._?.[1];
16
- if (!filepath) {
17
- return React.createElement(UhOh, { text: "You must specify a path to the .PO file." });
18
- }
19
- else if (!fs.existsSync(filepath)) {
20
- return React.createElement(UhOh, { text: "No .PO file found at given path." });
21
- }
22
- const po = fs.readFileSync(filepath, 'utf8');
23
- const request = {
24
- method: 'PUT',
25
- url: `/translations/${params.domain || 'default'}/${locale}`,
26
- headers: {
27
- 'Content-Type': 'text/plain',
28
- },
29
- body: po,
30
- };
31
- useEffect(() => {
32
- api(request, url, apikey).then(res => setResp(res));
33
- }, []);
34
- return (React.createElement(React.Fragment, null,
35
- React.createElement(Request, { request: request, response: resp }),
36
- React.createElement(Response, { response: resp })));
37
- };
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- declare const _default: () => React.JSX.Element;
3
- export default _default;
@@ -1,38 +0,0 @@
1
- import { Alert } from '@inkjs/ui';
2
- import React, { useEffect, useState } from 'react';
3
- import { useBoolean } from 'usehooks-ts';
4
- import { useCliContext } from '../components/Context.js';
5
- import Spinner from '../components/Spinner.js';
6
- import { Box } from 'ink';
7
- import { execa } from 'execa';
8
- import constants from '../constants.js';
9
- export default () => {
10
- const { version } = useCliContext();
11
- const running = useBoolean(true);
12
- const [error, setError] = useState();
13
- useEffect(() => {
14
- if (version.latest) {
15
- upgrade();
16
- }
17
- }, [version.latest]);
18
- const upgrade = async () => {
19
- try {
20
- await execa('npm', ['install', '-g', `${constants.package_name}`, '--', 'latest'], {
21
- shell: true,
22
- });
23
- }
24
- catch (e) {
25
- setError(e.message);
26
- }
27
- finally {
28
- running.setFalse();
29
- }
30
- };
31
- if (running.value) {
32
- return React.createElement(Spinner, { text: `Upgrading Courier CLI ${version.latest}` });
33
- }
34
- else {
35
- const text = `Courier CLI upgraded to ${version.latest}`;
36
- return (React.createElement(Box, { width: error ? undefined : text.length + 8 }, error?.length ? (React.createElement(Alert, { variant: "error", title: 'Error' }, error)) : (React.createElement(Alert, { variant: "success", title: 'Upgraded' }, text))));
37
- }
38
- };
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- declare const UserToken: () => React.JSX.Element;
3
- export default UserToken;