@secondlayer/shared 2.0.0 → 3.0.0-alpha.0
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/README.md +2 -2
- package/dist/src/db/index.d.ts +64 -130
- package/dist/src/db/index.js.map +2 -2
- package/dist/src/db/jsonb.d.ts +5 -1
- package/dist/src/db/jsonb.js.map +2 -2
- package/dist/src/db/queries/account-spend-caps.d.ts +379 -0
- package/dist/src/db/queries/account-spend-caps.js +60 -0
- package/dist/src/db/queries/account-spend-caps.js.map +10 -0
- package/dist/src/db/queries/account-usage.d.ts +403 -0
- package/dist/src/db/queries/account-usage.js +222 -0
- package/dist/src/db/queries/account-usage.js.map +11 -0
- package/dist/src/db/queries/accounts.d.ts +61 -108
- package/dist/src/db/queries/accounts.js +15 -1
- package/dist/src/db/queries/accounts.js.map +3 -3
- package/dist/src/db/queries/integrity.d.ts +47 -107
- package/dist/src/db/queries/projects.d.ts +47 -107
- package/dist/src/db/queries/{workflows.d.ts → provisioning-audit.d.ts} +70 -142
- package/dist/src/db/queries/provisioning-audit.js +40 -0
- package/dist/src/db/queries/provisioning-audit.js.map +10 -0
- package/dist/src/db/queries/subgraph-gaps.d.ts +47 -107
- package/dist/src/db/queries/subgraphs.d.ts +47 -108
- package/dist/src/db/queries/subgraphs.js +2 -3
- package/dist/src/db/queries/subgraphs.js.map +4 -4
- package/dist/src/db/queries/{marketplace.d.ts → tenant-compute-addons.d.ts} +66 -159
- package/dist/src/db/queries/tenant-compute-addons.js +47 -0
- package/dist/src/db/queries/tenant-compute-addons.js.map +10 -0
- package/dist/src/db/queries/tenants.d.ts +67 -110
- package/dist/src/db/queries/tenants.js +35 -6
- package/dist/src/db/queries/tenants.js.map +3 -3
- package/dist/src/db/queries/usage.d.ts +48 -132
- package/dist/src/db/queries/usage.js +5 -64
- package/dist/src/db/queries/usage.js.map +4 -5
- package/dist/src/db/schema.d.ts +59 -129
- package/dist/src/errors.d.ts +8 -7
- package/dist/src/errors.js +11 -12
- package/dist/src/errors.js.map +3 -3
- package/dist/src/index.d.ts +98 -212
- package/dist/src/index.js +69 -80
- package/dist/src/index.js.map +6 -6
- package/dist/src/mode.d.ts +4 -5
- package/dist/src/mode.js.map +2 -2
- package/dist/src/node/local-client.d.ts +47 -107
- package/dist/src/pricing.d.ts +20 -1
- package/dist/src/pricing.js +58 -1
- package/dist/src/pricing.js.map +3 -3
- package/dist/src/schemas/accounts.d.ts +14 -0
- package/dist/src/schemas/{marketplace.js → accounts.js} +4 -14
- package/dist/src/schemas/accounts.js.map +10 -0
- package/dist/src/schemas/index.d.ts +28 -77
- package/dist/src/schemas/index.js +59 -69
- package/dist/src/schemas/index.js.map +4 -4
- package/migrations/0043_tenant_usage_monthly.ts +36 -0
- package/migrations/0044_provisioning_audit_log.ts +40 -0
- package/migrations/0045_drop_marketplace_columns.ts +47 -0
- package/migrations/0046_tenant_activity_signal.ts +47 -0
- package/migrations/0047_usage_daily_tenant_id.ts +73 -0
- package/migrations/0048_tenant_compute_addons.ts +49 -0
- package/migrations/0049_accounts_stripe_customer_id.ts +30 -0
- package/migrations/0050_account_spend_caps.ts +45 -0
- package/migrations/0051_workflow_ai_usage_daily.ts +40 -0
- package/migrations/0052_sentries.ts +61 -0
- package/migrations/0053_workflow_runtime.ts +88 -0
- package/migrations/0054_accounts_plan_hobby.ts +32 -0
- package/migrations/0055_ai_usage_account_scope.ts +108 -0
- package/migrations/0056_drop_workflow_sentry_residuals.ts +23 -0
- package/package.json +33 -21
- package/dist/src/db/queries/marketplace.js +0 -139
- package/dist/src/db/queries/marketplace.js.map +0 -10
- package/dist/src/db/queries/workflows.js +0 -260
- package/dist/src/db/queries/workflows.js.map +0 -12
- package/dist/src/lib/plans.d.ts +0 -9
- package/dist/src/lib/plans.js +0 -37
- package/dist/src/lib/plans.js.map +0 -10
- package/dist/src/schemas/marketplace.d.ts +0 -63
- package/dist/src/schemas/marketplace.js.map +0 -10
- package/dist/src/schemas/workflows.d.ts +0 -70
- package/dist/src/schemas/workflows.js +0 -43
- package/dist/src/schemas/workflows.js.map +0 -10
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import { z } from "zod/v4";
|
|
2
|
+
/**
|
|
3
|
+
* Account profile shapes. Unrelated to marketplace — previously lived in
|
|
4
|
+
* schemas/marketplace.ts alongside public-directory types. Kept here now
|
|
5
|
+
* that marketplace is gone so the profile fields (display_name, bio, slug)
|
|
6
|
+
* have a stable home.
|
|
7
|
+
*/
|
|
8
|
+
interface UpdateProfileRequest {
|
|
9
|
+
display_name?: string;
|
|
10
|
+
bio?: string;
|
|
11
|
+
slug?: string;
|
|
12
|
+
}
|
|
13
|
+
declare const UpdateProfileRequestSchema: z.ZodType<UpdateProfileRequest>;
|
|
14
|
+
import { z as z2 } from "zod/v4";
|
|
2
15
|
interface StxTransferFilter {
|
|
3
16
|
type: "stx_transfer";
|
|
4
17
|
sender?: string;
|
|
@@ -77,82 +90,20 @@ interface PrintEventFilter {
|
|
|
77
90
|
contains?: string;
|
|
78
91
|
}
|
|
79
92
|
type EventFilter = StxTransferFilter | StxMintFilter | StxBurnFilter | StxLockFilter | FtTransferFilter | FtMintFilter | FtBurnFilter | NftTransferFilter | NftMintFilter | NftBurnFilter | ContractCallFilter | ContractDeployFilter | PrintEventFilter;
|
|
80
|
-
declare const StxTransferFilterSchema:
|
|
81
|
-
declare const StxMintFilterSchema:
|
|
82
|
-
declare const StxBurnFilterSchema:
|
|
83
|
-
declare const StxLockFilterSchema:
|
|
84
|
-
declare const FtTransferFilterSchema:
|
|
85
|
-
declare const FtMintFilterSchema:
|
|
86
|
-
declare const FtBurnFilterSchema:
|
|
87
|
-
declare const NftTransferFilterSchema:
|
|
88
|
-
declare const NftMintFilterSchema:
|
|
89
|
-
declare const NftBurnFilterSchema:
|
|
90
|
-
declare const ContractCallFilterSchema:
|
|
91
|
-
declare const ContractDeployFilterSchema:
|
|
92
|
-
declare const PrintEventFilterSchema:
|
|
93
|
-
declare const EventFilterSchema:
|
|
94
|
-
import { z as z2 } from "zod/v4";
|
|
95
|
-
interface PublishSubgraphRequest {
|
|
96
|
-
tags?: string[];
|
|
97
|
-
description?: string;
|
|
98
|
-
}
|
|
99
|
-
interface UpdateProfileRequest {
|
|
100
|
-
display_name?: string;
|
|
101
|
-
bio?: string;
|
|
102
|
-
slug?: string;
|
|
103
|
-
}
|
|
104
|
-
interface ForkSubgraphRequest {
|
|
105
|
-
sourceSubgraphName: string;
|
|
106
|
-
newName?: string;
|
|
107
|
-
}
|
|
108
|
-
declare const PublishSubgraphRequestSchema: z2.ZodType<PublishSubgraphRequest>;
|
|
109
|
-
declare const UpdateProfileRequestSchema: z2.ZodType<UpdateProfileRequest>;
|
|
110
|
-
declare const ForkSubgraphRequestSchema: z2.ZodType<ForkSubgraphRequest>;
|
|
111
|
-
interface MarketplaceCreator {
|
|
112
|
-
displayName: string | null;
|
|
113
|
-
slug: string | null;
|
|
114
|
-
}
|
|
115
|
-
interface MarketplaceSubgraphSummary {
|
|
116
|
-
name: string;
|
|
117
|
-
description: string | null;
|
|
118
|
-
tags: string[];
|
|
119
|
-
creator: MarketplaceCreator;
|
|
120
|
-
status: string;
|
|
121
|
-
version: string;
|
|
122
|
-
tables: string[];
|
|
123
|
-
totalQueries7d: number;
|
|
124
|
-
progress: number;
|
|
125
|
-
createdAt: string;
|
|
126
|
-
}
|
|
127
|
-
interface MarketplaceSubgraphDetail extends MarketplaceSubgraphSummary {
|
|
128
|
-
tableSchemas: Record<string, {
|
|
129
|
-
columns: Record<string, {
|
|
130
|
-
type: string
|
|
131
|
-
nullable?: boolean
|
|
132
|
-
}>
|
|
133
|
-
rowCount: number
|
|
134
|
-
endpoint: string
|
|
135
|
-
}>;
|
|
136
|
-
sources: Record<string, unknown>;
|
|
137
|
-
startBlock: number;
|
|
138
|
-
lastProcessedBlock: number;
|
|
139
|
-
forkedFrom: string | null;
|
|
140
|
-
usage: {
|
|
141
|
-
totalQueries7d: number
|
|
142
|
-
totalQueries30d: number
|
|
143
|
-
daily: Array<{
|
|
144
|
-
date: string
|
|
145
|
-
count: number
|
|
146
|
-
}>
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
interface CreatorProfile {
|
|
150
|
-
displayName: string | null;
|
|
151
|
-
bio: string | null;
|
|
152
|
-
avatarUrl: string | null;
|
|
153
|
-
slug: string | null;
|
|
154
|
-
subgraphs: MarketplaceSubgraphSummary[];
|
|
155
|
-
}
|
|
93
|
+
declare const StxTransferFilterSchema: z2.ZodType<StxTransferFilter>;
|
|
94
|
+
declare const StxMintFilterSchema: z2.ZodType<StxMintFilter>;
|
|
95
|
+
declare const StxBurnFilterSchema: z2.ZodType<StxBurnFilter>;
|
|
96
|
+
declare const StxLockFilterSchema: z2.ZodType<StxLockFilter>;
|
|
97
|
+
declare const FtTransferFilterSchema: z2.ZodType<FtTransferFilter>;
|
|
98
|
+
declare const FtMintFilterSchema: z2.ZodType<FtMintFilter>;
|
|
99
|
+
declare const FtBurnFilterSchema: z2.ZodType<FtBurnFilter>;
|
|
100
|
+
declare const NftTransferFilterSchema: z2.ZodType<NftTransferFilter>;
|
|
101
|
+
declare const NftMintFilterSchema: z2.ZodType<NftMintFilter>;
|
|
102
|
+
declare const NftBurnFilterSchema: z2.ZodType<NftBurnFilter>;
|
|
103
|
+
declare const ContractCallFilterSchema: z2.ZodType<ContractCallFilter>;
|
|
104
|
+
declare const ContractDeployFilterSchema: z2.ZodType<ContractDeployFilter>;
|
|
105
|
+
declare const PrintEventFilterSchema: z2.ZodType<PrintEventFilter>;
|
|
106
|
+
declare const EventFilterSchema: z2.ZodType<EventFilter>;
|
|
156
107
|
import { z as z3 } from "zod/v4";
|
|
157
108
|
interface DeploySubgraphRequest {
|
|
158
109
|
name: string;
|
|
@@ -268,4 +219,4 @@ interface SubgraphQueryParams {
|
|
|
268
219
|
fields?: string;
|
|
269
220
|
filters?: Record<string, string>;
|
|
270
221
|
}
|
|
271
|
-
export { UpdateProfileRequestSchema, UpdateProfileRequest, SubgraphSyncInfo, SubgraphSummary, SubgraphQueryParams, SubgraphGapsResponse, SubgraphGapRange, SubgraphGapEntry, SubgraphDetail, StxTransferFilterSchema, StxTransferFilter, StxMintFilterSchema, StxMintFilter, StxLockFilterSchema, StxLockFilter, StxBurnFilterSchema, StxBurnFilter, ReindexResponse,
|
|
222
|
+
export { UpdateProfileRequestSchema, UpdateProfileRequest, SubgraphSyncInfo, SubgraphSummary, SubgraphQueryParams, SubgraphGapsResponse, SubgraphGapRange, SubgraphGapEntry, SubgraphDetail, StxTransferFilterSchema, StxTransferFilter, StxMintFilterSchema, StxMintFilter, StxLockFilterSchema, StxLockFilter, StxBurnFilterSchema, StxBurnFilter, ReindexResponse, PrintEventFilterSchema, PrintEventFilter, NftTransferFilterSchema, NftTransferFilter, NftMintFilterSchema, NftMintFilter, NftBurnFilterSchema, NftBurnFilter, FtTransferFilterSchema, FtTransferFilter, FtMintFilterSchema, FtMintFilter, FtBurnFilterSchema, FtBurnFilter, EventFilterSchema, EventFilter, DeploySubgraphResponse, DeploySubgraphRequestSchema, DeploySubgraphRequest, ContractDeployFilterSchema, ContractDeployFilter, ContractCallFilterSchema, ContractCallFilter };
|
|
@@ -14,11 +14,19 @@ var __export = (target, all) => {
|
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
+
// src/schemas/accounts.ts
|
|
18
|
+
import { z } from "zod/v4";
|
|
19
|
+
var UpdateProfileRequestSchema = z.object({
|
|
20
|
+
display_name: z.string().max(50).optional(),
|
|
21
|
+
bio: z.string().max(300).optional(),
|
|
22
|
+
slug: z.string().regex(/^[a-z0-9-]+$/, "lowercase alphanumeric + hyphens only").min(3).max(30).optional()
|
|
23
|
+
});
|
|
24
|
+
|
|
17
25
|
// src/schemas/filters.ts
|
|
18
26
|
import { isValidAddress as _isValidAddress } from "@secondlayer/stacks";
|
|
19
|
-
import { z } from "zod/v4";
|
|
27
|
+
import { z as z2 } from "zod/v4";
|
|
20
28
|
var isValidAddress = _isValidAddress;
|
|
21
|
-
var stacksPrincipal =
|
|
29
|
+
var stacksPrincipal = z2.string().refine((val) => {
|
|
22
30
|
const parts = val.split(".");
|
|
23
31
|
if (parts.length > 2)
|
|
24
32
|
return false;
|
|
@@ -28,81 +36,81 @@ var baseFilter = {
|
|
|
28
36
|
sender: stacksPrincipal.optional(),
|
|
29
37
|
recipient: stacksPrincipal.optional()
|
|
30
38
|
};
|
|
31
|
-
var StxTransferFilterSchema =
|
|
32
|
-
type:
|
|
39
|
+
var StxTransferFilterSchema = z2.object({
|
|
40
|
+
type: z2.literal("stx_transfer"),
|
|
33
41
|
...baseFilter,
|
|
34
|
-
minAmount:
|
|
35
|
-
maxAmount:
|
|
42
|
+
minAmount: z2.coerce.number().int().positive().optional(),
|
|
43
|
+
maxAmount: z2.coerce.number().int().positive().optional()
|
|
36
44
|
});
|
|
37
|
-
var StxMintFilterSchema =
|
|
38
|
-
type:
|
|
45
|
+
var StxMintFilterSchema = z2.object({
|
|
46
|
+
type: z2.literal("stx_mint"),
|
|
39
47
|
recipient: stacksPrincipal.optional(),
|
|
40
|
-
minAmount:
|
|
48
|
+
minAmount: z2.coerce.number().int().positive().optional()
|
|
41
49
|
});
|
|
42
|
-
var StxBurnFilterSchema =
|
|
43
|
-
type:
|
|
50
|
+
var StxBurnFilterSchema = z2.object({
|
|
51
|
+
type: z2.literal("stx_burn"),
|
|
44
52
|
sender: stacksPrincipal.optional(),
|
|
45
|
-
minAmount:
|
|
53
|
+
minAmount: z2.coerce.number().int().positive().optional()
|
|
46
54
|
});
|
|
47
|
-
var StxLockFilterSchema =
|
|
48
|
-
type:
|
|
55
|
+
var StxLockFilterSchema = z2.object({
|
|
56
|
+
type: z2.literal("stx_lock"),
|
|
49
57
|
lockedAddress: stacksPrincipal.optional(),
|
|
50
|
-
minAmount:
|
|
58
|
+
minAmount: z2.coerce.number().int().positive().optional()
|
|
51
59
|
});
|
|
52
|
-
var FtTransferFilterSchema =
|
|
53
|
-
type:
|
|
60
|
+
var FtTransferFilterSchema = z2.object({
|
|
61
|
+
type: z2.literal("ft_transfer"),
|
|
54
62
|
...baseFilter,
|
|
55
|
-
assetIdentifier:
|
|
56
|
-
minAmount:
|
|
63
|
+
assetIdentifier: z2.string().optional(),
|
|
64
|
+
minAmount: z2.coerce.number().int().positive().optional()
|
|
57
65
|
});
|
|
58
|
-
var FtMintFilterSchema =
|
|
59
|
-
type:
|
|
66
|
+
var FtMintFilterSchema = z2.object({
|
|
67
|
+
type: z2.literal("ft_mint"),
|
|
60
68
|
recipient: stacksPrincipal.optional(),
|
|
61
|
-
assetIdentifier:
|
|
62
|
-
minAmount:
|
|
69
|
+
assetIdentifier: z2.string().optional(),
|
|
70
|
+
minAmount: z2.coerce.number().int().positive().optional()
|
|
63
71
|
});
|
|
64
|
-
var FtBurnFilterSchema =
|
|
65
|
-
type:
|
|
72
|
+
var FtBurnFilterSchema = z2.object({
|
|
73
|
+
type: z2.literal("ft_burn"),
|
|
66
74
|
sender: stacksPrincipal.optional(),
|
|
67
|
-
assetIdentifier:
|
|
68
|
-
minAmount:
|
|
75
|
+
assetIdentifier: z2.string().optional(),
|
|
76
|
+
minAmount: z2.coerce.number().int().positive().optional()
|
|
69
77
|
});
|
|
70
|
-
var NftTransferFilterSchema =
|
|
71
|
-
type:
|
|
78
|
+
var NftTransferFilterSchema = z2.object({
|
|
79
|
+
type: z2.literal("nft_transfer"),
|
|
72
80
|
...baseFilter,
|
|
73
|
-
assetIdentifier:
|
|
74
|
-
tokenId:
|
|
81
|
+
assetIdentifier: z2.string().optional(),
|
|
82
|
+
tokenId: z2.string().optional()
|
|
75
83
|
});
|
|
76
|
-
var NftMintFilterSchema =
|
|
77
|
-
type:
|
|
84
|
+
var NftMintFilterSchema = z2.object({
|
|
85
|
+
type: z2.literal("nft_mint"),
|
|
78
86
|
recipient: stacksPrincipal.optional(),
|
|
79
|
-
assetIdentifier:
|
|
80
|
-
tokenId:
|
|
87
|
+
assetIdentifier: z2.string().optional(),
|
|
88
|
+
tokenId: z2.string().optional()
|
|
81
89
|
});
|
|
82
|
-
var NftBurnFilterSchema =
|
|
83
|
-
type:
|
|
90
|
+
var NftBurnFilterSchema = z2.object({
|
|
91
|
+
type: z2.literal("nft_burn"),
|
|
84
92
|
sender: stacksPrincipal.optional(),
|
|
85
|
-
assetIdentifier:
|
|
86
|
-
tokenId:
|
|
93
|
+
assetIdentifier: z2.string().optional(),
|
|
94
|
+
tokenId: z2.string().optional()
|
|
87
95
|
});
|
|
88
|
-
var ContractCallFilterSchema =
|
|
89
|
-
type:
|
|
96
|
+
var ContractCallFilterSchema = z2.object({
|
|
97
|
+
type: z2.literal("contract_call"),
|
|
90
98
|
contractId: stacksPrincipal.optional(),
|
|
91
|
-
functionName:
|
|
99
|
+
functionName: z2.string().optional(),
|
|
92
100
|
caller: stacksPrincipal.optional()
|
|
93
101
|
});
|
|
94
|
-
var ContractDeployFilterSchema =
|
|
95
|
-
type:
|
|
102
|
+
var ContractDeployFilterSchema = z2.object({
|
|
103
|
+
type: z2.literal("contract_deploy"),
|
|
96
104
|
deployer: stacksPrincipal.optional(),
|
|
97
|
-
contractName:
|
|
105
|
+
contractName: z2.string().optional()
|
|
98
106
|
});
|
|
99
|
-
var PrintEventFilterSchema =
|
|
100
|
-
type:
|
|
107
|
+
var PrintEventFilterSchema = z2.object({
|
|
108
|
+
type: z2.literal("print_event"),
|
|
101
109
|
contractId: stacksPrincipal.optional(),
|
|
102
|
-
topic:
|
|
103
|
-
contains:
|
|
110
|
+
topic: z2.string().optional(),
|
|
111
|
+
contains: z2.string().optional()
|
|
104
112
|
});
|
|
105
|
-
var EventFilterSchema =
|
|
113
|
+
var EventFilterSchema = z2.discriminatedUnion("type", [
|
|
106
114
|
StxTransferFilterSchema,
|
|
107
115
|
StxMintFilterSchema,
|
|
108
116
|
StxBurnFilterSchema,
|
|
@@ -118,22 +126,6 @@ var EventFilterSchema = z.discriminatedUnion("type", [
|
|
|
118
126
|
PrintEventFilterSchema
|
|
119
127
|
]);
|
|
120
128
|
|
|
121
|
-
// src/schemas/marketplace.ts
|
|
122
|
-
import { z as z2 } from "zod/v4";
|
|
123
|
-
var PublishSubgraphRequestSchema = z2.object({
|
|
124
|
-
tags: z2.array(z2.string().max(30)).max(5).optional(),
|
|
125
|
-
description: z2.string().max(500).optional()
|
|
126
|
-
});
|
|
127
|
-
var UpdateProfileRequestSchema = z2.object({
|
|
128
|
-
display_name: z2.string().max(50).optional(),
|
|
129
|
-
bio: z2.string().max(300).optional(),
|
|
130
|
-
slug: z2.string().regex(/^[a-z0-9-]+$/, "lowercase alphanumeric + hyphens only").min(3).max(30).optional()
|
|
131
|
-
});
|
|
132
|
-
var ForkSubgraphRequestSchema = z2.object({
|
|
133
|
-
sourceSubgraphName: z2.string(),
|
|
134
|
-
newName: z2.string().regex(/^[a-z0-9-]+$/, "lowercase alphanumeric + hyphens only").max(63).optional()
|
|
135
|
-
});
|
|
136
|
-
|
|
137
129
|
// src/schemas/subgraphs.ts
|
|
138
130
|
import { z as z3 } from "zod/v4";
|
|
139
131
|
var DeploySubgraphRequestSchema = z3.object({
|
|
@@ -152,7 +144,6 @@ export {
|
|
|
152
144
|
StxMintFilterSchema,
|
|
153
145
|
StxLockFilterSchema,
|
|
154
146
|
StxBurnFilterSchema,
|
|
155
|
-
PublishSubgraphRequestSchema,
|
|
156
147
|
PrintEventFilterSchema,
|
|
157
148
|
NftTransferFilterSchema,
|
|
158
149
|
NftMintFilterSchema,
|
|
@@ -160,12 +151,11 @@ export {
|
|
|
160
151
|
FtTransferFilterSchema,
|
|
161
152
|
FtMintFilterSchema,
|
|
162
153
|
FtBurnFilterSchema,
|
|
163
|
-
ForkSubgraphRequestSchema,
|
|
164
154
|
EventFilterSchema,
|
|
165
155
|
DeploySubgraphRequestSchema,
|
|
166
156
|
ContractDeployFilterSchema,
|
|
167
157
|
ContractCallFilterSchema
|
|
168
158
|
};
|
|
169
159
|
|
|
170
|
-
//# debugId=
|
|
160
|
+
//# debugId=C2E332004F21E1EA64756E2164756E21
|
|
171
161
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/schemas/
|
|
3
|
+
"sources": ["../src/schemas/accounts.ts", "../src/schemas/filters.ts", "../src/schemas/subgraphs.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
+
"import { z } from \"zod/v4\";\n\n/**\n * Account profile shapes. Unrelated to marketplace — previously lived in\n * schemas/marketplace.ts alongside public-directory types. Kept here now\n * that marketplace is gone so the profile fields (display_name, bio, slug)\n * have a stable home.\n */\n\nexport interface UpdateProfileRequest {\n\tdisplay_name?: string;\n\tbio?: string;\n\tslug?: string;\n}\n\nexport const UpdateProfileRequestSchema: z.ZodType<UpdateProfileRequest> =\n\tz.object({\n\t\tdisplay_name: z.string().max(50).optional(),\n\t\tbio: z.string().max(300).optional(),\n\t\tslug: z\n\t\t\t.string()\n\t\t\t.regex(/^[a-z0-9-]+$/, \"lowercase alphanumeric + hyphens only\")\n\t\t\t.min(3)\n\t\t\t.max(30)\n\t\t\t.optional(),\n\t});\n",
|
|
5
6
|
"import { isValidAddress as _isValidAddress } from \"@secondlayer/stacks\";\nimport { z } from \"zod/v4\";\n\nconst isValidAddress = _isValidAddress as (addr: string) => boolean;\n\n/** Validate a Stacks principal (standard or contract, e.g. SP2J...ABC or SP2J...ABC.contract-name) */\nconst stacksPrincipal = z.string().refine((val) => {\n\tconst parts = val.split(\".\");\n\tif (parts.length > 2) return false;\n\treturn isValidAddress(parts[0]!);\n}, \"Invalid Stacks principal address\");\n\n// Base filter with common fields\nconst baseFilter = {\n\t// Optional: filter by sender\n\tsender: stacksPrincipal.optional(),\n\t// Optional: filter by recipient\n\trecipient: stacksPrincipal.optional(),\n};\n\n// Type exports — defined first so they can annotate schemas\nexport interface StxTransferFilter {\n\ttype: \"stx_transfer\";\n\tsender?: string;\n\trecipient?: string;\n\tminAmount?: number;\n\tmaxAmount?: number;\n}\n\nexport interface StxMintFilter {\n\ttype: \"stx_mint\";\n\trecipient?: string;\n\tminAmount?: number;\n}\n\nexport interface StxBurnFilter {\n\ttype: \"stx_burn\";\n\tsender?: string;\n\tminAmount?: number;\n}\n\nexport interface StxLockFilter {\n\ttype: \"stx_lock\";\n\tlockedAddress?: string;\n\tminAmount?: number;\n}\n\nexport interface FtTransferFilter {\n\ttype: \"ft_transfer\";\n\tsender?: string;\n\trecipient?: string;\n\tassetIdentifier?: string;\n\tminAmount?: number;\n}\n\nexport interface FtMintFilter {\n\ttype: \"ft_mint\";\n\trecipient?: string;\n\tassetIdentifier?: string;\n\tminAmount?: number;\n}\n\nexport interface FtBurnFilter {\n\ttype: \"ft_burn\";\n\tsender?: string;\n\tassetIdentifier?: string;\n\tminAmount?: number;\n}\n\nexport interface NftTransferFilter {\n\ttype: \"nft_transfer\";\n\tsender?: string;\n\trecipient?: string;\n\tassetIdentifier?: string;\n\ttokenId?: string;\n}\n\nexport interface NftMintFilter {\n\ttype: \"nft_mint\";\n\trecipient?: string;\n\tassetIdentifier?: string;\n\ttokenId?: string;\n}\n\nexport interface NftBurnFilter {\n\ttype: \"nft_burn\";\n\tsender?: string;\n\tassetIdentifier?: string;\n\ttokenId?: string;\n}\n\nexport interface ContractCallFilter {\n\ttype: \"contract_call\";\n\tcontractId?: string;\n\tfunctionName?: string;\n\tcaller?: string;\n}\n\nexport interface ContractDeployFilter {\n\ttype: \"contract_deploy\";\n\tdeployer?: string;\n\tcontractName?: string;\n}\n\nexport interface PrintEventFilter {\n\ttype: \"print_event\";\n\tcontractId?: string;\n\ttopic?: string;\n\tcontains?: string;\n}\n\nexport type EventFilter =\n\t| StxTransferFilter\n\t| StxMintFilter\n\t| StxBurnFilter\n\t| StxLockFilter\n\t| FtTransferFilter\n\t| FtMintFilter\n\t| FtBurnFilter\n\t| NftTransferFilter\n\t| NftMintFilter\n\t| NftBurnFilter\n\t| ContractCallFilter\n\t| ContractDeployFilter\n\t| PrintEventFilter;\n\n// STX Transfer Filter\nexport const StxTransferFilterSchema: z.ZodType<StxTransferFilter> = z.object({\n\ttype: z.literal(\"stx_transfer\"),\n\t...baseFilter,\n\t// Optional: minimum amount in microSTX\n\tminAmount: z.coerce.number().int().positive().optional(),\n\t// Optional: maximum amount in microSTX\n\tmaxAmount: z.coerce.number().int().positive().optional(),\n});\n\n// STX Mint Filter\nexport const StxMintFilterSchema: z.ZodType<StxMintFilter> = z.object({\n\ttype: z.literal(\"stx_mint\"),\n\trecipient: stacksPrincipal.optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// STX Burn Filter\nexport const StxBurnFilterSchema: z.ZodType<StxBurnFilter> = z.object({\n\ttype: z.literal(\"stx_burn\"),\n\tsender: stacksPrincipal.optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// STX Lock Filter\nexport const StxLockFilterSchema: z.ZodType<StxLockFilter> = z.object({\n\ttype: z.literal(\"stx_lock\"),\n\tlockedAddress: stacksPrincipal.optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// FT Transfer Filter\nexport const FtTransferFilterSchema: z.ZodType<FtTransferFilter> = z.object({\n\ttype: z.literal(\"ft_transfer\"),\n\t...baseFilter,\n\t// Contract that defines the token (e.g., SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wstx)\n\tassetIdentifier: z.string().optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// FT Mint Filter\nexport const FtMintFilterSchema: z.ZodType<FtMintFilter> = z.object({\n\ttype: z.literal(\"ft_mint\"),\n\trecipient: stacksPrincipal.optional(),\n\tassetIdentifier: z.string().optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// FT Burn Filter\nexport const FtBurnFilterSchema: z.ZodType<FtBurnFilter> = z.object({\n\ttype: z.literal(\"ft_burn\"),\n\tsender: stacksPrincipal.optional(),\n\tassetIdentifier: z.string().optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// NFT Transfer Filter\nexport const NftTransferFilterSchema: z.ZodType<NftTransferFilter> = z.object({\n\ttype: z.literal(\"nft_transfer\"),\n\t...baseFilter,\n\tassetIdentifier: z.string().optional(),\n\t// Optional: filter by specific token ID (Clarity value as hex)\n\ttokenId: z.string().optional(),\n});\n\n// NFT Mint Filter\nexport const NftMintFilterSchema: z.ZodType<NftMintFilter> = z.object({\n\ttype: z.literal(\"nft_mint\"),\n\trecipient: stacksPrincipal.optional(),\n\tassetIdentifier: z.string().optional(),\n\ttokenId: z.string().optional(),\n});\n\n// NFT Burn Filter\nexport const NftBurnFilterSchema: z.ZodType<NftBurnFilter> = z.object({\n\ttype: z.literal(\"nft_burn\"),\n\tsender: stacksPrincipal.optional(),\n\tassetIdentifier: z.string().optional(),\n\ttokenId: z.string().optional(),\n});\n\n// Contract Call Filter\nexport const ContractCallFilterSchema: z.ZodType<ContractCallFilter> = z.object(\n\t{\n\t\ttype: z.literal(\"contract_call\"),\n\t\t// Contract being called\n\t\tcontractId: stacksPrincipal.optional(),\n\t\t// Function name (supports wildcards with *)\n\t\tfunctionName: z.string().optional(),\n\t\t// Caller address\n\t\tcaller: stacksPrincipal.optional(),\n\t},\n);\n\n// Contract Deploy Filter\nexport const ContractDeployFilterSchema: z.ZodType<ContractDeployFilter> =\n\tz.object({\n\t\ttype: z.literal(\"contract_deploy\"),\n\t\t// Deployer address\n\t\tdeployer: stacksPrincipal.optional(),\n\t\t// Contract name pattern (supports wildcards)\n\t\tcontractName: z.string().optional(),\n\t});\n\n// Print Event Filter (smart contract events)\nexport const PrintEventFilterSchema: z.ZodType<PrintEventFilter> = z.object({\n\ttype: z.literal(\"print_event\"),\n\t// Contract emitting the event\n\tcontractId: stacksPrincipal.optional(),\n\t// Topic/name of the event\n\ttopic: z.string().optional(),\n\t// Search for substring in event data\n\tcontains: z.string().optional(),\n});\n\n// Union of all filter types\nexport const EventFilterSchema: z.ZodType<EventFilter> = z.discriminatedUnion(\n\t\"type\",\n\t[\n\t\tStxTransferFilterSchema as any,\n\t\tStxMintFilterSchema as any,\n\t\tStxBurnFilterSchema as any,\n\t\tStxLockFilterSchema as any,\n\t\tFtTransferFilterSchema as any,\n\t\tFtMintFilterSchema as any,\n\t\tFtBurnFilterSchema as any,\n\t\tNftTransferFilterSchema as any,\n\t\tNftMintFilterSchema as any,\n\t\tNftBurnFilterSchema as any,\n\t\tContractCallFilterSchema as any,\n\t\tContractDeployFilterSchema as any,\n\t\tPrintEventFilterSchema as any,\n\t],\n);\n",
|
|
6
|
-
"import { z } from \"zod/v4\";\n\n// ── Request Types ────────────────────────────────────────────────────\n\nexport interface PublishSubgraphRequest {\n\ttags?: string[];\n\tdescription?: string;\n}\n\nexport interface UpdateProfileRequest {\n\tdisplay_name?: string;\n\tbio?: string;\n\tslug?: string;\n}\n\nexport interface ForkSubgraphRequest {\n\tsourceSubgraphName: string;\n\tnewName?: string;\n}\n\n// ── Request Schemas ───────────────────────────────────────────────────\n\nexport const PublishSubgraphRequestSchema: z.ZodType<PublishSubgraphRequest> =\n\tz.object({\n\t\ttags: z.array(z.string().max(30)).max(5).optional(),\n\t\tdescription: z.string().max(500).optional(),\n\t});\n\nexport const UpdateProfileRequestSchema: z.ZodType<UpdateProfileRequest> =\n\tz.object({\n\t\tdisplay_name: z.string().max(50).optional(),\n\t\tbio: z.string().max(300).optional(),\n\t\tslug: z\n\t\t\t.string()\n\t\t\t.regex(/^[a-z0-9-]+$/, \"lowercase alphanumeric + hyphens only\")\n\t\t\t.min(3)\n\t\t\t.max(30)\n\t\t\t.optional(),\n\t});\n\nexport const ForkSubgraphRequestSchema: z.ZodType<ForkSubgraphRequest> =\n\tz.object({\n\t\tsourceSubgraphName: z.string(),\n\t\tnewName: z\n\t\t\t.string()\n\t\t\t.regex(/^[a-z0-9-]+$/, \"lowercase alphanumeric + hyphens only\")\n\t\t\t.max(63)\n\t\t\t.optional(),\n\t});\n\n// ── Response Types ────────────────────────────────────────────────────\n\nexport interface MarketplaceCreator {\n\tdisplayName: string | null;\n\tslug: string | null;\n}\n\nexport interface MarketplaceSubgraphSummary {\n\tname: string;\n\tdescription: string | null;\n\ttags: string[];\n\tcreator: MarketplaceCreator;\n\tstatus: string;\n\tversion: string;\n\ttables: string[];\n\ttotalQueries7d: number;\n\tprogress: number;\n\tcreatedAt: string;\n}\n\nexport interface MarketplaceSubgraphDetail extends MarketplaceSubgraphSummary {\n\ttableSchemas: Record<\n\t\tstring,\n\t\t{\n\t\t\tcolumns: Record<string, { type: string; nullable?: boolean }>;\n\t\t\trowCount: number;\n\t\t\tendpoint: string;\n\t\t}\n\t>;\n\tsources: Record<string, unknown>;\n\tstartBlock: number;\n\tlastProcessedBlock: number;\n\tforkedFrom: string | null;\n\tusage: {\n\t\ttotalQueries7d: number;\n\t\ttotalQueries30d: number;\n\t\tdaily: Array<{ date: string; count: number }>;\n\t};\n}\n\nexport interface CreatorProfile {\n\tdisplayName: string | null;\n\tbio: string | null;\n\tavatarUrl: string | null;\n\tslug: string | null;\n\tsubgraphs: MarketplaceSubgraphSummary[];\n}\n",
|
|
7
7
|
"import { z } from \"zod/v4\";\n\n// ── Deploy Subgraph Request ─────────────────────────────────────────────────\n\nexport interface DeploySubgraphRequest {\n\tname: string;\n\tversion?: string;\n\tdescription?: string;\n\tsources: Record<string, Record<string, unknown>>;\n\tschema: Record<string, unknown>;\n\thandlerCode: string;\n\t/** Original TypeScript source, persisted so chat can read/diff/edit later. */\n\tsourceCode?: string;\n\t/** @deprecated Use server auto-reindex on breaking changes instead */\n\treindex?: boolean;\n}\n\nexport const DeploySubgraphRequestSchema: z.ZodType<DeploySubgraphRequest> =\n\tz.object({\n\t\tname: z\n\t\t\t.string()\n\t\t\t.regex(/^[a-z0-9-]+$/, \"lowercase alphanumeric + hyphens only\")\n\t\t\t.max(63),\n\t\tversion: z.string().optional(),\n\t\tdescription: z.string().optional(),\n\t\tsources: z\n\t\t\t.record(z.string(), z.record(z.string(), z.unknown()))\n\t\t\t.refine(\n\t\t\t\t(s) => Object.keys(s).length > 0,\n\t\t\t\t\"Must have at least one source\",\n\t\t\t),\n\t\tschema: z.record(z.string(), z.unknown()),\n\t\thandlerCode: z.string().max(1_048_576, \"handler code exceeds 1MB limit\"),\n\t\tsourceCode: z\n\t\t\t.string()\n\t\t\t.max(1_048_576, \"source code exceeds 1MB limit\")\n\t\t\t.optional(),\n\t\treindex: z.boolean().optional(),\n\t});\n\nexport interface DeploySubgraphResponse {\n\taction: \"created\" | \"unchanged\" | \"updated\" | \"reindexed\";\n\tsubgraphId: string;\n\tversion: string;\n\tmessage: string;\n\tdiff?: {\n\t\taddedTables: string[];\n\t\tremovedTables: string[];\n\t\taddedColumns: Record<string, string[]>;\n\t\tbreakingChanges: string[];\n\t};\n}\n\n// Subgraph API response types\n\nexport interface SubgraphSummary {\n\tname: string;\n\tversion: string;\n\tstatus: string;\n\tlastProcessedBlock: number;\n\ttotalProcessed: number;\n\ttotalErrors: number;\n\ttables: string[];\n\tchainTip: number;\n\tprogress: number;\n\tgapCount: number;\n\tintegrity: \"complete\" | \"gaps_detected\";\n\tcreatedAt: string;\n}\n\nexport interface SubgraphGapRange {\n\tstart: number;\n\tend: number;\n\tsize: number;\n\treason: string;\n}\n\nexport interface SubgraphSyncInfo {\n\tstatus: \"synced\" | \"catching_up\" | \"reindexing\" | \"error\";\n\tstartBlock: number;\n\tlastProcessedBlock: number;\n\tchainTip: number;\n\tblocksRemaining: number;\n\tprogress: number;\n\tgaps: {\n\t\tcount: number;\n\t\ttotalMissingBlocks: number;\n\t\tranges: SubgraphGapRange[];\n\t};\n\tintegrity: \"complete\" | \"gaps_detected\";\n}\n\nexport interface SubgraphDetail {\n\tname: string;\n\tversion: string;\n\tstatus: string;\n\tlastProcessedBlock: number;\n\thealth: {\n\t\ttotalProcessed: number;\n\t\ttotalErrors: number;\n\t\terrorRate: number;\n\t\tlastError: string | null;\n\t\tlastErrorAt: string | null;\n\t};\n\tsync: SubgraphSyncInfo;\n\ttables: Record<\n\t\tstring,\n\t\t{\n\t\t\tendpoint: string;\n\t\t\tcolumns: Record<string, { type: string; nullable?: boolean }>;\n\t\t\trowCount: number;\n\t\t\texample: string;\n\t\t}\n\t>;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\nexport interface SubgraphGapEntry {\n\tstart: number;\n\tend: number;\n\tsize: number;\n\treason: string;\n\tdetectedAt: string;\n\tresolvedAt: string | null;\n}\n\nexport interface SubgraphGapsResponse {\n\tdata: SubgraphGapEntry[];\n\tmeta: {\n\t\ttotal: number;\n\t\ttotalMissingBlocks: number;\n\t\tlimit: number;\n\t\toffset: number;\n\t};\n}\n\nexport interface ReindexResponse {\n\tmessage: string;\n\tfromBlock: number;\n\ttoBlock: number | string;\n}\n\nexport interface SubgraphQueryParams {\n\tsort?: string;\n\torder?: string;\n\tlimit?: number;\n\toffset?: number;\n\tfields?: string;\n\tfilters?: Record<string, string>;\n}\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA,2BAAS;AACT;
|
|
10
|
-
"debugId": "
|
|
9
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAeO,IAAM,6BACZ,EAAE,OAAO;AAAA,EACR,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,SAAS;AAAA,EAC1C,KAAK,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,SAAS;AAAA,EAClC,MAAM,EACJ,OAAO,EACP,MAAM,gBAAgB,uCAAuC,EAC7D,IAAI,CAAC,EACL,IAAI,EAAE,EACN,SAAS;AACZ,CAAC;;;ACzBF,2BAAS;AACT,cAAS;AAET,IAAM,iBAAiB;AAGvB,IAAM,kBAAkB,GAAE,OAAO,EAAE,OAAO,CAAC,QAAQ;AAAA,EAClD,MAAM,QAAQ,IAAI,MAAM,GAAG;AAAA,EAC3B,IAAI,MAAM,SAAS;AAAA,IAAG,OAAO;AAAA,EAC7B,OAAO,eAAe,MAAM,EAAG;AAAA,GAC7B,kCAAkC;AAGr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|
4
|
+
* Monthly usage snapshots for tenants. Billing lands later; this table
|
|
5
|
+
* captures the raw measurements so we can backfill charges once pricing
|
|
6
|
+
* ships.
|
|
7
|
+
*
|
|
8
|
+
* One row per (tenant_id, period_month). The period_month is the first
|
|
9
|
+
* day of the calendar month in UTC (e.g. 2026-04-01). `storage_peak_mb`
|
|
10
|
+
* is the max observation within the period; `measurements` counts how
|
|
11
|
+
* many samples fed into peak/avg so we can judge confidence.
|
|
12
|
+
*/
|
|
13
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
14
|
+
await sql`
|
|
15
|
+
CREATE TABLE tenant_usage_monthly (
|
|
16
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
17
|
+
tenant_id uuid NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
18
|
+
period_month date NOT NULL,
|
|
19
|
+
storage_peak_mb integer NOT NULL DEFAULT 0,
|
|
20
|
+
storage_avg_mb integer NOT NULL DEFAULT 0,
|
|
21
|
+
storage_last_mb integer NOT NULL DEFAULT 0,
|
|
22
|
+
measurements integer NOT NULL DEFAULT 0,
|
|
23
|
+
first_at timestamptz NOT NULL DEFAULT now(),
|
|
24
|
+
last_at timestamptz NOT NULL DEFAULT now(),
|
|
25
|
+
UNIQUE (tenant_id, period_month)
|
|
26
|
+
)
|
|
27
|
+
`.execute(db);
|
|
28
|
+
await sql`
|
|
29
|
+
CREATE INDEX tenant_usage_monthly_period_idx
|
|
30
|
+
ON tenant_usage_monthly (period_month DESC)
|
|
31
|
+
`.execute(db);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
35
|
+
await sql`DROP TABLE IF EXISTS tenant_usage_monthly`.execute(db);
|
|
36
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Audit trail of provisioning-facing lifecycle events. Captures what
|
|
5
|
+
* happened, who triggered it, and the outcome — source of truth for
|
|
6
|
+
* post-incident review and billing disputes.
|
|
7
|
+
*
|
|
8
|
+
* `tenant_id` is nullable so provision-start rows (where the tenant row
|
|
9
|
+
* does not yet exist) can be recorded alongside lifecycle events on an
|
|
10
|
+
* existing tenant.
|
|
11
|
+
*/
|
|
12
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
13
|
+
await sql`
|
|
14
|
+
CREATE TABLE provisioning_audit_log (
|
|
15
|
+
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
16
|
+
tenant_id uuid REFERENCES tenants(id) ON DELETE SET NULL,
|
|
17
|
+
tenant_slug text,
|
|
18
|
+
account_id uuid REFERENCES accounts(id) ON DELETE SET NULL,
|
|
19
|
+
actor text NOT NULL,
|
|
20
|
+
event text NOT NULL,
|
|
21
|
+
status text NOT NULL,
|
|
22
|
+
detail jsonb,
|
|
23
|
+
error text,
|
|
24
|
+
created_at timestamptz NOT NULL DEFAULT now()
|
|
25
|
+
)
|
|
26
|
+
`.execute(db);
|
|
27
|
+
await sql`CREATE INDEX provisioning_audit_tenant_idx ON provisioning_audit_log (tenant_id, created_at DESC)`.execute(
|
|
28
|
+
db,
|
|
29
|
+
);
|
|
30
|
+
await sql`CREATE INDEX provisioning_audit_account_idx ON provisioning_audit_log (account_id, created_at DESC)`.execute(
|
|
31
|
+
db,
|
|
32
|
+
);
|
|
33
|
+
await sql`CREATE INDEX provisioning_audit_event_idx ON provisioning_audit_log (event, created_at DESC)`.execute(
|
|
34
|
+
db,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
39
|
+
await sql`DROP TABLE IF EXISTS provisioning_audit_log`.execute(db);
|
|
40
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Drop the marketplace-era columns from `subgraphs`. The marketplace
|
|
5
|
+
* feature is gone (see `0022_marketplace`); these columns were only
|
|
6
|
+
* written by the deleted publish/unpublish endpoints and read by the
|
|
7
|
+
* deleted marketplace browse routes.
|
|
8
|
+
*
|
|
9
|
+
* Production note: the platform DB's `subgraphs` table was manually dropped
|
|
10
|
+
* after migration `0041` as part of the shared→dedicated cutover (see the
|
|
11
|
+
* note there). This migration must tolerate that — it runs fine on OSS
|
|
12
|
+
* deployments and fresh dev DBs where the table still exists, and no-ops
|
|
13
|
+
* on production where the table is already gone.
|
|
14
|
+
*
|
|
15
|
+
* Indexes `subgraphs_is_public_idx` and `subgraphs_tags_idx` from 0022
|
|
16
|
+
* drop automatically with the columns.
|
|
17
|
+
*/
|
|
18
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
19
|
+
await sql`SET lock_timeout = '30s'`.execute(db);
|
|
20
|
+
await sql`
|
|
21
|
+
DO $$
|
|
22
|
+
BEGIN
|
|
23
|
+
IF to_regclass('public.subgraphs') IS NOT NULL THEN
|
|
24
|
+
ALTER TABLE subgraphs DROP COLUMN IF EXISTS forked_from_id;
|
|
25
|
+
ALTER TABLE subgraphs DROP COLUMN IF EXISTS description;
|
|
26
|
+
ALTER TABLE subgraphs DROP COLUMN IF EXISTS tags;
|
|
27
|
+
ALTER TABLE subgraphs DROP COLUMN IF EXISTS is_public;
|
|
28
|
+
END IF;
|
|
29
|
+
END$$
|
|
30
|
+
`.execute(db);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
34
|
+
// Re-adding these columns would resurrect dead feature state; only
|
|
35
|
+
// restore them where the table exists, to match the up() guard.
|
|
36
|
+
await sql`
|
|
37
|
+
DO $$
|
|
38
|
+
BEGIN
|
|
39
|
+
IF to_regclass('public.subgraphs') IS NOT NULL THEN
|
|
40
|
+
ALTER TABLE subgraphs ADD COLUMN IF NOT EXISTS is_public boolean NOT NULL DEFAULT false;
|
|
41
|
+
ALTER TABLE subgraphs ADD COLUMN IF NOT EXISTS tags text[] NOT NULL DEFAULT '{}';
|
|
42
|
+
ALTER TABLE subgraphs ADD COLUMN IF NOT EXISTS description text;
|
|
43
|
+
ALTER TABLE subgraphs ADD COLUMN IF NOT EXISTS forked_from_id uuid REFERENCES subgraphs(id) ON DELETE SET NULL;
|
|
44
|
+
END IF;
|
|
45
|
+
END$$
|
|
46
|
+
`.execute(db);
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Switch tenant suspension from time-based (14-day trial) to activity-based
|
|
5
|
+
* (Supabase-style auto-pause on the Hobby tier).
|
|
6
|
+
*
|
|
7
|
+
* - Drop `tenants.trial_ends_at` + its supporting index. The trial model
|
|
8
|
+
* is gone; no grandfathering (pre-launch, zero external users).
|
|
9
|
+
* - Add `tenants.last_active_at timestamptz NOT NULL DEFAULT now()`. Bumped
|
|
10
|
+
* by tenant API middleware on 2xx responses + workflow-runner on run
|
|
11
|
+
* start. The new `tenant-idle-pause` cron suspends Hobby tenants idle
|
|
12
|
+
* beyond a threshold.
|
|
13
|
+
* - Add `tenants_last_active_idx` for the cron's WHERE clause (plan +
|
|
14
|
+
* last_active_at).
|
|
15
|
+
*/
|
|
16
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
17
|
+
await sql`SET lock_timeout = '30s'`.execute(db);
|
|
18
|
+
await sql`DROP INDEX IF EXISTS tenants_trial_ends_idx`.execute(db);
|
|
19
|
+
await sql`ALTER TABLE tenants DROP COLUMN IF EXISTS trial_ends_at`.execute(
|
|
20
|
+
db,
|
|
21
|
+
);
|
|
22
|
+
await sql`
|
|
23
|
+
ALTER TABLE tenants
|
|
24
|
+
ADD COLUMN last_active_at timestamptz NOT NULL DEFAULT now()
|
|
25
|
+
`.execute(db);
|
|
26
|
+
await sql`
|
|
27
|
+
CREATE INDEX tenants_last_active_idx
|
|
28
|
+
ON tenants (plan, last_active_at)
|
|
29
|
+
WHERE status = 'active'
|
|
30
|
+
`.execute(db);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
34
|
+
await sql`DROP INDEX IF EXISTS tenants_last_active_idx`.execute(db);
|
|
35
|
+
await sql`ALTER TABLE tenants DROP COLUMN IF EXISTS last_active_at`.execute(
|
|
36
|
+
db,
|
|
37
|
+
);
|
|
38
|
+
await sql`
|
|
39
|
+
ALTER TABLE tenants
|
|
40
|
+
ADD COLUMN trial_ends_at timestamptz NOT NULL DEFAULT (now() + interval '14 days')
|
|
41
|
+
`.execute(db);
|
|
42
|
+
await sql`
|
|
43
|
+
CREATE INDEX tenants_trial_ends_idx
|
|
44
|
+
ON tenants (trial_ends_at)
|
|
45
|
+
WHERE status IN ('provisioning', 'active')
|
|
46
|
+
`.execute(db);
|
|
47
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type Kysely, sql } from "kysely";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Tenant-scope the `usage_daily` table so Stripe metering (Sprint C) can
|
|
5
|
+
* bill per-tenant, not per-account. Account-level billing worked when
|
|
6
|
+
* accounts were 1:1 with tenants; once we adopt org-level billing where
|
|
7
|
+
* an account owns multiple projects (each = one tenant), we need the
|
|
8
|
+
* tenant dimension.
|
|
9
|
+
*
|
|
10
|
+
* - `tenant_id` added nullable — existing rows predate the column.
|
|
11
|
+
* Backfill is best-effort: rows where the account has exactly one
|
|
12
|
+
* tenant get that tenant's id; ambiguous rows stay NULL.
|
|
13
|
+
* - Unique constraint relaxed from `(account_id, date)` to
|
|
14
|
+
* `(account_id, tenant_id, date)` (NULLs treated as distinct per
|
|
15
|
+
* Postgres default) so future per-tenant rows don't collide with
|
|
16
|
+
* account-level history.
|
|
17
|
+
*/
|
|
18
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
19
|
+
await sql`SET lock_timeout = '30s'`.execute(db);
|
|
20
|
+
|
|
21
|
+
await sql`
|
|
22
|
+
ALTER TABLE usage_daily
|
|
23
|
+
ADD COLUMN IF NOT EXISTS tenant_id uuid REFERENCES tenants(id) ON DELETE SET NULL
|
|
24
|
+
`.execute(db);
|
|
25
|
+
|
|
26
|
+
// Best-effort backfill — only fill rows where the account has a single
|
|
27
|
+
// tenant. Ambiguous accounts (multi-tenant) stay NULL; Sprint C starts
|
|
28
|
+
// writing tenant_id on every new row.
|
|
29
|
+
await sql`
|
|
30
|
+
UPDATE usage_daily u
|
|
31
|
+
SET tenant_id = t.id
|
|
32
|
+
FROM tenants t
|
|
33
|
+
WHERE u.tenant_id IS NULL
|
|
34
|
+
AND t.account_id = u.account_id
|
|
35
|
+
AND t.status <> 'deleted'
|
|
36
|
+
AND NOT EXISTS (
|
|
37
|
+
SELECT 1 FROM tenants t2
|
|
38
|
+
WHERE t2.account_id = u.account_id
|
|
39
|
+
AND t2.id <> t.id
|
|
40
|
+
AND t2.status <> 'deleted'
|
|
41
|
+
)
|
|
42
|
+
`.execute(db);
|
|
43
|
+
|
|
44
|
+
// Drop old PK/unique so we can widen to include tenant_id.
|
|
45
|
+
await sql`
|
|
46
|
+
ALTER TABLE usage_daily DROP CONSTRAINT IF EXISTS usage_daily_pkey
|
|
47
|
+
`.execute(db);
|
|
48
|
+
await sql`
|
|
49
|
+
ALTER TABLE usage_daily
|
|
50
|
+
ADD CONSTRAINT usage_daily_pkey
|
|
51
|
+
UNIQUE (account_id, tenant_id, date)
|
|
52
|
+
`.execute(db);
|
|
53
|
+
|
|
54
|
+
await sql`
|
|
55
|
+
CREATE INDEX IF NOT EXISTS usage_daily_tenant_date_idx
|
|
56
|
+
ON usage_daily (tenant_id, date DESC)
|
|
57
|
+
`.execute(db);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
61
|
+
await sql`DROP INDEX IF EXISTS usage_daily_tenant_date_idx`.execute(db);
|
|
62
|
+
await sql`
|
|
63
|
+
ALTER TABLE usage_daily DROP CONSTRAINT IF EXISTS usage_daily_pkey
|
|
64
|
+
`.execute(db);
|
|
65
|
+
await sql`
|
|
66
|
+
ALTER TABLE usage_daily
|
|
67
|
+
ADD CONSTRAINT usage_daily_pkey
|
|
68
|
+
PRIMARY KEY (account_id, date)
|
|
69
|
+
`.execute(db);
|
|
70
|
+
await sql`ALTER TABLE usage_daily DROP COLUMN IF EXISTS tenant_id`.execute(
|
|
71
|
+
db,
|
|
72
|
+
);
|
|
73
|
+
}
|