@faces-sh/cli 1.0.0 → 1.0.1

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.
@@ -11,7 +11,7 @@ export default class AuthConnections extends BaseCommand {
11
11
  async run() {
12
12
  const { flags } = await this.parse(AuthConnections);
13
13
  const client = this.makeClient(flags);
14
- const data = await client.get('/v1/oauth');
14
+ const data = await client.get('/v1/oauth', { requireJwt: true });
15
15
  if (!this.jsonEnabled()) {
16
16
  const rows = data;
17
17
  if (!rows || rows.length === 0) {
@@ -16,7 +16,7 @@ export default class BillingCardDefault extends BaseCommand {
16
16
  const client = this.makeClient(flags);
17
17
  let data;
18
18
  try {
19
- data = await client.post(`/v1/billing/payment-methods/${seg(args.card_id)}/default`);
19
+ data = await client.post(`/v1/billing/payment-methods/${seg(args.card_id)}/default`, { requireJwt: true });
20
20
  }
21
21
  catch (err) {
22
22
  if (err instanceof FacesAPIError) {
@@ -19,7 +19,7 @@ export default class BillingCardRemove extends BaseCommand {
19
19
  await this.confirmOrRefuse(`Remove card ${args.card_id}?`, flags.yes);
20
20
  let data;
21
21
  try {
22
- data = await client.delete(`/v1/billing/payment-methods/${seg(args.card_id)}`);
22
+ data = await client.delete(`/v1/billing/payment-methods/${seg(args.card_id)}`, { requireJwt: true });
23
23
  }
24
24
  catch (err) {
25
25
  if (err instanceof FacesAPIError) {
@@ -18,7 +18,7 @@ export default class BillingCardSetup extends BaseCommand {
18
18
  const client = this.makeClient(flags);
19
19
  let data;
20
20
  try {
21
- data = await client.post('/v1/billing/card-setup', flags.default ? {} : { body: { make_default: false } });
21
+ data = await client.post('/v1/billing/card-setup', flags.default ? { requireJwt: true } : { requireJwt: true, body: { make_default: false } });
22
22
  }
23
23
  catch (err) {
24
24
  if (err instanceof FacesAPIError)
@@ -41,7 +41,7 @@ export default class BillingSubscriptionActivate extends BaseCommand {
41
41
  if (plan === want && cancelAtPeriodEnd) {
42
42
  let data;
43
43
  try {
44
- data = await client.post('/v1/billing/subscription/reactivate');
44
+ data = await client.post('/v1/billing/subscription/reactivate', { requireJwt: true });
45
45
  }
46
46
  catch (err) {
47
47
  if (err instanceof FacesAPIError)
@@ -66,7 +66,7 @@ export default class BillingSubscriptionActivate extends BaseCommand {
66
66
  }
67
67
  let data;
68
68
  try {
69
- data = await client.post(`/v1/billing/checkout?plan=${want}&source=cli`);
69
+ data = await client.post(`/v1/billing/checkout?plan=${want}&source=cli`, { requireJwt: true });
70
70
  }
71
71
  catch (err) {
72
72
  if (err instanceof FacesAPIError) {
@@ -37,7 +37,7 @@ export default class BillingSubscriptionCancel extends BaseCommand {
37
37
  await this.confirmOrRefuse(`Cancel the ${name} plan? You'll keep access until ${periodEnd}.`, flags.yes);
38
38
  let data;
39
39
  try {
40
- data = await client.post('/v1/billing/subscription/cancel');
40
+ data = await client.post('/v1/billing/subscription/cancel', { requireJwt: true });
41
41
  }
42
42
  catch (err) {
43
43
  if (err instanceof FacesAPIError)
@@ -49,7 +49,7 @@ export default class BillingSubscriptionPlan extends BaseCommand {
49
49
  await this.confirmOrRefuse(`Switch from ${planName(plan)} to ${planName(want)} (${PLAN_PRICE[want]})? The difference is prorated on your default card.`, flags.yes);
50
50
  let data;
51
51
  try {
52
- data = await client.post(`/v1/billing/subscription/plan?plan=${want}`);
52
+ data = await client.post(`/v1/billing/subscription/plan?plan=${want}`, { requireJwt: true });
53
53
  }
54
54
  catch (err) {
55
55
  if (err instanceof FacesAPIError && err.statusCode >= 500) {
@@ -29,7 +29,7 @@ export default class BillingTopup extends BaseCommand {
29
29
  payload.allow_duplicate = true;
30
30
  let data;
31
31
  try {
32
- data = await client.post('/v1/billing/topup', { body: payload });
32
+ data = await client.post('/v1/billing/topup', { requireJwt: true, body: payload });
33
33
  }
34
34
  catch (err) {
35
35
  if (!(err instanceof FacesAPIError && err.statusCode === 409 && err.errorCode === 'duplicate_topup'))
@@ -39,7 +39,7 @@ export default class BillingTopup extends BaseCommand {
39
39
  }
40
40
  await this.confirmOrRefuse(`${err.message}\nCharge $${amount.toFixed(2)} again anyway?`, false);
41
41
  try {
42
- data = await client.post('/v1/billing/topup', { body: { ...payload, allow_duplicate: true } });
42
+ data = await client.post('/v1/billing/topup', { requireJwt: true, body: { ...payload, allow_duplicate: true } });
43
43
  }
44
44
  catch (again) {
45
45
  this.fail(again, flags.card);
@@ -18,7 +18,7 @@ export default class FaceDelete extends BaseCommand {
18
18
  await this.confirmOrRefuse(`Delete face '${args.face_id}'? This cannot be undone.`, flags.yes);
19
19
  let data;
20
20
  try {
21
- data = await client.delete(`/v1/faces/${seg(args.face_id)}`);
21
+ data = await client.delete(`/v1/faces/${seg(args.face_id)}`, { requireJwt: true });
22
22
  }
23
23
  catch (err) {
24
24
  if (err instanceof FacesAPIError && err.statusCode === 404 && isMeAlias(args.face_id))
@@ -23,6 +23,7 @@ export default class FacePublish extends BaseCommand {
23
23
  let data;
24
24
  try {
25
25
  data = (await client.patch(`/v1/faces/${seg(args.alias)}/publish`, {
26
+ requireJwt: true,
26
27
  body: { published: true },
27
28
  }));
28
29
  }
@@ -63,6 +63,7 @@ export default class FaceShare extends BaseCommand {
63
63
  let data;
64
64
  try {
65
65
  data = (await client.patch(`/v1/faces/${seg(args.alias)}/share`, {
66
+ requireJwt: true,
66
67
  body: { shared_with: next },
67
68
  }));
68
69
  }
@@ -15,6 +15,7 @@ export default class FaceUnpublish extends BaseCommand {
15
15
  let data;
16
16
  try {
17
17
  data = (await client.patch(`/v1/faces/${seg(args.alias)}/publish`, {
18
+ requireJwt: true,
18
19
  body: { published: false },
19
20
  }));
20
21
  }
@@ -50,7 +50,7 @@ export default class FaceUnshare extends BaseCommand {
50
50
  }
51
51
  let data;
52
52
  try {
53
- data = await client.patch(`/v1/faces/${seg(args.alias)}/share`, { body: { shared_with: next } });
53
+ data = await client.patch(`/v1/faces/${seg(args.alias)}/share`, { requireJwt: true, body: { shared_with: next } });
54
54
  }
55
55
  catch (err) {
56
56
  if (err instanceof FacesAPIError)
@@ -4,11 +4,12 @@ import { FacesAPIError } from '../../client.js';
4
4
  import { STYLE_FACES_PATH } from '../../style.js';
5
5
  import { faceStyles, seg } from '../../utils.js';
6
6
  export default class StyleDelete extends BaseCommand {
7
- static description = "Delete a face's built style. A face holds one per medium, so name which with --medium, or pass " +
8
- '--all to remove every one. On a face with several, an unscoped delete is refused rather than taking ' +
9
- 'them all. The material a style was built from is always kept, so it can be built again without ' +
10
- 're-uploading; to remove source text use compile:doc:delete, or compile:doc:reset to withdraw it from ' +
11
- 'the face while keeping it.';
7
+ static description = "Delete a face's style build. A face holds one per medium, so name which with --medium, or pass " +
8
+ '--all to delete every one. On a face with several, an unscoped delete is refused rather than taking ' +
9
+ 'them all. Only the build goes: the uploaded material is kept, so it can be built again without ' +
10
+ 're-uploading, and what the face learned about how it writes from its documents and threads stays ' +
11
+ 'until they are deleted. To remove a style completely, delete that medium\'s documents and threads ' +
12
+ '(compile:doc:delete, compile:thread:delete), then the build.';
12
13
  static examples = [
13
14
  '<%= config.bin %> <%= command.id %> alice --medium email',
14
15
  '<%= config.bin %> <%= command.id %> alice --all --yes',
@@ -16,11 +17,11 @@ export default class StyleDelete extends BaseCommand {
16
17
  static flags = {
17
18
  ...BaseCommand.baseFlags,
18
19
  medium: Flags.string({
19
- description: 'Delete only this medium\'s style, leaving the rest. See faces style:versions <alias>.',
20
+ description: 'Delete only this medium\'s style build, leaving the rest. See faces style:versions <alias>.',
20
21
  exclusive: ['all'],
21
22
  }),
22
23
  all: Flags.boolean({
23
- description: 'Delete every style the face has. Required when it holds more than one.',
24
+ description: 'Delete every style build the face has. Required when it holds more than one.',
24
25
  default: false,
25
26
  exclusive: ['medium'],
26
27
  }),
@@ -35,13 +36,14 @@ export default class StyleDelete extends BaseCommand {
35
36
  if (!flags.yes) {
36
37
  const media = await this.mediaOf(client, args.alias);
37
38
  const scope = flags.medium
38
- ? `its ${flags.medium} style`
39
+ ? `the ${flags.medium} style build`
39
40
  : media.length > 1
40
- ? `all ${media.length} of its styles (${media.join(', ')})`
41
+ ? `all ${media.length} style builds (${media.join(', ')})`
41
42
  : media.length === 1
42
- ? `its ${media[0]} style`
43
- : 'its style';
44
- const what = `'${args.alias}' will forget ${scope}. Its documents, threads and uploaded material are kept.`;
43
+ ? `the ${media[0]} style build`
44
+ : 'the style build';
45
+ const what = `This deletes ${scope} of '${args.alias}'. Its documents, threads and uploaded material are kept, ` +
46
+ 'and so is what it learned from them.';
45
47
  await this.confirmOrRefuse(`${what}\nDelete?`, false);
46
48
  }
47
49
  const params = new URLSearchParams();
@@ -76,8 +78,8 @@ export default class StyleDelete extends BaseCommand {
76
78
  const scoped = data.scoped === true || typeof data.medium === 'string';
77
79
  const medium = data.medium;
78
80
  this.log(scoped && medium
79
- ? `'${args.alias}' has forgotten its ${medium} style. Its other styles and all its source material are untouched.`
80
- : `'${args.alias}' has forgotten its styles. Its source material is untouched.`);
81
+ ? `Deleted the ${medium} style build of '${args.alias}'. Its other styles, its sources and what it learned from them are untouched.`
82
+ : `Deleted the style builds of '${args.alias}'. Its sources and what it learned from them are untouched.`);
81
83
  this.log(`Build it again with: faces style:make ${args.alias} --all`);
82
84
  return data;
83
85
  }