@capgo/cli 4.3.0 → 4.3.2
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 +4 -0
- package/dist/index.js +31 -18
- package/package.json +1 -1
- package/src/app/add.ts +2 -2
- package/src/bundle/unlink.ts +7 -2
- package/src/bundle/upload.ts +8 -3
- package/src/channel/set.ts +3 -1
- package/src/types/supabase.types.ts +381 -361
- package/src/utils.ts +27 -10
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
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.3.2](https://github.com/Cap-go/CLI/compare/v4.3.1...v4.3.2) (2024-04-14)
|
|
6
|
+
|
|
7
|
+
### [4.3.1](https://github.com/Cap-go/CLI/compare/v4.3.0...v4.3.1) (2024-04-14)
|
|
8
|
+
|
|
5
9
|
## [4.3.0](https://github.com/Cap-go/CLI/compare/v4.2.12...v4.3.0) (2024-03-31)
|
|
6
10
|
|
|
7
11
|
|
package/dist/index.js
CHANGED
|
@@ -91634,7 +91634,7 @@ var {
|
|
|
91634
91634
|
// package.json
|
|
91635
91635
|
var package_default = {
|
|
91636
91636
|
name: "@capgo/cli",
|
|
91637
|
-
version: "4.3.
|
|
91637
|
+
version: "4.3.2",
|
|
91638
91638
|
description: "A CLI to upload to capgo servers",
|
|
91639
91639
|
main: "dist/index.js",
|
|
91640
91640
|
bin: {
|
|
@@ -92884,16 +92884,16 @@ async function checkKey(supabase, apikey, keymode) {
|
|
|
92884
92884
|
program.error("");
|
|
92885
92885
|
}
|
|
92886
92886
|
}
|
|
92887
|
-
async function
|
|
92888
|
-
const { data } = await supabase.rpc("
|
|
92887
|
+
async function isPayingOrg(supabase, orgId) {
|
|
92888
|
+
const { data } = await supabase.rpc("is_paying_org", { orgid: orgId }).single();
|
|
92889
92889
|
return data || false;
|
|
92890
92890
|
}
|
|
92891
|
-
async function
|
|
92892
|
-
const { data } = await supabase.rpc("
|
|
92891
|
+
async function isTrialOrg(supabase, orgId) {
|
|
92892
|
+
const { data } = await supabase.rpc("is_trial_org", { orgid: orgId }).single();
|
|
92893
92893
|
return data || 0;
|
|
92894
92894
|
}
|
|
92895
|
-
async function
|
|
92896
|
-
const { data } = await supabase.rpc("
|
|
92895
|
+
async function isAllowedActionOrg(supabase, orgId) {
|
|
92896
|
+
const { data } = await supabase.rpc("is_allowed_action_org", { orgid: orgId }).single();
|
|
92897
92897
|
return !!data;
|
|
92898
92898
|
}
|
|
92899
92899
|
async function isAllowedActionAppIdApiKey(supabase, appId, apikey) {
|
|
@@ -92993,9 +92993,9 @@ async function isAllowedAppOrg(supabase, apikey, appId) {
|
|
|
92993
92993
|
error: functionError
|
|
92994
92994
|
};
|
|
92995
92995
|
}
|
|
92996
|
-
async function checkPlanValid(supabase,
|
|
92996
|
+
async function checkPlanValid(supabase, orgId, apikey, appId, warning = true) {
|
|
92997
92997
|
const config = await getRemoteConfig();
|
|
92998
|
-
const validPlan = await (appId ? isAllowedActionAppIdApiKey(supabase, appId, apikey) :
|
|
92998
|
+
const validPlan = await (appId ? isAllowedActionAppIdApiKey(supabase, appId, apikey) : isAllowedActionOrg(supabase, orgId));
|
|
92999
92999
|
if (!validPlan) {
|
|
93000
93000
|
f2.error(`You need to upgrade your plan to continue to use capgo.
|
|
93001
93001
|
Upgrade here: ${config.hostWeb}/dashboard/settings/plans
|
|
@@ -93007,8 +93007,10 @@ async function checkPlanValid(supabase, userId, apikey, appId, warning = true) {
|
|
|
93007
93007
|
wait(500);
|
|
93008
93008
|
program.error("");
|
|
93009
93009
|
}
|
|
93010
|
-
const trialDays = await
|
|
93011
|
-
|
|
93010
|
+
const [trialDays, ispaying] = await Promise.all([
|
|
93011
|
+
isTrialOrg(supabase, orgId),
|
|
93012
|
+
isPayingOrg(supabase, orgId)
|
|
93013
|
+
]);
|
|
93012
93014
|
if (trialDays > 0 && warning && !ispaying)
|
|
93013
93015
|
f2.warn(`WARNING !!
|
|
93014
93016
|
Trial expires in ${trialDays} days, upgrade here: ${config.hostWeb}/dashboard/settings/plans
|
|
@@ -93119,6 +93121,15 @@ async function verifyUser(supabase, apikey, keymod = ["all"]) {
|
|
|
93119
93121
|
}
|
|
93120
93122
|
return userId;
|
|
93121
93123
|
}
|
|
93124
|
+
async function getOrganizationId(supabase, appId) {
|
|
93125
|
+
const { data, error } = await supabase.from("apps").select("owner_org").eq("app_id", appId).single();
|
|
93126
|
+
if (!data || error) {
|
|
93127
|
+
f2.error(`Cannot get organization id for app id ${appId}`);
|
|
93128
|
+
formatError(error);
|
|
93129
|
+
program.error("");
|
|
93130
|
+
}
|
|
93131
|
+
return data.owner_org;
|
|
93132
|
+
}
|
|
93122
93133
|
async function requireUpdateMetadata(supabase, channel2, appId) {
|
|
93123
93134
|
const { data, error } = await supabase.from("channels").select("disableAutoUpdate").eq("name", channel2).eq("app_id", appId).limit(1);
|
|
93124
93135
|
if (error) {
|
|
@@ -94011,7 +94022,8 @@ async function uploadBundle(appid, options, shouldExit = true) {
|
|
|
94011
94022
|
const supabase = await createSupabaseClient(options.apikey);
|
|
94012
94023
|
const userId = await verifyUser(supabase, options.apikey, ["write", "all", "upload"]);
|
|
94013
94024
|
const permissions = await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appid, 2 /* upload */);
|
|
94014
|
-
await
|
|
94025
|
+
const orgId = await getOrganizationId(supabase, appid);
|
|
94026
|
+
await checkPlanValid(supabase, orgId, options.apikey, appid, true);
|
|
94015
94027
|
const updateMetadataRequired = await requireUpdateMetadata(supabase, channel2, appid);
|
|
94016
94028
|
const { data: channelData, error: channelError } = await supabase.from("channels").select("version ( minUpdateVersion, native_packages )").eq("name", channel2).eq("app_id", appid).single();
|
|
94017
94029
|
let localDependencies = void 0;
|
|
@@ -94065,11 +94077,11 @@ async function uploadBundle(appid, options, shouldExit = true) {
|
|
|
94065
94077
|
program.error("");
|
|
94066
94078
|
}
|
|
94067
94079
|
}
|
|
94068
|
-
const { data:
|
|
94069
|
-
if (
|
|
94080
|
+
const { data: isTrial, error: isTrialsError } = await supabase.rpc("is_trial_org", { orgid: orgId }).single();
|
|
94081
|
+
if (isTrial && isTrial > 0 || isTrialsError) {
|
|
94070
94082
|
f2.warn(`WARNING !!
|
|
94071
|
-
Trial expires in ${
|
|
94072
|
-
f2.warn(`Upgrade here: ${localConfig.hostWeb}/dashboard/settings/plans`);
|
|
94083
|
+
Trial expires in ${isTrial} days`);
|
|
94084
|
+
f2.warn(`Upgrade here: ${localConfig.hostWeb}/dashboard/settings/plans?oid=${orgId}`);
|
|
94073
94085
|
}
|
|
94074
94086
|
const { data: appVersion, error: appVersionError } = await supabase.rpc("exist_app_versions", { appid, apikey: options.apikey, name_version: bundle2 }).single();
|
|
94075
94087
|
if (appVersion || appVersionError) {
|
|
@@ -94483,7 +94495,6 @@ async function addApp(appId, options, throwErr = true) {
|
|
|
94483
94495
|
}
|
|
94484
94496
|
const supabase = await createSupabaseClient(options.apikey);
|
|
94485
94497
|
let userId = await verifyUser(supabase, options.apikey, ["write", "all"]);
|
|
94486
|
-
await checkPlanValid(supabase, userId, options.apikey, void 0, false);
|
|
94487
94498
|
const appExist = await checkAppExists(supabase, appId);
|
|
94488
94499
|
if (throwErr && appExist) {
|
|
94489
94500
|
f2.error(`App ${appId} already exist`);
|
|
@@ -94512,6 +94523,7 @@ async function addApp(appId, options, throwErr = true) {
|
|
|
94512
94523
|
const organization = allOrganizations.find((org) => org.gid === organizationUid);
|
|
94513
94524
|
userId = organization.created_by;
|
|
94514
94525
|
f2.info(`Using the organization "${organization.name}" as the app owner`);
|
|
94526
|
+
await checkPlanValid(supabase, organizationUid, options.apikey, void 0, false);
|
|
94515
94527
|
let { name, icon } = options;
|
|
94516
94528
|
appId = appId || config?.app?.appId;
|
|
94517
94529
|
name = name || config?.app?.appName || "Unknown";
|
|
@@ -95173,6 +95185,7 @@ async function setChannel(channel2, appId, options) {
|
|
|
95173
95185
|
const supabase = await createSupabaseClient(options.apikey);
|
|
95174
95186
|
const userId = await verifyUser(supabase, options.apikey, ["write", "all"]);
|
|
95175
95187
|
await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, 4 /* admin */);
|
|
95188
|
+
const orgId = await getOrganizationId(supabase, appId);
|
|
95176
95189
|
const { bundle: bundle2, latest, downgrade, upgrade, ios, android, selfAssign, state, disableAutoUpdate } = options;
|
|
95177
95190
|
if (!channel2) {
|
|
95178
95191
|
f2.error("Missing argument, you need to provide a channel");
|
|
@@ -95187,7 +95200,7 @@ async function setChannel(channel2, appId, options) {
|
|
|
95187
95200
|
program.error("");
|
|
95188
95201
|
}
|
|
95189
95202
|
try {
|
|
95190
|
-
await checkPlanValid(supabase,
|
|
95203
|
+
await checkPlanValid(supabase, orgId, options.apikey, appId);
|
|
95191
95204
|
const channelPayload = {
|
|
95192
95205
|
created_by: userId,
|
|
95193
95206
|
app_id: appId,
|
package/package.json
CHANGED
package/src/app/add.ts
CHANGED
|
@@ -39,8 +39,6 @@ export async function addApp(appId: string, options: Options, throwErr = true) {
|
|
|
39
39
|
|
|
40
40
|
let userId = await verifyUser(supabase, options.apikey, ['write', 'all'])
|
|
41
41
|
|
|
42
|
-
await checkPlanValid(supabase, userId, options.apikey, undefined, false)
|
|
43
|
-
|
|
44
42
|
// Check we have app access to this appId
|
|
45
43
|
const appExist = await checkAppExists(supabase, appId)
|
|
46
44
|
if (throwErr && appExist) {
|
|
@@ -82,6 +80,8 @@ export async function addApp(appId: string, options: Options, throwErr = true) {
|
|
|
82
80
|
|
|
83
81
|
p.log.info(`Using the organization "${organization.name}" as the app owner`)
|
|
84
82
|
|
|
83
|
+
await checkPlanValid(supabase, organizationUid, options.apikey, undefined, false)
|
|
84
|
+
|
|
85
85
|
let { name, icon } = options
|
|
86
86
|
appId = appId || config?.app?.appId
|
|
87
87
|
name = name || config?.app?.appName || 'Unknown'
|
package/src/bundle/unlink.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
findSavedKey,
|
|
16
16
|
formatError,
|
|
17
17
|
getConfig,
|
|
18
|
+
getOrganizationId,
|
|
18
19
|
useLogSnag,
|
|
19
20
|
verifyUser,
|
|
20
21
|
} from '../utils'
|
|
@@ -47,7 +48,11 @@ export async function unlinkDevice(channel: string, appId: string, options: Opti
|
|
|
47
48
|
}
|
|
48
49
|
const supabase = await createSupabaseClient(options.apikey)
|
|
49
50
|
|
|
50
|
-
const userId = await
|
|
51
|
+
const [userId, orgId] = await Promise.all([
|
|
52
|
+
verifyUser(supabase, options.apikey, ['all', 'write']),
|
|
53
|
+
getOrganizationId(supabase, appId),
|
|
54
|
+
])
|
|
55
|
+
|
|
51
56
|
// Check we have app access to this appId
|
|
52
57
|
await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, OrganizationPerm.write)
|
|
53
58
|
|
|
@@ -56,7 +61,7 @@ export async function unlinkDevice(channel: string, appId: string, options: Opti
|
|
|
56
61
|
program.error('')
|
|
57
62
|
}
|
|
58
63
|
try {
|
|
59
|
-
await checkPlanValid(supabase,
|
|
64
|
+
await checkPlanValid(supabase, orgId, options.apikey, appId)
|
|
60
65
|
|
|
61
66
|
const versionData = await getVersionData(supabase, appId, bundle)
|
|
62
67
|
await checkVersionNotUsedInChannel(supabase, appId, versionData)
|
package/src/bundle/upload.ts
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
getConfig,
|
|
33
33
|
getLocalConfig,
|
|
34
34
|
getLocalDepenencies,
|
|
35
|
+
getOrganizationId,
|
|
35
36
|
hasOrganizationPerm,
|
|
36
37
|
regexSemver,
|
|
37
38
|
requireUpdateMetadata,
|
|
@@ -149,7 +150,10 @@ export async function uploadBundle(appid: string, options: Options, shouldExit =
|
|
|
149
150
|
// await checkAppExistsAndHasPermissionErr(supabase, options.apikey, appid);
|
|
150
151
|
|
|
151
152
|
const permissions = await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appid, OrganizationPerm.upload)
|
|
152
|
-
|
|
153
|
+
|
|
154
|
+
// Now if it does exist we will fetch the org id
|
|
155
|
+
const orgId = await getOrganizationId(supabase, appid)
|
|
156
|
+
await checkPlanValid(supabase, orgId, options.apikey, appid, true)
|
|
153
157
|
|
|
154
158
|
const updateMetadataRequired = await requireUpdateMetadata(supabase, channel, appid)
|
|
155
159
|
|
|
@@ -227,11 +231,12 @@ export async function uploadBundle(appid: string, options: Options, shouldExit =
|
|
|
227
231
|
}
|
|
228
232
|
|
|
229
233
|
const { data: isTrial, error: isTrialsError } = await supabase
|
|
230
|
-
.rpc('
|
|
234
|
+
.rpc('is_trial_org', { orgid: orgId })
|
|
231
235
|
.single()
|
|
232
236
|
if ((isTrial && isTrial > 0) || isTrialsError) {
|
|
237
|
+
// TODO: Come back to this to fix for orgs v3
|
|
233
238
|
p.log.warn(`WARNING !!\nTrial expires in ${isTrial} days`)
|
|
234
|
-
p.log.warn(`Upgrade here: ${localConfig.hostWeb}/dashboard/settings/plans`)
|
|
239
|
+
p.log.warn(`Upgrade here: ${localConfig.hostWeb}/dashboard/settings/plans?oid=${orgId}`)
|
|
235
240
|
}
|
|
236
241
|
|
|
237
242
|
// check if app already exist
|
package/src/channel/set.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
findSavedKey,
|
|
14
14
|
formatError,
|
|
15
15
|
getConfig,
|
|
16
|
+
getOrganizationId,
|
|
16
17
|
updateOrCreateChannel,
|
|
17
18
|
useLogSnag,
|
|
18
19
|
verifyUser,
|
|
@@ -53,6 +54,7 @@ export async function setChannel(channel: string, appId: string, options: Option
|
|
|
53
54
|
const userId = await verifyUser(supabase, options.apikey, ['write', 'all'])
|
|
54
55
|
// Check we have app access to this appId
|
|
55
56
|
await checkAppExistsAndHasPermissionOrgErr(supabase, options.apikey, appId, OrganizationPerm.admin)
|
|
57
|
+
const orgId = await getOrganizationId(supabase, appId)
|
|
56
58
|
|
|
57
59
|
const { bundle, latest, downgrade, upgrade, ios, android, selfAssign, state, disableAutoUpdate } = options
|
|
58
60
|
if (!channel) {
|
|
@@ -76,7 +78,7 @@ export async function setChannel(channel: string, appId: string, options: Option
|
|
|
76
78
|
program.error('')
|
|
77
79
|
}
|
|
78
80
|
try {
|
|
79
|
-
await checkPlanValid(supabase,
|
|
81
|
+
await checkPlanValid(supabase, orgId, options.apikey, appId)
|
|
80
82
|
const channelPayload: Database['public']['Tables']['channels']['Insert'] = {
|
|
81
83
|
created_by: userId,
|
|
82
84
|
app_id: appId,
|
|
@@ -7,6 +7,31 @@ export type Json =
|
|
|
7
7
|
| Json[]
|
|
8
8
|
|
|
9
9
|
export interface Database {
|
|
10
|
+
graphql_public: {
|
|
11
|
+
Tables: {
|
|
12
|
+
[_ in never]: never
|
|
13
|
+
}
|
|
14
|
+
Views: {
|
|
15
|
+
[_ in never]: never
|
|
16
|
+
}
|
|
17
|
+
Functions: {
|
|
18
|
+
graphql: {
|
|
19
|
+
Args: {
|
|
20
|
+
operationName?: string
|
|
21
|
+
query?: string
|
|
22
|
+
variables?: Json
|
|
23
|
+
extensions?: Json
|
|
24
|
+
}
|
|
25
|
+
Returns: Json
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
Enums: {
|
|
29
|
+
[_ in never]: never
|
|
30
|
+
}
|
|
31
|
+
CompositeTypes: {
|
|
32
|
+
[_ in never]: never
|
|
33
|
+
}
|
|
34
|
+
}
|
|
10
35
|
public: {
|
|
11
36
|
Tables: {
|
|
12
37
|
apikeys: {
|
|
@@ -44,78 +69,12 @@ export interface Database {
|
|
|
44
69
|
},
|
|
45
70
|
]
|
|
46
71
|
}
|
|
47
|
-
app_stats: {
|
|
48
|
-
Row: {
|
|
49
|
-
app_id: string
|
|
50
|
-
bandwidth: number
|
|
51
|
-
channels: number
|
|
52
|
-
created_at: string | null
|
|
53
|
-
date_id: string
|
|
54
|
-
devices: number
|
|
55
|
-
devices_real: number
|
|
56
|
-
mlu: number
|
|
57
|
-
mlu_real: number
|
|
58
|
-
shared: number
|
|
59
|
-
updated_at: string | null
|
|
60
|
-
user_id: string
|
|
61
|
-
version_size: number
|
|
62
|
-
versions: number
|
|
63
|
-
}
|
|
64
|
-
Insert: {
|
|
65
|
-
app_id: string
|
|
66
|
-
bandwidth?: number
|
|
67
|
-
channels?: number
|
|
68
|
-
created_at?: string | null
|
|
69
|
-
date_id?: string
|
|
70
|
-
devices?: number
|
|
71
|
-
devices_real?: number
|
|
72
|
-
mlu?: number
|
|
73
|
-
mlu_real?: number
|
|
74
|
-
shared?: number
|
|
75
|
-
updated_at?: string | null
|
|
76
|
-
user_id: string
|
|
77
|
-
version_size?: number
|
|
78
|
-
versions?: number
|
|
79
|
-
}
|
|
80
|
-
Update: {
|
|
81
|
-
app_id?: string
|
|
82
|
-
bandwidth?: number
|
|
83
|
-
channels?: number
|
|
84
|
-
created_at?: string | null
|
|
85
|
-
date_id?: string
|
|
86
|
-
devices?: number
|
|
87
|
-
devices_real?: number
|
|
88
|
-
mlu?: number
|
|
89
|
-
mlu_real?: number
|
|
90
|
-
shared?: number
|
|
91
|
-
updated_at?: string | null
|
|
92
|
-
user_id?: string
|
|
93
|
-
version_size?: number
|
|
94
|
-
versions?: number
|
|
95
|
-
}
|
|
96
|
-
Relationships: [
|
|
97
|
-
{
|
|
98
|
-
foreignKeyName: 'app_stats_app_id_fkey'
|
|
99
|
-
columns: ['app_id']
|
|
100
|
-
isOneToOne: false
|
|
101
|
-
referencedRelation: 'apps'
|
|
102
|
-
referencedColumns: ['app_id']
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
foreignKeyName: 'app_stats_user_id_fkey'
|
|
106
|
-
columns: ['user_id']
|
|
107
|
-
isOneToOne: false
|
|
108
|
-
referencedRelation: 'users'
|
|
109
|
-
referencedColumns: ['id']
|
|
110
|
-
},
|
|
111
|
-
]
|
|
112
|
-
}
|
|
113
72
|
app_usage: {
|
|
114
73
|
Row: {
|
|
115
74
|
app_id: string
|
|
116
75
|
bandwidth: number
|
|
117
76
|
date: string | null
|
|
118
|
-
|
|
77
|
+
fail: number
|
|
119
78
|
get: number
|
|
120
79
|
id: string
|
|
121
80
|
install: number
|
|
@@ -128,7 +87,7 @@ export interface Database {
|
|
|
128
87
|
app_id: string
|
|
129
88
|
bandwidth?: number
|
|
130
89
|
date?: string | null
|
|
131
|
-
|
|
90
|
+
fail?: number
|
|
132
91
|
get?: number
|
|
133
92
|
id?: string
|
|
134
93
|
install?: number
|
|
@@ -141,7 +100,7 @@ export interface Database {
|
|
|
141
100
|
app_id?: string
|
|
142
101
|
bandwidth?: number
|
|
143
102
|
date?: string | null
|
|
144
|
-
|
|
103
|
+
fail?: number
|
|
145
104
|
get?: number
|
|
146
105
|
id?: string
|
|
147
106
|
install?: number
|
|
@@ -293,11 +252,12 @@ export interface Database {
|
|
|
293
252
|
app_id: string
|
|
294
253
|
created_at: string | null
|
|
295
254
|
icon_url: string
|
|
296
|
-
id:
|
|
255
|
+
id: number
|
|
297
256
|
last_version: string | null
|
|
298
257
|
name: string | null
|
|
299
258
|
owner_org: string
|
|
300
259
|
retention: number
|
|
260
|
+
tmp_id: string | null
|
|
301
261
|
updated_at: string | null
|
|
302
262
|
user_id: string | null
|
|
303
263
|
}
|
|
@@ -305,11 +265,12 @@ export interface Database {
|
|
|
305
265
|
app_id: string
|
|
306
266
|
created_at?: string | null
|
|
307
267
|
icon_url: string
|
|
308
|
-
id?:
|
|
268
|
+
id?: number
|
|
309
269
|
last_version?: string | null
|
|
310
270
|
name?: string | null
|
|
311
271
|
owner_org: string
|
|
312
272
|
retention?: number
|
|
273
|
+
tmp_id?: string | null
|
|
313
274
|
updated_at?: string | null
|
|
314
275
|
user_id?: string | null
|
|
315
276
|
}
|
|
@@ -317,11 +278,12 @@ export interface Database {
|
|
|
317
278
|
app_id?: string
|
|
318
279
|
created_at?: string | null
|
|
319
280
|
icon_url?: string
|
|
320
|
-
id?:
|
|
281
|
+
id?: number
|
|
321
282
|
last_version?: string | null
|
|
322
283
|
name?: string | null
|
|
323
284
|
owner_org?: string
|
|
324
285
|
retention?: number
|
|
286
|
+
tmp_id?: string | null
|
|
325
287
|
updated_at?: string | null
|
|
326
288
|
user_id?: string | null
|
|
327
289
|
}
|
|
@@ -342,18 +304,6 @@ export interface Database {
|
|
|
342
304
|
},
|
|
343
305
|
]
|
|
344
306
|
}
|
|
345
|
-
auth_uid: {
|
|
346
|
-
Row: {
|
|
347
|
-
uid: string | null
|
|
348
|
-
}
|
|
349
|
-
Insert: {
|
|
350
|
-
uid?: string | null
|
|
351
|
-
}
|
|
352
|
-
Update: {
|
|
353
|
-
uid?: string | null
|
|
354
|
-
}
|
|
355
|
-
Relationships: []
|
|
356
|
-
}
|
|
357
307
|
channel_devices: {
|
|
358
308
|
Row: {
|
|
359
309
|
app_id: string
|
|
@@ -507,183 +457,6 @@ export interface Database {
|
|
|
507
457
|
},
|
|
508
458
|
]
|
|
509
459
|
}
|
|
510
|
-
clickhouse_app_usage: {
|
|
511
|
-
Row: {
|
|
512
|
-
app_id: string | null
|
|
513
|
-
bandwidth: number | null
|
|
514
|
-
date: string | null
|
|
515
|
-
fail: number | null
|
|
516
|
-
get: number | null
|
|
517
|
-
install: number | null
|
|
518
|
-
mau: number | null
|
|
519
|
-
storage_added: number | null
|
|
520
|
-
storage_deleted: number | null
|
|
521
|
-
uninstall: number | null
|
|
522
|
-
}
|
|
523
|
-
Insert: {
|
|
524
|
-
app_id?: string | null
|
|
525
|
-
bandwidth?: number | null
|
|
526
|
-
date?: string | null
|
|
527
|
-
fail?: number | null
|
|
528
|
-
get?: number | null
|
|
529
|
-
install?: number | null
|
|
530
|
-
mau?: number | null
|
|
531
|
-
storage_added?: number | null
|
|
532
|
-
storage_deleted?: number | null
|
|
533
|
-
uninstall?: number | null
|
|
534
|
-
}
|
|
535
|
-
Update: {
|
|
536
|
-
app_id?: string | null
|
|
537
|
-
bandwidth?: number | null
|
|
538
|
-
date?: string | null
|
|
539
|
-
fail?: number | null
|
|
540
|
-
get?: number | null
|
|
541
|
-
install?: number | null
|
|
542
|
-
mau?: number | null
|
|
543
|
-
storage_added?: number | null
|
|
544
|
-
storage_deleted?: number | null
|
|
545
|
-
uninstall?: number | null
|
|
546
|
-
}
|
|
547
|
-
Relationships: []
|
|
548
|
-
}
|
|
549
|
-
clickhouse_app_usage_parm: {
|
|
550
|
-
Row: {
|
|
551
|
-
_app_list: string | null
|
|
552
|
-
_end_date: string | null
|
|
553
|
-
_start_date: string | null
|
|
554
|
-
app_id: string | null
|
|
555
|
-
bandwidth: number | null
|
|
556
|
-
date: string | null
|
|
557
|
-
fail: number | null
|
|
558
|
-
get: number | null
|
|
559
|
-
install: number | null
|
|
560
|
-
mau: number | null
|
|
561
|
-
storage_added: number | null
|
|
562
|
-
storage_deleted: number | null
|
|
563
|
-
uninstall: number | null
|
|
564
|
-
}
|
|
565
|
-
Insert: {
|
|
566
|
-
_app_list?: string | null
|
|
567
|
-
_end_date?: string | null
|
|
568
|
-
_start_date?: string | null
|
|
569
|
-
app_id?: string | null
|
|
570
|
-
bandwidth?: number | null
|
|
571
|
-
date?: string | null
|
|
572
|
-
fail?: number | null
|
|
573
|
-
get?: number | null
|
|
574
|
-
install?: number | null
|
|
575
|
-
mau?: number | null
|
|
576
|
-
storage_added?: number | null
|
|
577
|
-
storage_deleted?: number | null
|
|
578
|
-
uninstall?: number | null
|
|
579
|
-
}
|
|
580
|
-
Update: {
|
|
581
|
-
_app_list?: string | null
|
|
582
|
-
_end_date?: string | null
|
|
583
|
-
_start_date?: string | null
|
|
584
|
-
app_id?: string | null
|
|
585
|
-
bandwidth?: number | null
|
|
586
|
-
date?: string | null
|
|
587
|
-
fail?: number | null
|
|
588
|
-
get?: number | null
|
|
589
|
-
install?: number | null
|
|
590
|
-
mau?: number | null
|
|
591
|
-
storage_added?: number | null
|
|
592
|
-
storage_deleted?: number | null
|
|
593
|
-
uninstall?: number | null
|
|
594
|
-
}
|
|
595
|
-
Relationships: []
|
|
596
|
-
}
|
|
597
|
-
clickhouse_devices: {
|
|
598
|
-
Row: {
|
|
599
|
-
app_id: string | null
|
|
600
|
-
created_at: string | null
|
|
601
|
-
custom_id: string | null
|
|
602
|
-
device_id: string | null
|
|
603
|
-
is_emulator: boolean | null
|
|
604
|
-
is_prod: boolean | null
|
|
605
|
-
os_version: string | null
|
|
606
|
-
platform: string | null
|
|
607
|
-
plugin_version: string | null
|
|
608
|
-
updated_at: string | null
|
|
609
|
-
version: number | null
|
|
610
|
-
version_build: string | null
|
|
611
|
-
}
|
|
612
|
-
Insert: {
|
|
613
|
-
app_id?: string | null
|
|
614
|
-
created_at?: string | null
|
|
615
|
-
custom_id?: string | null
|
|
616
|
-
device_id?: string | null
|
|
617
|
-
is_emulator?: boolean | null
|
|
618
|
-
is_prod?: boolean | null
|
|
619
|
-
os_version?: string | null
|
|
620
|
-
platform?: string | null
|
|
621
|
-
plugin_version?: string | null
|
|
622
|
-
updated_at?: string | null
|
|
623
|
-
version?: number | null
|
|
624
|
-
version_build?: string | null
|
|
625
|
-
}
|
|
626
|
-
Update: {
|
|
627
|
-
app_id?: string | null
|
|
628
|
-
created_at?: string | null
|
|
629
|
-
custom_id?: string | null
|
|
630
|
-
device_id?: string | null
|
|
631
|
-
is_emulator?: boolean | null
|
|
632
|
-
is_prod?: boolean | null
|
|
633
|
-
os_version?: string | null
|
|
634
|
-
platform?: string | null
|
|
635
|
-
plugin_version?: string | null
|
|
636
|
-
updated_at?: string | null
|
|
637
|
-
version?: number | null
|
|
638
|
-
version_build?: string | null
|
|
639
|
-
}
|
|
640
|
-
Relationships: []
|
|
641
|
-
}
|
|
642
|
-
clickhouse_logs: {
|
|
643
|
-
Row: {
|
|
644
|
-
action: string | null
|
|
645
|
-
app_id: string | null
|
|
646
|
-
created_at: string | null
|
|
647
|
-
device_id: string | null
|
|
648
|
-
platform: string | null
|
|
649
|
-
version: number | null
|
|
650
|
-
version_build: string | null
|
|
651
|
-
}
|
|
652
|
-
Insert: {
|
|
653
|
-
action?: string | null
|
|
654
|
-
app_id?: string | null
|
|
655
|
-
created_at?: string | null
|
|
656
|
-
device_id?: string | null
|
|
657
|
-
platform?: string | null
|
|
658
|
-
version?: number | null
|
|
659
|
-
version_build?: string | null
|
|
660
|
-
}
|
|
661
|
-
Update: {
|
|
662
|
-
action?: string | null
|
|
663
|
-
app_id?: string | null
|
|
664
|
-
created_at?: string | null
|
|
665
|
-
device_id?: string | null
|
|
666
|
-
platform?: string | null
|
|
667
|
-
version?: number | null
|
|
668
|
-
version_build?: string | null
|
|
669
|
-
}
|
|
670
|
-
Relationships: []
|
|
671
|
-
}
|
|
672
|
-
cycle_info: {
|
|
673
|
-
Row: {
|
|
674
|
-
subscription_anchor_end: string | null
|
|
675
|
-
subscription_anchor_start: string | null
|
|
676
|
-
}
|
|
677
|
-
Insert: {
|
|
678
|
-
subscription_anchor_end?: string | null
|
|
679
|
-
subscription_anchor_start?: string | null
|
|
680
|
-
}
|
|
681
|
-
Update: {
|
|
682
|
-
subscription_anchor_end?: string | null
|
|
683
|
-
subscription_anchor_start?: string | null
|
|
684
|
-
}
|
|
685
|
-
Relationships: []
|
|
686
|
-
}
|
|
687
460
|
deleted_account: {
|
|
688
461
|
Row: {
|
|
689
462
|
created_at: string | null
|
|
@@ -692,7 +465,7 @@ export interface Database {
|
|
|
692
465
|
}
|
|
693
466
|
Insert: {
|
|
694
467
|
created_at?: string | null
|
|
695
|
-
email
|
|
468
|
+
email: string
|
|
696
469
|
id?: string
|
|
697
470
|
}
|
|
698
471
|
Update: {
|
|
@@ -990,24 +763,30 @@ export interface Database {
|
|
|
990
763
|
Row: {
|
|
991
764
|
created_at: string | null
|
|
992
765
|
created_by: string
|
|
766
|
+
customer_id: string | null
|
|
993
767
|
id: string
|
|
994
768
|
logo: string | null
|
|
769
|
+
management_email: string
|
|
995
770
|
name: string
|
|
996
771
|
updated_at: string | null
|
|
997
772
|
}
|
|
998
773
|
Insert: {
|
|
999
774
|
created_at?: string | null
|
|
1000
775
|
created_by: string
|
|
776
|
+
customer_id?: string | null
|
|
1001
777
|
id?: string
|
|
1002
778
|
logo?: string | null
|
|
779
|
+
management_email: string
|
|
1003
780
|
name: string
|
|
1004
781
|
updated_at?: string | null
|
|
1005
782
|
}
|
|
1006
783
|
Update: {
|
|
1007
784
|
created_at?: string | null
|
|
1008
785
|
created_by?: string
|
|
786
|
+
customer_id?: string | null
|
|
1009
787
|
id?: string
|
|
1010
788
|
logo?: string | null
|
|
789
|
+
management_email?: string
|
|
1011
790
|
name?: string
|
|
1012
791
|
updated_at?: string | null
|
|
1013
792
|
}
|
|
@@ -1019,12 +798,22 @@ export interface Database {
|
|
|
1019
798
|
referencedRelation: 'users'
|
|
1020
799
|
referencedColumns: ['id']
|
|
1021
800
|
},
|
|
801
|
+
{
|
|
802
|
+
foreignKeyName: 'orgs_customer_id_fkey'
|
|
803
|
+
columns: ['customer_id']
|
|
804
|
+
isOneToOne: true
|
|
805
|
+
referencedRelation: 'stripe_info'
|
|
806
|
+
referencedColumns: ['customer_id']
|
|
807
|
+
},
|
|
1022
808
|
]
|
|
1023
809
|
}
|
|
1024
810
|
plans: {
|
|
1025
811
|
Row: {
|
|
812
|
+
abtest: boolean
|
|
813
|
+
app: number
|
|
1026
814
|
bandwidth: number
|
|
1027
815
|
bandwidth_unit: number | null
|
|
816
|
+
channel: number
|
|
1028
817
|
created_at: string
|
|
1029
818
|
description: string
|
|
1030
819
|
id: string
|
|
@@ -1039,14 +828,21 @@ export interface Database {
|
|
|
1039
828
|
price_m_storage_id: string | null
|
|
1040
829
|
price_y: number
|
|
1041
830
|
price_y_id: string
|
|
831
|
+
progressive_deploy: boolean
|
|
832
|
+
shared: number
|
|
1042
833
|
storage: number
|
|
1043
834
|
storage_unit: number | null
|
|
1044
835
|
stripe_id: string
|
|
836
|
+
update: number
|
|
1045
837
|
updated_at: string
|
|
838
|
+
version: number
|
|
1046
839
|
}
|
|
1047
840
|
Insert: {
|
|
841
|
+
abtest?: boolean
|
|
842
|
+
app?: number
|
|
1048
843
|
bandwidth: number
|
|
1049
844
|
bandwidth_unit?: number | null
|
|
845
|
+
channel?: number
|
|
1050
846
|
created_at?: string
|
|
1051
847
|
description?: string
|
|
1052
848
|
id?: string
|
|
@@ -1061,14 +857,21 @@ export interface Database {
|
|
|
1061
857
|
price_m_storage_id?: string | null
|
|
1062
858
|
price_y?: number
|
|
1063
859
|
price_y_id: string
|
|
860
|
+
progressive_deploy?: boolean
|
|
861
|
+
shared?: number
|
|
1064
862
|
storage: number
|
|
1065
863
|
storage_unit?: number | null
|
|
1066
864
|
stripe_id?: string
|
|
865
|
+
update?: number
|
|
1067
866
|
updated_at?: string
|
|
867
|
+
version?: number
|
|
1068
868
|
}
|
|
1069
869
|
Update: {
|
|
870
|
+
abtest?: boolean
|
|
871
|
+
app?: number
|
|
1070
872
|
bandwidth?: number
|
|
1071
873
|
bandwidth_unit?: number | null
|
|
874
|
+
channel?: number
|
|
1072
875
|
created_at?: string
|
|
1073
876
|
description?: string
|
|
1074
877
|
id?: string
|
|
@@ -1083,10 +886,14 @@ export interface Database {
|
|
|
1083
886
|
price_m_storage_id?: string | null
|
|
1084
887
|
price_y?: number
|
|
1085
888
|
price_y_id?: string
|
|
889
|
+
progressive_deploy?: boolean
|
|
890
|
+
shared?: number
|
|
1086
891
|
storage?: number
|
|
1087
892
|
storage_unit?: number | null
|
|
1088
893
|
stripe_id?: string
|
|
894
|
+
update?: number
|
|
1089
895
|
updated_at?: string
|
|
896
|
+
version?: number
|
|
1090
897
|
}
|
|
1091
898
|
Relationships: []
|
|
1092
899
|
}
|
|
@@ -1265,14 +1072,6 @@ export interface Database {
|
|
|
1265
1072
|
}
|
|
1266
1073
|
Returns: string
|
|
1267
1074
|
}
|
|
1268
|
-
calculate_cycle_usage: {
|
|
1269
|
-
Args: Record<PropertyKey, never>
|
|
1270
|
-
Returns: undefined
|
|
1271
|
-
}
|
|
1272
|
-
calculate_daily_app_usage: {
|
|
1273
|
-
Args: Record<PropertyKey, never>
|
|
1274
|
-
Returns: undefined
|
|
1275
|
-
}
|
|
1276
1075
|
check_min_rights:
|
|
1277
1076
|
| {
|
|
1278
1077
|
Args: {
|
|
@@ -1338,10 +1137,6 @@ export interface Database {
|
|
|
1338
1137
|
Args: Record<PropertyKey, never>
|
|
1339
1138
|
Returns: number
|
|
1340
1139
|
}
|
|
1341
|
-
count_all_paying: {
|
|
1342
|
-
Args: Record<PropertyKey, never>
|
|
1343
|
-
Returns: number
|
|
1344
|
-
}
|
|
1345
1140
|
count_all_plans: {
|
|
1346
1141
|
Args: Record<PropertyKey, never>
|
|
1347
1142
|
Returns: {
|
|
@@ -1360,13 +1155,6 @@ export interface Database {
|
|
|
1360
1155
|
Args: Record<PropertyKey, never>
|
|
1361
1156
|
Returns: number
|
|
1362
1157
|
}
|
|
1363
|
-
create_partitions: {
|
|
1364
|
-
Args: {
|
|
1365
|
-
start_date: string
|
|
1366
|
-
num_years: number
|
|
1367
|
-
}
|
|
1368
|
-
Returns: undefined
|
|
1369
|
-
}
|
|
1370
1158
|
delete_user: {
|
|
1371
1159
|
Args: Record<PropertyKey, never>
|
|
1372
1160
|
Returns: undefined
|
|
@@ -1436,6 +1224,16 @@ export interface Database {
|
|
|
1436
1224
|
storage: number
|
|
1437
1225
|
}[]
|
|
1438
1226
|
}
|
|
1227
|
+
get_current_plan_max_org: {
|
|
1228
|
+
Args: {
|
|
1229
|
+
orgid: string
|
|
1230
|
+
}
|
|
1231
|
+
Returns: {
|
|
1232
|
+
mau: number
|
|
1233
|
+
bandwidth: number
|
|
1234
|
+
storage: number
|
|
1235
|
+
}[]
|
|
1236
|
+
}
|
|
1439
1237
|
get_current_plan_name:
|
|
1440
1238
|
| {
|
|
1441
1239
|
Args: Record<PropertyKey, never>
|
|
@@ -1447,6 +1245,12 @@ export interface Database {
|
|
|
1447
1245
|
}
|
|
1448
1246
|
Returns: string
|
|
1449
1247
|
}
|
|
1248
|
+
get_current_plan_name_org: {
|
|
1249
|
+
Args: {
|
|
1250
|
+
orgid: string
|
|
1251
|
+
}
|
|
1252
|
+
Returns: string
|
|
1253
|
+
}
|
|
1450
1254
|
get_customer_counts: {
|
|
1451
1255
|
Args: Record<PropertyKey, never>
|
|
1452
1256
|
Returns: {
|
|
@@ -1455,23 +1259,24 @@ export interface Database {
|
|
|
1455
1259
|
total: number
|
|
1456
1260
|
}[]
|
|
1457
1261
|
}
|
|
1458
|
-
get_cycle_info:
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
Returns: {
|
|
1462
|
-
subscription_anchor_start: string
|
|
1463
|
-
subscription_anchor_end: string
|
|
1464
|
-
}[]
|
|
1262
|
+
get_cycle_info: {
|
|
1263
|
+
Args: {
|
|
1264
|
+
userid: string
|
|
1465
1265
|
}
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1266
|
+
Returns: {
|
|
1267
|
+
subscription_anchor_start: string
|
|
1268
|
+
subscription_anchor_end: string
|
|
1269
|
+
}[]
|
|
1270
|
+
}
|
|
1271
|
+
get_cycle_info_org: {
|
|
1272
|
+
Args: {
|
|
1273
|
+
orgid: string
|
|
1474
1274
|
}
|
|
1275
|
+
Returns: {
|
|
1276
|
+
subscription_anchor_start: string
|
|
1277
|
+
subscription_anchor_end: string
|
|
1278
|
+
}[]
|
|
1279
|
+
}
|
|
1475
1280
|
get_db_url: {
|
|
1476
1281
|
Args: Record<PropertyKey, never>
|
|
1477
1282
|
Returns: string
|
|
@@ -1504,25 +1309,13 @@ export interface Database {
|
|
|
1504
1309
|
}
|
|
1505
1310
|
Returns: string
|
|
1506
1311
|
}
|
|
1507
|
-
get_infos: {
|
|
1508
|
-
Args: {
|
|
1509
|
-
appid: string
|
|
1510
|
-
deviceid: string
|
|
1511
|
-
versionname: string
|
|
1512
|
-
}
|
|
1513
|
-
Returns: {
|
|
1514
|
-
current_version_id: number
|
|
1515
|
-
versiondata: Json
|
|
1516
|
-
channel: Json
|
|
1517
|
-
}[]
|
|
1518
|
-
}
|
|
1519
1312
|
get_max_plan:
|
|
1520
1313
|
| {
|
|
1521
1314
|
Args: Record<PropertyKey, never>
|
|
1522
1315
|
Returns: {
|
|
1523
1316
|
mau: number
|
|
1524
|
-
bandwidth: number
|
|
1525
1317
|
storage: number
|
|
1318
|
+
bandwidth: number
|
|
1526
1319
|
}[]
|
|
1527
1320
|
}
|
|
1528
1321
|
| {
|
|
@@ -1630,9 +1423,59 @@ export interface Database {
|
|
|
1630
1423
|
subscription_end: string
|
|
1631
1424
|
}[]
|
|
1632
1425
|
}
|
|
1633
|
-
|
|
1426
|
+
get_orgs_v5:
|
|
1427
|
+
| {
|
|
1428
|
+
Args: Record<PropertyKey, never>
|
|
1429
|
+
Returns: {
|
|
1430
|
+
gid: string
|
|
1431
|
+
created_by: string
|
|
1432
|
+
logo: string
|
|
1433
|
+
name: string
|
|
1434
|
+
role: string
|
|
1435
|
+
paying: boolean
|
|
1436
|
+
trial_left: number
|
|
1437
|
+
can_use_more: boolean
|
|
1438
|
+
is_canceled: boolean
|
|
1439
|
+
app_count: number
|
|
1440
|
+
subscription_start: string
|
|
1441
|
+
subscription_end: string
|
|
1442
|
+
management_email: string
|
|
1443
|
+
}[]
|
|
1444
|
+
}
|
|
1445
|
+
| {
|
|
1446
|
+
Args: {
|
|
1447
|
+
userid: string
|
|
1448
|
+
}
|
|
1449
|
+
Returns: {
|
|
1450
|
+
gid: string
|
|
1451
|
+
created_by: string
|
|
1452
|
+
logo: string
|
|
1453
|
+
name: string
|
|
1454
|
+
role: string
|
|
1455
|
+
paying: boolean
|
|
1456
|
+
trial_left: number
|
|
1457
|
+
can_use_more: boolean
|
|
1458
|
+
is_canceled: boolean
|
|
1459
|
+
app_count: number
|
|
1460
|
+
subscription_start: string
|
|
1461
|
+
subscription_end: string
|
|
1462
|
+
management_email: string
|
|
1463
|
+
}[]
|
|
1464
|
+
}
|
|
1465
|
+
get_plan_usage_percent:
|
|
1466
|
+
| {
|
|
1467
|
+
Args: Record<PropertyKey, never>
|
|
1468
|
+
Returns: number
|
|
1469
|
+
}
|
|
1470
|
+
| {
|
|
1471
|
+
Args: {
|
|
1472
|
+
userid: string
|
|
1473
|
+
}
|
|
1474
|
+
Returns: number
|
|
1475
|
+
}
|
|
1476
|
+
get_plan_usage_percent_org: {
|
|
1634
1477
|
Args: {
|
|
1635
|
-
|
|
1478
|
+
orgid: string
|
|
1636
1479
|
}
|
|
1637
1480
|
Returns: number
|
|
1638
1481
|
}
|
|
@@ -1667,27 +1510,24 @@ export interface Database {
|
|
|
1667
1510
|
storage: number
|
|
1668
1511
|
}[]
|
|
1669
1512
|
}
|
|
1513
|
+
get_total_stats_v5_org: {
|
|
1514
|
+
Args: {
|
|
1515
|
+
orgid: string
|
|
1516
|
+
}
|
|
1517
|
+
Returns: {
|
|
1518
|
+
mau: number
|
|
1519
|
+
bandwidth: number
|
|
1520
|
+
storage: number
|
|
1521
|
+
}[]
|
|
1522
|
+
}
|
|
1670
1523
|
get_total_storage_size:
|
|
1671
1524
|
| {
|
|
1672
1525
|
Args: Record<PropertyKey, never>
|
|
1673
1526
|
Returns: number
|
|
1674
1527
|
}
|
|
1675
|
-
| {
|
|
1676
|
-
Args: {
|
|
1677
|
-
appid: string
|
|
1678
|
-
}
|
|
1679
|
-
Returns: number
|
|
1680
|
-
}
|
|
1681
|
-
| {
|
|
1682
|
-
Args: {
|
|
1683
|
-
userid: string
|
|
1684
|
-
}
|
|
1685
|
-
Returns: number
|
|
1686
|
-
}
|
|
1687
1528
|
| {
|
|
1688
1529
|
Args: {
|
|
1689
1530
|
userid: string
|
|
1690
|
-
appid: string
|
|
1691
1531
|
}
|
|
1692
1532
|
Returns: number
|
|
1693
1533
|
}
|
|
@@ -1812,6 +1652,12 @@ export interface Database {
|
|
|
1812
1652
|
}
|
|
1813
1653
|
Returns: boolean
|
|
1814
1654
|
}
|
|
1655
|
+
is_allowed_action_org: {
|
|
1656
|
+
Args: {
|
|
1657
|
+
orgid: string
|
|
1658
|
+
}
|
|
1659
|
+
Returns: boolean
|
|
1660
|
+
}
|
|
1815
1661
|
is_allowed_action_user:
|
|
1816
1662
|
| {
|
|
1817
1663
|
Args: Record<PropertyKey, never>
|
|
@@ -1892,6 +1738,12 @@ export interface Database {
|
|
|
1892
1738
|
}
|
|
1893
1739
|
Returns: boolean
|
|
1894
1740
|
}
|
|
1741
|
+
is_canceled_org: {
|
|
1742
|
+
Args: {
|
|
1743
|
+
orgid: string
|
|
1744
|
+
}
|
|
1745
|
+
Returns: boolean
|
|
1746
|
+
}
|
|
1895
1747
|
is_free_usage:
|
|
1896
1748
|
| {
|
|
1897
1749
|
Args: Record<PropertyKey, never>
|
|
@@ -1903,12 +1755,6 @@ export interface Database {
|
|
|
1903
1755
|
}
|
|
1904
1756
|
Returns: boolean
|
|
1905
1757
|
}
|
|
1906
|
-
is_good_plan_v3: {
|
|
1907
|
-
Args: {
|
|
1908
|
-
userid: string
|
|
1909
|
-
}
|
|
1910
|
-
Returns: boolean
|
|
1911
|
-
}
|
|
1912
1758
|
is_good_plan_v5: {
|
|
1913
1759
|
Args: {
|
|
1914
1760
|
userid: string
|
|
@@ -1979,6 +1825,18 @@ export interface Database {
|
|
|
1979
1825
|
}
|
|
1980
1826
|
Returns: boolean
|
|
1981
1827
|
}
|
|
1828
|
+
is_paying_and_good_plan_org: {
|
|
1829
|
+
Args: {
|
|
1830
|
+
orgid: string
|
|
1831
|
+
}
|
|
1832
|
+
Returns: boolean
|
|
1833
|
+
}
|
|
1834
|
+
is_paying_org: {
|
|
1835
|
+
Args: {
|
|
1836
|
+
orgid: string
|
|
1837
|
+
}
|
|
1838
|
+
Returns: boolean
|
|
1839
|
+
}
|
|
1982
1840
|
is_trial:
|
|
1983
1841
|
| {
|
|
1984
1842
|
Args: Record<PropertyKey, never>
|
|
@@ -1990,24 +1848,16 @@ export interface Database {
|
|
|
1990
1848
|
}
|
|
1991
1849
|
Returns: number
|
|
1992
1850
|
}
|
|
1851
|
+
is_trial_org: {
|
|
1852
|
+
Args: {
|
|
1853
|
+
orgid: string
|
|
1854
|
+
}
|
|
1855
|
+
Returns: number
|
|
1856
|
+
}
|
|
1993
1857
|
one_month_ahead: {
|
|
1994
1858
|
Args: Record<PropertyKey, never>
|
|
1995
1859
|
Returns: string
|
|
1996
1860
|
}
|
|
1997
|
-
post_replication_sql:
|
|
1998
|
-
| {
|
|
1999
|
-
Args: {
|
|
2000
|
-
sql_query: string
|
|
2001
|
-
}
|
|
2002
|
-
Returns: undefined
|
|
2003
|
-
}
|
|
2004
|
-
| {
|
|
2005
|
-
Args: {
|
|
2006
|
-
sql_query: string
|
|
2007
|
-
params: string[]
|
|
2008
|
-
}
|
|
2009
|
-
Returns: undefined
|
|
2010
|
-
}
|
|
2011
1861
|
process_current_jobs_if_unlocked: {
|
|
2012
1862
|
Args: Record<PropertyKey, never>
|
|
2013
1863
|
Returns: number[]
|
|
@@ -2016,6 +1866,13 @@ export interface Database {
|
|
|
2016
1866
|
Args: Record<PropertyKey, never>
|
|
2017
1867
|
Returns: undefined
|
|
2018
1868
|
}
|
|
1869
|
+
remove_enum_value: {
|
|
1870
|
+
Args: {
|
|
1871
|
+
enum_type: unknown
|
|
1872
|
+
enum_value: string
|
|
1873
|
+
}
|
|
1874
|
+
Returns: undefined
|
|
1875
|
+
}
|
|
2019
1876
|
reset_and_seed_data: {
|
|
2020
1877
|
Args: Record<PropertyKey, never>
|
|
2021
1878
|
Returns: undefined
|
|
@@ -2028,27 +1885,14 @@ export interface Database {
|
|
|
2028
1885
|
Args: Record<PropertyKey, never>
|
|
2029
1886
|
Returns: undefined
|
|
2030
1887
|
}
|
|
2031
|
-
update_app_usage:
|
|
2032
|
-
| {
|
|
2033
|
-
Args: Record<PropertyKey, never>
|
|
2034
|
-
Returns: undefined
|
|
2035
|
-
}
|
|
2036
|
-
| {
|
|
2037
|
-
Args: {
|
|
2038
|
-
minutes_interval: number
|
|
2039
|
-
}
|
|
2040
|
-
Returns: undefined
|
|
2041
|
-
}
|
|
2042
1888
|
verify_mfa: {
|
|
2043
1889
|
Args: Record<PropertyKey, never>
|
|
2044
1890
|
Returns: boolean
|
|
2045
1891
|
}
|
|
2046
1892
|
}
|
|
2047
1893
|
Enums: {
|
|
2048
|
-
app_mode: 'prod' | 'dev' | 'livereload'
|
|
2049
1894
|
disable_update: 'major' | 'minor' | 'version_number' | 'none'
|
|
2050
1895
|
key_mode: 'read' | 'write' | 'all' | 'upload'
|
|
2051
|
-
pay_as_you_go_type: 'base' | 'units'
|
|
2052
1896
|
platform_os: 'ios' | 'android'
|
|
2053
1897
|
queue_job_status: 'inserted' | 'requested' | 'failed'
|
|
2054
1898
|
stripe_status:
|
|
@@ -2058,7 +1902,7 @@ export interface Database {
|
|
|
2058
1902
|
| 'failed'
|
|
2059
1903
|
| 'deleted'
|
|
2060
1904
|
| 'canceled'
|
|
2061
|
-
usage_mode: '
|
|
1905
|
+
usage_mode: 'last_saved' | '5min' | 'day' | 'cycle'
|
|
2062
1906
|
user_min_right:
|
|
2063
1907
|
| 'invite_read'
|
|
2064
1908
|
| 'invite_upload'
|
|
@@ -2073,9 +1917,6 @@ export interface Database {
|
|
|
2073
1917
|
user_role: 'read' | 'upload' | 'write' | 'admin'
|
|
2074
1918
|
}
|
|
2075
1919
|
CompositeTypes: {
|
|
2076
|
-
match_plan: {
|
|
2077
|
-
name: string | null
|
|
2078
|
-
}
|
|
2079
1920
|
orgs_table: {
|
|
2080
1921
|
id: string | null
|
|
2081
1922
|
created_by: string | null
|
|
@@ -2098,6 +1939,185 @@ export interface Database {
|
|
|
2098
1939
|
}
|
|
2099
1940
|
}
|
|
2100
1941
|
}
|
|
1942
|
+
storage: {
|
|
1943
|
+
Tables: {
|
|
1944
|
+
buckets: {
|
|
1945
|
+
Row: {
|
|
1946
|
+
allowed_mime_types: string[] | null
|
|
1947
|
+
avif_autodetection: boolean | null
|
|
1948
|
+
created_at: string | null
|
|
1949
|
+
file_size_limit: number | null
|
|
1950
|
+
id: string
|
|
1951
|
+
name: string
|
|
1952
|
+
owner: string | null
|
|
1953
|
+
owner_id: string | null
|
|
1954
|
+
public: boolean | null
|
|
1955
|
+
updated_at: string | null
|
|
1956
|
+
}
|
|
1957
|
+
Insert: {
|
|
1958
|
+
allowed_mime_types?: string[] | null
|
|
1959
|
+
avif_autodetection?: boolean | null
|
|
1960
|
+
created_at?: string | null
|
|
1961
|
+
file_size_limit?: number | null
|
|
1962
|
+
id: string
|
|
1963
|
+
name: string
|
|
1964
|
+
owner?: string | null
|
|
1965
|
+
owner_id?: string | null
|
|
1966
|
+
public?: boolean | null
|
|
1967
|
+
updated_at?: string | null
|
|
1968
|
+
}
|
|
1969
|
+
Update: {
|
|
1970
|
+
allowed_mime_types?: string[] | null
|
|
1971
|
+
avif_autodetection?: boolean | null
|
|
1972
|
+
created_at?: string | null
|
|
1973
|
+
file_size_limit?: number | null
|
|
1974
|
+
id?: string
|
|
1975
|
+
name?: string
|
|
1976
|
+
owner?: string | null
|
|
1977
|
+
owner_id?: string | null
|
|
1978
|
+
public?: boolean | null
|
|
1979
|
+
updated_at?: string | null
|
|
1980
|
+
}
|
|
1981
|
+
Relationships: []
|
|
1982
|
+
}
|
|
1983
|
+
migrations: {
|
|
1984
|
+
Row: {
|
|
1985
|
+
executed_at: string | null
|
|
1986
|
+
hash: string
|
|
1987
|
+
id: number
|
|
1988
|
+
name: string
|
|
1989
|
+
}
|
|
1990
|
+
Insert: {
|
|
1991
|
+
executed_at?: string | null
|
|
1992
|
+
hash: string
|
|
1993
|
+
id: number
|
|
1994
|
+
name: string
|
|
1995
|
+
}
|
|
1996
|
+
Update: {
|
|
1997
|
+
executed_at?: string | null
|
|
1998
|
+
hash?: string
|
|
1999
|
+
id?: number
|
|
2000
|
+
name?: string
|
|
2001
|
+
}
|
|
2002
|
+
Relationships: []
|
|
2003
|
+
}
|
|
2004
|
+
objects: {
|
|
2005
|
+
Row: {
|
|
2006
|
+
bucket_id: string | null
|
|
2007
|
+
created_at: string | null
|
|
2008
|
+
id: string
|
|
2009
|
+
last_accessed_at: string | null
|
|
2010
|
+
metadata: Json | null
|
|
2011
|
+
name: string | null
|
|
2012
|
+
owner: string | null
|
|
2013
|
+
owner_id: string | null
|
|
2014
|
+
path_tokens: string[] | null
|
|
2015
|
+
updated_at: string | null
|
|
2016
|
+
version: string | null
|
|
2017
|
+
}
|
|
2018
|
+
Insert: {
|
|
2019
|
+
bucket_id?: string | null
|
|
2020
|
+
created_at?: string | null
|
|
2021
|
+
id?: string
|
|
2022
|
+
last_accessed_at?: string | null
|
|
2023
|
+
metadata?: Json | null
|
|
2024
|
+
name?: string | null
|
|
2025
|
+
owner?: string | null
|
|
2026
|
+
owner_id?: string | null
|
|
2027
|
+
path_tokens?: string[] | null
|
|
2028
|
+
updated_at?: string | null
|
|
2029
|
+
version?: string | null
|
|
2030
|
+
}
|
|
2031
|
+
Update: {
|
|
2032
|
+
bucket_id?: string | null
|
|
2033
|
+
created_at?: string | null
|
|
2034
|
+
id?: string
|
|
2035
|
+
last_accessed_at?: string | null
|
|
2036
|
+
metadata?: Json | null
|
|
2037
|
+
name?: string | null
|
|
2038
|
+
owner?: string | null
|
|
2039
|
+
owner_id?: string | null
|
|
2040
|
+
path_tokens?: string[] | null
|
|
2041
|
+
updated_at?: string | null
|
|
2042
|
+
version?: string | null
|
|
2043
|
+
}
|
|
2044
|
+
Relationships: [
|
|
2045
|
+
{
|
|
2046
|
+
foreignKeyName: 'objects_bucketId_fkey'
|
|
2047
|
+
columns: ['bucket_id']
|
|
2048
|
+
isOneToOne: false
|
|
2049
|
+
referencedRelation: 'buckets'
|
|
2050
|
+
referencedColumns: ['id']
|
|
2051
|
+
},
|
|
2052
|
+
]
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
Views: {
|
|
2056
|
+
[_ in never]: never
|
|
2057
|
+
}
|
|
2058
|
+
Functions: {
|
|
2059
|
+
can_insert_object: {
|
|
2060
|
+
Args: {
|
|
2061
|
+
bucketid: string
|
|
2062
|
+
name: string
|
|
2063
|
+
owner: string
|
|
2064
|
+
metadata: Json
|
|
2065
|
+
}
|
|
2066
|
+
Returns: undefined
|
|
2067
|
+
}
|
|
2068
|
+
extension: {
|
|
2069
|
+
Args: {
|
|
2070
|
+
name: string
|
|
2071
|
+
}
|
|
2072
|
+
Returns: string
|
|
2073
|
+
}
|
|
2074
|
+
filename: {
|
|
2075
|
+
Args: {
|
|
2076
|
+
name: string
|
|
2077
|
+
}
|
|
2078
|
+
Returns: string
|
|
2079
|
+
}
|
|
2080
|
+
foldername: {
|
|
2081
|
+
Args: {
|
|
2082
|
+
name: string
|
|
2083
|
+
}
|
|
2084
|
+
Returns: string[]
|
|
2085
|
+
}
|
|
2086
|
+
get_size_by_bucket: {
|
|
2087
|
+
Args: Record<PropertyKey, never>
|
|
2088
|
+
Returns: {
|
|
2089
|
+
size: number
|
|
2090
|
+
bucket_id: string
|
|
2091
|
+
}[]
|
|
2092
|
+
}
|
|
2093
|
+
search: {
|
|
2094
|
+
Args: {
|
|
2095
|
+
prefix: string
|
|
2096
|
+
bucketname: string
|
|
2097
|
+
limits?: number
|
|
2098
|
+
levels?: number
|
|
2099
|
+
offsets?: number
|
|
2100
|
+
search?: string
|
|
2101
|
+
sortcolumn?: string
|
|
2102
|
+
sortorder?: string
|
|
2103
|
+
}
|
|
2104
|
+
Returns: {
|
|
2105
|
+
name: string
|
|
2106
|
+
id: string
|
|
2107
|
+
updated_at: string
|
|
2108
|
+
created_at: string
|
|
2109
|
+
last_accessed_at: string
|
|
2110
|
+
metadata: Json
|
|
2111
|
+
}[]
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
Enums: {
|
|
2115
|
+
[_ in never]: never
|
|
2116
|
+
}
|
|
2117
|
+
CompositeTypes: {
|
|
2118
|
+
[_ in never]: never
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2101
2121
|
}
|
|
2102
2122
|
|
|
2103
2123
|
type PublicSchema = Database[Extract<keyof Database, 'public'>]
|
package/src/utils.ts
CHANGED
|
@@ -134,23 +134,23 @@ export async function isGoodPlan(supabase: SupabaseClient<Database>, userId: str
|
|
|
134
134
|
return data || false
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
export async function
|
|
137
|
+
export async function isPayingOrg(supabase: SupabaseClient<Database>, orgId: string): Promise<boolean> {
|
|
138
138
|
const { data } = await supabase
|
|
139
|
-
.rpc('
|
|
139
|
+
.rpc('is_paying_org', { orgid: orgId })
|
|
140
140
|
.single()
|
|
141
141
|
return data || false
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
export async function
|
|
144
|
+
export async function isTrialOrg(supabase: SupabaseClient<Database>, orgId: string): Promise<number> {
|
|
145
145
|
const { data } = await supabase
|
|
146
|
-
.rpc('
|
|
146
|
+
.rpc('is_trial_org', { orgid: orgId })
|
|
147
147
|
.single()
|
|
148
148
|
return data || 0
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
export async function
|
|
151
|
+
export async function isAllowedActionOrg(supabase: SupabaseClient<Database>, orgId: string): Promise<boolean> {
|
|
152
152
|
const { data } = await supabase
|
|
153
|
-
.rpc('
|
|
153
|
+
.rpc('is_allowed_action_org', { orgid: orgId })
|
|
154
154
|
.single()
|
|
155
155
|
return !!data
|
|
156
156
|
}
|
|
@@ -283,10 +283,11 @@ export async function isAllowedAppOrg(supabase: SupabaseClient<Database>, apikey
|
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
export async function checkPlanValid(supabase: SupabaseClient<Database>,
|
|
286
|
+
export async function checkPlanValid(supabase: SupabaseClient<Database>, orgId: string, apikey: string, appId?: string, warning = true) {
|
|
287
287
|
const config = await getRemoteConfig()
|
|
288
288
|
|
|
289
|
-
|
|
289
|
+
// isAllowedActionAppIdApiKey was updated in the orgs_v3 migration to work with the new system
|
|
290
|
+
const validPlan = await (appId ? isAllowedActionAppIdApiKey(supabase, appId, apikey) : isAllowedActionOrg(supabase, orgId))
|
|
290
291
|
if (!validPlan) {
|
|
291
292
|
p.log.error(`You need to upgrade your plan to continue to use capgo.\n Upgrade here: ${config.hostWeb}/dashboard/settings/plans\n`)
|
|
292
293
|
wait(100)
|
|
@@ -297,8 +298,10 @@ export async function checkPlanValid(supabase: SupabaseClient<Database>, userId:
|
|
|
297
298
|
wait(500)
|
|
298
299
|
program.error('')
|
|
299
300
|
}
|
|
300
|
-
const trialDays = await
|
|
301
|
-
|
|
301
|
+
const [trialDays, ispaying] = await Promise.all([
|
|
302
|
+
isTrialOrg(supabase, orgId),
|
|
303
|
+
isPayingOrg(supabase, orgId),
|
|
304
|
+
])
|
|
302
305
|
if (trialDays > 0 && warning && !ispaying)
|
|
303
306
|
p.log.warn(`WARNING !!\nTrial expires in ${trialDays} days, upgrade here: ${config.hostWeb}/dashboard/settings/plans\n`)
|
|
304
307
|
}
|
|
@@ -498,6 +501,20 @@ export async function verifyUser(supabase: SupabaseClient<Database>, apikey: str
|
|
|
498
501
|
return userId
|
|
499
502
|
}
|
|
500
503
|
|
|
504
|
+
export async function getOrganizationId(supabase: SupabaseClient<Database>, appId: string) {
|
|
505
|
+
const { data, error } = await supabase.from('apps')
|
|
506
|
+
.select('owner_org')
|
|
507
|
+
.eq('app_id', appId)
|
|
508
|
+
.single()
|
|
509
|
+
|
|
510
|
+
if (!data || error) {
|
|
511
|
+
p.log.error(`Cannot get organization id for app id ${appId}`)
|
|
512
|
+
formatError(error)
|
|
513
|
+
program.error('')
|
|
514
|
+
}
|
|
515
|
+
return data.owner_org
|
|
516
|
+
}
|
|
517
|
+
|
|
501
518
|
export async function requireUpdateMetadata(supabase: SupabaseClient<Database>, channel: string, appId: string): Promise<boolean> {
|
|
502
519
|
const { data, error } = await supabase
|
|
503
520
|
.from('channels')
|