stitchkit 0.136.6 → 0.136.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/entrypoints/cli/publish.d.ts +4 -4
- package/dist/entrypoints/cli/publish.d.ts.map +1 -1
- package/dist/entrypoints/cli/publish.js +154 -46
- package/dist/entrypoints/cli.d.ts +1 -1
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +3 -1
- package/dist/entrypoints/postgres.d.ts +8 -0
- package/dist/entrypoints/postgres.d.ts.map +1 -0
- package/dist/entrypoints/postgres.js +380 -0
- package/dist/{index-f103md2v.js → index-3zt0r4y0.js} +84 -19
- package/dist/postgres/connection-config.d.ts +54 -0
- package/dist/postgres/connection-config.d.ts.map +1 -0
- package/dist/postgres/serialize-prisma.d.ts +40 -0
- package/dist/postgres/serialize-prisma.d.ts.map +1 -0
- package/dist/tools/cli/distribution-config.d.ts +39 -1
- package/dist/tools/cli/distribution-config.d.ts.map +1 -1
- package/dist/tools/cli/distribution-routes.d.ts +4 -2
- package/dist/tools/cli/distribution-routes.d.ts.map +1 -1
- package/dist/tools/cli/publication-contract.d.ts +9 -2
- package/dist/tools/cli/publication-contract.d.ts.map +1 -1
- package/dist/tools/cli/publication.d.ts.map +1 -1
- package/dist/tools/cli/signature.d.ts +23 -9
- package/dist/tools/cli/signature.d.ts.map +1 -1
- package/dist/tools/cli/update.d.ts +6 -1
- package/dist/tools/cli/update.d.ts.map +1 -1
- package/llms/cli-publish.txt +4 -1
- package/llms/cli.2.txt +32 -43
- package/llms/cli.3.txt +32 -1
- package/llms/postgres.txt +47 -0
- package/llms/stitchkit.txt +3 -1
- package/llms-full.txt +77 -15
- package/llms.txt +4 -3
- package/package.json +7 -3
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
// src/postgres/connection-config.ts
|
|
2
|
+
var CONTROL_CHAR_PATTERN = /[\u0000-\u001f\u007f]/;
|
|
3
|
+
var ALLOWED_PROTOCOLS = new Set(["postgres:", "postgresql:", "socket:"]);
|
|
4
|
+
var EMPTY_HOST_WITH_CREDS = /^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^/?#]*@)\//;
|
|
5
|
+
var TIME_ZONE_PATTERN = /^[A-Za-z0-9_+-][A-Za-z0-9_./+:,-]{0,127}$/;
|
|
6
|
+
var SEARCH_PATH_ITEM_PATTERN = /^(?:\$user|"\$user"|[A-Za-z_][A-Za-z0-9_$]{0,62}|"(?:[^"\\\s]|""){1,63}")$/;
|
|
7
|
+
var PARAMETER_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]{0,62}(?:\.[A-Za-z_][A-Za-z0-9_]{0,62})?$/;
|
|
8
|
+
var RESERVED_PARAMETERS = new Set(["timezone", "search_path"]);
|
|
9
|
+
function isPlainObject(value) {
|
|
10
|
+
if (typeof value !== "object" || value === null)
|
|
11
|
+
return false;
|
|
12
|
+
const proto = Object.getPrototypeOf(value);
|
|
13
|
+
return proto === Object.prototype || proto === null;
|
|
14
|
+
}
|
|
15
|
+
function parseAndStripConnectionString(raw) {
|
|
16
|
+
if (typeof raw !== "string" || raw.length === 0 || raw !== raw.trim() || CONTROL_CHAR_PATTERN.test(raw)) {
|
|
17
|
+
throw new TypeError("postgresConnectionConfig received an invalid PostgreSQL connectionString");
|
|
18
|
+
}
|
|
19
|
+
if (raw.startsWith("/")) {
|
|
20
|
+
return { connectionString: raw, urlOptions: [] };
|
|
21
|
+
}
|
|
22
|
+
const candidateUrl = EMPTY_HOST_WITH_CREDS.test(raw) ? raw.replace(EMPTY_HOST_WITH_CREDS, "$1___stitchkit_empty_host___/") : raw;
|
|
23
|
+
let parsed;
|
|
24
|
+
try {
|
|
25
|
+
parsed = new URL(candidateUrl);
|
|
26
|
+
} catch {
|
|
27
|
+
throw new TypeError("postgresConnectionConfig received an invalid PostgreSQL connectionString");
|
|
28
|
+
}
|
|
29
|
+
if (!ALLOWED_PROTOCOLS.has(parsed.protocol)) {
|
|
30
|
+
throw new TypeError("postgresConnectionConfig connectionString must use postgres://, postgresql://, or socket:");
|
|
31
|
+
}
|
|
32
|
+
if (parsed.protocol === "socket:") {
|
|
33
|
+
if (parsed.pathname.length === 0) {
|
|
34
|
+
throw new TypeError("postgresConnectionConfig socket: connectionString must include a socket path");
|
|
35
|
+
}
|
|
36
|
+
} else if (!raw.slice(parsed.protocol.length).startsWith("//")) {
|
|
37
|
+
throw new TypeError("postgresConnectionConfig connectionString must use an authority-form postgres:// or postgresql:// URL");
|
|
38
|
+
}
|
|
39
|
+
const hashIndex = raw.indexOf("#");
|
|
40
|
+
const withoutHash = hashIndex === -1 ? raw : raw.slice(0, hashIndex);
|
|
41
|
+
const hashPart = hashIndex === -1 ? "" : raw.slice(hashIndex);
|
|
42
|
+
const queryIndex = withoutHash.indexOf("?");
|
|
43
|
+
if (queryIndex === -1) {
|
|
44
|
+
return { connectionString: raw, urlOptions: [] };
|
|
45
|
+
}
|
|
46
|
+
const beforeQuery = withoutHash.slice(0, queryIndex);
|
|
47
|
+
const rawQuery = withoutHash.slice(queryIndex + 1);
|
|
48
|
+
const segments = rawQuery.split("&");
|
|
49
|
+
const keptSegments = [];
|
|
50
|
+
const urlOptions = [];
|
|
51
|
+
let strippedAny = false;
|
|
52
|
+
for (const segment of segments) {
|
|
53
|
+
const params = new URLSearchParams(`&${segment}`);
|
|
54
|
+
if (params.has("options")) {
|
|
55
|
+
strippedAny = true;
|
|
56
|
+
for (const value of params.getAll("options")) {
|
|
57
|
+
urlOptions.push(value);
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
keptSegments.push(segment);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (!strippedAny) {
|
|
64
|
+
return { connectionString: raw, urlOptions: [] };
|
|
65
|
+
}
|
|
66
|
+
const remaining = keptSegments.filter((segment) => segment.length > 0);
|
|
67
|
+
const connectionString = remaining.length > 0 ? `${beforeQuery}?${remaining.join("&")}${hashPart}` : `${beforeQuery}${hashPart}`;
|
|
68
|
+
return { connectionString, urlOptions };
|
|
69
|
+
}
|
|
70
|
+
function normalizeRawOptionFragment(raw, source) {
|
|
71
|
+
if (CONTROL_CHAR_PATTERN.test(raw)) {
|
|
72
|
+
throw new TypeError(`postgresConnectionConfig ${source} must not contain control characters`);
|
|
73
|
+
}
|
|
74
|
+
const tokens = [];
|
|
75
|
+
let current = "";
|
|
76
|
+
let inToken = false;
|
|
77
|
+
let escaping = false;
|
|
78
|
+
let start = -1;
|
|
79
|
+
let end = -1;
|
|
80
|
+
for (let i = 0;i < raw.length; i += 1) {
|
|
81
|
+
const ch = raw[i];
|
|
82
|
+
if (ch === undefined)
|
|
83
|
+
break;
|
|
84
|
+
if (escaping) {
|
|
85
|
+
current += ch;
|
|
86
|
+
escaping = false;
|
|
87
|
+
end = i + 1;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (ch === "\\") {
|
|
91
|
+
if (!inToken) {
|
|
92
|
+
inToken = true;
|
|
93
|
+
if (start === -1)
|
|
94
|
+
start = i;
|
|
95
|
+
}
|
|
96
|
+
escaping = true;
|
|
97
|
+
end = i + 1;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (ch === " ") {
|
|
101
|
+
if (inToken) {
|
|
102
|
+
tokens.push(current);
|
|
103
|
+
current = "";
|
|
104
|
+
inToken = false;
|
|
105
|
+
}
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (/\s/.test(ch)) {
|
|
109
|
+
throw new TypeError(`postgresConnectionConfig ${source} contains unsupported whitespace characters`);
|
|
110
|
+
}
|
|
111
|
+
if (!inToken) {
|
|
112
|
+
inToken = true;
|
|
113
|
+
if (start === -1)
|
|
114
|
+
start = i;
|
|
115
|
+
}
|
|
116
|
+
current += ch;
|
|
117
|
+
end = i + 1;
|
|
118
|
+
}
|
|
119
|
+
if (escaping) {
|
|
120
|
+
throw new TypeError(`postgresConnectionConfig ${source} must not end with an unescaped backslash`);
|
|
121
|
+
}
|
|
122
|
+
if (inToken) {
|
|
123
|
+
tokens.push(current);
|
|
124
|
+
}
|
|
125
|
+
if (tokens.length === 0)
|
|
126
|
+
return;
|
|
127
|
+
if (tokens.includes("--")) {
|
|
128
|
+
throw new TypeError(`postgresConnectionConfig ${source} must not contain a standalone "--" option terminator`);
|
|
129
|
+
}
|
|
130
|
+
if (tokens[tokens.length - 1] === "-c") {
|
|
131
|
+
throw new TypeError(`postgresConnectionConfig ${source} must not end with an incomplete "-c" flag`);
|
|
132
|
+
}
|
|
133
|
+
return raw.slice(start, end);
|
|
134
|
+
}
|
|
135
|
+
function formatTimeZoneFlag(value) {
|
|
136
|
+
if (value === null)
|
|
137
|
+
return;
|
|
138
|
+
const timeZone = value === undefined ? "UTC" : value;
|
|
139
|
+
if (typeof timeZone !== "string" || timeZone.includes("..") || !TIME_ZONE_PATTERN.test(timeZone)) {
|
|
140
|
+
throw new TypeError("postgresConnectionConfig options.timeZone must be a valid PostgreSQL time zone name, UTC offset, or null");
|
|
141
|
+
}
|
|
142
|
+
return `-c TimeZone=${timeZone}`;
|
|
143
|
+
}
|
|
144
|
+
function formatSearchPathFlag(value) {
|
|
145
|
+
if (value === undefined)
|
|
146
|
+
return;
|
|
147
|
+
let items;
|
|
148
|
+
if (typeof value === "string") {
|
|
149
|
+
if (CONTROL_CHAR_PATTERN.test(value)) {
|
|
150
|
+
throw new TypeError("postgresConnectionConfig options.searchPath must not contain control characters");
|
|
151
|
+
}
|
|
152
|
+
items = value.split(",").map((part) => part.trim());
|
|
153
|
+
} else if (Array.isArray(value)) {
|
|
154
|
+
if (value.length === 0) {
|
|
155
|
+
throw new TypeError("postgresConnectionConfig options.searchPath must not be empty");
|
|
156
|
+
}
|
|
157
|
+
items = [];
|
|
158
|
+
for (const entry of value) {
|
|
159
|
+
if (typeof entry !== "string" || entry.length === 0 || entry !== entry.trim() || entry.includes(",") || CONTROL_CHAR_PATTERN.test(entry)) {
|
|
160
|
+
throw new TypeError("postgresConnectionConfig options.searchPath entries must be valid trimmed schema names without commas");
|
|
161
|
+
}
|
|
162
|
+
items.push(entry);
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
throw new TypeError("postgresConnectionConfig options.searchPath must be a string or an array of schema names");
|
|
166
|
+
}
|
|
167
|
+
for (const item of items) {
|
|
168
|
+
if (item.length === 0 || CONTROL_CHAR_PATTERN.test(item) || !SEARCH_PATH_ITEM_PATTERN.test(item)) {
|
|
169
|
+
throw new TypeError(`postgresConnectionConfig options.searchPath contains an invalid schema identifier: ${item}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return `-c search_path=${items.join(",")}`;
|
|
173
|
+
}
|
|
174
|
+
function formatParameterFlags(value) {
|
|
175
|
+
if (value === undefined)
|
|
176
|
+
return [];
|
|
177
|
+
if (!isPlainObject(value)) {
|
|
178
|
+
throw new TypeError("postgresConnectionConfig options.parameters must be a plain object");
|
|
179
|
+
}
|
|
180
|
+
const seen = new Set;
|
|
181
|
+
const flags = [];
|
|
182
|
+
for (const [name, paramValue] of Object.entries(value)) {
|
|
183
|
+
if (!PARAMETER_NAME_PATTERN.test(name)) {
|
|
184
|
+
throw new TypeError(`postgresConnectionConfig options.parameters contains an invalid parameter name: ${name}`);
|
|
185
|
+
}
|
|
186
|
+
const normalized = name.toLowerCase();
|
|
187
|
+
if (RESERVED_PARAMETERS.has(normalized)) {
|
|
188
|
+
throw new TypeError(`postgresConnectionConfig options.parameters forbids "${name}"; use the dedicated timeZone or searchPath option`);
|
|
189
|
+
}
|
|
190
|
+
if (seen.has(normalized)) {
|
|
191
|
+
throw new TypeError(`postgresConnectionConfig options.parameters contains duplicate parameter "${name}"`);
|
|
192
|
+
}
|
|
193
|
+
seen.add(normalized);
|
|
194
|
+
if (typeof paramValue !== "string" || paramValue.length === 0 || CONTROL_CHAR_PATTERN.test(paramValue) || /\s/.test(paramValue) || paramValue.includes("\\")) {
|
|
195
|
+
throw new TypeError(`postgresConnectionConfig options.parameters.${name} must be a non-empty string without whitespace, backslashes, or control characters`);
|
|
196
|
+
}
|
|
197
|
+
flags.push(`-c ${name}=${paramValue}`);
|
|
198
|
+
}
|
|
199
|
+
return flags;
|
|
200
|
+
}
|
|
201
|
+
function resolveConnectionConfig(rest, rawConnectionString, rawConfigOptions, options) {
|
|
202
|
+
if (options !== undefined && !isPlainObject(options)) {
|
|
203
|
+
throw new TypeError("postgresConnectionConfig options must be a plain object");
|
|
204
|
+
}
|
|
205
|
+
const { connectionString, urlOptions } = parseAndStripConnectionString(rawConnectionString);
|
|
206
|
+
const parts = [];
|
|
207
|
+
for (const fragment of urlOptions) {
|
|
208
|
+
const normalized = normalizeRawOptionFragment(fragment, "URL options");
|
|
209
|
+
if (normalized !== undefined)
|
|
210
|
+
parts.push(normalized);
|
|
211
|
+
}
|
|
212
|
+
if (rawConfigOptions !== undefined) {
|
|
213
|
+
if (typeof rawConfigOptions !== "string") {
|
|
214
|
+
throw new TypeError("postgresConnectionConfig config.options must be a string");
|
|
215
|
+
}
|
|
216
|
+
const normalized = normalizeRawOptionFragment(rawConfigOptions, "config.options");
|
|
217
|
+
if (normalized !== undefined)
|
|
218
|
+
parts.push(normalized);
|
|
219
|
+
}
|
|
220
|
+
for (const flag of formatParameterFlags(options?.parameters)) {
|
|
221
|
+
parts.push(flag);
|
|
222
|
+
}
|
|
223
|
+
const searchPathFlag = formatSearchPathFlag(options?.searchPath);
|
|
224
|
+
if (searchPathFlag !== undefined)
|
|
225
|
+
parts.push(searchPathFlag);
|
|
226
|
+
const timeZoneFlag = formatTimeZoneFlag(options?.timeZone);
|
|
227
|
+
if (timeZoneFlag !== undefined)
|
|
228
|
+
parts.push(timeZoneFlag);
|
|
229
|
+
const mergedOptions = parts.length > 0 ? parts.join(" ") : undefined;
|
|
230
|
+
return {
|
|
231
|
+
...rest,
|
|
232
|
+
connectionString,
|
|
233
|
+
...mergedOptions !== undefined && { options: mergedOptions }
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
function postgresConnectionConfig(input, options) {
|
|
237
|
+
if (typeof input === "string") {
|
|
238
|
+
return resolveConnectionConfig(undefined, input, undefined, options);
|
|
239
|
+
}
|
|
240
|
+
if (!isPlainObject(input)) {
|
|
241
|
+
throw new TypeError("postgresConnectionConfig expects a connection string or a plain config object");
|
|
242
|
+
}
|
|
243
|
+
const { connectionString: rawUrl, options: rawConfigOptions, ...rest } = input;
|
|
244
|
+
return resolveConnectionConfig(rest, rawUrl, rawConfigOptions, options);
|
|
245
|
+
}
|
|
246
|
+
// src/postgres/serialize-prisma.ts
|
|
247
|
+
var CONNECT_FACTORY_METHODS = new Set([
|
|
248
|
+
"connect",
|
|
249
|
+
"connectToShadowDb"
|
|
250
|
+
]);
|
|
251
|
+
var SERIALIZED_TRANSACTION_METHODS = new Set([
|
|
252
|
+
"queryRaw",
|
|
253
|
+
"executeRaw",
|
|
254
|
+
"commit",
|
|
255
|
+
"rollback",
|
|
256
|
+
"createSavepoint",
|
|
257
|
+
"rollbackToSavepoint",
|
|
258
|
+
"releaseSavepoint"
|
|
259
|
+
]);
|
|
260
|
+
var wrappedFactories = new WeakSet;
|
|
261
|
+
var wrappedAdapters = new WeakSet;
|
|
262
|
+
var wrappedTransactions = new WeakSet;
|
|
263
|
+
function isObject(value) {
|
|
264
|
+
return typeof value === "object" && value !== null;
|
|
265
|
+
}
|
|
266
|
+
function assertWrappableMethods(target, keys, kind) {
|
|
267
|
+
for (const key of keys) {
|
|
268
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, key);
|
|
269
|
+
if (descriptor !== undefined && !descriptor.configurable && !descriptor.writable && "value" in descriptor && typeof descriptor.value === "function") {
|
|
270
|
+
throw new TypeError(`withSerializedPrismaTransactions cannot wrap non-configurable, non-writable ${kind} method "${String(key)}"`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function readOwnProperty(target, key) {
|
|
275
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, key);
|
|
276
|
+
if (descriptor !== undefined && !descriptor.configurable && !descriptor.writable && "value" in descriptor) {
|
|
277
|
+
return descriptor.value;
|
|
278
|
+
}
|
|
279
|
+
const value = Reflect.get(target, key, target);
|
|
280
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
281
|
+
}
|
|
282
|
+
function wrapTransaction(transaction) {
|
|
283
|
+
if (wrappedTransactions.has(transaction))
|
|
284
|
+
return transaction;
|
|
285
|
+
assertWrappableMethods(transaction, SERIALIZED_TRANSACTION_METHODS, "transaction");
|
|
286
|
+
let previous = Promise.resolve();
|
|
287
|
+
const proxy = new Proxy(transaction, {
|
|
288
|
+
get(target, key) {
|
|
289
|
+
if (SERIALIZED_TRANSACTION_METHODS.has(key)) {
|
|
290
|
+
const raw = Reflect.get(target, key, target);
|
|
291
|
+
if (typeof raw !== "function")
|
|
292
|
+
return raw;
|
|
293
|
+
return (...args) => {
|
|
294
|
+
let release = () => {
|
|
295
|
+
return;
|
|
296
|
+
};
|
|
297
|
+
const gate = new Promise((resolve) => {
|
|
298
|
+
release = resolve;
|
|
299
|
+
});
|
|
300
|
+
const wait = previous;
|
|
301
|
+
previous = gate;
|
|
302
|
+
return wait.then(async () => {
|
|
303
|
+
try {
|
|
304
|
+
return await Reflect.apply(raw, target, args);
|
|
305
|
+
} finally {
|
|
306
|
+
release();
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
return readOwnProperty(target, key);
|
|
312
|
+
},
|
|
313
|
+
set(target, key, value) {
|
|
314
|
+
return Reflect.set(target, key, value, target);
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
wrappedTransactions.add(proxy);
|
|
318
|
+
return proxy;
|
|
319
|
+
}
|
|
320
|
+
function wrapAdapter(adapter) {
|
|
321
|
+
if (wrappedAdapters.has(adapter))
|
|
322
|
+
return adapter;
|
|
323
|
+
assertWrappableMethods(adapter, ["startTransaction"], "adapter");
|
|
324
|
+
const proxy = new Proxy(adapter, {
|
|
325
|
+
get(target, key) {
|
|
326
|
+
if (key === "startTransaction") {
|
|
327
|
+
const raw = Reflect.get(target, key, target);
|
|
328
|
+
if (typeof raw !== "function")
|
|
329
|
+
return raw;
|
|
330
|
+
return async (...args) => {
|
|
331
|
+
const transaction = await Reflect.apply(raw, target, args);
|
|
332
|
+
return isObject(transaction) ? wrapTransaction(transaction) : transaction;
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
return readOwnProperty(target, key);
|
|
336
|
+
},
|
|
337
|
+
set(target, key, value) {
|
|
338
|
+
return Reflect.set(target, key, value, target);
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
wrappedAdapters.add(proxy);
|
|
342
|
+
return proxy;
|
|
343
|
+
}
|
|
344
|
+
function withSerializedPrismaTransactions(adapter) {
|
|
345
|
+
if (!isObject(adapter)) {
|
|
346
|
+
throw new TypeError("withSerializedPrismaTransactions expects a Prisma driver adapter factory object");
|
|
347
|
+
}
|
|
348
|
+
if (wrappedFactories.has(adapter))
|
|
349
|
+
return adapter;
|
|
350
|
+
const provider = Reflect.get(adapter, "provider", adapter);
|
|
351
|
+
const adapterName = Reflect.get(adapter, "adapterName", adapter);
|
|
352
|
+
const connect = Reflect.get(adapter, "connect", adapter);
|
|
353
|
+
if (typeof provider !== "string" || typeof adapterName !== "string" || typeof connect !== "function") {
|
|
354
|
+
throw new TypeError("withSerializedPrismaTransactions expects a Prisma driver adapter factory with string provider, string adapterName and a connect() method");
|
|
355
|
+
}
|
|
356
|
+
assertWrappableMethods(adapter, CONNECT_FACTORY_METHODS, "adapter factory");
|
|
357
|
+
const proxy = new Proxy(adapter, {
|
|
358
|
+
get(target, key) {
|
|
359
|
+
if (CONNECT_FACTORY_METHODS.has(key)) {
|
|
360
|
+
const raw = Reflect.get(target, key, target);
|
|
361
|
+
if (typeof raw !== "function")
|
|
362
|
+
return raw;
|
|
363
|
+
return async (...args) => {
|
|
364
|
+
const connected = await Reflect.apply(raw, target, args);
|
|
365
|
+
return isObject(connected) ? wrapAdapter(connected) : connected;
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
return readOwnProperty(target, key);
|
|
369
|
+
},
|
|
370
|
+
set(target, key, value) {
|
|
371
|
+
return Reflect.set(target, key, value, target);
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
wrappedFactories.add(proxy);
|
|
375
|
+
return proxy;
|
|
376
|
+
}
|
|
377
|
+
export {
|
|
378
|
+
postgresConnectionConfig,
|
|
379
|
+
withSerializedPrismaTransactions
|
|
380
|
+
};
|
|
@@ -159,6 +159,72 @@ var CliBuildSignatureSchema2 = z.object({
|
|
|
159
159
|
keyId: z.string().min(1),
|
|
160
160
|
signature: z.string().min(1)
|
|
161
161
|
});
|
|
162
|
+
var UNSAFE_TRUST_KEY_IDS = new Set(["__proto__", "constructor", "prototype"]);
|
|
163
|
+
var CANONICAL_RAW_ED25519_BASE64 = /^[A-Za-z0-9+/]{43}=?$/;
|
|
164
|
+
var STRICT_SPKI_PUBLIC_KEY_PEM = /^-----BEGIN PUBLIC KEY-----\r?\n[A-Za-z0-9+/\r\n]+=*\r?\n-----END PUBLIC KEY-----$/;
|
|
165
|
+
function publicKeyOf(material) {
|
|
166
|
+
const trimmed = material.trim();
|
|
167
|
+
if (trimmed.includes("BEGIN ") || trimmed.includes("END ")) {
|
|
168
|
+
if (!STRICT_SPKI_PUBLIC_KEY_PEM.test(trimmed)) {
|
|
169
|
+
throw new Error("[stitchkit] an Ed25519 SPKI public key PEM is required");
|
|
170
|
+
}
|
|
171
|
+
const key = createPublicKey(trimmed);
|
|
172
|
+
if (key.asymmetricKeyType !== "ed25519") {
|
|
173
|
+
throw new Error("[stitchkit] an Ed25519 public key is required");
|
|
174
|
+
}
|
|
175
|
+
return key;
|
|
176
|
+
}
|
|
177
|
+
if (!CANONICAL_RAW_ED25519_BASE64.test(trimmed)) {
|
|
178
|
+
throw new Error("[stitchkit] an Ed25519 public key is 32 bytes or SPKI PEM");
|
|
179
|
+
}
|
|
180
|
+
const raw = Buffer.from(trimmed, "base64");
|
|
181
|
+
const canonical = raw.toString("base64");
|
|
182
|
+
if (raw.length !== 32 || trimmed !== canonical && trimmed !== canonical.slice(0, -1)) {
|
|
183
|
+
throw new Error("[stitchkit] an Ed25519 public key is 32 bytes or SPKI PEM");
|
|
184
|
+
}
|
|
185
|
+
const spki = Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), raw]);
|
|
186
|
+
return createPublicKey({ key: spki, format: "der", type: "spki" });
|
|
187
|
+
}
|
|
188
|
+
var trustKeyIdSchema = z.string().min(1, "trust key id must not be empty").refine((id) => id === id.trim(), "trust key id must not have leading or trailing whitespace").refine((id) => !UNSAFE_TRUST_KEY_IDS.has(id), "trust key id must not be a prototype property");
|
|
189
|
+
var trustPublicKeySchema = z.string().min(1, "trust public key must not be empty").refine((material) => {
|
|
190
|
+
if (material.trim().length === 0)
|
|
191
|
+
return false;
|
|
192
|
+
try {
|
|
193
|
+
publicKeyOf(material);
|
|
194
|
+
return true;
|
|
195
|
+
} catch {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
}, "trust public key must be an Ed25519 SPKI PEM or 32-byte base64 key");
|
|
199
|
+
function hasOwnUnsafeTrustKeyId(value) {
|
|
200
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
201
|
+
return false;
|
|
202
|
+
return Object.getOwnPropertyNames(value).some((key) => UNSAFE_TRUST_KEY_IDS.has(key));
|
|
203
|
+
}
|
|
204
|
+
var trustKeysRecordSchema = z.record(trustKeyIdSchema, trustPublicKeySchema).readonly().refine((keys) => Object.keys(keys).length > 0, "trust.keys must contain at least one signing key");
|
|
205
|
+
var CliTrustRootSchema2 = z.strictObject({
|
|
206
|
+
keys: z.unknown().refine((value) => !hasOwnUnsafeTrustKeyId(value), "trust key id must not be a prototype property").pipe(trustKeysRecordSchema)
|
|
207
|
+
});
|
|
208
|
+
function isUnsafeTrustKeyId(keyId) {
|
|
209
|
+
return UNSAFE_TRUST_KEY_IDS.has(keyId);
|
|
210
|
+
}
|
|
211
|
+
function isUnenforcedEmptyTrustRoot(trust) {
|
|
212
|
+
if (typeof trust !== "object" || trust === null)
|
|
213
|
+
return false;
|
|
214
|
+
const keys = Reflect.get(trust, "keys");
|
|
215
|
+
if (typeof keys !== "object" || keys === null || Array.isArray(keys))
|
|
216
|
+
return false;
|
|
217
|
+
if (hasOwnUnsafeTrustKeyId(keys))
|
|
218
|
+
return false;
|
|
219
|
+
return Object.keys(keys).length === 0;
|
|
220
|
+
}
|
|
221
|
+
function freezeTrustRoot(trust) {
|
|
222
|
+
const keys = Object.create(null);
|
|
223
|
+
for (const [keyId, material] of Object.entries(trust.keys)) {
|
|
224
|
+
keys[keyId] = material;
|
|
225
|
+
}
|
|
226
|
+
return Object.freeze({ keys: Object.freeze(keys) });
|
|
227
|
+
}
|
|
162
228
|
function cliManifestSigningPayload2(manifest) {
|
|
163
229
|
return serializeCanonicalJson({
|
|
164
230
|
name: manifest.name,
|
|
@@ -174,17 +240,6 @@ function cliManifestSigningPayload2(manifest) {
|
|
|
174
240
|
}))
|
|
175
241
|
});
|
|
176
242
|
}
|
|
177
|
-
function publicKeyOf(material) {
|
|
178
|
-
const trimmed = material.trim();
|
|
179
|
-
if (trimmed.includes("BEGIN PUBLIC KEY"))
|
|
180
|
-
return createPublicKey(trimmed);
|
|
181
|
-
const raw = Buffer.from(trimmed, "base64");
|
|
182
|
-
if (raw.length !== 32) {
|
|
183
|
-
throw new Error("[stitchkit] an Ed25519 public key is 32 bytes or SPKI PEM");
|
|
184
|
-
}
|
|
185
|
-
const spki = Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), raw]);
|
|
186
|
-
return createPublicKey({ key: spki, format: "der", type: "spki" });
|
|
187
|
-
}
|
|
188
243
|
function signCliManifest2(manifest, options) {
|
|
189
244
|
const signature = cryptoSign(null, Buffer.from(cliManifestSigningPayload2(manifest), "utf8"), createPrivateKey(typeof options.privateKey === "string" ? options.privateKey : { key: Buffer.from(options.privateKey), format: "der", type: "pkcs8" }));
|
|
190
245
|
return {
|
|
@@ -570,14 +625,19 @@ var DEFAULT_DOWNLOAD_IDLE_TIMEOUT_MS = 30000;
|
|
|
570
625
|
var DEFAULT_VERIFY_TIMEOUT_MS = 30000;
|
|
571
626
|
var MANIFEST_MAX_BYTES = 256 * 1024;
|
|
572
627
|
var DEFAULT_MAX_ASSET_BYTES = 256 * 1024 * 1024;
|
|
628
|
+
var SEMVER_PATTERN = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;
|
|
573
629
|
function parseVersion(value) {
|
|
574
|
-
const match =
|
|
630
|
+
const match = SEMVER_PATTERN.exec(value.trim());
|
|
575
631
|
if (!match)
|
|
576
632
|
return;
|
|
577
633
|
const numbers = [match[1], match[2], match[3]].map((part) => Number(part));
|
|
578
|
-
if (numbers.some((part) => !Number.
|
|
634
|
+
if (numbers.some((part) => !Number.isSafeInteger(part)))
|
|
635
|
+
return;
|
|
636
|
+
const prerelease = match[4];
|
|
637
|
+
if (prerelease?.split(".").some((part) => /^0\d+$/.test(part))) {
|
|
579
638
|
return;
|
|
580
|
-
|
|
639
|
+
}
|
|
640
|
+
return { numbers, prerelease };
|
|
581
641
|
}
|
|
582
642
|
function compareCliVersions2(left, right) {
|
|
583
643
|
const a = parseVersion(left);
|
|
@@ -682,15 +742,20 @@ async function applyCliUpdate2(config) {
|
|
|
682
742
|
assertTimerMs("[stitchkit] update: timeoutMs", config.timeoutMs);
|
|
683
743
|
assertTimerMs("[stitchkit] update: idleTimeoutMs", config.idleTimeoutMs);
|
|
684
744
|
assertTimerMs("[stitchkit] update: verifyTimeoutMs", config.verifyTimeoutMs);
|
|
685
|
-
if (config.trust) {
|
|
745
|
+
if (config.trust !== undefined && !isUnenforcedEmptyTrustRoot(config.trust)) {
|
|
746
|
+
const parsedTrust = CliTrustRootSchema2.safeParse(config.trust);
|
|
747
|
+
if (!parsedTrust.success) {
|
|
748
|
+
throw new Error("[stitchkit] update: refusing to install — trust root must contain valid Ed25519 keys", { cause: parsedTrust.error });
|
|
749
|
+
}
|
|
686
750
|
if (!config.manifest) {
|
|
687
751
|
throw new Error("[stitchkit] update: a trust root needs the manifest the asset came from");
|
|
688
752
|
}
|
|
689
|
-
const
|
|
690
|
-
|
|
753
|
+
const trust = freezeTrustRoot(parsedTrust.data);
|
|
754
|
+
const verdict = verifyCliManifest2(config.manifest, config.manifest.signature, trust);
|
|
755
|
+
if (verdict !== "valid") {
|
|
691
756
|
throw new Error(`[stitchkit] update: refusing to install — manifest signature ${verdict}`);
|
|
692
757
|
}
|
|
693
|
-
if (!config.manifest.assets.some((asset) => asset.sha256 === config.asset.sha256)) {
|
|
758
|
+
if (!config.manifest.assets.some((asset) => asset.sha256 === config.asset.sha256 && asset.size === config.asset.size && asset.compression === config.asset.compression && asset.platform === config.asset.platform && asset.arch === config.asset.arch)) {
|
|
694
759
|
throw new Error("[stitchkit] update: the asset is not one the signed manifest names");
|
|
695
760
|
}
|
|
696
761
|
}
|
|
@@ -767,4 +832,4 @@ function rollbackCliUpdate2(config) {
|
|
|
767
832
|
return { path: target, bytes: bytes.length, sha256 };
|
|
768
833
|
}
|
|
769
834
|
|
|
770
|
-
export { renderCliInstaller2, CliBuildSignatureSchema2, cliManifestSigningPayload2, signCliManifest2, verifyCliManifest2, cliSignatureAccepted2, CliBuildTargetSchema2, CliBuildAssetSchema2, CliBuildManifestSchema2, CliBuildStampSchema2, formatCliBuildStamp2, currentCliBuildTarget2, selectCliBuildAsset2, assertCliPublishable2, waitForPublication, withPublicationDeadline, collectCliBytes, gzipCliAsset, decodeCliAsset, compareCliVersions2, checkCliUpdate2, applyCliUpdate2, rollbackCliUpdate2 };
|
|
835
|
+
export { renderCliInstaller2, CliBuildSignatureSchema2, CliTrustRootSchema2, isUnsafeTrustKeyId, freezeTrustRoot, cliManifestSigningPayload2, signCliManifest2, verifyCliManifest2, cliSignatureAccepted2, CliBuildTargetSchema2, CliBuildAssetSchema2, CliBuildManifestSchema2, CliBuildStampSchema2, formatCliBuildStamp2, currentCliBuildTarget2, selectCliBuildAsset2, assertCliPublishable2, waitForPublication, withPublicationDeadline, collectCliBytes, gzipCliAsset, decodeCliAsset, compareCliVersions2, checkCliUpdate2, applyCliUpdate2, rollbackCliUpdate2 };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Peer-free PostgreSQL connection configuration helper (`stitchkit/postgres`).
|
|
3
|
+
*
|
|
4
|
+
* `pg`'s `ConnectionParameters` merges parsed `connectionString` query parameters on top of
|
|
5
|
+
* `config`, so any `?options=...` (including an empty `?options=`) in `DATABASE_URL` silently
|
|
6
|
+
* overwrites `config.options` and erases required `-c TimeZone=UTC` / `-c search_path=...` flags.
|
|
7
|
+
*
|
|
8
|
+
* This module surgically removes `options` query parameters from the raw `connectionString`
|
|
9
|
+
* (without rewriting unrelated query segments or credentials), validates raw option fragments
|
|
10
|
+
* against PostgreSQL `pg_split_opts` boundaries, and appends structured `parameters`,
|
|
11
|
+
* `searchPath`, and `timeZone` (defaulting to `'UTC'`) at the end so later startup options win.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Minimal PostgreSQL connection configuration accepted and returned by
|
|
15
|
+
* {@link postgresConnectionConfig}, structurally compatible with `pg.PoolConfig`
|
|
16
|
+
* and `PrismaPg` without importing `pg`.
|
|
17
|
+
*/
|
|
18
|
+
export interface PostgresConnectionConfig {
|
|
19
|
+
/** PostgreSQL connection URL (with any `?options=` stripped) or raw Unix socket path. */
|
|
20
|
+
connectionString: string;
|
|
21
|
+
/** Merged PostgreSQL startup `options` string (`-c key=value ...`), omitted when empty. */
|
|
22
|
+
options?: string | undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Structured session parameters appended after any URL or config `options` by
|
|
26
|
+
* {@link postgresConnectionConfig}.
|
|
27
|
+
*/
|
|
28
|
+
export interface PostgresConnectionOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Session `TimeZone` enforced via `-c TimeZone=<value>`. Defaults to `'UTC'`.
|
|
31
|
+
* Pass `null` to omit setting `TimeZone`.
|
|
32
|
+
*/
|
|
33
|
+
timeZone?: string | null | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Session `search_path` enforced via `-c search_path=<schemas>`, as a comma-separated
|
|
36
|
+
* string or an array of schema identifiers (including `$user` or double-quoted names).
|
|
37
|
+
*/
|
|
38
|
+
searchPath?: string | readonly string[] | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Additional PostgreSQL session parameters appended as `-c <name>=<value>` before
|
|
41
|
+
* `searchPath` and `timeZone`. `timezone` and `search_path` (case-insensitive) are
|
|
42
|
+
* rejected here so callers use the dedicated fields.
|
|
43
|
+
*/
|
|
44
|
+
parameters?: Readonly<Record<string, string>> | undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Build a `pg.PoolConfig` / `PrismaPg` connection object that preserves user `?options=` from
|
|
48
|
+
* `connectionString`, strips `options` from the URL so `pg` cannot overwrite `config.options`,
|
|
49
|
+
* and appends structured session parameters (`parameters`, `searchPath`, and `timeZone`,
|
|
50
|
+
* defaulting to `'UTC'`) at the end.
|
|
51
|
+
*/
|
|
52
|
+
export declare function postgresConnectionConfig(connectionString: string, options?: PostgresConnectionOptions): PostgresConnectionConfig;
|
|
53
|
+
export declare function postgresConnectionConfig<T extends PostgresConnectionConfig>(config: T, options?: PostgresConnectionOptions): Omit<T, 'connectionString' | 'options'> & PostgresConnectionConfig;
|
|
54
|
+
//# sourceMappingURL=connection-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-config.d.ts","sourceRoot":"","sources":["../../src/postgres/connection-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAaH;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC,yFAAyF;IACzF,gBAAgB,EAAE,MAAM,CAAC;IACzB,2FAA2F;IAC3F,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACrC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACpD;;;;OAIG;IACH,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;CAC3D;AAuTD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,gBAAgB,EAAE,MAAM,EACxB,OAAO,CAAC,EAAE,yBAAyB,GAClC,wBAAwB,CAAC;AAC5B,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,wBAAwB,EACzE,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,yBAAyB,GAClC,IAAI,CAAC,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC,GAAG,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serializes interactive transaction statements on a Prisma SQL driver adapter
|
|
3
|
+
* without importing `@prisma/adapter-pg` or `pg`.
|
|
4
|
+
*
|
|
5
|
+
* Prisma 7 can dispatch independent query-plan nodes (such as included
|
|
6
|
+
* relations) concurrently with `Promise.all` onto a single interactive
|
|
7
|
+
* transaction handle. On PostgreSQL (`pg`), all statements of an interactive
|
|
8
|
+
* transaction share one `pg.Client`: `pg@8` queues overlapping calls with a
|
|
9
|
+
* deprecation warning and `pg@9` refuses them.
|
|
10
|
+
*
|
|
11
|
+
* Wrapping the factory keeps queries outside a transaction parallel across the
|
|
12
|
+
* pool, keeps `commit`/`rollback` (which release the `pg.PoolClient`) in the
|
|
13
|
+
* same FIFO queue as `queryRaw`/`executeRaw` and savepoint statements, and
|
|
14
|
+
* preserves the adapter's own connection lifecycle across `$disconnect()` and
|
|
15
|
+
* reconnect.
|
|
16
|
+
*/
|
|
17
|
+
/** Minimal structural handle for a Prisma interactive transaction whose statements run serially on one connection. */
|
|
18
|
+
export interface PrismaDriverTransaction {
|
|
19
|
+
queryRaw(query: never): Promise<unknown>;
|
|
20
|
+
executeRaw(query: never): Promise<unknown>;
|
|
21
|
+
commit(): Promise<unknown>;
|
|
22
|
+
rollback(): Promise<unknown>;
|
|
23
|
+
readonly createSavepoint?: ((name: never) => Promise<unknown>) | undefined;
|
|
24
|
+
readonly rollbackToSavepoint?: ((name: never) => Promise<unknown>) | undefined;
|
|
25
|
+
readonly releaseSavepoint?: ((name: never) => Promise<unknown>) | undefined;
|
|
26
|
+
}
|
|
27
|
+
/** Minimal structural handle for a connected Prisma SQL driver adapter whose interactive transactions are serialized. */
|
|
28
|
+
export interface PrismaDriverAdapter {
|
|
29
|
+
startTransaction(isolationLevel: never): Promise<PrismaDriverTransaction>;
|
|
30
|
+
}
|
|
31
|
+
/** Minimal structural handle for a Prisma SQL driver adapter factory accepted by `withSerializedPrismaTransactions`. */
|
|
32
|
+
export interface PrismaDriverAdapterFactory {
|
|
33
|
+
readonly provider: string;
|
|
34
|
+
readonly adapterName: string;
|
|
35
|
+
connect(): Promise<PrismaDriverAdapter>;
|
|
36
|
+
readonly connectToShadowDb?: (() => Promise<PrismaDriverAdapter>) | undefined;
|
|
37
|
+
}
|
|
38
|
+
/** Wrap a Prisma SQL driver adapter factory so statements inside each interactive transaction run one at a time. */
|
|
39
|
+
export declare function withSerializedPrismaTransactions<F extends PrismaDriverAdapterFactory>(adapter: F): F;
|
|
40
|
+
//# sourceMappingURL=serialize-prisma.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialize-prisma.d.ts","sourceRoot":"","sources":["../../src/postgres/serialize-prisma.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,sHAAsH;AACtH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3B,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7B,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAC3E,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAC/E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;CAC7E;AAED,yHAAyH;AACzH,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,CAAC,cAAc,EAAE,KAAK,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;CAC3E;AAED,wHAAwH;AACxH,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,OAAO,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACxC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,SAAS,CAAC;CAC/E;AA6HD,oHAAoH;AACpH,wBAAgB,gCAAgC,CAAC,CAAC,SAAS,0BAA0B,EACnF,OAAO,EAAE,CAAC,GACT,CAAC,CAwCH"}
|