@capgo/cli 4.2.3 → 4.2.7

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.
@@ -648,42 +648,54 @@ export interface Database {
648
648
  global_stats: {
649
649
  Row: {
650
650
  apps: number
651
+ apps_active: number | null
651
652
  created_at: string | null
652
653
  date_id: string
653
654
  need_upgrade: number | null
654
655
  not_paying: number | null
655
656
  onboarded: number | null
656
657
  paying: number | null
658
+ paying_monthly: number | null
659
+ paying_yearly: number | null
657
660
  stars: number
658
661
  trial: number | null
659
662
  updates: number
660
663
  users: number | null
664
+ users_active: number | null
661
665
  }
662
666
  Insert: {
663
667
  apps: number
668
+ apps_active?: number | null
664
669
  created_at?: string | null
665
670
  date_id: string
666
671
  need_upgrade?: number | null
667
672
  not_paying?: number | null
668
673
  onboarded?: number | null
669
674
  paying?: number | null
675
+ paying_monthly?: number | null
676
+ paying_yearly?: number | null
670
677
  stars: number
671
678
  trial?: number | null
672
679
  updates: number
673
680
  users?: number | null
681
+ users_active?: number | null
674
682
  }
675
683
  Update: {
676
684
  apps?: number
685
+ apps_active?: number | null
677
686
  created_at?: string | null
678
687
  date_id?: string
679
688
  need_upgrade?: number | null
680
689
  not_paying?: number | null
681
690
  onboarded?: number | null
682
691
  paying?: number | null
692
+ paying_monthly?: number | null
693
+ paying_yearly?: number | null
683
694
  stars?: number
684
695
  trial?: number | null
685
696
  updates?: number
686
697
  users?: number | null
698
+ users_active?: number | null
687
699
  }
688
700
  Relationships: []
689
701
  }
@@ -1257,6 +1269,12 @@ export interface Database {
1257
1269
  }
1258
1270
  Returns: number
1259
1271
  }
1272
+ count_active_users: {
1273
+ Args: {
1274
+ app_ids: string[]
1275
+ }
1276
+ Returns: number
1277
+ }
1260
1278
  count_all_apps: {
1261
1279
  Args: Record<PropertyKey, never>
1262
1280
  Returns: number
@@ -1382,6 +1400,14 @@ export interface Database {
1382
1400
  }
1383
1401
  Returns: string
1384
1402
  }
1403
+ get_customer_counts: {
1404
+ Args: Record<PropertyKey, never>
1405
+ Returns: {
1406
+ yearly: number
1407
+ monthly: number
1408
+ total: number
1409
+ }[]
1410
+ }
1385
1411
  get_cycle_info:
1386
1412
  | {
1387
1413
  Args: Record<PropertyKey, never>
@@ -1930,35 +1956,37 @@ export interface Database {
1930
1956
  }
1931
1957
  CompositeTypes: {
1932
1958
  match_plan: {
1933
- name: string
1959
+ name: string | null
1934
1960
  }
1935
1961
  orgs_table: {
1936
- id: string
1937
- created_by: string
1938
- created_at: string
1939
- updated_at: string
1940
- logo: string
1941
- name: string
1962
+ id: string | null
1963
+ created_by: string | null
1964
+ created_at: string | null
1965
+ updated_at: string | null
1966
+ logo: string | null
1967
+ name: string | null
1942
1968
  }
1943
1969
  owned_orgs: {
1944
- id: string
1945
- created_by: string
1946
- logo: string
1947
- name: string
1948
- role: string
1970
+ id: string | null
1971
+ created_by: string | null
1972
+ logo: string | null
1973
+ name: string | null
1974
+ role: string | null
1949
1975
  }
1950
1976
  stats_table: {
1951
- mau: number
1952
- bandwidth: number
1953
- storage: number
1977
+ mau: number | null
1978
+ bandwidth: number | null
1979
+ storage: number | null
1954
1980
  }
1955
1981
  }
1956
1982
  }
1957
1983
  }
1958
1984
 
1985
+ type PublicSchema = Database[Extract<keyof Database, 'public'>]
1986
+
1959
1987
  export type Tables<
1960
1988
  PublicTableNameOrOptions extends
1961
- | keyof (Database['public']['Tables'] & Database['public']['Views'])
1989
+ | keyof (PublicSchema['Tables'] & PublicSchema['Views'])
1962
1990
  | { schema: keyof Database },
1963
1991
  TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
1964
1992
  ? keyof (Database[PublicTableNameOrOptions['schema']]['Tables'] &
@@ -1971,10 +1999,10 @@ export type Tables<
1971
1999
  }
1972
2000
  ? R
1973
2001
  : never
1974
- : PublicTableNameOrOptions extends keyof (Database['public']['Tables'] &
1975
- Database['public']['Views'])
1976
- ? (Database['public']['Tables'] &
1977
- Database['public']['Views'])[PublicTableNameOrOptions] extends {
2002
+ : PublicTableNameOrOptions extends keyof (PublicSchema['Tables'] &
2003
+ PublicSchema['Views'])
2004
+ ? (PublicSchema['Tables'] &
2005
+ PublicSchema['Views'])[PublicTableNameOrOptions] extends {
1978
2006
  Row: infer R
1979
2007
  }
1980
2008
  ? R
@@ -1983,7 +2011,7 @@ export type Tables<
1983
2011
 
1984
2012
  export type TablesInsert<
1985
2013
  PublicTableNameOrOptions extends
1986
- | keyof Database['public']['Tables']
2014
+ | keyof PublicSchema['Tables']
1987
2015
  | { schema: keyof Database },
1988
2016
  TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
1989
2017
  ? keyof Database[PublicTableNameOrOptions['schema']]['Tables']
@@ -1994,8 +2022,8 @@ export type TablesInsert<
1994
2022
  }
1995
2023
  ? I
1996
2024
  : never
1997
- : PublicTableNameOrOptions extends keyof Database['public']['Tables']
1998
- ? Database['public']['Tables'][PublicTableNameOrOptions] extends {
2025
+ : PublicTableNameOrOptions extends keyof PublicSchema['Tables']
2026
+ ? PublicSchema['Tables'][PublicTableNameOrOptions] extends {
1999
2027
  Insert: infer I
2000
2028
  }
2001
2029
  ? I
@@ -2004,7 +2032,7 @@ export type TablesInsert<
2004
2032
 
2005
2033
  export type TablesUpdate<
2006
2034
  PublicTableNameOrOptions extends
2007
- | keyof Database['public']['Tables']
2035
+ | keyof PublicSchema['Tables']
2008
2036
  | { schema: keyof Database },
2009
2037
  TableName extends PublicTableNameOrOptions extends { schema: keyof Database }
2010
2038
  ? keyof Database[PublicTableNameOrOptions['schema']]['Tables']
@@ -2015,8 +2043,8 @@ export type TablesUpdate<
2015
2043
  }
2016
2044
  ? U
2017
2045
  : never
2018
- : PublicTableNameOrOptions extends keyof Database['public']['Tables']
2019
- ? Database['public']['Tables'][PublicTableNameOrOptions] extends {
2046
+ : PublicTableNameOrOptions extends keyof PublicSchema['Tables']
2047
+ ? PublicSchema['Tables'][PublicTableNameOrOptions] extends {
2020
2048
  Update: infer U
2021
2049
  }
2022
2050
  ? U
@@ -2025,13 +2053,13 @@ export type TablesUpdate<
2025
2053
 
2026
2054
  export type Enums<
2027
2055
  PublicEnumNameOrOptions extends
2028
- | keyof Database['public']['Enums']
2056
+ | keyof PublicSchema['Enums']
2029
2057
  | { schema: keyof Database },
2030
2058
  EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database }
2031
2059
  ? keyof Database[PublicEnumNameOrOptions['schema']]['Enums']
2032
2060
  : never = never,
2033
2061
  > = PublicEnumNameOrOptions extends { schema: keyof Database }
2034
2062
  ? Database[PublicEnumNameOrOptions['schema']]['Enums'][EnumName]
2035
- : PublicEnumNameOrOptions extends keyof Database['public']['Enums']
2036
- ? Database['public']['Enums'][PublicEnumNameOrOptions]
2063
+ : PublicEnumNameOrOptions extends keyof PublicSchema['Enums']
2064
+ ? PublicSchema['Enums'][PublicEnumNameOrOptions]
2037
2065
  : never
package/src/utils.ts CHANGED
@@ -18,6 +18,7 @@ export const baseKeyPub = `${baseKey}.pub`
18
18
  export const defaultHost = 'https://capgo.app'
19
19
  export const defaultApiHost = 'https://api.capgo.app'
20
20
  export const defaultHostWeb = 'https://web.capgo.app'
21
+ export const EMPTY_UUID = '00000000-0000-0000-0000-000000000000'
21
22
 
22
23
  export const regexSemver = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
23
24
  export const formatError = (error: any) => error ? `\n${prettyjson.render(error)}` : ''
@@ -192,7 +193,7 @@ export enum OrganizationPerm {
192
193
  upload = 2,
193
194
  write = 3,
194
195
  admin = 4,
195
- owner = 5,
196
+ super_admin = 5,
196
197
  }
197
198
 
198
199
  export const hasOrganizationPerm = (perm: OrganizationPerm, required: OrganizationPerm): boolean => (perm as number) >= (required as number)
@@ -234,7 +235,7 @@ export async function isAllowedAppOrg(supabase: SupabaseClient<Database>, apikey
234
235
  break
235
236
  }
236
237
  case 'perm_owner': {
237
- perm = OrganizationPerm.owner
238
+ perm = OrganizationPerm.super_admin
238
239
  break
239
240
  }
240
241
  default: {
@@ -406,10 +407,10 @@ export async function updateOrCreateVersion(supabase: SupabaseClient<Database>,
406
407
  .eq('name', update.name)
407
408
  }
408
409
 
409
- export async function uploadUrl(supabase: SupabaseClient<Database>, appId: string, bucketId: string): Promise<string> {
410
+ export async function uploadUrl(supabase: SupabaseClient<Database>, appId: string, name: string): Promise<string> {
410
411
  const data = {
411
412
  app_id: appId,
412
- bucket_id: bucketId,
413
+ name,
413
414
  }
414
415
  try {
415
416
  const pathUploadLink = 'private/upload_link'
@@ -433,7 +434,7 @@ export async function updateOrCreateChannel(supabase: SupabaseClient<Database>,
433
434
  .select('enable_progressive_deploy, secondaryVersionPercentage, secondVersion')
434
435
  .eq('app_id', update.app_id)
435
436
  .eq('name', update.name)
436
- // .eq('created_by', update.created_by)
437
+ // .eq('created_by', update.created_by)
437
438
  .single()
438
439
 
439
440
  if (data && !error) {
@@ -459,7 +460,7 @@ export async function updateOrCreateChannel(supabase: SupabaseClient<Database>,
459
460
  .update(update)
460
461
  .eq('app_id', update.app_id)
461
462
  .eq('name', update.name)
462
- // .eq('created_by', update.created_by)
463
+ // .eq('created_by', update.created_by)
463
464
  .select()
464
465
  .single()
465
466
  }