@constructive-io/sdk 0.20.9 → 0.21.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.
@@ -35,6 +35,7 @@ import { AppLimitEventModel } from './models/appLimitEvent';
35
35
  import { OrgLimitEventModel } from './models/orgLimitEvent';
36
36
  import { OrgGrantModel } from './models/orgGrant';
37
37
  import { OrgChartEdgeModel } from './models/orgChartEdge';
38
+ import { UsageSnapshotModel } from './models/usageSnapshot';
38
39
  import { OrgMemberProfileModel } from './models/orgMemberProfile';
39
40
  import { AppLevelModel } from './models/appLevel';
40
41
  import { AppLimitModel } from './models/appLimit';
@@ -112,6 +113,7 @@ export declare function createClient(config: OrmClientConfig): {
112
113
  orgLimitEvent: OrgLimitEventModel;
113
114
  orgGrant: OrgGrantModel;
114
115
  orgChartEdge: OrgChartEdgeModel;
116
+ usageSnapshot: UsageSnapshotModel;
115
117
  orgMemberProfile: OrgMemberProfileModel;
116
118
  appLevel: AppLevelModel;
117
119
  appLimit: AppLimitModel;
@@ -58,6 +58,7 @@ const appLimitEvent_1 = require("./models/appLimitEvent");
58
58
  const orgLimitEvent_1 = require("./models/orgLimitEvent");
59
59
  const orgGrant_1 = require("./models/orgGrant");
60
60
  const orgChartEdge_1 = require("./models/orgChartEdge");
61
+ const usageSnapshot_1 = require("./models/usageSnapshot");
61
62
  const orgMemberProfile_1 = require("./models/orgMemberProfile");
62
63
  const appLevel_1 = require("./models/appLevel");
63
64
  const appLimit_1 = require("./models/appLimit");
@@ -142,6 +143,7 @@ function createClient(config) {
142
143
  orgLimitEvent: new orgLimitEvent_1.OrgLimitEventModel(client),
143
144
  orgGrant: new orgGrant_1.OrgGrantModel(client),
144
145
  orgChartEdge: new orgChartEdge_1.OrgChartEdgeModel(client),
146
+ usageSnapshot: new usageSnapshot_1.UsageSnapshotModel(client),
145
147
  orgMemberProfile: new orgMemberProfile_1.OrgMemberProfileModel(client),
146
148
  appLevel: new appLevel_1.AppLevelModel(client),
147
149
  appLimit: new appLimit_1.AppLimitModel(client),
@@ -661,6 +661,20 @@ export interface OrgChartEdge {
661
661
  /** Numeric seniority level for this position (higher = more senior) */
662
662
  positionLevel?: number | null;
663
663
  }
664
+ /** Periodic snapshot of a single metric for a database. Collected by the snapshot_usage() cron job in constructive-limits. Each row records one metric measurement (e.g. reads, writes, storage_bytes) at a point in time, with optional dimensions for sub-metric breakdowns. */
665
+ export interface UsageSnapshot {
666
+ /** The database this snapshot belongs to. References metaschema_public.database.id but declared without an FK constraint — the snapshot collector runs in a platform context where the FK would add overhead without value. */
667
+ databaseId?: string | null;
668
+ /** Identifier for the metric being measured (e.g. 'reads', 'writes', 'storage_bytes', 'compute_time_ms'). */
669
+ metricName?: string | null;
670
+ /** The measured value at the time of capture. Interpretation depends on metric_name (count, bytes, milliseconds, etc.). */
671
+ metricValue?: string | null;
672
+ /** Optional sub-metric breakdowns as key-value pairs (e.g. {"query_type": "select"} for reads). Empty object when no breakdown is needed. */
673
+ dimensions?: Record<string, unknown> | null;
674
+ /** When this snapshot was taken. Defaults to the current timestamp; the snapshot collector may override this for backdated imports. */
675
+ capturedAt?: string | null;
676
+ id: string;
677
+ }
664
678
  /** Per-membership profile information visible to other entity members (display name, email, title, bio, avatar) */
665
679
  export interface OrgMemberProfile {
666
680
  id: string;
@@ -1008,6 +1022,8 @@ export interface OrgGrantRelations {
1008
1022
  }
1009
1023
  export interface OrgChartEdgeRelations {
1010
1024
  }
1025
+ export interface UsageSnapshotRelations {
1026
+ }
1011
1027
  export interface OrgMemberProfileRelations {
1012
1028
  membership?: OrgMembership | null;
1013
1029
  }
@@ -1066,6 +1082,7 @@ export type AppLimitEventWithRelations = AppLimitEvent & AppLimitEventRelations;
1066
1082
  export type OrgLimitEventWithRelations = OrgLimitEvent & OrgLimitEventRelations;
1067
1083
  export type OrgGrantWithRelations = OrgGrant & OrgGrantRelations;
1068
1084
  export type OrgChartEdgeWithRelations = OrgChartEdge & OrgChartEdgeRelations;
1085
+ export type UsageSnapshotWithRelations = UsageSnapshot & UsageSnapshotRelations;
1069
1086
  export type OrgMemberProfileWithRelations = OrgMemberProfile & OrgMemberProfileRelations;
1070
1087
  export type AppLevelWithRelations = AppLevel & AppLevelRelations;
1071
1088
  export type AppLimitWithRelations = AppLimit & AppLimitRelations;
@@ -1393,6 +1410,14 @@ export type OrgChartEdgeSelect = {
1393
1410
  positionTitle?: boolean;
1394
1411
  positionLevel?: boolean;
1395
1412
  };
1413
+ export type UsageSnapshotSelect = {
1414
+ databaseId?: boolean;
1415
+ metricName?: boolean;
1416
+ metricValue?: boolean;
1417
+ dimensions?: boolean;
1418
+ capturedAt?: boolean;
1419
+ id?: boolean;
1420
+ };
1396
1421
  export type OrgMemberProfileSelect = {
1397
1422
  id?: boolean;
1398
1423
  createdAt?: boolean;
@@ -2252,6 +2277,26 @@ export interface OrgChartEdgeFilter {
2252
2277
  /** Negates the expression. */
2253
2278
  not?: OrgChartEdgeFilter;
2254
2279
  }
2280
+ export interface UsageSnapshotFilter {
2281
+ /** Filter by the object’s `databaseId` field. */
2282
+ databaseId?: UUIDFilter;
2283
+ /** Filter by the object’s `metricName` field. */
2284
+ metricName?: StringFilter;
2285
+ /** Filter by the object’s `metricValue` field. */
2286
+ metricValue?: BigIntFilter;
2287
+ /** Filter by the object’s `dimensions` field. */
2288
+ dimensions?: JSONFilter;
2289
+ /** Filter by the object’s `capturedAt` field. */
2290
+ capturedAt?: DatetimeFilter;
2291
+ /** Filter by the object’s `id` field. */
2292
+ id?: UUIDFilter;
2293
+ /** Checks for all expressions in this list. */
2294
+ and?: UsageSnapshotFilter[];
2295
+ /** Checks for any expressions in this list. */
2296
+ or?: UsageSnapshotFilter[];
2297
+ /** Negates the expression. */
2298
+ not?: UsageSnapshotFilter;
2299
+ }
2255
2300
  export interface OrgMemberProfileFilter {
2256
2301
  /** Filter by the object’s `id` field. */
2257
2302
  id?: UUIDFilter;
@@ -2628,6 +2673,7 @@ export type AppLimitEventOrderBy = 'NATURAL' | 'NAME_ASC' | 'NAME_DESC' | 'ACTOR
2628
2673
  export type OrgLimitEventOrderBy = 'NATURAL' | 'NAME_ASC' | 'NAME_DESC' | 'ACTOR_ID_ASC' | 'ACTOR_ID_DESC' | 'ENTITY_ID_ASC' | 'ENTITY_ID_DESC' | 'EVENT_TYPE_ASC' | 'EVENT_TYPE_DESC' | 'DELTA_ASC' | 'DELTA_DESC' | 'NUM_BEFORE_ASC' | 'NUM_BEFORE_DESC' | 'NUM_AFTER_ASC' | 'NUM_AFTER_DESC' | 'MAX_AT_EVENT_ASC' | 'MAX_AT_EVENT_DESC' | 'REASON_ASC' | 'REASON_DESC';
2629
2674
  export type OrgGrantOrderBy = 'NATURAL' | 'PRIMARY_KEY_ASC' | 'PRIMARY_KEY_DESC' | 'ID_ASC' | 'ID_DESC' | 'PERMISSIONS_ASC' | 'PERMISSIONS_DESC' | 'IS_GRANT_ASC' | 'IS_GRANT_DESC' | 'ACTOR_ID_ASC' | 'ACTOR_ID_DESC' | 'ENTITY_ID_ASC' | 'ENTITY_ID_DESC' | 'GRANTOR_ID_ASC' | 'GRANTOR_ID_DESC' | 'CREATED_AT_ASC' | 'CREATED_AT_DESC' | 'UPDATED_AT_ASC' | 'UPDATED_AT_DESC';
2630
2675
  export type OrgChartEdgeOrderBy = 'NATURAL' | 'PRIMARY_KEY_ASC' | 'PRIMARY_KEY_DESC' | 'ID_ASC' | 'ID_DESC' | 'CREATED_AT_ASC' | 'CREATED_AT_DESC' | 'UPDATED_AT_ASC' | 'UPDATED_AT_DESC' | 'ENTITY_ID_ASC' | 'ENTITY_ID_DESC' | 'CHILD_ID_ASC' | 'CHILD_ID_DESC' | 'PARENT_ID_ASC' | 'PARENT_ID_DESC' | 'POSITION_TITLE_ASC' | 'POSITION_TITLE_DESC' | 'POSITION_LEVEL_ASC' | 'POSITION_LEVEL_DESC';
2676
+ export type UsageSnapshotOrderBy = 'NATURAL' | 'PRIMARY_KEY_ASC' | 'PRIMARY_KEY_DESC' | 'DATABASE_ID_ASC' | 'DATABASE_ID_DESC' | 'METRIC_NAME_ASC' | 'METRIC_NAME_DESC' | 'METRIC_VALUE_ASC' | 'METRIC_VALUE_DESC' | 'DIMENSIONS_ASC' | 'DIMENSIONS_DESC' | 'CAPTURED_AT_ASC' | 'CAPTURED_AT_DESC' | 'ID_ASC' | 'ID_DESC';
2631
2677
  export type OrgMemberProfileOrderBy = 'NATURAL' | 'PRIMARY_KEY_ASC' | 'PRIMARY_KEY_DESC' | 'ID_ASC' | 'ID_DESC' | 'CREATED_AT_ASC' | 'CREATED_AT_DESC' | 'UPDATED_AT_ASC' | 'UPDATED_AT_DESC' | 'MEMBERSHIP_ID_ASC' | 'MEMBERSHIP_ID_DESC' | 'ENTITY_ID_ASC' | 'ENTITY_ID_DESC' | 'ACTOR_ID_ASC' | 'ACTOR_ID_DESC' | 'DISPLAY_NAME_ASC' | 'DISPLAY_NAME_DESC' | 'EMAIL_ASC' | 'EMAIL_DESC' | 'TITLE_ASC' | 'TITLE_DESC' | 'BIO_ASC' | 'BIO_DESC' | 'PROFILE_PICTURE_ASC' | 'PROFILE_PICTURE_DESC';
2632
2678
  export type AppLevelOrderBy = 'NATURAL' | 'PRIMARY_KEY_ASC' | 'PRIMARY_KEY_DESC' | 'ID_ASC' | 'ID_DESC' | 'NAME_ASC' | 'NAME_DESC' | 'DESCRIPTION_ASC' | 'DESCRIPTION_DESC' | 'IMAGE_ASC' | 'IMAGE_DESC' | 'OWNER_ID_ASC' | 'OWNER_ID_DESC' | 'CREATED_AT_ASC' | 'CREATED_AT_DESC' | 'UPDATED_AT_ASC' | 'UPDATED_AT_DESC';
2633
2679
  export type AppLimitOrderBy = 'NATURAL' | 'PRIMARY_KEY_ASC' | 'PRIMARY_KEY_DESC' | 'ID_ASC' | 'ID_DESC' | 'NAME_ASC' | 'NAME_DESC' | 'ACTOR_ID_ASC' | 'ACTOR_ID_DESC' | 'NUM_ASC' | 'NUM_DESC' | 'MAX_ASC' | 'MAX_DESC' | 'SOFT_MAX_ASC' | 'SOFT_MAX_DESC' | 'WINDOW_START_ASC' | 'WINDOW_START_DESC' | 'WINDOW_DURATION_ASC' | 'WINDOW_DURATION_DESC' | 'PLAN_MAX_ASC' | 'PLAN_MAX_DESC' | 'PURCHASED_CREDITS_ASC' | 'PURCHASED_CREDITS_DESC' | 'PERIOD_CREDITS_ASC' | 'PERIOD_CREDITS_DESC';
@@ -3492,6 +3538,32 @@ export interface DeleteOrgChartEdgeInput {
3492
3538
  clientMutationId?: string;
3493
3539
  id: string;
3494
3540
  }
3541
+ export interface CreateUsageSnapshotInput {
3542
+ clientMutationId?: string;
3543
+ usageSnapshot: {
3544
+ databaseId: string;
3545
+ metricName: string;
3546
+ metricValue?: string;
3547
+ dimensions?: Record<string, unknown>;
3548
+ capturedAt?: string;
3549
+ };
3550
+ }
3551
+ export interface UsageSnapshotPatch {
3552
+ databaseId?: string | null;
3553
+ metricName?: string | null;
3554
+ metricValue?: string | null;
3555
+ dimensions?: Record<string, unknown> | null;
3556
+ capturedAt?: string | null;
3557
+ }
3558
+ export interface UpdateUsageSnapshotInput {
3559
+ clientMutationId?: string;
3560
+ id: string;
3561
+ usageSnapshotPatch: UsageSnapshotPatch;
3562
+ }
3563
+ export interface DeleteUsageSnapshotInput {
3564
+ clientMutationId?: string;
3565
+ id: string;
3566
+ }
3495
3567
  export interface CreateOrgMemberProfileInput {
3496
3568
  clientMutationId?: string;
3497
3569
  orgMemberProfile: {
@@ -5978,6 +6050,51 @@ export type DeleteOrgChartEdgePayloadSelect = {
5978
6050
  select: OrgChartEdgeEdgeSelect;
5979
6051
  };
5980
6052
  };
6053
+ export interface CreateUsageSnapshotPayload {
6054
+ clientMutationId?: string | null;
6055
+ /** The `UsageSnapshot` that was created by this mutation. */
6056
+ usageSnapshot?: UsageSnapshot | null;
6057
+ usageSnapshotEdge?: UsageSnapshotEdge | null;
6058
+ }
6059
+ export type CreateUsageSnapshotPayloadSelect = {
6060
+ clientMutationId?: boolean;
6061
+ usageSnapshot?: {
6062
+ select: UsageSnapshotSelect;
6063
+ };
6064
+ usageSnapshotEdge?: {
6065
+ select: UsageSnapshotEdgeSelect;
6066
+ };
6067
+ };
6068
+ export interface UpdateUsageSnapshotPayload {
6069
+ clientMutationId?: string | null;
6070
+ /** The `UsageSnapshot` that was updated by this mutation. */
6071
+ usageSnapshot?: UsageSnapshot | null;
6072
+ usageSnapshotEdge?: UsageSnapshotEdge | null;
6073
+ }
6074
+ export type UpdateUsageSnapshotPayloadSelect = {
6075
+ clientMutationId?: boolean;
6076
+ usageSnapshot?: {
6077
+ select: UsageSnapshotSelect;
6078
+ };
6079
+ usageSnapshotEdge?: {
6080
+ select: UsageSnapshotEdgeSelect;
6081
+ };
6082
+ };
6083
+ export interface DeleteUsageSnapshotPayload {
6084
+ clientMutationId?: string | null;
6085
+ /** The `UsageSnapshot` that was deleted by this mutation. */
6086
+ usageSnapshot?: UsageSnapshot | null;
6087
+ usageSnapshotEdge?: UsageSnapshotEdge | null;
6088
+ }
6089
+ export type DeleteUsageSnapshotPayloadSelect = {
6090
+ clientMutationId?: boolean;
6091
+ usageSnapshot?: {
6092
+ select: UsageSnapshotSelect;
6093
+ };
6094
+ usageSnapshotEdge?: {
6095
+ select: UsageSnapshotEdgeSelect;
6096
+ };
6097
+ };
5981
6098
  export interface CreateOrgMemberProfilePayload {
5982
6099
  clientMutationId?: string | null;
5983
6100
  /** The `OrgMemberProfile` that was created by this mutation. */
@@ -6829,6 +6946,18 @@ export type OrgChartEdgeEdgeSelect = {
6829
6946
  select: OrgChartEdgeSelect;
6830
6947
  };
6831
6948
  };
6949
+ /** A `UsageSnapshot` edge in the connection. */
6950
+ export interface UsageSnapshotEdge {
6951
+ cursor?: string | null;
6952
+ /** The `UsageSnapshot` at the end of the edge. */
6953
+ node?: UsageSnapshot | null;
6954
+ }
6955
+ export type UsageSnapshotEdgeSelect = {
6956
+ cursor?: boolean;
6957
+ node?: {
6958
+ select: UsageSnapshotSelect;
6959
+ };
6960
+ };
6832
6961
  /** A `OrgMemberProfile` edge in the connection. */
6833
6962
  export interface OrgMemberProfileEdge {
6834
6963
  cursor?: string | null;
@@ -39,6 +39,7 @@ export { AppLimitEventModel } from './appLimitEvent';
39
39
  export { OrgLimitEventModel } from './orgLimitEvent';
40
40
  export { OrgGrantModel } from './orgGrant';
41
41
  export { OrgChartEdgeModel } from './orgChartEdge';
42
+ export { UsageSnapshotModel } from './usageSnapshot';
42
43
  export { OrgMemberProfileModel } from './orgMemberProfile';
43
44
  export { AppLevelModel } from './appLevel';
44
45
  export { AppLimitModel } from './appLimit';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OrgMembershipModel = exports.AppMembershipModel = exports.OrgInviteModel = exports.OrgLimitModel = exports.OrgLimitAggregateModel = exports.OrgMembershipSettingModel = exports.AppInviteModel = exports.AppLimitModel = exports.AppLevelModel = exports.OrgMemberProfileModel = exports.OrgChartEdgeModel = exports.OrgGrantModel = exports.OrgLimitEventModel = exports.AppLimitEventModel = exports.OrgClaimedInviteModel = exports.OrgMembershipDefaultModel = exports.AppMembershipDefaultModel = exports.AppGrantModel = exports.AppClaimedInviteModel = exports.OrgChartEdgeGrantModel = exports.OrgLimitCreditModel = exports.OrgLimitDefaultModel = exports.AppLimitDefaultModel = exports.MembershipTypeModel = exports.OrgOwnerGrantModel = exports.OrgAdminGrantModel = exports.OrgLimitCapModel = exports.AppLimitCapModel = exports.OrgLimitCapsDefaultModel = exports.AppLimitCapsDefaultModel = exports.AppStepModel = exports.AppAchievementModel = exports.AppOwnerGrantModel = exports.AppAdminGrantModel = exports.OrgPermissionDefaultModel = exports.AppLimitCreditCodeModel = exports.AppPermissionDefaultModel = exports.OrgMemberModel = exports.AppLimitCreditModel = exports.AppLimitCreditCodeItemModel = exports.AppLimitCreditRedemptionModel = exports.AppLevelRequirementModel = exports.OrgPermissionModel = exports.AppPermissionModel = exports.OrgGetSubordinatesRecordModel = exports.OrgGetManagersRecordModel = void 0;
3
+ exports.OrgMembershipModel = exports.AppMembershipModel = exports.OrgInviteModel = exports.OrgLimitModel = exports.OrgLimitAggregateModel = exports.OrgMembershipSettingModel = exports.AppInviteModel = exports.AppLimitModel = exports.AppLevelModel = exports.OrgMemberProfileModel = exports.UsageSnapshotModel = exports.OrgChartEdgeModel = exports.OrgGrantModel = exports.OrgLimitEventModel = exports.AppLimitEventModel = exports.OrgClaimedInviteModel = exports.OrgMembershipDefaultModel = exports.AppMembershipDefaultModel = exports.AppGrantModel = exports.AppClaimedInviteModel = exports.OrgChartEdgeGrantModel = exports.OrgLimitCreditModel = exports.OrgLimitDefaultModel = exports.AppLimitDefaultModel = exports.MembershipTypeModel = exports.OrgOwnerGrantModel = exports.OrgAdminGrantModel = exports.OrgLimitCapModel = exports.AppLimitCapModel = exports.OrgLimitCapsDefaultModel = exports.AppLimitCapsDefaultModel = exports.AppStepModel = exports.AppAchievementModel = exports.AppOwnerGrantModel = exports.AppAdminGrantModel = exports.OrgPermissionDefaultModel = exports.AppLimitCreditCodeModel = exports.AppPermissionDefaultModel = exports.OrgMemberModel = exports.AppLimitCreditModel = exports.AppLimitCreditCodeItemModel = exports.AppLimitCreditRedemptionModel = exports.AppLevelRequirementModel = exports.OrgPermissionModel = exports.AppPermissionModel = exports.OrgGetSubordinatesRecordModel = exports.OrgGetManagersRecordModel = void 0;
4
4
  /**
5
5
  * Models barrel export
6
6
  * @generated by @constructive-io/graphql-codegen
@@ -78,6 +78,8 @@ var orgGrant_1 = require("./orgGrant");
78
78
  Object.defineProperty(exports, "OrgGrantModel", { enumerable: true, get: function () { return orgGrant_1.OrgGrantModel; } });
79
79
  var orgChartEdge_1 = require("./orgChartEdge");
80
80
  Object.defineProperty(exports, "OrgChartEdgeModel", { enumerable: true, get: function () { return orgChartEdge_1.OrgChartEdgeModel; } });
81
+ var usageSnapshot_1 = require("./usageSnapshot");
82
+ Object.defineProperty(exports, "UsageSnapshotModel", { enumerable: true, get: function () { return usageSnapshot_1.UsageSnapshotModel; } });
81
83
  var orgMemberProfile_1 = require("./orgMemberProfile");
82
84
  Object.defineProperty(exports, "OrgMemberProfileModel", { enumerable: true, get: function () { return orgMemberProfile_1.OrgMemberProfileModel; } });
83
85
  var appLevel_1 = require("./appLevel");
@@ -0,0 +1,56 @@
1
+ /**
2
+ * UsageSnapshot model for ORM client
3
+ * @generated by @constructive-io/graphql-codegen
4
+ * DO NOT EDIT - changes will be overwritten
5
+ */
6
+ import { OrmClient } from '../client';
7
+ import { QueryBuilder } from '../query-builder';
8
+ import type { ConnectionResult, FindManyArgs, FindFirstArgs, CreateArgs, UpdateArgs, DeleteArgs, InferSelectResult, StrictSelect } from '../select-types';
9
+ import type { UsageSnapshotWithRelations, UsageSnapshotSelect, UsageSnapshotFilter, UsageSnapshotOrderBy, CreateUsageSnapshotInput, UsageSnapshotPatch } from '../input-types';
10
+ export declare class UsageSnapshotModel {
11
+ private client;
12
+ constructor(client: OrmClient);
13
+ findMany<S extends UsageSnapshotSelect>(args: FindManyArgs<S, UsageSnapshotFilter, UsageSnapshotOrderBy> & {
14
+ select: S;
15
+ } & StrictSelect<S, UsageSnapshotSelect>): QueryBuilder<{
16
+ usageSnapshots: ConnectionResult<InferSelectResult<UsageSnapshotWithRelations, S>>;
17
+ }>;
18
+ findFirst<S extends UsageSnapshotSelect>(args: FindFirstArgs<S, UsageSnapshotFilter> & {
19
+ select: S;
20
+ } & StrictSelect<S, UsageSnapshotSelect>): QueryBuilder<{
21
+ usageSnapshots: {
22
+ nodes: InferSelectResult<UsageSnapshotWithRelations, S>[];
23
+ };
24
+ }>;
25
+ findOne<S extends UsageSnapshotSelect>(args: {
26
+ id: string;
27
+ select: S;
28
+ } & StrictSelect<S, UsageSnapshotSelect>): QueryBuilder<{
29
+ usageSnapshot: InferSelectResult<UsageSnapshotWithRelations, S> | null;
30
+ }>;
31
+ create<S extends UsageSnapshotSelect>(args: CreateArgs<S, CreateUsageSnapshotInput['usageSnapshot']> & {
32
+ select: S;
33
+ } & StrictSelect<S, UsageSnapshotSelect>): QueryBuilder<{
34
+ createUsageSnapshot: {
35
+ usageSnapshot: InferSelectResult<UsageSnapshotWithRelations, S>;
36
+ };
37
+ }>;
38
+ update<S extends UsageSnapshotSelect>(args: UpdateArgs<S, {
39
+ id: string;
40
+ }, UsageSnapshotPatch> & {
41
+ select: S;
42
+ } & StrictSelect<S, UsageSnapshotSelect>): QueryBuilder<{
43
+ updateUsageSnapshot: {
44
+ usageSnapshot: InferSelectResult<UsageSnapshotWithRelations, S>;
45
+ };
46
+ }>;
47
+ delete<S extends UsageSnapshotSelect>(args: DeleteArgs<{
48
+ id: string;
49
+ }, S> & {
50
+ select: S;
51
+ } & StrictSelect<S, UsageSnapshotSelect>): QueryBuilder<{
52
+ deleteUsageSnapshot: {
53
+ usageSnapshot: InferSelectResult<UsageSnapshotWithRelations, S>;
54
+ };
55
+ }>;
56
+ }
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UsageSnapshotModel = void 0;
4
+ const query_builder_1 = require("../query-builder");
5
+ const input_types_1 = require("../input-types");
6
+ class UsageSnapshotModel {
7
+ client;
8
+ constructor(client) {
9
+ this.client = client;
10
+ }
11
+ findMany(args) {
12
+ const { document, variables } = (0, query_builder_1.buildFindManyDocument)('UsageSnapshot', 'usageSnapshots', args.select, {
13
+ where: args?.where,
14
+ orderBy: args?.orderBy,
15
+ first: args?.first,
16
+ last: args?.last,
17
+ after: args?.after,
18
+ before: args?.before,
19
+ offset: args?.offset,
20
+ }, 'UsageSnapshotFilter', 'UsageSnapshotOrderBy', input_types_1.connectionFieldsMap);
21
+ return new query_builder_1.QueryBuilder({
22
+ client: this.client,
23
+ operation: 'query',
24
+ operationName: 'UsageSnapshot',
25
+ fieldName: 'usageSnapshots',
26
+ document,
27
+ variables,
28
+ });
29
+ }
30
+ findFirst(args) {
31
+ const { document, variables } = (0, query_builder_1.buildFindFirstDocument)('UsageSnapshot', 'usageSnapshots', args.select, {
32
+ where: args?.where,
33
+ }, 'UsageSnapshotFilter', input_types_1.connectionFieldsMap);
34
+ return new query_builder_1.QueryBuilder({
35
+ client: this.client,
36
+ operation: 'query',
37
+ operationName: 'UsageSnapshot',
38
+ fieldName: 'usageSnapshots',
39
+ document,
40
+ variables,
41
+ });
42
+ }
43
+ findOne(args) {
44
+ const { document, variables } = (0, query_builder_1.buildFindManyDocument)('UsageSnapshot', 'usageSnapshots', args.select, {
45
+ where: {
46
+ id: {
47
+ equalTo: args.id,
48
+ },
49
+ },
50
+ first: 1,
51
+ }, 'UsageSnapshotFilter', 'UsageSnapshotOrderBy', input_types_1.connectionFieldsMap);
52
+ return new query_builder_1.QueryBuilder({
53
+ client: this.client,
54
+ operation: 'query',
55
+ operationName: 'UsageSnapshot',
56
+ fieldName: 'usageSnapshot',
57
+ document,
58
+ variables,
59
+ transform: (data) => ({
60
+ usageSnapshot: data.usageSnapshots?.nodes?.[0] ?? null,
61
+ }),
62
+ });
63
+ }
64
+ create(args) {
65
+ const { document, variables } = (0, query_builder_1.buildCreateDocument)('UsageSnapshot', 'createUsageSnapshot', 'usageSnapshot', args.select, args.data, 'CreateUsageSnapshotInput', input_types_1.connectionFieldsMap);
66
+ return new query_builder_1.QueryBuilder({
67
+ client: this.client,
68
+ operation: 'mutation',
69
+ operationName: 'UsageSnapshot',
70
+ fieldName: 'createUsageSnapshot',
71
+ document,
72
+ variables,
73
+ });
74
+ }
75
+ update(args) {
76
+ const { document, variables } = (0, query_builder_1.buildUpdateByPkDocument)('UsageSnapshot', 'updateUsageSnapshot', 'usageSnapshot', args.select, args.where.id, args.data, 'UpdateUsageSnapshotInput', 'id', 'usageSnapshotPatch', input_types_1.connectionFieldsMap);
77
+ return new query_builder_1.QueryBuilder({
78
+ client: this.client,
79
+ operation: 'mutation',
80
+ operationName: 'UsageSnapshot',
81
+ fieldName: 'updateUsageSnapshot',
82
+ document,
83
+ variables,
84
+ });
85
+ }
86
+ delete(args) {
87
+ const { document, variables } = (0, query_builder_1.buildDeleteByPkDocument)('UsageSnapshot', 'deleteUsageSnapshot', 'usageSnapshot', {
88
+ id: args.where.id,
89
+ }, 'DeleteUsageSnapshotInput', args.select, input_types_1.connectionFieldsMap);
90
+ return new query_builder_1.QueryBuilder({
91
+ client: this.client,
92
+ operation: 'mutation',
93
+ operationName: 'UsageSnapshot',
94
+ fieldName: 'deleteUsageSnapshot',
95
+ document,
96
+ variables,
97
+ });
98
+ }
99
+ }
100
+ exports.UsageSnapshotModel = UsageSnapshotModel;
@@ -35,6 +35,7 @@ import { AppLimitEventModel } from './models/appLimitEvent';
35
35
  import { OrgLimitEventModel } from './models/orgLimitEvent';
36
36
  import { OrgGrantModel } from './models/orgGrant';
37
37
  import { OrgChartEdgeModel } from './models/orgChartEdge';
38
+ import { UsageSnapshotModel } from './models/usageSnapshot';
38
39
  import { OrgMemberProfileModel } from './models/orgMemberProfile';
39
40
  import { AppLevelModel } from './models/appLevel';
40
41
  import { AppLimitModel } from './models/appLimit';
@@ -112,6 +113,7 @@ export declare function createClient(config: OrmClientConfig): {
112
113
  orgLimitEvent: OrgLimitEventModel;
113
114
  orgGrant: OrgGrantModel;
114
115
  orgChartEdge: OrgChartEdgeModel;
116
+ usageSnapshot: UsageSnapshotModel;
115
117
  orgMemberProfile: OrgMemberProfileModel;
116
118
  appLevel: AppLevelModel;
117
119
  appLimit: AppLimitModel;
@@ -40,6 +40,7 @@ import { AppLimitEventModel } from './models/appLimitEvent';
40
40
  import { OrgLimitEventModel } from './models/orgLimitEvent';
41
41
  import { OrgGrantModel } from './models/orgGrant';
42
42
  import { OrgChartEdgeModel } from './models/orgChartEdge';
43
+ import { UsageSnapshotModel } from './models/usageSnapshot';
43
44
  import { OrgMemberProfileModel } from './models/orgMemberProfile';
44
45
  import { AppLevelModel } from './models/appLevel';
45
46
  import { AppLimitModel } from './models/appLimit';
@@ -120,6 +121,7 @@ export function createClient(config) {
120
121
  orgLimitEvent: new OrgLimitEventModel(client),
121
122
  orgGrant: new OrgGrantModel(client),
122
123
  orgChartEdge: new OrgChartEdgeModel(client),
124
+ usageSnapshot: new UsageSnapshotModel(client),
123
125
  orgMemberProfile: new OrgMemberProfileModel(client),
124
126
  appLevel: new AppLevelModel(client),
125
127
  appLimit: new AppLimitModel(client),
@@ -661,6 +661,20 @@ export interface OrgChartEdge {
661
661
  /** Numeric seniority level for this position (higher = more senior) */
662
662
  positionLevel?: number | null;
663
663
  }
664
+ /** Periodic snapshot of a single metric for a database. Collected by the snapshot_usage() cron job in constructive-limits. Each row records one metric measurement (e.g. reads, writes, storage_bytes) at a point in time, with optional dimensions for sub-metric breakdowns. */
665
+ export interface UsageSnapshot {
666
+ /** The database this snapshot belongs to. References metaschema_public.database.id but declared without an FK constraint — the snapshot collector runs in a platform context where the FK would add overhead without value. */
667
+ databaseId?: string | null;
668
+ /** Identifier for the metric being measured (e.g. 'reads', 'writes', 'storage_bytes', 'compute_time_ms'). */
669
+ metricName?: string | null;
670
+ /** The measured value at the time of capture. Interpretation depends on metric_name (count, bytes, milliseconds, etc.). */
671
+ metricValue?: string | null;
672
+ /** Optional sub-metric breakdowns as key-value pairs (e.g. {"query_type": "select"} for reads). Empty object when no breakdown is needed. */
673
+ dimensions?: Record<string, unknown> | null;
674
+ /** When this snapshot was taken. Defaults to the current timestamp; the snapshot collector may override this for backdated imports. */
675
+ capturedAt?: string | null;
676
+ id: string;
677
+ }
664
678
  /** Per-membership profile information visible to other entity members (display name, email, title, bio, avatar) */
665
679
  export interface OrgMemberProfile {
666
680
  id: string;
@@ -1008,6 +1022,8 @@ export interface OrgGrantRelations {
1008
1022
  }
1009
1023
  export interface OrgChartEdgeRelations {
1010
1024
  }
1025
+ export interface UsageSnapshotRelations {
1026
+ }
1011
1027
  export interface OrgMemberProfileRelations {
1012
1028
  membership?: OrgMembership | null;
1013
1029
  }
@@ -1066,6 +1082,7 @@ export type AppLimitEventWithRelations = AppLimitEvent & AppLimitEventRelations;
1066
1082
  export type OrgLimitEventWithRelations = OrgLimitEvent & OrgLimitEventRelations;
1067
1083
  export type OrgGrantWithRelations = OrgGrant & OrgGrantRelations;
1068
1084
  export type OrgChartEdgeWithRelations = OrgChartEdge & OrgChartEdgeRelations;
1085
+ export type UsageSnapshotWithRelations = UsageSnapshot & UsageSnapshotRelations;
1069
1086
  export type OrgMemberProfileWithRelations = OrgMemberProfile & OrgMemberProfileRelations;
1070
1087
  export type AppLevelWithRelations = AppLevel & AppLevelRelations;
1071
1088
  export type AppLimitWithRelations = AppLimit & AppLimitRelations;
@@ -1393,6 +1410,14 @@ export type OrgChartEdgeSelect = {
1393
1410
  positionTitle?: boolean;
1394
1411
  positionLevel?: boolean;
1395
1412
  };
1413
+ export type UsageSnapshotSelect = {
1414
+ databaseId?: boolean;
1415
+ metricName?: boolean;
1416
+ metricValue?: boolean;
1417
+ dimensions?: boolean;
1418
+ capturedAt?: boolean;
1419
+ id?: boolean;
1420
+ };
1396
1421
  export type OrgMemberProfileSelect = {
1397
1422
  id?: boolean;
1398
1423
  createdAt?: boolean;
@@ -2252,6 +2277,26 @@ export interface OrgChartEdgeFilter {
2252
2277
  /** Negates the expression. */
2253
2278
  not?: OrgChartEdgeFilter;
2254
2279
  }
2280
+ export interface UsageSnapshotFilter {
2281
+ /** Filter by the object’s `databaseId` field. */
2282
+ databaseId?: UUIDFilter;
2283
+ /** Filter by the object’s `metricName` field. */
2284
+ metricName?: StringFilter;
2285
+ /** Filter by the object’s `metricValue` field. */
2286
+ metricValue?: BigIntFilter;
2287
+ /** Filter by the object’s `dimensions` field. */
2288
+ dimensions?: JSONFilter;
2289
+ /** Filter by the object’s `capturedAt` field. */
2290
+ capturedAt?: DatetimeFilter;
2291
+ /** Filter by the object’s `id` field. */
2292
+ id?: UUIDFilter;
2293
+ /** Checks for all expressions in this list. */
2294
+ and?: UsageSnapshotFilter[];
2295
+ /** Checks for any expressions in this list. */
2296
+ or?: UsageSnapshotFilter[];
2297
+ /** Negates the expression. */
2298
+ not?: UsageSnapshotFilter;
2299
+ }
2255
2300
  export interface OrgMemberProfileFilter {
2256
2301
  /** Filter by the object’s `id` field. */
2257
2302
  id?: UUIDFilter;
@@ -2628,6 +2673,7 @@ export type AppLimitEventOrderBy = 'NATURAL' | 'NAME_ASC' | 'NAME_DESC' | 'ACTOR
2628
2673
  export type OrgLimitEventOrderBy = 'NATURAL' | 'NAME_ASC' | 'NAME_DESC' | 'ACTOR_ID_ASC' | 'ACTOR_ID_DESC' | 'ENTITY_ID_ASC' | 'ENTITY_ID_DESC' | 'EVENT_TYPE_ASC' | 'EVENT_TYPE_DESC' | 'DELTA_ASC' | 'DELTA_DESC' | 'NUM_BEFORE_ASC' | 'NUM_BEFORE_DESC' | 'NUM_AFTER_ASC' | 'NUM_AFTER_DESC' | 'MAX_AT_EVENT_ASC' | 'MAX_AT_EVENT_DESC' | 'REASON_ASC' | 'REASON_DESC';
2629
2674
  export type OrgGrantOrderBy = 'NATURAL' | 'PRIMARY_KEY_ASC' | 'PRIMARY_KEY_DESC' | 'ID_ASC' | 'ID_DESC' | 'PERMISSIONS_ASC' | 'PERMISSIONS_DESC' | 'IS_GRANT_ASC' | 'IS_GRANT_DESC' | 'ACTOR_ID_ASC' | 'ACTOR_ID_DESC' | 'ENTITY_ID_ASC' | 'ENTITY_ID_DESC' | 'GRANTOR_ID_ASC' | 'GRANTOR_ID_DESC' | 'CREATED_AT_ASC' | 'CREATED_AT_DESC' | 'UPDATED_AT_ASC' | 'UPDATED_AT_DESC';
2630
2675
  export type OrgChartEdgeOrderBy = 'NATURAL' | 'PRIMARY_KEY_ASC' | 'PRIMARY_KEY_DESC' | 'ID_ASC' | 'ID_DESC' | 'CREATED_AT_ASC' | 'CREATED_AT_DESC' | 'UPDATED_AT_ASC' | 'UPDATED_AT_DESC' | 'ENTITY_ID_ASC' | 'ENTITY_ID_DESC' | 'CHILD_ID_ASC' | 'CHILD_ID_DESC' | 'PARENT_ID_ASC' | 'PARENT_ID_DESC' | 'POSITION_TITLE_ASC' | 'POSITION_TITLE_DESC' | 'POSITION_LEVEL_ASC' | 'POSITION_LEVEL_DESC';
2676
+ export type UsageSnapshotOrderBy = 'NATURAL' | 'PRIMARY_KEY_ASC' | 'PRIMARY_KEY_DESC' | 'DATABASE_ID_ASC' | 'DATABASE_ID_DESC' | 'METRIC_NAME_ASC' | 'METRIC_NAME_DESC' | 'METRIC_VALUE_ASC' | 'METRIC_VALUE_DESC' | 'DIMENSIONS_ASC' | 'DIMENSIONS_DESC' | 'CAPTURED_AT_ASC' | 'CAPTURED_AT_DESC' | 'ID_ASC' | 'ID_DESC';
2631
2677
  export type OrgMemberProfileOrderBy = 'NATURAL' | 'PRIMARY_KEY_ASC' | 'PRIMARY_KEY_DESC' | 'ID_ASC' | 'ID_DESC' | 'CREATED_AT_ASC' | 'CREATED_AT_DESC' | 'UPDATED_AT_ASC' | 'UPDATED_AT_DESC' | 'MEMBERSHIP_ID_ASC' | 'MEMBERSHIP_ID_DESC' | 'ENTITY_ID_ASC' | 'ENTITY_ID_DESC' | 'ACTOR_ID_ASC' | 'ACTOR_ID_DESC' | 'DISPLAY_NAME_ASC' | 'DISPLAY_NAME_DESC' | 'EMAIL_ASC' | 'EMAIL_DESC' | 'TITLE_ASC' | 'TITLE_DESC' | 'BIO_ASC' | 'BIO_DESC' | 'PROFILE_PICTURE_ASC' | 'PROFILE_PICTURE_DESC';
2632
2678
  export type AppLevelOrderBy = 'NATURAL' | 'PRIMARY_KEY_ASC' | 'PRIMARY_KEY_DESC' | 'ID_ASC' | 'ID_DESC' | 'NAME_ASC' | 'NAME_DESC' | 'DESCRIPTION_ASC' | 'DESCRIPTION_DESC' | 'IMAGE_ASC' | 'IMAGE_DESC' | 'OWNER_ID_ASC' | 'OWNER_ID_DESC' | 'CREATED_AT_ASC' | 'CREATED_AT_DESC' | 'UPDATED_AT_ASC' | 'UPDATED_AT_DESC';
2633
2679
  export type AppLimitOrderBy = 'NATURAL' | 'PRIMARY_KEY_ASC' | 'PRIMARY_KEY_DESC' | 'ID_ASC' | 'ID_DESC' | 'NAME_ASC' | 'NAME_DESC' | 'ACTOR_ID_ASC' | 'ACTOR_ID_DESC' | 'NUM_ASC' | 'NUM_DESC' | 'MAX_ASC' | 'MAX_DESC' | 'SOFT_MAX_ASC' | 'SOFT_MAX_DESC' | 'WINDOW_START_ASC' | 'WINDOW_START_DESC' | 'WINDOW_DURATION_ASC' | 'WINDOW_DURATION_DESC' | 'PLAN_MAX_ASC' | 'PLAN_MAX_DESC' | 'PURCHASED_CREDITS_ASC' | 'PURCHASED_CREDITS_DESC' | 'PERIOD_CREDITS_ASC' | 'PERIOD_CREDITS_DESC';
@@ -3492,6 +3538,32 @@ export interface DeleteOrgChartEdgeInput {
3492
3538
  clientMutationId?: string;
3493
3539
  id: string;
3494
3540
  }
3541
+ export interface CreateUsageSnapshotInput {
3542
+ clientMutationId?: string;
3543
+ usageSnapshot: {
3544
+ databaseId: string;
3545
+ metricName: string;
3546
+ metricValue?: string;
3547
+ dimensions?: Record<string, unknown>;
3548
+ capturedAt?: string;
3549
+ };
3550
+ }
3551
+ export interface UsageSnapshotPatch {
3552
+ databaseId?: string | null;
3553
+ metricName?: string | null;
3554
+ metricValue?: string | null;
3555
+ dimensions?: Record<string, unknown> | null;
3556
+ capturedAt?: string | null;
3557
+ }
3558
+ export interface UpdateUsageSnapshotInput {
3559
+ clientMutationId?: string;
3560
+ id: string;
3561
+ usageSnapshotPatch: UsageSnapshotPatch;
3562
+ }
3563
+ export interface DeleteUsageSnapshotInput {
3564
+ clientMutationId?: string;
3565
+ id: string;
3566
+ }
3495
3567
  export interface CreateOrgMemberProfileInput {
3496
3568
  clientMutationId?: string;
3497
3569
  orgMemberProfile: {
@@ -5978,6 +6050,51 @@ export type DeleteOrgChartEdgePayloadSelect = {
5978
6050
  select: OrgChartEdgeEdgeSelect;
5979
6051
  };
5980
6052
  };
6053
+ export interface CreateUsageSnapshotPayload {
6054
+ clientMutationId?: string | null;
6055
+ /** The `UsageSnapshot` that was created by this mutation. */
6056
+ usageSnapshot?: UsageSnapshot | null;
6057
+ usageSnapshotEdge?: UsageSnapshotEdge | null;
6058
+ }
6059
+ export type CreateUsageSnapshotPayloadSelect = {
6060
+ clientMutationId?: boolean;
6061
+ usageSnapshot?: {
6062
+ select: UsageSnapshotSelect;
6063
+ };
6064
+ usageSnapshotEdge?: {
6065
+ select: UsageSnapshotEdgeSelect;
6066
+ };
6067
+ };
6068
+ export interface UpdateUsageSnapshotPayload {
6069
+ clientMutationId?: string | null;
6070
+ /** The `UsageSnapshot` that was updated by this mutation. */
6071
+ usageSnapshot?: UsageSnapshot | null;
6072
+ usageSnapshotEdge?: UsageSnapshotEdge | null;
6073
+ }
6074
+ export type UpdateUsageSnapshotPayloadSelect = {
6075
+ clientMutationId?: boolean;
6076
+ usageSnapshot?: {
6077
+ select: UsageSnapshotSelect;
6078
+ };
6079
+ usageSnapshotEdge?: {
6080
+ select: UsageSnapshotEdgeSelect;
6081
+ };
6082
+ };
6083
+ export interface DeleteUsageSnapshotPayload {
6084
+ clientMutationId?: string | null;
6085
+ /** The `UsageSnapshot` that was deleted by this mutation. */
6086
+ usageSnapshot?: UsageSnapshot | null;
6087
+ usageSnapshotEdge?: UsageSnapshotEdge | null;
6088
+ }
6089
+ export type DeleteUsageSnapshotPayloadSelect = {
6090
+ clientMutationId?: boolean;
6091
+ usageSnapshot?: {
6092
+ select: UsageSnapshotSelect;
6093
+ };
6094
+ usageSnapshotEdge?: {
6095
+ select: UsageSnapshotEdgeSelect;
6096
+ };
6097
+ };
5981
6098
  export interface CreateOrgMemberProfilePayload {
5982
6099
  clientMutationId?: string | null;
5983
6100
  /** The `OrgMemberProfile` that was created by this mutation. */
@@ -6829,6 +6946,18 @@ export type OrgChartEdgeEdgeSelect = {
6829
6946
  select: OrgChartEdgeSelect;
6830
6947
  };
6831
6948
  };
6949
+ /** A `UsageSnapshot` edge in the connection. */
6950
+ export interface UsageSnapshotEdge {
6951
+ cursor?: string | null;
6952
+ /** The `UsageSnapshot` at the end of the edge. */
6953
+ node?: UsageSnapshot | null;
6954
+ }
6955
+ export type UsageSnapshotEdgeSelect = {
6956
+ cursor?: boolean;
6957
+ node?: {
6958
+ select: UsageSnapshotSelect;
6959
+ };
6960
+ };
6832
6961
  /** A `OrgMemberProfile` edge in the connection. */
6833
6962
  export interface OrgMemberProfileEdge {
6834
6963
  cursor?: string | null;
@@ -39,6 +39,7 @@ export { AppLimitEventModel } from './appLimitEvent';
39
39
  export { OrgLimitEventModel } from './orgLimitEvent';
40
40
  export { OrgGrantModel } from './orgGrant';
41
41
  export { OrgChartEdgeModel } from './orgChartEdge';
42
+ export { UsageSnapshotModel } from './usageSnapshot';
42
43
  export { OrgMemberProfileModel } from './orgMemberProfile';
43
44
  export { AppLevelModel } from './appLevel';
44
45
  export { AppLimitModel } from './appLimit';
@@ -39,6 +39,7 @@ export { AppLimitEventModel } from './appLimitEvent';
39
39
  export { OrgLimitEventModel } from './orgLimitEvent';
40
40
  export { OrgGrantModel } from './orgGrant';
41
41
  export { OrgChartEdgeModel } from './orgChartEdge';
42
+ export { UsageSnapshotModel } from './usageSnapshot';
42
43
  export { OrgMemberProfileModel } from './orgMemberProfile';
43
44
  export { AppLevelModel } from './appLevel';
44
45
  export { AppLimitModel } from './appLimit';