@capgo/cli 4.2.2 → 4.2.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [4.2.3](https://github.com/Cap-go/CLI/compare/v4.2.2...v4.2.3) (2024-03-12)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * issue check plan ([ed64d10](https://github.com/Cap-go/CLI/commit/ed64d107612cfc58548dca80bf1915e90b98ec33))
11
+
5
12
  ### [4.2.2](https://github.com/Cap-go/CLI/compare/v4.2.1...v4.2.2) (2024-03-11)
6
13
 
7
14
  ### [4.2.1](https://github.com/Cap-go/CLI/compare/v4.2.0...v4.2.1) (2024-03-08)
package/dist/index.js CHANGED
@@ -61137,7 +61137,7 @@ var {
61137
61137
  // package.json
61138
61138
  var package_default = {
61139
61139
  name: "@capgo/cli",
61140
- version: "4.2.2",
61140
+ version: "4.2.3",
61141
61141
  description: "A CLI to upload to capgo servers",
61142
61142
  main: "dist/index.js",
61143
61143
  bin: {
@@ -62393,6 +62393,10 @@ async function isTrial(supabase, userId) {
62393
62393
  const { data } = await supabase.rpc("is_trial", { userid: userId }).single();
62394
62394
  return data || 0;
62395
62395
  }
62396
+ async function isAllowedAction(supabase, userId) {
62397
+ const { data } = await supabase.rpc("is_allowed_action_user", { userid: userId }).single();
62398
+ return !!data;
62399
+ }
62396
62400
  async function isAllowedActionAppIdApiKey(supabase, appId, apikey) {
62397
62401
  const { data } = await supabase.rpc("is_allowed_action", { apikey, appid: appId }).single();
62398
62402
  return !!data;
@@ -62494,9 +62498,9 @@ async function isAllowedAppOrg(supabase, apikey, appId) {
62494
62498
  error: functionError
62495
62499
  };
62496
62500
  }
62497
- async function checkPlanValid(supabase, userId, appId, apikey, warning = true) {
62501
+ async function checkPlanValid(supabase, userId, apikey, appId, warning = true) {
62498
62502
  const config = await getRemoteConfig();
62499
- const validPlan = await isAllowedActionAppIdApiKey(supabase, appId, apikey);
62503
+ const validPlan = await (appId ? isAllowedActionAppIdApiKey(supabase, appId, apikey) : isAllowedAction(supabase, userId));
62500
62504
  if (!validPlan) {
62501
62505
  f2.error(`You need to upgrade your plan to continue to use capgo.
62502
62506
  Upgrade here: ${config.hostWeb}/dashboard/settings/plans
@@ -63504,7 +63508,7 @@ async function uploadBundle(appid, options, shouldExit = true) {
63504
63508
  const supabase = await createSupabaseClient(options.apikey);
63505
63509
  const userId = await verifyUser(supabase, options.apikey, ["write", "all", "upload"]);
63506
63510
  const permissions = await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appid, 2 /* upload */);
63507
- await checkPlanValid(supabase, userId, appid, options.apikey, true);
63511
+ await checkPlanValid(supabase, userId, options.apikey, appid, true);
63508
63512
  const updateMetadataRequired = await requireUpdateMetadata(supabase, channel2);
63509
63513
  const { data: channelData, error: channelError } = await supabase.from("channels").select("version ( minUpdateVersion, native_packages )").eq("name", channel2).eq("app_id", appid).single();
63510
63514
  let localDependencies = void 0;
@@ -63942,6 +63946,7 @@ async function addApp(appId, options, throwErr = true) {
63942
63946
  }
63943
63947
  const supabase = await createSupabaseClient(options.apikey);
63944
63948
  const userId = await verifyUser(supabase, options.apikey, ["write", "all"]);
63949
+ await checkPlanValid(supabase, userId, options.apikey, void 0, false);
63945
63950
  const appExist = await checkAppExists(supabase, appId);
63946
63951
  if (throwErr && appExist) {
63947
63952
  f2.error(`App ${appId} already exist`);
@@ -63961,7 +63966,6 @@ async function addApp(appId, options, throwErr = true) {
63961
63966
  f2.info(`Adding ${appId} to Capgo`);
63962
63967
  let iconBuff;
63963
63968
  let iconType;
63964
- await checkPlanValid(supabase, userId, appId, options.apikey, false);
63965
63969
  if (icon && (0, import_node_fs10.existsSync)(icon)) {
63966
63970
  iconBuff = (0, import_node_fs10.readFileSync)(icon);
63967
63971
  const contentType = src_default.getType(icon);
@@ -64621,7 +64625,7 @@ async function setChannel(channel2, appId, options) {
64621
64625
  program.error("");
64622
64626
  }
64623
64627
  try {
64624
- await checkPlanValid(supabase, userId, appId, options.apikey);
64628
+ await checkPlanValid(supabase, userId, options.apikey, appId);
64625
64629
  const channelPayload = {
64626
64630
  created_by: userId,
64627
64631
  app_id: appId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/cli",
3
- "version": "4.2.2",
3
+ "version": "4.2.3",
4
4
  "description": "A CLI to upload to capgo servers",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/src/app/add.ts CHANGED
@@ -38,6 +38,9 @@ export async function addApp(appId: string, options: Options, throwErr = true) {
38
38
  const supabase = await createSupabaseClient(options.apikey)
39
39
 
40
40
  const userId = await verifyUser(supabase, options.apikey, ['write', 'all'])
41
+
42
+ await checkPlanValid(supabase, userId, options.apikey, undefined, false)
43
+
41
44
  // Check we have app access to this appId
42
45
  const appExist = await checkAppExists(supabase, appId)
43
46
  if (throwErr && appExist) {
@@ -62,8 +65,6 @@ export async function addApp(appId: string, options: Options, throwErr = true) {
62
65
  let iconBuff
63
66
  let iconType
64
67
 
65
- await checkPlanValid(supabase, userId, appId, options.apikey, false)
66
-
67
68
  if (icon && existsSync(icon)) {
68
69
  iconBuff = readFileSync(icon)
69
70
  const contentType = mime.getType(icon)
@@ -55,7 +55,7 @@ export async function unlinkDevice(channel: string, appId: string, options: Opti
55
55
  program.error('')
56
56
  }
57
57
  try {
58
- await checkPlanValid(supabase, userId, appId, options.apikey)
58
+ await checkPlanValid(supabase, userId, options.apikey, appId)
59
59
 
60
60
  const versionData = await getVersionData(supabase, appId, userId, bundle)
61
61
  await checkVersionNotUsedInChannel(supabase, appId, userId, versionData)
@@ -118,7 +118,7 @@ export async function uploadBundle(appid: string, options: Options, shouldExit =
118
118
  // await checkAppExistsAndHasPermissionErr(supabase, options.apikey, appid);
119
119
 
120
120
  const permissions = await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appid, OrganizationPerm.upload)
121
- await checkPlanValid(supabase, userId, appid, options.apikey, true)
121
+ await checkPlanValid(supabase, userId, options.apikey, appid, true)
122
122
 
123
123
  const updateMetadataRequired = await requireUpdateMetadata(supabase, channel)
124
124
 
@@ -75,7 +75,7 @@ export async function setChannel(channel: string, appId: string, options: Option
75
75
  program.error('')
76
76
  }
77
77
  try {
78
- await checkPlanValid(supabase, userId, appId, options.apikey)
78
+ await checkPlanValid(supabase, userId, options.apikey, appId)
79
79
  const channelPayload: Database['public']['Tables']['channels']['Insert'] = {
80
80
  created_by: userId,
81
81
  app_id: appId,
package/src/utils.ts CHANGED
@@ -282,9 +282,10 @@ export async function isAllowedAppOrg(supabase: SupabaseClient<Database>, apikey
282
282
  }
283
283
  }
284
284
 
285
- export async function checkPlanValid(supabase: SupabaseClient<Database>, userId: string, appId: string, apikey: string, warning = true) {
285
+ export async function checkPlanValid(supabase: SupabaseClient<Database>, userId: string, apikey: string, appId?: string, warning = true) {
286
286
  const config = await getRemoteConfig()
287
- const validPlan = await isAllowedActionAppIdApiKey(supabase, appId, apikey)
287
+
288
+ const validPlan = await (appId ? isAllowedActionAppIdApiKey(supabase, appId, apikey) : isAllowedAction(supabase, userId))
288
289
  if (!validPlan) {
289
290
  p.log.error(`You need to upgrade your plan to continue to use capgo.\n Upgrade here: ${config.hostWeb}/dashboard/settings/plans\n`)
290
291
  wait(100)