@kozou/svelte-ui 0.0.1 → 0.1.1
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/LICENSE +202 -0
- package/README.md +107 -1
- package/build/client/_app/immutable/assets/0.CZsFVllx.css +2 -0
- package/build/client/_app/immutable/assets/0.CZsFVllx.css.br +0 -0
- package/build/client/_app/immutable/assets/0.CZsFVllx.css.gz +0 -0
- package/build/client/_app/immutable/chunks/BpIM_fT8.js +2 -0
- package/build/client/_app/immutable/chunks/BpIM_fT8.js.br +0 -0
- package/build/client/_app/immutable/chunks/BpIM_fT8.js.gz +0 -0
- package/build/client/_app/immutable/chunks/C4vVozd5.js +4 -0
- package/build/client/_app/immutable/chunks/C4vVozd5.js.br +0 -0
- package/build/client/_app/immutable/chunks/C4vVozd5.js.gz +0 -0
- package/build/client/_app/immutable/chunks/Cu9GwMht.js +214 -0
- package/build/client/_app/immutable/chunks/Cu9GwMht.js.br +0 -0
- package/build/client/_app/immutable/chunks/Cu9GwMht.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DQLVkJ9E.js +1 -0
- package/build/client/_app/immutable/chunks/DQLVkJ9E.js.br +0 -0
- package/build/client/_app/immutable/chunks/DQLVkJ9E.js.gz +0 -0
- package/build/client/_app/immutable/chunks/kNaey6uv.js +1 -0
- package/build/client/_app/immutable/chunks/kNaey6uv.js.br +0 -0
- package/build/client/_app/immutable/chunks/kNaey6uv.js.gz +0 -0
- package/build/client/_app/immutable/chunks/xihTtKlq.js +1 -0
- package/build/client/_app/immutable/chunks/xihTtKlq.js.br +1 -0
- package/build/client/_app/immutable/chunks/xihTtKlq.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.D4C-SzYE.js +2 -0
- package/build/client/_app/immutable/entry/app.D4C-SzYE.js.br +0 -0
- package/build/client/_app/immutable/entry/app.D4C-SzYE.js.gz +0 -0
- package/build/client/_app/immutable/entry/start.BgPykZWX.js +1 -0
- package/build/client/_app/immutable/entry/start.BgPykZWX.js.br +0 -0
- package/build/client/_app/immutable/entry/start.BgPykZWX.js.gz +0 -0
- package/build/client/_app/immutable/nodes/0.Ct90k1ZK.js +1 -0
- package/build/client/_app/immutable/nodes/0.Ct90k1ZK.js.br +0 -0
- package/build/client/_app/immutable/nodes/0.Ct90k1ZK.js.gz +0 -0
- package/build/client/_app/immutable/nodes/1.ByzpIkVa.js +1 -0
- package/build/client/_app/immutable/nodes/1.ByzpIkVa.js.br +0 -0
- package/build/client/_app/immutable/nodes/1.ByzpIkVa.js.gz +0 -0
- package/build/client/_app/immutable/nodes/2.DKSRkbg2.js +1 -0
- package/build/client/_app/immutable/nodes/2.DKSRkbg2.js.br +0 -0
- package/build/client/_app/immutable/nodes/2.DKSRkbg2.js.gz +0 -0
- package/build/client/_app/immutable/nodes/3.BRseKH3J.js +1 -0
- package/build/client/_app/immutable/nodes/3.BRseKH3J.js.br +0 -0
- package/build/client/_app/immutable/nodes/3.BRseKH3J.js.gz +0 -0
- package/build/client/_app/immutable/nodes/4.hHssvcSO.js +1 -0
- package/build/client/_app/immutable/nodes/4.hHssvcSO.js.br +0 -0
- package/build/client/_app/immutable/nodes/4.hHssvcSO.js.gz +0 -0
- package/build/client/_app/immutable/nodes/5.CfrPDIy5.js +1 -0
- package/build/client/_app/immutable/nodes/5.CfrPDIy5.js.br +0 -0
- package/build/client/_app/immutable/nodes/5.CfrPDIy5.js.gz +0 -0
- package/build/client/_app/immutable/nodes/6.nxvsG8yx.js +1 -0
- package/build/client/_app/immutable/nodes/6.nxvsG8yx.js.br +3 -0
- package/build/client/_app/immutable/nodes/6.nxvsG8yx.js.gz +0 -0
- package/build/client/_app/immutable/nodes/7.Bfhyc_gZ.js +1 -0
- package/build/client/_app/immutable/nodes/7.Bfhyc_gZ.js.br +0 -0
- package/build/client/_app/immutable/nodes/7.Bfhyc_gZ.js.gz +0 -0
- package/build/client/_app/version.json +1 -0
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/env.js +94 -0
- package/build/handler.js +1494 -0
- package/build/index.js +345 -0
- package/build/server/chunks/0-BFDPzvW-.js +24 -0
- package/build/server/chunks/0-BFDPzvW-.js.map +1 -0
- package/build/server/chunks/1-Dmzzx_Xf.js +9 -0
- package/build/server/chunks/1-Dmzzx_Xf.js.map +1 -0
- package/build/server/chunks/2-B1IcZygX.js +35 -0
- package/build/server/chunks/2-B1IcZygX.js.map +1 -0
- package/build/server/chunks/3-BVIqnkRy.js +70 -0
- package/build/server/chunks/3-BVIqnkRy.js.map +1 -0
- package/build/server/chunks/4-BeHrsGek.js +103 -0
- package/build/server/chunks/4-BeHrsGek.js.map +1 -0
- package/build/server/chunks/5-Cw01QEjm.js +69 -0
- package/build/server/chunks/5-Cw01QEjm.js.map +1 -0
- package/build/server/chunks/6-DdCU04G4.js +70 -0
- package/build/server/chunks/6-DdCU04G4.js.map +1 -0
- package/build/server/chunks/7-BJeosbkA.js +66 -0
- package/build/server/chunks/7-BJeosbkA.js.map +1 -0
- package/build/server/chunks/_layout.svelte-ClzaQTuQ.js +15 -0
- package/build/server/chunks/_layout.svelte-ClzaQTuQ.js.map +1 -0
- package/build/server/chunks/_page.svelte-B8Bnkzob.js +78 -0
- package/build/server/chunks/_page.svelte-B8Bnkzob.js.map +1 -0
- package/build/server/chunks/_page.svelte-BN1au56r.js +51 -0
- package/build/server/chunks/_page.svelte-BN1au56r.js.map +1 -0
- package/build/server/chunks/_page.svelte-Bu4SlGir.js +86 -0
- package/build/server/chunks/_page.svelte-Bu4SlGir.js.map +1 -0
- package/build/server/chunks/_page.svelte-DHhstcmi.js +70 -0
- package/build/server/chunks/_page.svelte-DHhstcmi.js.map +1 -0
- package/build/server/chunks/_page.svelte-DKhYDtNl.js +86 -0
- package/build/server/chunks/_page.svelte-DKhYDtNl.js.map +1 -0
- package/build/server/chunks/_page.svelte-DYlwwhHn.js +70 -0
- package/build/server/chunks/_page.svelte-DYlwwhHn.js.map +1 -0
- package/build/server/chunks/adapter-DSZ-_PM_.js +273 -0
- package/build/server/chunks/adapter-DSZ-_PM_.js.map +1 -0
- package/build/server/chunks/app-DST8OmzT.js +12 -0
- package/build/server/chunks/app-DST8OmzT.js.map +1 -0
- package/build/server/chunks/client-Bcpj9QFB.js +69 -0
- package/build/server/chunks/client-Bcpj9QFB.js.map +1 -0
- package/build/server/chunks/dev-yFiAtg5l.js +4498 -0
- package/build/server/chunks/dev-yFiAtg5l.js.map +1 -0
- package/build/server/chunks/error.svelte-1lnafu4q.js +68 -0
- package/build/server/chunks/error.svelte-1lnafu4q.js.map +1 -0
- package/build/server/chunks/hooks.server-BBW_dqIs.js +14060 -0
- package/build/server/chunks/hooks.server-BBW_dqIs.js.map +1 -0
- package/build/server/chunks/index-5kYmxIr9.js +191 -0
- package/build/server/chunks/index-5kYmxIr9.js.map +1 -0
- package/build/server/chunks/index-DBqjc0Yf.js +77 -0
- package/build/server/chunks/index-DBqjc0Yf.js.map +1 -0
- package/build/server/chunks/internal-BrzrGF6g.js +1757 -0
- package/build/server/chunks/internal-BrzrGF6g.js.map +1 -0
- package/build/server/chunks/list-params-DjWk7B1o.js +44 -0
- package/build/server/chunks/list-params-DjWk7B1o.js.map +1 -0
- package/build/server/chunks/widget-registry-CYJ6dCZP.js +242 -0
- package/build/server/chunks/widget-registry-CYJ6dCZP.js.map +1 -0
- package/build/server/chunks/zod-from-table-Cqu9YCfY.js +6923 -0
- package/build/server/chunks/zod-from-table-Cqu9YCfY.js.map +1 -0
- package/build/server/index.js +4447 -0
- package/build/server/index.js.map +1 -0
- package/build/server/manifest.js +86 -0
- package/build/server/manifest.js.map +1 -0
- package/build/shims.js +32 -0
- package/package.json +71 -4
package/build/index.js
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import http from 'node:http';
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
import { handler } from './handler.js';
|
|
4
|
+
import { env, timeout_env } from './env.js';
|
|
5
|
+
import { setImmediate } from 'node:timers';
|
|
6
|
+
import * as qs from 'node:querystring';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {string|RegExp} input The route pattern
|
|
10
|
+
* @param {boolean} [loose] Allow open-ended matching. Ignored with `RegExp` input.
|
|
11
|
+
*/
|
|
12
|
+
function parse$1(input, loose) {
|
|
13
|
+
if (input instanceof RegExp) return { keys:false, pattern:input };
|
|
14
|
+
var c, o, tmp, ext, keys=[], pattern='', arr = input.split('/');
|
|
15
|
+
arr[0] || arr.shift();
|
|
16
|
+
|
|
17
|
+
while (tmp = arr.shift()) {
|
|
18
|
+
c = tmp[0];
|
|
19
|
+
if (c === '*') {
|
|
20
|
+
keys.push(c);
|
|
21
|
+
pattern += tmp[1] === '?' ? '(?:/(.*))?' : '/(.*)';
|
|
22
|
+
} else if (c === ':') {
|
|
23
|
+
o = tmp.indexOf('?', 1);
|
|
24
|
+
ext = tmp.indexOf('.', 1);
|
|
25
|
+
keys.push( tmp.substring(1, !!~o ? o : !!~ext ? ext : tmp.length) );
|
|
26
|
+
pattern += !!~o && !~ext ? '(?:/([^/]+?))?' : '/([^/]+?)';
|
|
27
|
+
if (!!~ext) pattern += (!!~o ? '?' : '') + '\\' + tmp.substring(ext);
|
|
28
|
+
} else {
|
|
29
|
+
pattern += '/' + tmp;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
keys: keys,
|
|
35
|
+
pattern: new RegExp('^' + pattern + (loose ? '(?=$|\/)' : '\/?$'), 'i')
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const MAP = {
|
|
40
|
+
"": 0,
|
|
41
|
+
GET: 1,
|
|
42
|
+
HEAD: 2,
|
|
43
|
+
PATCH: 3,
|
|
44
|
+
OPTIONS: 4,
|
|
45
|
+
CONNECT: 5,
|
|
46
|
+
DELETE: 6,
|
|
47
|
+
TRACE: 7,
|
|
48
|
+
POST: 8,
|
|
49
|
+
PUT: 9,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
class Trouter {
|
|
53
|
+
constructor() {
|
|
54
|
+
this.routes = [];
|
|
55
|
+
|
|
56
|
+
this.all = this.add.bind(this, '');
|
|
57
|
+
this.get = this.add.bind(this, 'GET');
|
|
58
|
+
this.head = this.add.bind(this, 'HEAD');
|
|
59
|
+
this.patch = this.add.bind(this, 'PATCH');
|
|
60
|
+
this.options = this.add.bind(this, 'OPTIONS');
|
|
61
|
+
this.connect = this.add.bind(this, 'CONNECT');
|
|
62
|
+
this.delete = this.add.bind(this, 'DELETE');
|
|
63
|
+
this.trace = this.add.bind(this, 'TRACE');
|
|
64
|
+
this.post = this.add.bind(this, 'POST');
|
|
65
|
+
this.put = this.add.bind(this, 'PUT');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
use(route, ...fns) {
|
|
69
|
+
let handlers = [].concat.apply([], fns);
|
|
70
|
+
let { keys, pattern } = parse$1(route, true);
|
|
71
|
+
this.routes.push({ keys, pattern, method: '', handlers, midx: MAP[''] });
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
add(method, route, ...fns) {
|
|
76
|
+
let { keys, pattern } = parse$1(route);
|
|
77
|
+
let handlers = [].concat.apply([], fns);
|
|
78
|
+
this.routes.push({ keys, pattern, method, handlers, midx: MAP[method] });
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
find(method, url) {
|
|
83
|
+
let midx = MAP[method];
|
|
84
|
+
let isHEAD = (midx === 2);
|
|
85
|
+
let i=0, j=0, k, tmp, arr=this.routes;
|
|
86
|
+
let matches=[], params={}, handlers=[];
|
|
87
|
+
for (; i < arr.length; i++) {
|
|
88
|
+
tmp = arr[i];
|
|
89
|
+
if (tmp.midx === midx || tmp.midx === 0 || (isHEAD && tmp.midx===1) ) {
|
|
90
|
+
if (tmp.keys === false) {
|
|
91
|
+
matches = tmp.pattern.exec(url);
|
|
92
|
+
if (matches === null) continue;
|
|
93
|
+
if (matches.groups !== void 0) for (k in matches.groups) params[k]=matches.groups[k];
|
|
94
|
+
tmp.handlers.length > 1 ? (handlers=handlers.concat(tmp.handlers)) : handlers.push(tmp.handlers[0]);
|
|
95
|
+
} else if (tmp.keys.length > 0) {
|
|
96
|
+
matches = tmp.pattern.exec(url);
|
|
97
|
+
if (matches === null) continue;
|
|
98
|
+
for (j=0; j < tmp.keys.length;) params[tmp.keys[j]]=matches[++j];
|
|
99
|
+
tmp.handlers.length > 1 ? (handlers=handlers.concat(tmp.handlers)) : handlers.push(tmp.handlers[0]);
|
|
100
|
+
} else if (tmp.pattern.test(url)) {
|
|
101
|
+
tmp.handlers.length > 1 ? (handlers=handlers.concat(tmp.handlers)) : handlers.push(tmp.handlers[0]);
|
|
102
|
+
}
|
|
103
|
+
} // else not a match
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return { params, handlers };
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @typedef ParsedURL
|
|
112
|
+
* @type {import('.').ParsedURL}
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @typedef Request
|
|
117
|
+
* @property {string} url
|
|
118
|
+
* @property {ParsedURL} _parsedUrl
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @param {Request} req
|
|
123
|
+
* @returns {ParsedURL|void}
|
|
124
|
+
*/
|
|
125
|
+
function parse(req) {
|
|
126
|
+
let raw = req.url;
|
|
127
|
+
if (raw == null) return;
|
|
128
|
+
|
|
129
|
+
let prev = req._parsedUrl;
|
|
130
|
+
if (prev && prev.raw === raw) return prev;
|
|
131
|
+
|
|
132
|
+
let pathname=raw, search='', query;
|
|
133
|
+
|
|
134
|
+
if (raw.length > 1) {
|
|
135
|
+
let idx = raw.indexOf('?', 1);
|
|
136
|
+
|
|
137
|
+
if (idx !== -1) {
|
|
138
|
+
search = raw.substring(idx);
|
|
139
|
+
pathname = raw.substring(0, idx);
|
|
140
|
+
if (search.length > 1) {
|
|
141
|
+
query = qs.parse(search.substring(1));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return req._parsedUrl = { pathname, search, query, raw };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function onError(err, req, res) {
|
|
150
|
+
let code = typeof err.status === 'number' && err.status;
|
|
151
|
+
code = res.statusCode = (code && code >= 100 ? code : 500);
|
|
152
|
+
if (typeof err === 'string' || Buffer.isBuffer(err)) res.end(err);
|
|
153
|
+
else res.end(err.message || http.STATUS_CODES[code]);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const mount = fn => fn instanceof Polka ? fn.attach : fn;
|
|
157
|
+
|
|
158
|
+
class Polka extends Trouter {
|
|
159
|
+
constructor(opts={}) {
|
|
160
|
+
super();
|
|
161
|
+
this.parse = parse;
|
|
162
|
+
this.server = opts.server;
|
|
163
|
+
this.handler = this.handler.bind(this);
|
|
164
|
+
this.onError = opts.onError || onError; // catch-all handler
|
|
165
|
+
this.onNoMatch = opts.onNoMatch || this.onError.bind(null, { status: 404 });
|
|
166
|
+
this.attach = (req, res) => setImmediate(this.handler, req, res);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
use(base, ...fns) {
|
|
170
|
+
if (base === '/') {
|
|
171
|
+
super.use(base, fns.map(mount));
|
|
172
|
+
} else if (typeof base === 'function' || base instanceof Polka) {
|
|
173
|
+
super.use('/', [base, ...fns].map(mount));
|
|
174
|
+
} else {
|
|
175
|
+
super.use(base,
|
|
176
|
+
(req, _, next) => {
|
|
177
|
+
if (typeof base === 'string') {
|
|
178
|
+
let len = base.length;
|
|
179
|
+
base.startsWith('/') || len++;
|
|
180
|
+
req.url = req.url.substring(len) || '/';
|
|
181
|
+
req.path = req.path.substring(len) || '/';
|
|
182
|
+
} else {
|
|
183
|
+
req.url = req.url.replace(base, '') || '/';
|
|
184
|
+
req.path = req.path.replace(base, '') || '/';
|
|
185
|
+
}
|
|
186
|
+
if (req.url.charAt(0) !== '/') {
|
|
187
|
+
req.url = '/' + req.url;
|
|
188
|
+
}
|
|
189
|
+
next();
|
|
190
|
+
},
|
|
191
|
+
fns.map(mount),
|
|
192
|
+
(req, _, next) => {
|
|
193
|
+
req.path = req._parsedUrl.pathname;
|
|
194
|
+
req.url = req.path + req._parsedUrl.search;
|
|
195
|
+
next();
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
return this; // chainable
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
listen() {
|
|
203
|
+
(this.server = this.server || http.createServer()).on('request', this.attach);
|
|
204
|
+
this.server.listen.apply(this.server, arguments);
|
|
205
|
+
return this;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
handler(req, res, next) {
|
|
209
|
+
let info = this.parse(req), path = info.pathname;
|
|
210
|
+
let obj = this.find(req.method, req.path=path);
|
|
211
|
+
|
|
212
|
+
req.url = path + info.search;
|
|
213
|
+
req.originalUrl = req.originalUrl || req.url;
|
|
214
|
+
req.query = info.query || {};
|
|
215
|
+
req.search = info.search;
|
|
216
|
+
req.params = obj.params;
|
|
217
|
+
|
|
218
|
+
if (path.length > 1 && path.indexOf('%', 1) !== -1) {
|
|
219
|
+
for (let k in req.params) {
|
|
220
|
+
try { req.params[k] = decodeURIComponent(req.params[k]); }
|
|
221
|
+
catch (e) { /* malform uri segment */ }
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
let i=0, arr=obj.handlers.concat(this.onNoMatch), len=arr.length;
|
|
226
|
+
let loop = async () => res.finished || (i < len) && arr[i++](req, res, next);
|
|
227
|
+
(next = next || (err => err ? this.onError(err, req, res, next) : loop().catch(next)))(); // init
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function polka (opts) {
|
|
232
|
+
return new Polka(opts);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const path = env('SOCKET_PATH', false);
|
|
236
|
+
const host = env('HOST', '0.0.0.0');
|
|
237
|
+
const port = env('PORT', !path && '3000');
|
|
238
|
+
|
|
239
|
+
const shutdown_timeout = parseInt(env('SHUTDOWN_TIMEOUT', '30'));
|
|
240
|
+
const idle_timeout = parseInt(env('IDLE_TIMEOUT', '0'));
|
|
241
|
+
const listen_pid = parseInt(env('LISTEN_PID', '0'));
|
|
242
|
+
const listen_fds = parseInt(env('LISTEN_FDS', '0'));
|
|
243
|
+
// https://www.freedesktop.org/software/systemd/man/latest/sd_listen_fds.html
|
|
244
|
+
const SD_LISTEN_FDS_START = 3;
|
|
245
|
+
|
|
246
|
+
if (listen_pid !== 0 && listen_pid !== process.pid) {
|
|
247
|
+
throw new Error(`received LISTEN_PID ${listen_pid} but current process id is ${process.pid}`);
|
|
248
|
+
}
|
|
249
|
+
if (listen_fds > 1) {
|
|
250
|
+
throw new Error(
|
|
251
|
+
`only one socket is allowed for socket activation, but LISTEN_FDS was set to ${listen_fds}`
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const socket_activation = listen_pid === process.pid && listen_fds === 1;
|
|
256
|
+
|
|
257
|
+
let requests = 0;
|
|
258
|
+
/** @type {NodeJS.Timeout | void} */
|
|
259
|
+
let shutdown_timeout_id;
|
|
260
|
+
/** @type {NodeJS.Timeout | void} */
|
|
261
|
+
let idle_timeout_id;
|
|
262
|
+
|
|
263
|
+
// Initialize the HTTP server here so that we can set properties before starting to listen.
|
|
264
|
+
// Otherwise, polka delays creating the server until listen() is called. Settings these
|
|
265
|
+
// properties after the server has started listening could lead to race conditions.
|
|
266
|
+
const httpServer = http.createServer();
|
|
267
|
+
|
|
268
|
+
const keep_alive_timeout = timeout_env('KEEP_ALIVE_TIMEOUT');
|
|
269
|
+
if (keep_alive_timeout !== undefined) {
|
|
270
|
+
// Convert the keep-alive timeout from seconds to milliseconds (the unit Node.js expects).
|
|
271
|
+
httpServer.keepAliveTimeout = keep_alive_timeout * 1000;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const headers_timeout = timeout_env('HEADERS_TIMEOUT');
|
|
275
|
+
if (headers_timeout !== undefined) {
|
|
276
|
+
// Convert the headers timeout from seconds to milliseconds (the unit Node.js expects).
|
|
277
|
+
httpServer.headersTimeout = headers_timeout * 1000;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const server = polka({ server: httpServer }).use(handler);
|
|
281
|
+
|
|
282
|
+
if (socket_activation) {
|
|
283
|
+
server.listen({ fd: SD_LISTEN_FDS_START }, () => {
|
|
284
|
+
console.log(`Listening on file descriptor ${SD_LISTEN_FDS_START}`);
|
|
285
|
+
});
|
|
286
|
+
} else {
|
|
287
|
+
server.listen({ path, host, port }, () => {
|
|
288
|
+
console.log(`Listening on ${path || `http://${host}:${port}`}`);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** @param {'SIGINT' | 'SIGTERM' | 'IDLE'} reason */
|
|
293
|
+
function graceful_shutdown(reason) {
|
|
294
|
+
if (shutdown_timeout_id) return;
|
|
295
|
+
|
|
296
|
+
// If a connection was opened with a keep-alive header close() will wait for the connection to
|
|
297
|
+
// time out rather than close it even if it is not handling any requests, so call this first
|
|
298
|
+
httpServer.closeIdleConnections();
|
|
299
|
+
|
|
300
|
+
httpServer.close((error) => {
|
|
301
|
+
// occurs if the server is already closed
|
|
302
|
+
if (error) return;
|
|
303
|
+
|
|
304
|
+
if (shutdown_timeout_id) {
|
|
305
|
+
clearTimeout(shutdown_timeout_id);
|
|
306
|
+
}
|
|
307
|
+
if (idle_timeout_id) {
|
|
308
|
+
clearTimeout(idle_timeout_id);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// @ts-expect-error custom events cannot be typed
|
|
312
|
+
process.emit('sveltekit:shutdown', reason);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
shutdown_timeout_id = setTimeout(() => httpServer.closeAllConnections(), shutdown_timeout * 1000);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
httpServer.on(
|
|
319
|
+
'request',
|
|
320
|
+
/** @param {import('node:http').IncomingMessage} req */
|
|
321
|
+
(req) => {
|
|
322
|
+
requests++;
|
|
323
|
+
|
|
324
|
+
if (socket_activation && idle_timeout_id) {
|
|
325
|
+
idle_timeout_id = clearTimeout(idle_timeout_id);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
req.on('close', () => {
|
|
329
|
+
requests--;
|
|
330
|
+
|
|
331
|
+
if (shutdown_timeout_id) {
|
|
332
|
+
// close connections as soon as they become idle, so they don't accept new requests
|
|
333
|
+
httpServer.closeIdleConnections();
|
|
334
|
+
}
|
|
335
|
+
if (requests === 0 && socket_activation && idle_timeout) {
|
|
336
|
+
idle_timeout_id = setTimeout(() => graceful_shutdown('IDLE'), idle_timeout * 1000);
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
);
|
|
341
|
+
|
|
342
|
+
process.on('SIGTERM', graceful_shutdown);
|
|
343
|
+
process.on('SIGINT', graceful_shutdown);
|
|
344
|
+
|
|
345
|
+
export { host, path, port, server };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/routes/+layout.server.ts
|
|
2
|
+
var load = ({ locals }) => {
|
|
3
|
+
return {
|
|
4
|
+
appName: "Kozou",
|
|
5
|
+
tableCount: locals.schema.tables.length,
|
|
6
|
+
viewCount: locals.schema.views.length
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
var _layout_server_ts = /*#__PURE__*/Object.freeze({
|
|
11
|
+
__proto__: null,
|
|
12
|
+
load: load
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const index = 0;
|
|
16
|
+
let component_cache;
|
|
17
|
+
const component = async () => component_cache ??= (await import('./_layout.svelte-ClzaQTuQ.js')).default;
|
|
18
|
+
const server_id = "src/routes/+layout.server.ts";
|
|
19
|
+
const imports = ["_app/immutable/nodes/0.Ct90k1ZK.js","_app/immutable/chunks/BpIM_fT8.js","_app/immutable/chunks/xihTtKlq.js"];
|
|
20
|
+
const stylesheets = ["_app/immutable/assets/0.CZsFVllx.css"];
|
|
21
|
+
const fonts = [];
|
|
22
|
+
|
|
23
|
+
export { component, fonts, imports, index, _layout_server_ts as server, server_id, stylesheets };
|
|
24
|
+
//# sourceMappingURL=0-BFDPzvW-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0-BFDPzvW-.js","sources":["../../../.svelte-kit/adapter-node/entries/pages/_layout.server.ts.js","../../../.svelte-kit/adapter-node/nodes/0.js"],"sourcesContent":["//#region src/routes/+layout.server.ts\nvar load = ({ locals }) => {\n\treturn {\n\t\tappName: \"Kozou\",\n\t\ttableCount: locals.schema.tables.length,\n\t\tviewCount: locals.schema.views.length\n\t};\n};\n//#endregion\nexport { load };\n","import * as server from '../entries/pages/_layout.server.ts.js';\n\nexport const index = 0;\nlet component_cache;\nexport const component = async () => component_cache ??= (await import('../entries/pages/_layout.svelte.js')).default;\nexport { server };\nexport const server_id = \"src/routes/+layout.server.ts\";\nexport const imports = [\"_app/immutable/nodes/0.Ct90k1ZK.js\",\"_app/immutable/chunks/BpIM_fT8.js\",\"_app/immutable/chunks/xihTtKlq.js\"];\nexport const stylesheets = [\"_app/immutable/assets/0.CZsFVllx.css\"];\nexport const fonts = [];\n"],"names":[],"mappings":"AAAA;AACA,IAAI,IAAI,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK;AAC3B,CAAC,OAAO;AACR,EAAE,OAAO,EAAE,OAAO;AAClB,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM;AACzC,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;AACjC,EAAE;AACF,CAAC;;;;;;;ACLW,MAAC,KAAK,GAAG;AACrB,IAAI,eAAe;AACP,MAAC,SAAS,GAAG,YAAY,eAAe,KAAK,CAAC,MAAM,OAAO,8BAAoC,CAAC,EAAE;AAElG,MAAC,SAAS,GAAG;AACb,MAAC,OAAO,GAAG,CAAC,oCAAoC,CAAC,mCAAmC,CAAC,mCAAmC;AACxH,MAAC,WAAW,GAAG,CAAC,sCAAsC;AACtD,MAAC,KAAK,GAAG;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const index = 1;
|
|
2
|
+
let component_cache;
|
|
3
|
+
const component = async () => component_cache ??= (await import('./error.svelte-1lnafu4q.js')).default;
|
|
4
|
+
const imports = ["_app/immutable/nodes/1.ByzpIkVa.js","_app/immutable/chunks/BpIM_fT8.js","_app/immutable/chunks/C4vVozd5.js","_app/immutable/chunks/xihTtKlq.js"];
|
|
5
|
+
const stylesheets = [];
|
|
6
|
+
const fonts = [];
|
|
7
|
+
|
|
8
|
+
export { component, fonts, imports, index, stylesheets };
|
|
9
|
+
//# sourceMappingURL=1-Dmzzx_Xf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1-Dmzzx_Xf.js","sources":["../../../.svelte-kit/adapter-node/nodes/1.js"],"sourcesContent":["\n\nexport const index = 1;\nlet component_cache;\nexport const component = async () => component_cache ??= (await import('../entries/fallbacks/error.svelte.js')).default;\nexport const imports = [\"_app/immutable/nodes/1.ByzpIkVa.js\",\"_app/immutable/chunks/BpIM_fT8.js\",\"_app/immutable/chunks/C4vVozd5.js\",\"_app/immutable/chunks/xihTtKlq.js\"];\nexport const stylesheets = [];\nexport const fonts = [];\n"],"names":[],"mappings":"AAEY,MAAC,KAAK,GAAG;AACrB,IAAI,eAAe;AACP,MAAC,SAAS,GAAG,YAAY,eAAe,KAAK,CAAC,MAAM,OAAO,4BAAsC,CAAC,EAAE;AACpG,MAAC,OAAO,GAAG,CAAC,oCAAoC,CAAC,mCAAmC,CAAC,mCAAmC,CAAC,mCAAmC;AAC5J,MAAC,WAAW,GAAG;AACf,MAAC,KAAK,GAAG;;;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/lib/dashboard/group.ts
|
|
2
|
+
function groupForDashboard(schema) {
|
|
3
|
+
return {
|
|
4
|
+
tables: schema.tables.map(toDashboardItem).sort((a, b) => a.label.localeCompare(b.label)),
|
|
5
|
+
views: schema.views.map(toDashboardItem).sort((a, b) => a.label.localeCompare(b.label))
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
function toDashboardItem(item) {
|
|
9
|
+
return {
|
|
10
|
+
qualifiedName: item.qualifiedName,
|
|
11
|
+
label: item.label,
|
|
12
|
+
description: item.description
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/routes/+page.server.ts
|
|
17
|
+
var load = ({ locals }) => {
|
|
18
|
+
return { dashboard: groupForDashboard(locals.schema) };
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
var _page_server_ts = /*#__PURE__*/Object.freeze({
|
|
22
|
+
__proto__: null,
|
|
23
|
+
load: load
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const index = 2;
|
|
27
|
+
let component_cache;
|
|
28
|
+
const component = async () => component_cache ??= (await import('./_page.svelte-BN1au56r.js')).default;
|
|
29
|
+
const server_id = "src/routes/+page.server.ts";
|
|
30
|
+
const imports = ["_app/immutable/nodes/2.DKSRkbg2.js","_app/immutable/chunks/BpIM_fT8.js","_app/immutable/chunks/xihTtKlq.js"];
|
|
31
|
+
const stylesheets = [];
|
|
32
|
+
const fonts = [];
|
|
33
|
+
|
|
34
|
+
export { component, fonts, imports, index, _page_server_ts as server, server_id, stylesheets };
|
|
35
|
+
//# sourceMappingURL=2-B1IcZygX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2-B1IcZygX.js","sources":["../../../.svelte-kit/adapter-node/entries/pages/_page.server.ts.js","../../../.svelte-kit/adapter-node/nodes/2.js"],"sourcesContent":["//#region src/lib/dashboard/group.ts\nfunction groupForDashboard(schema) {\n\treturn {\n\t\ttables: schema.tables.map(toDashboardItem).sort((a, b) => a.label.localeCompare(b.label)),\n\t\tviews: schema.views.map(toDashboardItem).sort((a, b) => a.label.localeCompare(b.label))\n\t};\n}\nfunction toDashboardItem(item) {\n\treturn {\n\t\tqualifiedName: item.qualifiedName,\n\t\tlabel: item.label,\n\t\tdescription: item.description\n\t};\n}\n//#endregion\n//#region src/routes/+page.server.ts\nvar load = ({ locals }) => {\n\treturn { dashboard: groupForDashboard(locals.schema) };\n};\n//#endregion\nexport { load };\n","import * as server from '../entries/pages/_page.server.ts.js';\n\nexport const index = 2;\nlet component_cache;\nexport const component = async () => component_cache ??= (await import('../entries/pages/_page.svelte.js')).default;\nexport { server };\nexport const server_id = \"src/routes/+page.server.ts\";\nexport const imports = [\"_app/immutable/nodes/2.DKSRkbg2.js\",\"_app/immutable/chunks/BpIM_fT8.js\",\"_app/immutable/chunks/xihTtKlq.js\"];\nexport const stylesheets = [];\nexport const fonts = [];\n"],"names":[],"mappings":"AAAA;AACA,SAAS,iBAAiB,CAAC,MAAM,EAAE;AACnC,CAAC,OAAO;AACR,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAC3F,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC;AACxF,EAAE;AACF;AACA,SAAS,eAAe,CAAC,IAAI,EAAE;AAC/B,CAAC,OAAO;AACR,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa;AACnC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK;AACnB,EAAE,WAAW,EAAE,IAAI,CAAC;AACpB,EAAE;AACF;AACA;AACA;AACA,IAAI,IAAI,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK;AAC3B,CAAC,OAAO,EAAE,SAAS,EAAE,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;AACvD,CAAC;;;;;;;AChBW,MAAC,KAAK,GAAG;AACrB,IAAI,eAAe;AACP,MAAC,SAAS,GAAG,YAAY,eAAe,KAAK,CAAC,MAAM,OAAO,4BAAkC,CAAC,EAAE;AAEhG,MAAC,SAAS,GAAG;AACb,MAAC,OAAO,GAAG,CAAC,oCAAoC,CAAC,mCAAmC,CAAC,mCAAmC;AACxH,MAAC,WAAW,GAAG;AACf,MAAC,KAAK,GAAG;;;;"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { g as getAdapter } from './adapter-DSZ-_PM_.js';
|
|
2
|
+
import { p as parseListParamsFromUrl } from './list-params-DjWk7B1o.js';
|
|
3
|
+
import { e as error } from './index-5kYmxIr9.js';
|
|
4
|
+
import './index-DBqjc0Yf.js';
|
|
5
|
+
|
|
6
|
+
//#region src/routes/tables/[table]/+page.server.ts
|
|
7
|
+
var DISPLAY_COLUMN_LIMIT = 5;
|
|
8
|
+
var TEXT_LIKE_TYPE_PREFIXES = [
|
|
9
|
+
"text",
|
|
10
|
+
"character",
|
|
11
|
+
"varchar",
|
|
12
|
+
"citext",
|
|
13
|
+
"name"
|
|
14
|
+
];
|
|
15
|
+
var load = async ({ params, locals, url }) => {
|
|
16
|
+
const table = locals.schema.tables.find((t) => t.qualifiedName === params.table);
|
|
17
|
+
if (!table) throw error(404, `Unknown table: ${params.table}`);
|
|
18
|
+
const displayColumns = pickDisplayColumns(table);
|
|
19
|
+
const listParams = parseListParamsFromUrl({
|
|
20
|
+
url,
|
|
21
|
+
searchFields: pickSearchFields(table)
|
|
22
|
+
});
|
|
23
|
+
const result = await getAdapter().list(table.qualifiedName, listParams);
|
|
24
|
+
return {
|
|
25
|
+
table: {
|
|
26
|
+
qualifiedName: table.qualifiedName,
|
|
27
|
+
label: table.label,
|
|
28
|
+
primaryKey: table.primaryKey,
|
|
29
|
+
displayField: table.displayField,
|
|
30
|
+
columns: displayColumns.map((c) => ({
|
|
31
|
+
name: c.name,
|
|
32
|
+
label: c.label
|
|
33
|
+
}))
|
|
34
|
+
},
|
|
35
|
+
list: result,
|
|
36
|
+
listParams: {
|
|
37
|
+
search: listParams.search,
|
|
38
|
+
sort: listParams.sort,
|
|
39
|
+
page: listParams.page,
|
|
40
|
+
pageSize: listParams.pageSize
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
function pickDisplayColumns(table) {
|
|
45
|
+
const display = table.displayField;
|
|
46
|
+
return [...table.columns].sort((a, b) => {
|
|
47
|
+
if (a.name === display && b.name !== display) return -1;
|
|
48
|
+
if (b.name === display && a.name !== display) return 1;
|
|
49
|
+
return 0;
|
|
50
|
+
}).slice(0, DISPLAY_COLUMN_LIMIT);
|
|
51
|
+
}
|
|
52
|
+
function pickSearchFields(table) {
|
|
53
|
+
return table.columns.filter((c) => TEXT_LIKE_TYPE_PREFIXES.some((prefix) => c.dataType.toLowerCase().startsWith(prefix))).map((c) => c.name);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var _page_server_ts = /*#__PURE__*/Object.freeze({
|
|
57
|
+
__proto__: null,
|
|
58
|
+
load: load
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const index = 3;
|
|
62
|
+
let component_cache;
|
|
63
|
+
const component = async () => component_cache ??= (await import('./_page.svelte-Bu4SlGir.js')).default;
|
|
64
|
+
const server_id = "src/routes/tables/[table]/+page.server.ts";
|
|
65
|
+
const imports = ["_app/immutable/nodes/3.BRseKH3J.js","_app/immutable/chunks/BpIM_fT8.js","_app/immutable/chunks/xihTtKlq.js"];
|
|
66
|
+
const stylesheets = [];
|
|
67
|
+
const fonts = [];
|
|
68
|
+
|
|
69
|
+
export { component, fonts, imports, index, _page_server_ts as server, server_id, stylesheets };
|
|
70
|
+
//# sourceMappingURL=3-BVIqnkRy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3-BVIqnkRy.js","sources":["../../../.svelte-kit/adapter-node/entries/pages/tables/_table_/_page.server.ts.js","../../../.svelte-kit/adapter-node/nodes/3.js"],"sourcesContent":["import { t as getAdapter } from \"../../../../chunks/adapter.js\";\nimport { t as parseListParamsFromUrl } from \"../../../../chunks/list-params.js\";\nimport { error } from \"@sveltejs/kit\";\n//#region src/routes/tables/[table]/+page.server.ts\nvar DISPLAY_COLUMN_LIMIT = 5;\nvar TEXT_LIKE_TYPE_PREFIXES = [\n\t\"text\",\n\t\"character\",\n\t\"varchar\",\n\t\"citext\",\n\t\"name\"\n];\nvar load = async ({ params, locals, url }) => {\n\tconst table = locals.schema.tables.find((t) => t.qualifiedName === params.table);\n\tif (!table) throw error(404, `Unknown table: ${params.table}`);\n\tconst displayColumns = pickDisplayColumns(table);\n\tconst listParams = parseListParamsFromUrl({\n\t\turl,\n\t\tsearchFields: pickSearchFields(table)\n\t});\n\tconst result = await getAdapter().list(table.qualifiedName, listParams);\n\treturn {\n\t\ttable: {\n\t\t\tqualifiedName: table.qualifiedName,\n\t\t\tlabel: table.label,\n\t\t\tprimaryKey: table.primaryKey,\n\t\t\tdisplayField: table.displayField,\n\t\t\tcolumns: displayColumns.map((c) => ({\n\t\t\t\tname: c.name,\n\t\t\t\tlabel: c.label\n\t\t\t}))\n\t\t},\n\t\tlist: result,\n\t\tlistParams: {\n\t\t\tsearch: listParams.search,\n\t\t\tsort: listParams.sort,\n\t\t\tpage: listParams.page,\n\t\t\tpageSize: listParams.pageSize\n\t\t}\n\t};\n};\nfunction pickDisplayColumns(table) {\n\tconst display = table.displayField;\n\treturn [...table.columns].sort((a, b) => {\n\t\tif (a.name === display && b.name !== display) return -1;\n\t\tif (b.name === display && a.name !== display) return 1;\n\t\treturn 0;\n\t}).slice(0, DISPLAY_COLUMN_LIMIT);\n}\nfunction pickSearchFields(table) {\n\treturn table.columns.filter((c) => TEXT_LIKE_TYPE_PREFIXES.some((prefix) => c.dataType.toLowerCase().startsWith(prefix))).map((c) => c.name);\n}\n//#endregion\nexport { load };\n","import * as server from '../entries/pages/tables/_table_/_page.server.ts.js';\n\nexport const index = 3;\nlet component_cache;\nexport const component = async () => component_cache ??= (await import('../entries/pages/tables/_table_/_page.svelte.js')).default;\nexport { server };\nexport const server_id = \"src/routes/tables/[table]/+page.server.ts\";\nexport const imports = [\"_app/immutable/nodes/3.BRseKH3J.js\",\"_app/immutable/chunks/BpIM_fT8.js\",\"_app/immutable/chunks/xihTtKlq.js\"];\nexport const stylesheets = [];\nexport const fonts = [];\n"],"names":[],"mappings":";;;;;AAGA;AACA,IAAI,oBAAoB,GAAG,CAAC;AAC5B,IAAI,uBAAuB,GAAG;AAC9B,CAAC,MAAM;AACP,CAAC,WAAW;AACZ,CAAC,SAAS;AACV,CAAC,QAAQ;AACT,CAAC;AACD,CAAC;AACD,IAAI,IAAI,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK;AAC9C,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,aAAa,KAAK,MAAM,CAAC,KAAK,CAAC;AACjF,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/D,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAAC,KAAK,CAAC;AACjD,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAC3C,EAAE,GAAG;AACL,EAAE,YAAY,EAAE,gBAAgB,CAAC,KAAK;AACtC,EAAE,CAAC;AACH,CAAC,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,UAAU,CAAC;AACxE,CAAC,OAAO;AACR,EAAE,KAAK,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K,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;AAC7I;;;;;;;ACjDY,MAAC,KAAK,GAAG;AACrB,IAAI,eAAe;AACP,MAAC,SAAS,GAAG,YAAY,eAAe,KAAK,CAAC,MAAM,OAAO,4BAAiD,CAAC,EAAE;AAE/G,MAAC,SAAS,GAAG;AACb,MAAC,OAAO,GAAG,CAAC,oCAAoC,CAAC,mCAAmC,CAAC,mCAAmC;AACxH,MAAC,WAAW,GAAG;AACf,MAAC,KAAK,GAAG;;;;"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { g as getAdapter } from './adapter-DSZ-_PM_.js';
|
|
2
|
+
import { e as error, r as redirect } from './index-5kYmxIr9.js';
|
|
3
|
+
import './index-DBqjc0Yf.js';
|
|
4
|
+
|
|
5
|
+
//#region src/lib/detail/resolve-fk-labels.ts
|
|
6
|
+
async function resolveFkLabels(args) {
|
|
7
|
+
const { table, row, schema, loadRow } = args;
|
|
8
|
+
const out = {};
|
|
9
|
+
const lookups = [];
|
|
10
|
+
for (const relation of table.relations) {
|
|
11
|
+
const rawValue = row[relation.field];
|
|
12
|
+
if (rawValue === null || rawValue === void 0) continue;
|
|
13
|
+
if (typeof rawValue !== "string" && typeof rawValue !== "number") continue;
|
|
14
|
+
const value = rawValue;
|
|
15
|
+
const referencedQualifiedName = `${relation.references.schema}.${relation.references.table}`;
|
|
16
|
+
const referencedTable = schema.tables.find((t) => t.qualifiedName === referencedQualifiedName);
|
|
17
|
+
if (referencedTable === void 0) {
|
|
18
|
+
out[relation.field] = {
|
|
19
|
+
value,
|
|
20
|
+
label: null,
|
|
21
|
+
referencedQualifiedName
|
|
22
|
+
};
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
lookups.push(loadRow(referencedQualifiedName, value).then((targetRow) => {
|
|
26
|
+
const label = projectLabel(referencedTable, targetRow);
|
|
27
|
+
out[relation.field] = {
|
|
28
|
+
value,
|
|
29
|
+
label,
|
|
30
|
+
referencedQualifiedName
|
|
31
|
+
};
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
await Promise.all(lookups);
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
function projectLabel(referencedTable, targetRow) {
|
|
38
|
+
if (targetRow === null) return null;
|
|
39
|
+
const display = referencedTable.displayField;
|
|
40
|
+
if (display === null) return null;
|
|
41
|
+
const value = targetRow[display];
|
|
42
|
+
if (value === null || value === void 0) return null;
|
|
43
|
+
return String(value);
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/routes/tables/[table]/[id]/+page.server.ts
|
|
47
|
+
function findTable(tables, slug) {
|
|
48
|
+
return tables.find((t) => t.qualifiedName === slug) ?? null;
|
|
49
|
+
}
|
|
50
|
+
function tableViewModel(table) {
|
|
51
|
+
return {
|
|
52
|
+
qualifiedName: table.qualifiedName,
|
|
53
|
+
label: table.label,
|
|
54
|
+
columns: table.columns.map((c) => ({
|
|
55
|
+
name: c.name,
|
|
56
|
+
label: c.label,
|
|
57
|
+
widget: c.widget,
|
|
58
|
+
isPrimaryKey: c.isPrimaryKey,
|
|
59
|
+
isForeignKey: c.isForeignKey
|
|
60
|
+
}))
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
var load = async ({ params, locals }) => {
|
|
64
|
+
const table = findTable(locals.schema.tables, params.table);
|
|
65
|
+
if (!table) throw error(404, `Unknown table: ${params.table}`);
|
|
66
|
+
const adapter = getAdapter();
|
|
67
|
+
const row = await adapter.get(table.qualifiedName, params.id);
|
|
68
|
+
const fkLabels = await resolveFkLabels({
|
|
69
|
+
table,
|
|
70
|
+
row,
|
|
71
|
+
schema: locals.schema,
|
|
72
|
+
loadRow: (qualifiedName, id) => locals.fkRowCache.get(qualifiedName, id, (qn, identifier) => adapter.get(qn, identifier).catch(() => null))
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
table: tableViewModel(table),
|
|
76
|
+
row,
|
|
77
|
+
fkLabels,
|
|
78
|
+
id: params.id
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
var actions = { delete: async ({ params, locals }) => {
|
|
82
|
+
const table = findTable(locals.schema.tables, params.table);
|
|
83
|
+
if (!table) throw error(404, `Unknown table: ${params.table}`);
|
|
84
|
+
await getAdapter().delete(table.qualifiedName, params.id);
|
|
85
|
+
throw redirect(303, `/tables/${table.qualifiedName}`);
|
|
86
|
+
} };
|
|
87
|
+
|
|
88
|
+
var _page_server_ts = /*#__PURE__*/Object.freeze({
|
|
89
|
+
__proto__: null,
|
|
90
|
+
actions: actions,
|
|
91
|
+
load: load
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const index = 4;
|
|
95
|
+
let component_cache;
|
|
96
|
+
const component = async () => component_cache ??= (await import('./_page.svelte-DKhYDtNl.js')).default;
|
|
97
|
+
const server_id = "src/routes/tables/[table]/[id]/+page.server.ts";
|
|
98
|
+
const imports = ["_app/immutable/nodes/4.hHssvcSO.js","_app/immutable/chunks/BpIM_fT8.js","_app/immutable/chunks/DQLVkJ9E.js","_app/immutable/chunks/C4vVozd5.js","_app/immutable/chunks/xihTtKlq.js"];
|
|
99
|
+
const stylesheets = [];
|
|
100
|
+
const fonts = [];
|
|
101
|
+
|
|
102
|
+
export { component, fonts, imports, index, _page_server_ts as server, server_id, stylesheets };
|
|
103
|
+
//# sourceMappingURL=4-BeHrsGek.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"4-BeHrsGek.js","sources":["../../../.svelte-kit/adapter-node/entries/pages/tables/_table_/_id_/_page.server.ts.js","../../../.svelte-kit/adapter-node/nodes/4.js"],"sourcesContent":["import { t as getAdapter } from \"../../../../../chunks/adapter.js\";\nimport { error, redirect } from \"@sveltejs/kit\";\n//#region src/lib/detail/resolve-fk-labels.ts\nasync function resolveFkLabels(args) {\n\tconst { table, row, schema, loadRow } = args;\n\tconst out = {};\n\tconst lookups = [];\n\tfor (const relation of table.relations) {\n\t\tconst rawValue = row[relation.field];\n\t\tif (rawValue === null || rawValue === void 0) continue;\n\t\tif (typeof rawValue !== \"string\" && typeof rawValue !== \"number\") continue;\n\t\tconst value = rawValue;\n\t\tconst referencedQualifiedName = `${relation.references.schema}.${relation.references.table}`;\n\t\tconst referencedTable = schema.tables.find((t) => t.qualifiedName === referencedQualifiedName);\n\t\tif (referencedTable === void 0) {\n\t\t\tout[relation.field] = {\n\t\t\t\tvalue,\n\t\t\t\tlabel: null,\n\t\t\t\treferencedQualifiedName\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\t\tlookups.push(loadRow(referencedQualifiedName, value).then((targetRow) => {\n\t\t\tconst label = projectLabel(referencedTable, targetRow);\n\t\t\tout[relation.field] = {\n\t\t\t\tvalue,\n\t\t\t\tlabel,\n\t\t\t\treferencedQualifiedName\n\t\t\t};\n\t\t}));\n\t}\n\tawait Promise.all(lookups);\n\treturn out;\n}\nfunction projectLabel(referencedTable, targetRow) {\n\tif (targetRow === null) return null;\n\tconst display = referencedTable.displayField;\n\tif (display === null) return null;\n\tconst value = targetRow[display];\n\tif (value === null || value === void 0) return null;\n\treturn String(value);\n}\n//#endregion\n//#region src/routes/tables/[table]/[id]/+page.server.ts\nfunction findTable(tables, slug) {\n\treturn tables.find((t) => t.qualifiedName === slug) ?? null;\n}\nfunction tableViewModel(table) {\n\treturn {\n\t\tqualifiedName: table.qualifiedName,\n\t\tlabel: table.label,\n\t\tcolumns: table.columns.map((c) => ({\n\t\t\tname: c.name,\n\t\t\tlabel: c.label,\n\t\t\twidget: c.widget,\n\t\t\tisPrimaryKey: c.isPrimaryKey,\n\t\t\tisForeignKey: c.isForeignKey\n\t\t}))\n\t};\n}\nvar load = async ({ params, locals }) => {\n\tconst table = findTable(locals.schema.tables, params.table);\n\tif (!table) throw error(404, `Unknown table: ${params.table}`);\n\tconst adapter = getAdapter();\n\tconst row = await adapter.get(table.qualifiedName, params.id);\n\tconst fkLabels = await resolveFkLabels({\n\t\ttable,\n\t\trow,\n\t\tschema: locals.schema,\n\t\tloadRow: (qualifiedName, id) => locals.fkRowCache.get(qualifiedName, id, (qn, identifier) => adapter.get(qn, identifier).catch(() => null))\n\t});\n\treturn {\n\t\ttable: tableViewModel(table),\n\t\trow,\n\t\tfkLabels,\n\t\tid: params.id\n\t};\n};\nvar actions = { delete: async ({ params, locals }) => {\n\tconst table = findTable(locals.schema.tables, params.table);\n\tif (!table) throw error(404, `Unknown table: ${params.table}`);\n\tawait getAdapter().delete(table.qualifiedName, params.id);\n\tthrow redirect(303, `/tables/${table.qualifiedName}`);\n} };\n//#endregion\nexport { actions, load };\n","import * as server from '../entries/pages/tables/_table_/_id_/_page.server.ts.js';\n\nexport const index = 4;\nlet component_cache;\nexport const component = async () => component_cache ??= (await import('../entries/pages/tables/_table_/_id_/_page.svelte.js')).default;\nexport { server };\nexport const server_id = \"src/routes/tables/[table]/[id]/+page.server.ts\";\nexport const imports = [\"_app/immutable/nodes/4.hHssvcSO.js\",\"_app/immutable/chunks/BpIM_fT8.js\",\"_app/immutable/chunks/DQLVkJ9E.js\",\"_app/immutable/chunks/C4vVozd5.js\",\"_app/immutable/chunks/xihTtKlq.js\"];\nexport const stylesheets = [];\nexport const fonts = [];\n"],"names":[],"mappings":";;;;AAEA;AACA,eAAe,eAAe,CAAC,IAAI,EAAE;AACrC,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI;AAC7C,CAAC,MAAM,GAAG,GAAG,EAAE;AACf,CAAC,MAAM,OAAO,GAAG,EAAE;AACnB,CAAC,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE;AACzC,EAAE,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC;AACtC,EAAE,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ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