@vritti/api-sdk 0.3.3 → 0.3.6
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/dist/auth.cjs +942 -0
- package/dist/auth.cjs.map +1 -0
- package/dist/auth.d.cts +95 -0
- package/dist/auth.d.ts +95 -0
- package/dist/auth.js +884 -0
- package/dist/auth.js.map +1 -0
- package/dist/cache.cjs +182 -14
- package/dist/cache.cjs.map +1 -1
- package/dist/cache.d.cts +48 -4
- package/dist/cache.d.ts +48 -4
- package/dist/cache.js +177 -12
- package/dist/cache.js.map +1 -1
- package/dist/catalog-resolver.cjs +337 -140
- package/dist/catalog-resolver.cjs.map +1 -1
- package/dist/catalog-resolver.d.cts +70 -45
- package/dist/catalog-resolver.d.ts +70 -45
- package/dist/catalog-resolver.js +322 -135
- package/dist/catalog-resolver.js.map +1 -1
- package/dist/code-pattern-BP4zkNtT.d.cts +12 -0
- package/dist/code-pattern-BP4zkNtT.d.ts +12 -0
- package/dist/context.cjs +93 -0
- package/dist/context.cjs.map +1 -0
- package/dist/context.d.cts +19 -0
- package/dist/context.d.ts +19 -0
- package/dist/context.js +64 -0
- package/dist/context.js.map +1 -0
- package/dist/countries.cjs +1559 -0
- package/dist/countries.cjs.map +1 -0
- package/dist/countries.d.cts +13 -0
- package/dist/countries.d.ts +13 -0
- package/dist/countries.js +1532 -0
- package/dist/countries.js.map +1 -0
- package/dist/data-table.cjs +1280 -0
- package/dist/data-table.cjs.map +1 -0
- package/dist/data-table.d.cts +123 -0
- package/dist/data-table.d.ts +123 -0
- package/dist/data-table.js +1260 -0
- package/dist/data-table.js.map +1 -0
- package/dist/database.cjs +1510 -0
- package/dist/database.cjs.map +1 -0
- package/dist/database.d.cts +287 -0
- package/dist/database.d.ts +287 -0
- package/dist/database.js +1469 -0
- package/dist/database.js.map +1 -0
- package/dist/decimal.d.cts +0 -1
- package/dist/decimal.d.ts +0 -1
- package/dist/decorators.cjs +1817 -0
- package/dist/decorators.cjs.map +1 -0
- package/dist/decorators.d.cts +24 -0
- package/dist/decorators.d.ts +24 -0
- package/dist/decorators.js +1780 -0
- package/dist/decorators.js.map +1 -0
- package/dist/drizzle-pg-core.cjs +25 -0
- package/dist/drizzle-pg-core.cjs.map +1 -1
- package/dist/drizzle-pg-core.d.cts +7 -0
- package/dist/drizzle-pg-core.d.ts +7 -0
- package/dist/drizzle-pg-core.js +22 -0
- package/dist/drizzle-pg-core.js.map +1 -1
- package/dist/exceptions.cjs +301 -0
- package/dist/exceptions.cjs.map +1 -0
- package/dist/exceptions.d.cts +90 -0
- package/dist/exceptions.d.ts +90 -0
- package/dist/exceptions.js +257 -0
- package/dist/exceptions.js.map +1 -0
- package/dist/filter.types-PuARU9XD.d.cts +50 -0
- package/dist/filter.types-PuARU9XD.d.ts +50 -0
- package/dist/filters.cjs +407 -0
- package/dist/filters.cjs.map +1 -0
- package/dist/filters.d.cts +55 -0
- package/dist/filters.d.ts +55 -0
- package/dist/filters.js +377 -0
- package/dist/filters.js.map +1 -0
- package/dist/index.cjs +0 -5423
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +93 -854
- package/dist/index.d.ts +93 -854
- package/dist/index.js +0 -5301
- package/dist/index.js.map +1 -1
- package/dist/is-country.decorator-CcNwSSr5.d.cts +5 -0
- package/dist/is-country.decorator-CcNwSSr5.d.ts +5 -0
- package/dist/license.d.cts +1 -1
- package/dist/license.d.ts +1 -1
- package/dist/lodash.cjs.map +1 -1
- package/dist/lodash.js.map +1 -1
- package/dist/logger.cjs +862 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/logger.d.cts +118 -0
- package/dist/logger.d.ts +118 -0
- package/dist/logger.js +816 -0
- package/dist/logger.js.map +1 -0
- package/dist/migrate.cjs +2 -2
- package/dist/migrate.cjs.map +1 -1
- package/dist/migrate.d.cts +2 -0
- package/dist/migrate.d.ts +2 -0
- package/dist/migrate.js +2 -2
- package/dist/migrate.js.map +1 -1
- package/dist/money.cjs +18 -3
- package/dist/money.cjs.map +1 -1
- package/dist/money.d.cts +13 -13
- package/dist/money.d.ts +13 -13
- package/dist/money.js +18 -3
- package/dist/money.js.map +1 -1
- package/dist/nats.cjs +34 -35
- package/dist/nats.cjs.map +1 -1
- package/dist/nats.d.cts +14 -14
- package/dist/nats.d.ts +14 -14
- package/dist/nats.js +32 -33
- package/dist/nats.js.map +1 -1
- package/dist/root.cjs +225 -0
- package/dist/root.cjs.map +1 -0
- package/dist/root.d.cts +4 -0
- package/dist/root.d.ts +4 -0
- package/dist/root.js +200 -0
- package/dist/root.js.map +1 -0
- package/dist/{types-DQRwj5rr.d.cts → types-BBK6MG-U.d.cts} +37 -6
- package/dist/{types-DQRwj5rr.d.ts → types-BBK6MG-U.d.ts} +37 -6
- package/dist/types.cjs +19 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +17 -0
- package/dist/types.d.ts +17 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.cjs +273 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +8 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.js +245 -0
- package/dist/utils.js.map +1 -0
- package/package.json +122 -1
- package/dist/cache.service-_SuJIcNA.d.cts +0 -20
- package/dist/cache.service-_SuJIcNA.d.ts +0 -20
- package/dist/fastify-augmentation-CQPBNS5a.d.cts +0 -105
- package/dist/fastify-augmentation-CQPBNS5a.d.ts +0 -105
|
@@ -0,0 +1,1260 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
|
|
20
|
+
// src/data-table/data-table.module.ts
|
|
21
|
+
import { Module } from "@nestjs/common";
|
|
22
|
+
import { ConfigModule } from "@nestjs/config";
|
|
23
|
+
import { CacheModule } from "@vritti/api-sdk/cache";
|
|
24
|
+
|
|
25
|
+
// src/data-table/data-table.constants.ts
|
|
26
|
+
var DATA_TABLE_VIEWS_TABLE = Symbol("DATA_TABLE_VIEWS_TABLE");
|
|
27
|
+
|
|
28
|
+
// src/data-table/state/controllers/data-table-state.controller.ts
|
|
29
|
+
import { Body, Controller, HttpCode, HttpStatus, Logger as Logger2, Post } from "@nestjs/common";
|
|
30
|
+
import { ApiBearerAuth, ApiTags } from "@nestjs/swagger";
|
|
31
|
+
|
|
32
|
+
// src/auth/decorators/user-id.decorator.ts
|
|
33
|
+
import { createParamDecorator } from "@nestjs/common";
|
|
34
|
+
|
|
35
|
+
// src/context/extractors/graphql.extractor.ts
|
|
36
|
+
var graphqlExtractor = {
|
|
37
|
+
getRequest: /* @__PURE__ */ __name((host) => host.getArgByIndex(2).req, "getRequest"),
|
|
38
|
+
getResponse: /* @__PURE__ */ __name((host) => host.getArgByIndex(2).reply, "getResponse")
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// src/context/extractors/http.extractor.ts
|
|
42
|
+
var httpExtractor = {
|
|
43
|
+
getRequest: /* @__PURE__ */ __name((host) => host.switchToHttp().getRequest(), "getRequest"),
|
|
44
|
+
getResponse: /* @__PURE__ */ __name((host) => host.switchToHttp().getResponse(), "getResponse")
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// src/context/context.registry.ts
|
|
48
|
+
var registry = /* @__PURE__ */ new Map([
|
|
49
|
+
[
|
|
50
|
+
"http",
|
|
51
|
+
httpExtractor
|
|
52
|
+
],
|
|
53
|
+
[
|
|
54
|
+
"graphql",
|
|
55
|
+
graphqlExtractor
|
|
56
|
+
]
|
|
57
|
+
]);
|
|
58
|
+
function resolveExtractor(type) {
|
|
59
|
+
return registry.get(type) ?? httpExtractor;
|
|
60
|
+
}
|
|
61
|
+
__name(resolveExtractor, "resolveExtractor");
|
|
62
|
+
|
|
63
|
+
// src/context/get-request.ts
|
|
64
|
+
function getRequestFromContext(host) {
|
|
65
|
+
return resolveExtractor(host.getType()).getRequest(host);
|
|
66
|
+
}
|
|
67
|
+
__name(getRequestFromContext, "getRequestFromContext");
|
|
68
|
+
|
|
69
|
+
// src/auth/decorators/user-id.decorator.ts
|
|
70
|
+
var UserId = createParamDecorator((_data, ctx) => {
|
|
71
|
+
const request = getRequestFromContext(ctx);
|
|
72
|
+
const sessionInfo = request.sessionInfo;
|
|
73
|
+
if (!sessionInfo?.userId) {
|
|
74
|
+
throw new Error("User ID not found on request. Ensure route is protected by auth guard.");
|
|
75
|
+
}
|
|
76
|
+
return sessionInfo.userId;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// src/data-table/state/docs/data-table-state.docs.ts
|
|
80
|
+
import { applyDecorators } from "@nestjs/common";
|
|
81
|
+
import { ApiBody, ApiOperation, ApiResponse } from "@nestjs/swagger";
|
|
82
|
+
|
|
83
|
+
// src/data-table/state/dto/request/upsert-data-table-state.dto.ts
|
|
84
|
+
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
|
85
|
+
import { IsObject, IsOptional, IsString, IsUUID, MaxLength } from "class-validator";
|
|
86
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
87
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
88
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
89
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
90
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
91
|
+
}
|
|
92
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
93
|
+
function _ts_metadata(k, v) {
|
|
94
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
95
|
+
}
|
|
96
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
97
|
+
var UpsertDataTableStateDto = class {
|
|
98
|
+
static {
|
|
99
|
+
__name(this, "UpsertDataTableStateDto");
|
|
100
|
+
}
|
|
101
|
+
tableSlug;
|
|
102
|
+
state;
|
|
103
|
+
activeViewId;
|
|
104
|
+
};
|
|
105
|
+
_ts_decorate([
|
|
106
|
+
ApiProperty({
|
|
107
|
+
description: "Unique slug identifying the table",
|
|
108
|
+
example: "cloud-providers"
|
|
109
|
+
}),
|
|
110
|
+
IsString(),
|
|
111
|
+
MaxLength(200),
|
|
112
|
+
_ts_metadata("design:type", String)
|
|
113
|
+
], UpsertDataTableStateDto.prototype, "tableSlug", void 0);
|
|
114
|
+
_ts_decorate([
|
|
115
|
+
ApiProperty({
|
|
116
|
+
description: "Full table view state including filters, sort, and column visibility"
|
|
117
|
+
}),
|
|
118
|
+
IsObject(),
|
|
119
|
+
_ts_metadata("design:type", typeof TableViewState === "undefined" ? Object : TableViewState)
|
|
120
|
+
], UpsertDataTableStateDto.prototype, "state", void 0);
|
|
121
|
+
_ts_decorate([
|
|
122
|
+
ApiPropertyOptional(),
|
|
123
|
+
IsOptional(),
|
|
124
|
+
IsUUID(),
|
|
125
|
+
_ts_metadata("design:type", Object)
|
|
126
|
+
], UpsertDataTableStateDto.prototype, "activeViewId", void 0);
|
|
127
|
+
|
|
128
|
+
// src/data-table/state/docs/data-table-state.docs.ts
|
|
129
|
+
function ApiUpsertDataTableState() {
|
|
130
|
+
return applyDecorators(ApiOperation({
|
|
131
|
+
summary: "Save live table state",
|
|
132
|
+
description: "Stores the current filter, sort, and column visibility state in Redis cache. Called on filter Apply and sort column click. State expires after TABLE_STATE_CACHE_TTL seconds."
|
|
133
|
+
}), ApiBody({
|
|
134
|
+
type: UpsertDataTableStateDto
|
|
135
|
+
}), ApiResponse({
|
|
136
|
+
status: 200,
|
|
137
|
+
description: "Live state cached."
|
|
138
|
+
}), ApiResponse({
|
|
139
|
+
status: 400,
|
|
140
|
+
description: "Invalid request body."
|
|
141
|
+
}), ApiResponse({
|
|
142
|
+
status: 401,
|
|
143
|
+
description: "Unauthorized."
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
__name(ApiUpsertDataTableState, "ApiUpsertDataTableState");
|
|
147
|
+
|
|
148
|
+
// src/data-table/state/services/data-table-state.service.ts
|
|
149
|
+
import { Injectable, Logger } from "@nestjs/common";
|
|
150
|
+
import { ConfigService } from "@nestjs/config";
|
|
151
|
+
import { CacheService } from "@vritti/api-sdk/cache";
|
|
152
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
153
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
154
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
155
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
156
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
157
|
+
}
|
|
158
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
159
|
+
function _ts_metadata2(k, v) {
|
|
160
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
161
|
+
}
|
|
162
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
163
|
+
var EMPTY_TABLE_STATE = {
|
|
164
|
+
filters: [],
|
|
165
|
+
sort: [],
|
|
166
|
+
columnVisibility: {},
|
|
167
|
+
columnOrder: [],
|
|
168
|
+
columnSizing: {},
|
|
169
|
+
columnPinning: {
|
|
170
|
+
left: [],
|
|
171
|
+
right: []
|
|
172
|
+
},
|
|
173
|
+
lockedColumnSizing: false,
|
|
174
|
+
density: "normal",
|
|
175
|
+
filterOrder: [],
|
|
176
|
+
filterVisibility: {},
|
|
177
|
+
search: null,
|
|
178
|
+
pagination: {
|
|
179
|
+
limit: 20,
|
|
180
|
+
offset: 0
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
var DataTableStateService = class _DataTableStateService {
|
|
184
|
+
static {
|
|
185
|
+
__name(this, "DataTableStateService");
|
|
186
|
+
}
|
|
187
|
+
cacheService;
|
|
188
|
+
configService;
|
|
189
|
+
logger = new Logger(_DataTableStateService.name);
|
|
190
|
+
constructor(cacheService, configService) {
|
|
191
|
+
this.cacheService = cacheService;
|
|
192
|
+
this.configService = configService;
|
|
193
|
+
}
|
|
194
|
+
// Returns configured TTL for live table state in seconds, defaulting to 3600 (1h)
|
|
195
|
+
get stateTtl() {
|
|
196
|
+
return this.configService.get("TABLE_STATE_CACHE_TTL") ?? 3600;
|
|
197
|
+
}
|
|
198
|
+
// Saves live table state and active view ID to Redis; DB is not written
|
|
199
|
+
async upsertCurrentState(userId, dto) {
|
|
200
|
+
const key = `dt:${userId}:${dto.tableSlug}`;
|
|
201
|
+
await this.cacheService.set(key, {
|
|
202
|
+
state: dto.state,
|
|
203
|
+
activeViewId: dto.activeViewId ?? null
|
|
204
|
+
}, this.stateTtl);
|
|
205
|
+
this.logger.log(`Cached live state for user: ${userId}, table: ${dto.tableSlug}`);
|
|
206
|
+
}
|
|
207
|
+
// Returns live table state and active view ID from Redis; returns empty state on miss — no DB query
|
|
208
|
+
async getCurrentState(userId, tableSlug) {
|
|
209
|
+
const key = `dt:${userId}:${tableSlug}`;
|
|
210
|
+
const cached = await this.cacheService.get(key);
|
|
211
|
+
return cached ?? {
|
|
212
|
+
state: EMPTY_TABLE_STATE,
|
|
213
|
+
activeViewId: null
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
DataTableStateService = _ts_decorate2([
|
|
218
|
+
Injectable(),
|
|
219
|
+
_ts_metadata2("design:type", Function),
|
|
220
|
+
_ts_metadata2("design:paramtypes", [
|
|
221
|
+
typeof CacheService === "undefined" ? Object : CacheService,
|
|
222
|
+
typeof ConfigService === "undefined" ? Object : ConfigService
|
|
223
|
+
])
|
|
224
|
+
], DataTableStateService);
|
|
225
|
+
|
|
226
|
+
// src/data-table/state/controllers/data-table-state.controller.ts
|
|
227
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
228
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
229
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
230
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
231
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
232
|
+
}
|
|
233
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
234
|
+
function _ts_metadata3(k, v) {
|
|
235
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
236
|
+
}
|
|
237
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
238
|
+
function _ts_param(paramIndex, decorator) {
|
|
239
|
+
return function(target, key) {
|
|
240
|
+
decorator(target, key, paramIndex);
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
__name(_ts_param, "_ts_param");
|
|
244
|
+
var DataTableStateController = class _DataTableStateController {
|
|
245
|
+
static {
|
|
246
|
+
__name(this, "DataTableStateController");
|
|
247
|
+
}
|
|
248
|
+
dataTableStateService;
|
|
249
|
+
logger = new Logger2(_DataTableStateController.name);
|
|
250
|
+
constructor(dataTableStateService) {
|
|
251
|
+
this.dataTableStateService = dataTableStateService;
|
|
252
|
+
}
|
|
253
|
+
// Saves live table state to Redis cache for the authenticated user's table
|
|
254
|
+
upsertCurrentState(userId, dto) {
|
|
255
|
+
this.logger.log(`POST /table-states - User: ${userId}, table: ${dto.tableSlug}`);
|
|
256
|
+
return this.dataTableStateService.upsertCurrentState(userId, dto);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
_ts_decorate3([
|
|
260
|
+
Post(),
|
|
261
|
+
HttpCode(HttpStatus.OK),
|
|
262
|
+
ApiUpsertDataTableState(),
|
|
263
|
+
_ts_param(0, UserId()),
|
|
264
|
+
_ts_param(1, Body()),
|
|
265
|
+
_ts_metadata3("design:type", Function),
|
|
266
|
+
_ts_metadata3("design:paramtypes", [
|
|
267
|
+
String,
|
|
268
|
+
typeof UpsertDataTableStateDto === "undefined" ? Object : UpsertDataTableStateDto
|
|
269
|
+
]),
|
|
270
|
+
_ts_metadata3("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
271
|
+
], DataTableStateController.prototype, "upsertCurrentState", null);
|
|
272
|
+
DataTableStateController = _ts_decorate3([
|
|
273
|
+
ApiTags("Table States"),
|
|
274
|
+
ApiBearerAuth(),
|
|
275
|
+
Controller("table-states"),
|
|
276
|
+
_ts_metadata3("design:type", Function),
|
|
277
|
+
_ts_metadata3("design:paramtypes", [
|
|
278
|
+
typeof DataTableStateService === "undefined" ? Object : DataTableStateService
|
|
279
|
+
])
|
|
280
|
+
], DataTableStateController);
|
|
281
|
+
|
|
282
|
+
// src/data-table/views/controllers/data-table-views.controller.ts
|
|
283
|
+
import { Body as Body2, Controller as Controller2, Delete, Get, HttpCode as HttpCode2, HttpStatus as HttpStatus20, Logger as Logger4, Param, Patch, Post as Post2, Query } from "@nestjs/common";
|
|
284
|
+
import { ApiBearerAuth as ApiBearerAuth2, ApiTags as ApiTags2 } from "@nestjs/swagger";
|
|
285
|
+
|
|
286
|
+
// src/data-table/views/docs/data-table-views.docs.ts
|
|
287
|
+
import { applyDecorators as applyDecorators2 } from "@nestjs/common";
|
|
288
|
+
import { ApiBody as ApiBody2, ApiOperation as ApiOperation2, ApiParam, ApiQuery, ApiResponse as ApiResponse2 } from "@nestjs/swagger";
|
|
289
|
+
|
|
290
|
+
// src/data-table/views/dto/entity/data-table-view.dto.ts
|
|
291
|
+
import { ApiProperty as ApiProperty2, ApiPropertyOptional as ApiPropertyOptional2 } from "@nestjs/swagger";
|
|
292
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
293
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
294
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
295
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
296
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
297
|
+
}
|
|
298
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
299
|
+
function _ts_metadata4(k, v) {
|
|
300
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
301
|
+
}
|
|
302
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
303
|
+
var DataTableViewDto = class _DataTableViewDto {
|
|
304
|
+
static {
|
|
305
|
+
__name(this, "DataTableViewDto");
|
|
306
|
+
}
|
|
307
|
+
id;
|
|
308
|
+
name;
|
|
309
|
+
tableSlug;
|
|
310
|
+
state;
|
|
311
|
+
isShared;
|
|
312
|
+
isOwn;
|
|
313
|
+
createdAt;
|
|
314
|
+
updatedAt;
|
|
315
|
+
// Creates a response DTO from a DataTableView entity, computing isOwn by comparing userId
|
|
316
|
+
static from(view, userId) {
|
|
317
|
+
const dto = new _DataTableViewDto();
|
|
318
|
+
dto.id = view.id;
|
|
319
|
+
dto.name = view.name ?? null;
|
|
320
|
+
dto.tableSlug = view.tableSlug;
|
|
321
|
+
dto.state = view.state;
|
|
322
|
+
dto.isShared = view.isShared;
|
|
323
|
+
dto.isOwn = view.userId === userId;
|
|
324
|
+
dto.createdAt = view.createdAt;
|
|
325
|
+
dto.updatedAt = view.updatedAt ?? null;
|
|
326
|
+
return dto;
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
_ts_decorate4([
|
|
330
|
+
ApiProperty2({
|
|
331
|
+
description: "View unique identifier"
|
|
332
|
+
}),
|
|
333
|
+
_ts_metadata4("design:type", String)
|
|
334
|
+
], DataTableViewDto.prototype, "id", void 0);
|
|
335
|
+
_ts_decorate4([
|
|
336
|
+
ApiPropertyOptional2({
|
|
337
|
+
description: "Display name of the view",
|
|
338
|
+
nullable: true
|
|
339
|
+
}),
|
|
340
|
+
_ts_metadata4("design:type", Object)
|
|
341
|
+
], DataTableViewDto.prototype, "name", void 0);
|
|
342
|
+
_ts_decorate4([
|
|
343
|
+
ApiProperty2({
|
|
344
|
+
description: "Slug of the table this view belongs to",
|
|
345
|
+
example: "cloud-providers"
|
|
346
|
+
}),
|
|
347
|
+
_ts_metadata4("design:type", String)
|
|
348
|
+
], DataTableViewDto.prototype, "tableSlug", void 0);
|
|
349
|
+
_ts_decorate4([
|
|
350
|
+
ApiProperty2({
|
|
351
|
+
description: "Stored filter, sort, and column visibility state"
|
|
352
|
+
}),
|
|
353
|
+
_ts_metadata4("design:type", typeof TableViewState === "undefined" ? Object : TableViewState)
|
|
354
|
+
], DataTableViewDto.prototype, "state", void 0);
|
|
355
|
+
_ts_decorate4([
|
|
356
|
+
ApiProperty2({
|
|
357
|
+
description: "Whether the view is visible to all users",
|
|
358
|
+
example: false
|
|
359
|
+
}),
|
|
360
|
+
_ts_metadata4("design:type", Boolean)
|
|
361
|
+
], DataTableViewDto.prototype, "isShared", void 0);
|
|
362
|
+
_ts_decorate4([
|
|
363
|
+
ApiProperty2({
|
|
364
|
+
description: "Whether the requesting user owns this view",
|
|
365
|
+
example: true
|
|
366
|
+
}),
|
|
367
|
+
_ts_metadata4("design:type", Boolean)
|
|
368
|
+
], DataTableViewDto.prototype, "isOwn", void 0);
|
|
369
|
+
_ts_decorate4([
|
|
370
|
+
ApiProperty2({
|
|
371
|
+
description: "Creation timestamp"
|
|
372
|
+
}),
|
|
373
|
+
_ts_metadata4("design:type", typeof Date === "undefined" ? Object : Date)
|
|
374
|
+
], DataTableViewDto.prototype, "createdAt", void 0);
|
|
375
|
+
_ts_decorate4([
|
|
376
|
+
ApiPropertyOptional2({
|
|
377
|
+
description: "Last updated timestamp",
|
|
378
|
+
nullable: true
|
|
379
|
+
}),
|
|
380
|
+
_ts_metadata4("design:type", Object)
|
|
381
|
+
], DataTableViewDto.prototype, "updatedAt", void 0);
|
|
382
|
+
|
|
383
|
+
// src/data-table/views/dto/request/create-data-table-view.dto.ts
|
|
384
|
+
import { ApiProperty as ApiProperty3, ApiPropertyOptional as ApiPropertyOptional3 } from "@nestjs/swagger";
|
|
385
|
+
import { IsBoolean, IsObject as IsObject2, IsOptional as IsOptional2, IsString as IsString2, MaxLength as MaxLength2 } from "class-validator";
|
|
386
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
387
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
388
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
389
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
390
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
391
|
+
}
|
|
392
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
393
|
+
function _ts_metadata5(k, v) {
|
|
394
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
395
|
+
}
|
|
396
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
397
|
+
var CreateDataTableViewDto = class {
|
|
398
|
+
static {
|
|
399
|
+
__name(this, "CreateDataTableViewDto");
|
|
400
|
+
}
|
|
401
|
+
name;
|
|
402
|
+
tableSlug;
|
|
403
|
+
state;
|
|
404
|
+
isShared;
|
|
405
|
+
};
|
|
406
|
+
_ts_decorate5([
|
|
407
|
+
ApiProperty3({
|
|
408
|
+
description: "Display name for the saved view",
|
|
409
|
+
example: "AWS Only"
|
|
410
|
+
}),
|
|
411
|
+
IsString2(),
|
|
412
|
+
MaxLength2(100),
|
|
413
|
+
_ts_metadata5("design:type", String)
|
|
414
|
+
], CreateDataTableViewDto.prototype, "name", void 0);
|
|
415
|
+
_ts_decorate5([
|
|
416
|
+
ApiProperty3({
|
|
417
|
+
description: "Unique slug identifying the table",
|
|
418
|
+
example: "cloud-providers"
|
|
419
|
+
}),
|
|
420
|
+
IsString2(),
|
|
421
|
+
MaxLength2(200),
|
|
422
|
+
_ts_metadata5("design:type", String)
|
|
423
|
+
], CreateDataTableViewDto.prototype, "tableSlug", void 0);
|
|
424
|
+
_ts_decorate5([
|
|
425
|
+
ApiProperty3({
|
|
426
|
+
description: "Full table view state including filters, sort, and column visibility"
|
|
427
|
+
}),
|
|
428
|
+
IsObject2(),
|
|
429
|
+
_ts_metadata5("design:type", typeof TableViewState === "undefined" ? Object : TableViewState)
|
|
430
|
+
], CreateDataTableViewDto.prototype, "state", void 0);
|
|
431
|
+
_ts_decorate5([
|
|
432
|
+
ApiPropertyOptional3({
|
|
433
|
+
description: "Whether this view is visible to all users",
|
|
434
|
+
example: false
|
|
435
|
+
}),
|
|
436
|
+
IsBoolean(),
|
|
437
|
+
IsOptional2(),
|
|
438
|
+
_ts_metadata5("design:type", Boolean)
|
|
439
|
+
], CreateDataTableViewDto.prototype, "isShared", void 0);
|
|
440
|
+
|
|
441
|
+
// src/data-table/views/dto/request/rename-data-table-view.dto.ts
|
|
442
|
+
import { ApiProperty as ApiProperty4 } from "@nestjs/swagger";
|
|
443
|
+
import { IsString as IsString3, MaxLength as MaxLength3, MinLength } from "class-validator";
|
|
444
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
445
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
446
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
447
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
448
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
449
|
+
}
|
|
450
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
451
|
+
function _ts_metadata6(k, v) {
|
|
452
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
453
|
+
}
|
|
454
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
455
|
+
var RenameDataTableViewDto = class {
|
|
456
|
+
static {
|
|
457
|
+
__name(this, "RenameDataTableViewDto");
|
|
458
|
+
}
|
|
459
|
+
name;
|
|
460
|
+
};
|
|
461
|
+
_ts_decorate6([
|
|
462
|
+
ApiProperty4({
|
|
463
|
+
description: "New display name for the view",
|
|
464
|
+
example: "AWS Only"
|
|
465
|
+
}),
|
|
466
|
+
IsString3(),
|
|
467
|
+
MinLength(1),
|
|
468
|
+
MaxLength3(100),
|
|
469
|
+
_ts_metadata6("design:type", String)
|
|
470
|
+
], RenameDataTableViewDto.prototype, "name", void 0);
|
|
471
|
+
|
|
472
|
+
// src/data-table/views/dto/request/toggle-share-data-table-view.dto.ts
|
|
473
|
+
import { ApiProperty as ApiProperty5 } from "@nestjs/swagger";
|
|
474
|
+
import { IsBoolean as IsBoolean2 } from "class-validator";
|
|
475
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
476
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
477
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
478
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
479
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
480
|
+
}
|
|
481
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
482
|
+
function _ts_metadata7(k, v) {
|
|
483
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
484
|
+
}
|
|
485
|
+
__name(_ts_metadata7, "_ts_metadata");
|
|
486
|
+
var ToggleShareDataTableViewDto = class {
|
|
487
|
+
static {
|
|
488
|
+
__name(this, "ToggleShareDataTableViewDto");
|
|
489
|
+
}
|
|
490
|
+
isShared;
|
|
491
|
+
};
|
|
492
|
+
_ts_decorate7([
|
|
493
|
+
ApiProperty5({
|
|
494
|
+
description: "Whether the view should be visible to all users",
|
|
495
|
+
example: true
|
|
496
|
+
}),
|
|
497
|
+
IsBoolean2(),
|
|
498
|
+
_ts_metadata7("design:type", Boolean)
|
|
499
|
+
], ToggleShareDataTableViewDto.prototype, "isShared", void 0);
|
|
500
|
+
|
|
501
|
+
// src/data-table/views/dto/request/update-data-table-view.dto.ts
|
|
502
|
+
import { ApiProperty as ApiProperty6 } from "@nestjs/swagger";
|
|
503
|
+
import { IsObject as IsObject3 } from "class-validator";
|
|
504
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
505
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
506
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
507
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
508
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
509
|
+
}
|
|
510
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
511
|
+
function _ts_metadata8(k, v) {
|
|
512
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
513
|
+
}
|
|
514
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
515
|
+
var UpdateDataTableViewDto = class {
|
|
516
|
+
static {
|
|
517
|
+
__name(this, "UpdateDataTableViewDto");
|
|
518
|
+
}
|
|
519
|
+
state;
|
|
520
|
+
};
|
|
521
|
+
_ts_decorate8([
|
|
522
|
+
ApiProperty6({
|
|
523
|
+
description: "Updated filter, sort, and column visibility state"
|
|
524
|
+
}),
|
|
525
|
+
IsObject3(),
|
|
526
|
+
_ts_metadata8("design:type", typeof TableViewState === "undefined" ? Object : TableViewState)
|
|
527
|
+
], UpdateDataTableViewDto.prototype, "state", void 0);
|
|
528
|
+
|
|
529
|
+
// src/data-table/views/docs/data-table-views.docs.ts
|
|
530
|
+
function ApiListDataTableViews() {
|
|
531
|
+
return applyDecorators2(ApiOperation2({
|
|
532
|
+
summary: "List named table views",
|
|
533
|
+
description: "Returns the authenticated user's own named views plus all shared views for the given table slug."
|
|
534
|
+
}), ApiQuery({
|
|
535
|
+
name: "tableSlug",
|
|
536
|
+
description: "Slug of the table to fetch views for",
|
|
537
|
+
example: "cloud-providers",
|
|
538
|
+
required: true
|
|
539
|
+
}), ApiResponse2({
|
|
540
|
+
status: 200,
|
|
541
|
+
description: "Named views retrieved.",
|
|
542
|
+
type: [
|
|
543
|
+
DataTableViewDto
|
|
544
|
+
]
|
|
545
|
+
}), ApiResponse2({
|
|
546
|
+
status: 401,
|
|
547
|
+
description: "Unauthorized."
|
|
548
|
+
}));
|
|
549
|
+
}
|
|
550
|
+
__name(ApiListDataTableViews, "ApiListDataTableViews");
|
|
551
|
+
function ApiCreateDataTableView() {
|
|
552
|
+
return applyDecorators2(ApiOperation2({
|
|
553
|
+
summary: "Create named table view",
|
|
554
|
+
description: "Saves the current table state as a named view snapshot. The name must be unique per user+table."
|
|
555
|
+
}), ApiBody2({
|
|
556
|
+
type: CreateDataTableViewDto
|
|
557
|
+
}), ApiResponse2({
|
|
558
|
+
status: 201,
|
|
559
|
+
description: "Named view created.",
|
|
560
|
+
type: DataTableViewDto
|
|
561
|
+
}), ApiResponse2({
|
|
562
|
+
status: 400,
|
|
563
|
+
description: "Invalid request body."
|
|
564
|
+
}), ApiResponse2({
|
|
565
|
+
status: 401,
|
|
566
|
+
description: "Unauthorized."
|
|
567
|
+
}));
|
|
568
|
+
}
|
|
569
|
+
__name(ApiCreateDataTableView, "ApiCreateDataTableView");
|
|
570
|
+
function ApiUpdateDataTableView() {
|
|
571
|
+
return applyDecorators2(ApiOperation2({
|
|
572
|
+
summary: "Update named table view",
|
|
573
|
+
description: "Updates the state of an existing named view. Only the owner can update."
|
|
574
|
+
}), ApiParam({
|
|
575
|
+
name: "id",
|
|
576
|
+
description: "UUID of the table view to update"
|
|
577
|
+
}), ApiBody2({
|
|
578
|
+
type: UpdateDataTableViewDto
|
|
579
|
+
}), ApiResponse2({
|
|
580
|
+
status: 200,
|
|
581
|
+
description: "View updated.",
|
|
582
|
+
type: DataTableViewDto
|
|
583
|
+
}), ApiResponse2({
|
|
584
|
+
status: 400,
|
|
585
|
+
description: "Validation failed or not owned by caller."
|
|
586
|
+
}), ApiResponse2({
|
|
587
|
+
status: 401,
|
|
588
|
+
description: "Unauthorized."
|
|
589
|
+
}), ApiResponse2({
|
|
590
|
+
status: 404,
|
|
591
|
+
description: "View not found."
|
|
592
|
+
}));
|
|
593
|
+
}
|
|
594
|
+
__name(ApiUpdateDataTableView, "ApiUpdateDataTableView");
|
|
595
|
+
function ApiRenameDataTableView() {
|
|
596
|
+
return applyDecorators2(ApiOperation2({
|
|
597
|
+
summary: "Rename a named table view",
|
|
598
|
+
description: "Updates the display name of an existing view. The new name must be unique per user+table. Only the owner can rename."
|
|
599
|
+
}), ApiParam({
|
|
600
|
+
name: "id",
|
|
601
|
+
description: "UUID of the table view to rename"
|
|
602
|
+
}), ApiBody2({
|
|
603
|
+
type: RenameDataTableViewDto
|
|
604
|
+
}), ApiResponse2({
|
|
605
|
+
status: 200,
|
|
606
|
+
description: "View renamed.",
|
|
607
|
+
type: DataTableViewDto
|
|
608
|
+
}), ApiResponse2({
|
|
609
|
+
status: 400,
|
|
610
|
+
description: "Not owned by caller."
|
|
611
|
+
}), ApiResponse2({
|
|
612
|
+
status: 401,
|
|
613
|
+
description: "Unauthorized."
|
|
614
|
+
}), ApiResponse2({
|
|
615
|
+
status: 404,
|
|
616
|
+
description: "View not found."
|
|
617
|
+
}), ApiResponse2({
|
|
618
|
+
status: 409,
|
|
619
|
+
description: "A view with this name already exists."
|
|
620
|
+
}));
|
|
621
|
+
}
|
|
622
|
+
__name(ApiRenameDataTableView, "ApiRenameDataTableView");
|
|
623
|
+
function ApiToggleShareDataTableView() {
|
|
624
|
+
return applyDecorators2(ApiOperation2({
|
|
625
|
+
summary: "Toggle view sharing",
|
|
626
|
+
description: "Makes a view visible to all users (shared) or restricts it to the owner only (private). Only the owner can toggle sharing."
|
|
627
|
+
}), ApiParam({
|
|
628
|
+
name: "id",
|
|
629
|
+
description: "UUID of the table view"
|
|
630
|
+
}), ApiBody2({
|
|
631
|
+
type: ToggleShareDataTableViewDto
|
|
632
|
+
}), ApiResponse2({
|
|
633
|
+
status: 200,
|
|
634
|
+
description: "Sharing status updated.",
|
|
635
|
+
type: DataTableViewDto
|
|
636
|
+
}), ApiResponse2({
|
|
637
|
+
status: 400,
|
|
638
|
+
description: "Not owned by caller."
|
|
639
|
+
}), ApiResponse2({
|
|
640
|
+
status: 401,
|
|
641
|
+
description: "Unauthorized."
|
|
642
|
+
}), ApiResponse2({
|
|
643
|
+
status: 404,
|
|
644
|
+
description: "View not found."
|
|
645
|
+
}));
|
|
646
|
+
}
|
|
647
|
+
__name(ApiToggleShareDataTableView, "ApiToggleShareDataTableView");
|
|
648
|
+
function ApiDeleteDataTableView() {
|
|
649
|
+
return applyDecorators2(ApiOperation2({
|
|
650
|
+
summary: "Delete named table view",
|
|
651
|
+
description: "Permanently deletes a named view. Only the owner can delete their own views."
|
|
652
|
+
}), ApiParam({
|
|
653
|
+
name: "id",
|
|
654
|
+
description: "UUID of the table view to delete"
|
|
655
|
+
}), ApiResponse2({
|
|
656
|
+
status: 200,
|
|
657
|
+
description: "View deleted.",
|
|
658
|
+
type: DataTableViewDto
|
|
659
|
+
}), ApiResponse2({
|
|
660
|
+
status: 400,
|
|
661
|
+
description: "Not owned by caller."
|
|
662
|
+
}), ApiResponse2({
|
|
663
|
+
status: 401,
|
|
664
|
+
description: "Unauthorized."
|
|
665
|
+
}), ApiResponse2({
|
|
666
|
+
status: 404,
|
|
667
|
+
description: "View not found."
|
|
668
|
+
}));
|
|
669
|
+
}
|
|
670
|
+
__name(ApiDeleteDataTableView, "ApiDeleteDataTableView");
|
|
671
|
+
|
|
672
|
+
// src/data-table/views/services/data-table-views.service.ts
|
|
673
|
+
import { createHash } from "crypto";
|
|
674
|
+
import { Injectable as Injectable3, Logger as Logger3 } from "@nestjs/common";
|
|
675
|
+
import { ConfigService as ConfigService2 } from "@nestjs/config";
|
|
676
|
+
import { CacheService as CacheService2 } from "@vritti/api-sdk/cache";
|
|
677
|
+
|
|
678
|
+
// src/exceptions/bad-gateway.exception.ts
|
|
679
|
+
import { HttpStatus as HttpStatus2 } from "@nestjs/common";
|
|
680
|
+
|
|
681
|
+
// src/exceptions/base-field.exception.ts
|
|
682
|
+
import { HttpException } from "@nestjs/common";
|
|
683
|
+
var HttpProblemException = class extends HttpException {
|
|
684
|
+
static {
|
|
685
|
+
__name(this, "HttpProblemException");
|
|
686
|
+
}
|
|
687
|
+
constructor(detailOrOptions, httpStatus) {
|
|
688
|
+
const options = typeof detailOrOptions === "string" ? {
|
|
689
|
+
detail: detailOrOptions
|
|
690
|
+
} : detailOrOptions;
|
|
691
|
+
super({
|
|
692
|
+
type: options.type ?? "about:blank",
|
|
693
|
+
label: options.label,
|
|
694
|
+
detail: options.detail,
|
|
695
|
+
errors: options.errors ?? []
|
|
696
|
+
}, httpStatus);
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
// src/exceptions/bad-request.exception.ts
|
|
701
|
+
import { HttpStatus as HttpStatus3 } from "@nestjs/common";
|
|
702
|
+
var BadRequestException = class extends HttpProblemException {
|
|
703
|
+
static {
|
|
704
|
+
__name(this, "BadRequestException");
|
|
705
|
+
}
|
|
706
|
+
constructor(detailOrOptions) {
|
|
707
|
+
super(detailOrOptions ?? "Bad Request", HttpStatus3.BAD_REQUEST);
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
// src/exceptions/conflict.exception.ts
|
|
712
|
+
import { HttpStatus as HttpStatus4 } from "@nestjs/common";
|
|
713
|
+
var ConflictException = class extends HttpProblemException {
|
|
714
|
+
static {
|
|
715
|
+
__name(this, "ConflictException");
|
|
716
|
+
}
|
|
717
|
+
constructor(detailOrOptions) {
|
|
718
|
+
super(detailOrOptions ?? "Conflict", HttpStatus4.CONFLICT);
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
// src/exceptions/forbidden.exception.ts
|
|
723
|
+
import { HttpStatus as HttpStatus5 } from "@nestjs/common";
|
|
724
|
+
|
|
725
|
+
// src/exceptions/gone.exception.ts
|
|
726
|
+
import { HttpStatus as HttpStatus6 } from "@nestjs/common";
|
|
727
|
+
|
|
728
|
+
// src/exceptions/internal-server-error.exception.ts
|
|
729
|
+
import { HttpStatus as HttpStatus7 } from "@nestjs/common";
|
|
730
|
+
|
|
731
|
+
// src/exceptions/method-not-allowed.exception.ts
|
|
732
|
+
import { HttpStatus as HttpStatus8 } from "@nestjs/common";
|
|
733
|
+
|
|
734
|
+
// src/exceptions/not-acceptable.exception.ts
|
|
735
|
+
import { HttpStatus as HttpStatus9 } from "@nestjs/common";
|
|
736
|
+
|
|
737
|
+
// src/exceptions/not-found.exception.ts
|
|
738
|
+
import { HttpStatus as HttpStatus10 } from "@nestjs/common";
|
|
739
|
+
var NotFoundException = class extends HttpProblemException {
|
|
740
|
+
static {
|
|
741
|
+
__name(this, "NotFoundException");
|
|
742
|
+
}
|
|
743
|
+
constructor(detailOrOptions) {
|
|
744
|
+
super(detailOrOptions ?? "Not Found", HttpStatus10.NOT_FOUND);
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
|
|
748
|
+
// src/exceptions/not-implemented.exception.ts
|
|
749
|
+
import { HttpStatus as HttpStatus11 } from "@nestjs/common";
|
|
750
|
+
|
|
751
|
+
// src/exceptions/payload-too-large.exception.ts
|
|
752
|
+
import { HttpStatus as HttpStatus12 } from "@nestjs/common";
|
|
753
|
+
|
|
754
|
+
// src/exceptions/request-timeout.exception.ts
|
|
755
|
+
import { HttpStatus as HttpStatus13 } from "@nestjs/common";
|
|
756
|
+
|
|
757
|
+
// src/exceptions/service-unavailable.exception.ts
|
|
758
|
+
import { HttpStatus as HttpStatus14 } from "@nestjs/common";
|
|
759
|
+
|
|
760
|
+
// src/exceptions/too-many-requests.exception.ts
|
|
761
|
+
import { HttpStatus as HttpStatus15 } from "@nestjs/common";
|
|
762
|
+
|
|
763
|
+
// src/exceptions/unauthorized.exception.ts
|
|
764
|
+
import { HttpStatus as HttpStatus16 } from "@nestjs/common";
|
|
765
|
+
|
|
766
|
+
// src/exceptions/unprocessable-entity.exception.ts
|
|
767
|
+
import { HttpStatus as HttpStatus17 } from "@nestjs/common";
|
|
768
|
+
|
|
769
|
+
// src/exceptions/unsupported-media-type.exception.ts
|
|
770
|
+
import { HttpStatus as HttpStatus18 } from "@nestjs/common";
|
|
771
|
+
|
|
772
|
+
// src/exceptions/validation.exception.ts
|
|
773
|
+
import { HttpStatus as HttpStatus19 } from "@nestjs/common";
|
|
774
|
+
|
|
775
|
+
// src/data-table/views/repositories/data-table-views.repository.ts
|
|
776
|
+
import { Inject, Injectable as Injectable2 } from "@nestjs/common";
|
|
777
|
+
import { and, eq } from "drizzle-orm";
|
|
778
|
+
import { PrimaryBaseRepository, PrimaryDatabaseService } from "@vritti/api-sdk/database";
|
|
779
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
780
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
781
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
782
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
783
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
784
|
+
}
|
|
785
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
786
|
+
function _ts_metadata9(k, v) {
|
|
787
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
788
|
+
}
|
|
789
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
790
|
+
function _ts_param2(paramIndex, decorator) {
|
|
791
|
+
return function(target, key) {
|
|
792
|
+
decorator(target, key, paramIndex);
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
__name(_ts_param2, "_ts_param");
|
|
796
|
+
var NAMED_VIEWS_LIMIT = 100;
|
|
797
|
+
var DataTableViewsRepository = class extends PrimaryBaseRepository {
|
|
798
|
+
static {
|
|
799
|
+
__name(this, "DataTableViewsRepository");
|
|
800
|
+
}
|
|
801
|
+
constructor(database, table) {
|
|
802
|
+
super(database, table);
|
|
803
|
+
}
|
|
804
|
+
// Returns personal (non-shared) named views owned by the user for a given table
|
|
805
|
+
async findPersonalViewsBySlug(userId, tableSlug) {
|
|
806
|
+
const t = this.table;
|
|
807
|
+
return this.db.select().from(this.table).where(and(eq(t.tableSlug, tableSlug), eq(t.userId, userId), eq(t.isShared, false))).orderBy(t.createdAt).limit(NAMED_VIEWS_LIMIT);
|
|
808
|
+
}
|
|
809
|
+
// Returns all shared named views for a given table — visible to all users
|
|
810
|
+
async findSharedViewsBySlug(tableSlug) {
|
|
811
|
+
const t = this.table;
|
|
812
|
+
return this.db.select().from(this.table).where(and(eq(t.tableSlug, tableSlug), eq(t.isShared, true))).orderBy(t.createdAt).limit(NAMED_VIEWS_LIMIT);
|
|
813
|
+
}
|
|
814
|
+
};
|
|
815
|
+
DataTableViewsRepository = _ts_decorate9([
|
|
816
|
+
Injectable2(),
|
|
817
|
+
_ts_param2(1, Inject(DATA_TABLE_VIEWS_TABLE)),
|
|
818
|
+
_ts_metadata9("design:type", Function),
|
|
819
|
+
_ts_metadata9("design:paramtypes", [
|
|
820
|
+
typeof PrimaryDatabaseService === "undefined" ? Object : PrimaryDatabaseService,
|
|
821
|
+
typeof PgTable === "undefined" ? Object : PgTable
|
|
822
|
+
])
|
|
823
|
+
], DataTableViewsRepository);
|
|
824
|
+
|
|
825
|
+
// src/data-table/views/services/data-table-views.service.ts
|
|
826
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
827
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
828
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
829
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
830
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
831
|
+
}
|
|
832
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
833
|
+
function _ts_metadata10(k, v) {
|
|
834
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
835
|
+
}
|
|
836
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
837
|
+
function computeChecksum(value) {
|
|
838
|
+
return createHash("sha256").update(JSON.stringify(value)).digest("hex");
|
|
839
|
+
}
|
|
840
|
+
__name(computeChecksum, "computeChecksum");
|
|
841
|
+
var DataTableViewsService = class _DataTableViewsService {
|
|
842
|
+
static {
|
|
843
|
+
__name(this, "DataTableViewsService");
|
|
844
|
+
}
|
|
845
|
+
dataTableViewsRepository;
|
|
846
|
+
cacheService;
|
|
847
|
+
configService;
|
|
848
|
+
logger = new Logger3(_DataTableViewsService.name);
|
|
849
|
+
constructor(dataTableViewsRepository, cacheService, configService) {
|
|
850
|
+
this.dataTableViewsRepository = dataTableViewsRepository;
|
|
851
|
+
this.cacheService = cacheService;
|
|
852
|
+
this.configService = configService;
|
|
853
|
+
}
|
|
854
|
+
// Builds the Redis key for a user's personal (non-shared) views for a given table
|
|
855
|
+
personalViewsKey(userId, tableSlug) {
|
|
856
|
+
return `views:personal:${userId}:${tableSlug}`;
|
|
857
|
+
}
|
|
858
|
+
// Builds the Redis key for all shared views for a given table — same key for all users
|
|
859
|
+
sharedViewsKey(tableSlug) {
|
|
860
|
+
return `views:shared:${tableSlug}`;
|
|
861
|
+
}
|
|
862
|
+
// Returns configured TTL for named views in seconds, defaulting to 86400 (24h)
|
|
863
|
+
get viewsTtl() {
|
|
864
|
+
return this.configService.get("TABLE_VIEWS_CACHE_TTL") ?? 86400;
|
|
865
|
+
}
|
|
866
|
+
// Fetches personal views from cache; falls back to DB and warms cache on miss
|
|
867
|
+
async getOrCachePersonalViews(userId, tableSlug) {
|
|
868
|
+
const key = this.personalViewsKey(userId, tableSlug);
|
|
869
|
+
const cached = await this.cacheService.get(key);
|
|
870
|
+
if (cached) {
|
|
871
|
+
this.logger.debug(`Cache hit for personal views: user=${userId}, table=${tableSlug}`);
|
|
872
|
+
return cached;
|
|
873
|
+
}
|
|
874
|
+
const rows = await this.dataTableViewsRepository.findPersonalViewsBySlug(userId, tableSlug);
|
|
875
|
+
await this.cacheService.set(key, rows, this.viewsTtl);
|
|
876
|
+
return rows;
|
|
877
|
+
}
|
|
878
|
+
// Fetches shared views from cache; falls back to DB and warms cache on miss
|
|
879
|
+
async getOrCacheSharedViews(tableSlug) {
|
|
880
|
+
const key = this.sharedViewsKey(tableSlug);
|
|
881
|
+
const cached = await this.cacheService.get(key);
|
|
882
|
+
if (cached) {
|
|
883
|
+
this.logger.debug(`Cache hit for shared views: table=${tableSlug}`);
|
|
884
|
+
return cached;
|
|
885
|
+
}
|
|
886
|
+
const rows = await this.dataTableViewsRepository.findSharedViewsBySlug(tableSlug);
|
|
887
|
+
await this.cacheService.set(key, rows, this.viewsTtl);
|
|
888
|
+
return rows;
|
|
889
|
+
}
|
|
890
|
+
// Deletes personal and/or shared cache keys based on which pools the mutation affects
|
|
891
|
+
async invalidateViewsCache(userId, tableSlug, affectsPersonal, affectsShared) {
|
|
892
|
+
const toDelete = [];
|
|
893
|
+
if (affectsPersonal) toDelete.push(this.personalViewsKey(userId, tableSlug));
|
|
894
|
+
if (affectsShared) toDelete.push(this.sharedViewsKey(tableSlug));
|
|
895
|
+
if (toDelete.length > 0) await this.cacheService.del(...toDelete);
|
|
896
|
+
}
|
|
897
|
+
// Returns personal + shared named views — each pool fetched from cache or DB in parallel
|
|
898
|
+
async findViews(userId, tableSlug) {
|
|
899
|
+
const [personalRows, sharedRows] = await Promise.all([
|
|
900
|
+
this.getOrCachePersonalViews(userId, tableSlug),
|
|
901
|
+
this.getOrCacheSharedViews(tableSlug)
|
|
902
|
+
]);
|
|
903
|
+
return [
|
|
904
|
+
...personalRows,
|
|
905
|
+
...sharedRows
|
|
906
|
+
].map((row) => DataTableViewDto.from(row, userId));
|
|
907
|
+
}
|
|
908
|
+
// Creates a named snapshot and invalidates the relevant cache pool
|
|
909
|
+
async createView(userId, dto) {
|
|
910
|
+
const view = await this.dataTableViewsRepository.create({
|
|
911
|
+
userId,
|
|
912
|
+
tableSlug: dto.tableSlug,
|
|
913
|
+
name: dto.name,
|
|
914
|
+
state: dto.state,
|
|
915
|
+
isShared: dto.isShared ?? false
|
|
916
|
+
});
|
|
917
|
+
this.logger.log(`Created view "${dto.name}" for user: ${userId}, table: ${dto.tableSlug}`);
|
|
918
|
+
const isShared = dto.isShared ?? false;
|
|
919
|
+
await this.invalidateViewsCache(userId, dto.tableSlug, !isShared, isShared);
|
|
920
|
+
return DataTableViewDto.from(view, userId);
|
|
921
|
+
}
|
|
922
|
+
// Updates the state of a named view — skips DB write if state is unchanged
|
|
923
|
+
async updateView(userId, id, dto) {
|
|
924
|
+
const view = await this.dataTableViewsRepository.findById(id);
|
|
925
|
+
if (!view) throw new NotFoundException("Table view not found.");
|
|
926
|
+
if (view.userId !== userId) throw new BadRequestException("You do not have permission to update this view.");
|
|
927
|
+
if (computeChecksum(dto.state) === computeChecksum(view.state)) {
|
|
928
|
+
this.logger.log(`State unchanged for view ${id} \u2014 skipping DB write`);
|
|
929
|
+
return DataTableViewDto.from(view, userId);
|
|
930
|
+
}
|
|
931
|
+
const updated = await this.dataTableViewsRepository.update(id, {
|
|
932
|
+
state: dto.state
|
|
933
|
+
});
|
|
934
|
+
this.logger.log(`Updated state for view ${id}, user: ${userId}`);
|
|
935
|
+
await this.invalidateViewsCache(userId, view.tableSlug, !view.isShared, view.isShared);
|
|
936
|
+
return DataTableViewDto.from(updated, userId);
|
|
937
|
+
}
|
|
938
|
+
// Toggles the sharing status of a named view — updates both personal and shared cache
|
|
939
|
+
async toggleShareView(userId, id, isShared) {
|
|
940
|
+
const view = await this.dataTableViewsRepository.findById(id);
|
|
941
|
+
if (!view) throw new NotFoundException("Table view not found.");
|
|
942
|
+
if (view.userId !== userId) throw new BadRequestException("You do not have permission to share this view.");
|
|
943
|
+
const updated = await this.dataTableViewsRepository.update(id, {
|
|
944
|
+
isShared
|
|
945
|
+
});
|
|
946
|
+
this.logger.log(`Set isShared=${isShared} for view ${id}, user: ${userId}`);
|
|
947
|
+
await this.invalidateViewsCache(userId, view.tableSlug, true, true);
|
|
948
|
+
return DataTableViewDto.from(updated, userId);
|
|
949
|
+
}
|
|
950
|
+
// Renames a named view — enforces unique name per user+table, invalidates personal cache
|
|
951
|
+
async renameView(userId, id, name) {
|
|
952
|
+
const view = await this.dataTableViewsRepository.findById(id);
|
|
953
|
+
if (!view) throw new NotFoundException("Table view not found.");
|
|
954
|
+
if (view.userId !== userId) throw new BadRequestException("You do not have permission to rename this view.");
|
|
955
|
+
const existing = await this.dataTableViewsRepository.findOne({
|
|
956
|
+
userId,
|
|
957
|
+
tableSlug: view.tableSlug,
|
|
958
|
+
name,
|
|
959
|
+
isShared: false
|
|
960
|
+
});
|
|
961
|
+
if (existing && existing.id !== id) {
|
|
962
|
+
throw new ConflictException({
|
|
963
|
+
label: "Name Already Taken",
|
|
964
|
+
detail: "A view with this name already exists for this table.",
|
|
965
|
+
errors: [
|
|
966
|
+
{
|
|
967
|
+
field: "name",
|
|
968
|
+
message: "Name already taken"
|
|
969
|
+
}
|
|
970
|
+
]
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
const updated = await this.dataTableViewsRepository.update(id, {
|
|
974
|
+
name
|
|
975
|
+
});
|
|
976
|
+
this.logger.log(`Renamed view ${id} to "${name}" for user: ${userId}`);
|
|
977
|
+
await this.invalidateViewsCache(userId, view.tableSlug, !view.isShared, view.isShared);
|
|
978
|
+
return DataTableViewDto.from(updated, userId);
|
|
979
|
+
}
|
|
980
|
+
// Deletes a named view and invalidates the relevant cache pool
|
|
981
|
+
async deleteView(userId, id) {
|
|
982
|
+
const view = await this.dataTableViewsRepository.findById(id);
|
|
983
|
+
if (!view) throw new NotFoundException("Table view not found.");
|
|
984
|
+
if (view.userId !== userId) throw new BadRequestException("You do not have permission to delete this view.");
|
|
985
|
+
await this.dataTableViewsRepository.delete(id);
|
|
986
|
+
this.logger.log(`Deleted view ${id} for user: ${userId}`);
|
|
987
|
+
await this.invalidateViewsCache(userId, view.tableSlug, !view.isShared, view.isShared);
|
|
988
|
+
return DataTableViewDto.from(view, userId);
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
DataTableViewsService = _ts_decorate10([
|
|
992
|
+
Injectable3(),
|
|
993
|
+
_ts_metadata10("design:type", Function),
|
|
994
|
+
_ts_metadata10("design:paramtypes", [
|
|
995
|
+
typeof DataTableViewsRepository === "undefined" ? Object : DataTableViewsRepository,
|
|
996
|
+
typeof CacheService2 === "undefined" ? Object : CacheService2,
|
|
997
|
+
typeof ConfigService2 === "undefined" ? Object : ConfigService2
|
|
998
|
+
])
|
|
999
|
+
], DataTableViewsService);
|
|
1000
|
+
|
|
1001
|
+
// src/data-table/views/controllers/data-table-views.controller.ts
|
|
1002
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
1003
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1004
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1005
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1006
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1007
|
+
}
|
|
1008
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
1009
|
+
function _ts_metadata11(k, v) {
|
|
1010
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1011
|
+
}
|
|
1012
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
1013
|
+
function _ts_param3(paramIndex, decorator) {
|
|
1014
|
+
return function(target, key) {
|
|
1015
|
+
decorator(target, key, paramIndex);
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
__name(_ts_param3, "_ts_param");
|
|
1019
|
+
var DataTableViewsController = class _DataTableViewsController {
|
|
1020
|
+
static {
|
|
1021
|
+
__name(this, "DataTableViewsController");
|
|
1022
|
+
}
|
|
1023
|
+
dataTableViewsService;
|
|
1024
|
+
logger = new Logger4(_DataTableViewsController.name);
|
|
1025
|
+
constructor(dataTableViewsService) {
|
|
1026
|
+
this.dataTableViewsService = dataTableViewsService;
|
|
1027
|
+
}
|
|
1028
|
+
// Returns all named views for the given table — own plus shared
|
|
1029
|
+
findViews(userId, tableSlug) {
|
|
1030
|
+
this.logger.log(`GET /table-views?tableSlug=${tableSlug} - User: ${userId}`);
|
|
1031
|
+
return this.dataTableViewsService.findViews(userId, tableSlug);
|
|
1032
|
+
}
|
|
1033
|
+
// Creates a named snapshot of the current table state
|
|
1034
|
+
createView(userId, dto) {
|
|
1035
|
+
this.logger.log(`POST /table-views - User: ${userId}, table: ${dto.tableSlug}`);
|
|
1036
|
+
return this.dataTableViewsService.createView(userId, dto);
|
|
1037
|
+
}
|
|
1038
|
+
// Updates state of an existing named view
|
|
1039
|
+
updateView(userId, id, dto) {
|
|
1040
|
+
this.logger.log(`PATCH /table-views/${id} - User: ${userId}`);
|
|
1041
|
+
return this.dataTableViewsService.updateView(userId, id, dto);
|
|
1042
|
+
}
|
|
1043
|
+
// Renames an existing named view — enforces unique name per user+table
|
|
1044
|
+
renameView(userId, id, dto) {
|
|
1045
|
+
this.logger.log(`PATCH /table-views/${id}/rename - User: ${userId}`);
|
|
1046
|
+
return this.dataTableViewsService.renameView(userId, id, dto.name);
|
|
1047
|
+
}
|
|
1048
|
+
// Toggles sharing visibility of a named view
|
|
1049
|
+
toggleShareView(userId, id, dto) {
|
|
1050
|
+
this.logger.log(`PATCH /table-views/${id}/share - User: ${userId}`);
|
|
1051
|
+
return this.dataTableViewsService.toggleShareView(userId, id, dto.isShared);
|
|
1052
|
+
}
|
|
1053
|
+
// Deletes a named view owned by the authenticated user
|
|
1054
|
+
deleteView(userId, id) {
|
|
1055
|
+
this.logger.log(`DELETE /table-views/${id} - User: ${userId}`);
|
|
1056
|
+
return this.dataTableViewsService.deleteView(userId, id);
|
|
1057
|
+
}
|
|
1058
|
+
};
|
|
1059
|
+
_ts_decorate11([
|
|
1060
|
+
Get(),
|
|
1061
|
+
ApiListDataTableViews(),
|
|
1062
|
+
_ts_param3(0, UserId()),
|
|
1063
|
+
_ts_param3(1, Query("tableSlug")),
|
|
1064
|
+
_ts_metadata11("design:type", Function),
|
|
1065
|
+
_ts_metadata11("design:paramtypes", [
|
|
1066
|
+
String,
|
|
1067
|
+
String
|
|
1068
|
+
]),
|
|
1069
|
+
_ts_metadata11("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
1070
|
+
], DataTableViewsController.prototype, "findViews", null);
|
|
1071
|
+
_ts_decorate11([
|
|
1072
|
+
Post2(),
|
|
1073
|
+
HttpCode2(HttpStatus20.CREATED),
|
|
1074
|
+
ApiCreateDataTableView(),
|
|
1075
|
+
_ts_param3(0, UserId()),
|
|
1076
|
+
_ts_param3(1, Body2()),
|
|
1077
|
+
_ts_metadata11("design:type", Function),
|
|
1078
|
+
_ts_metadata11("design:paramtypes", [
|
|
1079
|
+
String,
|
|
1080
|
+
typeof CreateDataTableViewDto === "undefined" ? Object : CreateDataTableViewDto
|
|
1081
|
+
]),
|
|
1082
|
+
_ts_metadata11("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
1083
|
+
], DataTableViewsController.prototype, "createView", null);
|
|
1084
|
+
_ts_decorate11([
|
|
1085
|
+
Patch(":id"),
|
|
1086
|
+
ApiUpdateDataTableView(),
|
|
1087
|
+
_ts_param3(0, UserId()),
|
|
1088
|
+
_ts_param3(1, Param("id")),
|
|
1089
|
+
_ts_param3(2, Body2()),
|
|
1090
|
+
_ts_metadata11("design:type", Function),
|
|
1091
|
+
_ts_metadata11("design:paramtypes", [
|
|
1092
|
+
String,
|
|
1093
|
+
String,
|
|
1094
|
+
typeof UpdateDataTableViewDto === "undefined" ? Object : UpdateDataTableViewDto
|
|
1095
|
+
]),
|
|
1096
|
+
_ts_metadata11("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
1097
|
+
], DataTableViewsController.prototype, "updateView", null);
|
|
1098
|
+
_ts_decorate11([
|
|
1099
|
+
Patch(":id/rename"),
|
|
1100
|
+
ApiRenameDataTableView(),
|
|
1101
|
+
_ts_param3(0, UserId()),
|
|
1102
|
+
_ts_param3(1, Param("id")),
|
|
1103
|
+
_ts_param3(2, Body2()),
|
|
1104
|
+
_ts_metadata11("design:type", Function),
|
|
1105
|
+
_ts_metadata11("design:paramtypes", [
|
|
1106
|
+
String,
|
|
1107
|
+
String,
|
|
1108
|
+
typeof RenameDataTableViewDto === "undefined" ? Object : RenameDataTableViewDto
|
|
1109
|
+
]),
|
|
1110
|
+
_ts_metadata11("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
1111
|
+
], DataTableViewsController.prototype, "renameView", null);
|
|
1112
|
+
_ts_decorate11([
|
|
1113
|
+
Patch(":id/share"),
|
|
1114
|
+
ApiToggleShareDataTableView(),
|
|
1115
|
+
_ts_param3(0, UserId()),
|
|
1116
|
+
_ts_param3(1, Param("id")),
|
|
1117
|
+
_ts_param3(2, Body2()),
|
|
1118
|
+
_ts_metadata11("design:type", Function),
|
|
1119
|
+
_ts_metadata11("design:paramtypes", [
|
|
1120
|
+
String,
|
|
1121
|
+
String,
|
|
1122
|
+
typeof ToggleShareDataTableViewDto === "undefined" ? Object : ToggleShareDataTableViewDto
|
|
1123
|
+
]),
|
|
1124
|
+
_ts_metadata11("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
1125
|
+
], DataTableViewsController.prototype, "toggleShareView", null);
|
|
1126
|
+
_ts_decorate11([
|
|
1127
|
+
Delete(":id"),
|
|
1128
|
+
ApiDeleteDataTableView(),
|
|
1129
|
+
_ts_param3(0, UserId()),
|
|
1130
|
+
_ts_param3(1, Param("id")),
|
|
1131
|
+
_ts_metadata11("design:type", Function),
|
|
1132
|
+
_ts_metadata11("design:paramtypes", [
|
|
1133
|
+
String,
|
|
1134
|
+
String
|
|
1135
|
+
]),
|
|
1136
|
+
_ts_metadata11("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
1137
|
+
], DataTableViewsController.prototype, "deleteView", null);
|
|
1138
|
+
DataTableViewsController = _ts_decorate11([
|
|
1139
|
+
ApiTags2("Table Views"),
|
|
1140
|
+
ApiBearerAuth2(),
|
|
1141
|
+
Controller2("table-views"),
|
|
1142
|
+
_ts_metadata11("design:type", Function),
|
|
1143
|
+
_ts_metadata11("design:paramtypes", [
|
|
1144
|
+
typeof DataTableViewsService === "undefined" ? Object : DataTableViewsService
|
|
1145
|
+
])
|
|
1146
|
+
], DataTableViewsController);
|
|
1147
|
+
|
|
1148
|
+
// src/data-table/data-table.module.ts
|
|
1149
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
1150
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1151
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1152
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1153
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1154
|
+
}
|
|
1155
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
1156
|
+
var DataTableModule = class _DataTableModule {
|
|
1157
|
+
static {
|
|
1158
|
+
__name(this, "DataTableModule");
|
|
1159
|
+
}
|
|
1160
|
+
static forRoot(options) {
|
|
1161
|
+
return {
|
|
1162
|
+
global: true,
|
|
1163
|
+
module: _DataTableModule,
|
|
1164
|
+
imports: [
|
|
1165
|
+
ConfigModule,
|
|
1166
|
+
CacheModule
|
|
1167
|
+
],
|
|
1168
|
+
controllers: [
|
|
1169
|
+
DataTableStateController,
|
|
1170
|
+
DataTableViewsController
|
|
1171
|
+
],
|
|
1172
|
+
providers: [
|
|
1173
|
+
{
|
|
1174
|
+
provide: DATA_TABLE_VIEWS_TABLE,
|
|
1175
|
+
useValue: options.tableViews
|
|
1176
|
+
},
|
|
1177
|
+
DataTableViewsService,
|
|
1178
|
+
DataTableViewsRepository,
|
|
1179
|
+
DataTableStateService
|
|
1180
|
+
],
|
|
1181
|
+
exports: [
|
|
1182
|
+
DataTableViewsService,
|
|
1183
|
+
DataTableStateService
|
|
1184
|
+
]
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1188
|
+
DataTableModule = _ts_decorate12([
|
|
1189
|
+
Module({})
|
|
1190
|
+
], DataTableModule);
|
|
1191
|
+
|
|
1192
|
+
// src/drizzle-pg-core.ts
|
|
1193
|
+
var drizzle_pg_core_exports = {};
|
|
1194
|
+
__export(drizzle_pg_core_exports, {
|
|
1195
|
+
codeCheck: () => codeCheck
|
|
1196
|
+
});
|
|
1197
|
+
__reExport(drizzle_pg_core_exports, pg_core_star);
|
|
1198
|
+
import * as pg_core_star from "drizzle-orm/pg-core";
|
|
1199
|
+
import { sql } from "drizzle-orm";
|
|
1200
|
+
import { check } from "drizzle-orm/pg-core";
|
|
1201
|
+
|
|
1202
|
+
// src/decorators/code-pattern.ts
|
|
1203
|
+
var SEGMENT = "[a-z][a-z0-9-]*";
|
|
1204
|
+
var CODE_PATTERN_SOURCE = `^${SEGMENT}$`;
|
|
1205
|
+
var DOTTED_CODE_PATTERN_SOURCE = `^${SEGMENT}(\\.${SEGMENT})*$`;
|
|
1206
|
+
var CODE_PATTERN = new RegExp(CODE_PATTERN_SOURCE);
|
|
1207
|
+
var DOTTED_CODE_PATTERN = new RegExp(DOTTED_CODE_PATTERN_SOURCE);
|
|
1208
|
+
|
|
1209
|
+
// src/drizzle-pg-core.ts
|
|
1210
|
+
function codeCheck(name, column, options) {
|
|
1211
|
+
const source = options?.dotted ? DOTTED_CODE_PATTERN_SOURCE : CODE_PATTERN_SOURCE;
|
|
1212
|
+
return check(name, sql`${column} ~ ${sql.raw(`'${source}'`)}`);
|
|
1213
|
+
}
|
|
1214
|
+
__name(codeCheck, "codeCheck");
|
|
1215
|
+
|
|
1216
|
+
// src/data-table/schema/data-table-views.table.ts
|
|
1217
|
+
function dataTableViewsColumns() {
|
|
1218
|
+
return {
|
|
1219
|
+
id: (0, drizzle_pg_core_exports.uuid)("id").primaryKey().defaultRandom(),
|
|
1220
|
+
userId: (0, drizzle_pg_core_exports.uuid)("user_id").notNull(),
|
|
1221
|
+
tableSlug: (0, drizzle_pg_core_exports.varchar)("table_slug", {
|
|
1222
|
+
length: 200
|
|
1223
|
+
}).notNull(),
|
|
1224
|
+
name: (0, drizzle_pg_core_exports.varchar)("name", {
|
|
1225
|
+
length: 100
|
|
1226
|
+
}).notNull(),
|
|
1227
|
+
state: (0, drizzle_pg_core_exports.jsonb)("state").notNull().$type(),
|
|
1228
|
+
isShared: (0, drizzle_pg_core_exports.boolean)("is_shared").notNull().default(false),
|
|
1229
|
+
createdAt: (0, drizzle_pg_core_exports.timestamp)("created_at", {
|
|
1230
|
+
withTimezone: true
|
|
1231
|
+
}).notNull().defaultNow(),
|
|
1232
|
+
updatedAt: (0, drizzle_pg_core_exports.timestamp)("updated_at", {
|
|
1233
|
+
withTimezone: true
|
|
1234
|
+
}).$onUpdate(() => /* @__PURE__ */ new Date())
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
__name(dataTableViewsColumns, "dataTableViewsColumns");
|
|
1238
|
+
function dataTableViewsIndexes(table) {
|
|
1239
|
+
return [
|
|
1240
|
+
(0, drizzle_pg_core_exports.index)("table_views_user_table_idx").on(table.userId, table.tableSlug),
|
|
1241
|
+
(0, drizzle_pg_core_exports.index)("table_views_shared_slug_idx").on(table.tableSlug, table.isShared),
|
|
1242
|
+
(0, drizzle_pg_core_exports.uniqueIndex)("table_views_user_table_name_shared_unique").on(table.userId, table.tableSlug, table.name, table.isShared)
|
|
1243
|
+
];
|
|
1244
|
+
}
|
|
1245
|
+
__name(dataTableViewsIndexes, "dataTableViewsIndexes");
|
|
1246
|
+
export {
|
|
1247
|
+
CreateDataTableViewDto,
|
|
1248
|
+
DATA_TABLE_VIEWS_TABLE,
|
|
1249
|
+
DataTableModule,
|
|
1250
|
+
DataTableStateService,
|
|
1251
|
+
DataTableViewDto,
|
|
1252
|
+
DataTableViewsService,
|
|
1253
|
+
RenameDataTableViewDto,
|
|
1254
|
+
ToggleShareDataTableViewDto,
|
|
1255
|
+
UpdateDataTableViewDto,
|
|
1256
|
+
UpsertDataTableStateDto,
|
|
1257
|
+
dataTableViewsColumns,
|
|
1258
|
+
dataTableViewsIndexes
|
|
1259
|
+
};
|
|
1260
|
+
//# sourceMappingURL=data-table.js.map
|