gencow 0.1.251 → 0.1.253
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/core/index.js +129 -19
- package/dashboard/assets/index-BIT2bN8D.js +54 -0
- package/dashboard/assets/index-C6-BpKKR.css +2 -0
- package/dashboard/index.html +2 -2
- package/docs/packaging.md +7 -3
- package/docs/troubleshooting.md +1 -1
- package/lib/app-command.mjs +31 -1
- package/lib/backup-command.mjs +98 -16
- package/lib/backup-restore-diagnostic.mjs +185 -0
- package/lib/cli-artifact-guard.mjs +2 -0
- package/lib/component-readme.mjs +23 -1
- package/lib/deploy-command.mjs +10 -4
- package/lib/deploy-dependency-compat.mjs +14 -3
- package/lib/deploy-failure-diagnostic.mjs +6 -4
- package/lib/deploy-logs-diagnostic.mjs +67 -0
- package/lib/deploy-package-runtime.mjs +17 -14
- package/lib/deploy-runtime.mjs +2 -1
- package/lib/dev-cloud-bundle.mjs +13 -7
- package/lib/dev-cloud-command.mjs +3 -5
- package/lib/doctor-command.mjs +10 -2
- package/lib/init-command.mjs +1 -31
- package/lib/local-deploy-interrupt-guard.mjs +70 -0
- package/lib/managed-bom-advisory.mjs +116 -0
- package/lib/prod-create-failure.mjs +13 -0
- package/lib/project-dependency-lock-sync.mjs +137 -43
- package/lib/runtime-bom-api-contract.mjs +7 -2
- package/lib/runtime-bom-diagnostic.mjs +50 -1
- package/lib/runtime-bom.mjs +37 -58
- package/lib/runtime-command.mjs +49 -43
- package/lib/runtime-lock-check.mjs +91 -0
- package/lib/static-command.mjs +7 -1
- package/lib/static-deploy-command.mjs +180 -85
- package/package.json +16 -14
- package/runtime/config.mjs +7251 -2048
- package/runtime/dependency-lock.mjs +7418 -0
- package/runtime/dependency-version-report.mjs +103 -0
- package/runtime/server.mjs +958 -807
- package/runtime/tooling.mjs +7820 -2540
- package/scripts/bundle-internal.mjs +24 -0
- package/scripts/dependency-lock-entry.ts +2 -0
- package/scripts/pre-publish-check.mjs +2 -2
- package/scripts/tooling-entry.ts +1 -0
- package/dashboard/assets/index-BL3slXXq.js +0 -401
- package/dashboard/assets/index-DvEb2ey9.css +0 -1
package/core/index.js
CHANGED
|
@@ -4,6 +4,78 @@ function defineApi(api) {
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
// ../core/src/http-route.ts
|
|
7
|
+
var discardedResponseSymbol = /* @__PURE__ */ Symbol.for("@gencow/core/http-route/discarded-response/v1");
|
|
8
|
+
var discardedResponseCauseSymbol = /* @__PURE__ */ Symbol.for("@gencow/core/http-route/discarded-response-cause/v1");
|
|
9
|
+
var outputValidationFailureSymbol = /* @__PURE__ */ Symbol.for("@gencow/core/http-route/output-validation-failure/v1");
|
|
10
|
+
function getHttpRouteDiscardedResponse(value) {
|
|
11
|
+
if (!value || typeof value !== "object" && typeof value !== "function") return void 0;
|
|
12
|
+
try {
|
|
13
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, discardedResponseSymbol);
|
|
14
|
+
const response = descriptor && "value" in descriptor ? descriptor.value : void 0;
|
|
15
|
+
return response instanceof Response ? response : void 0;
|
|
16
|
+
} catch {
|
|
17
|
+
return void 0;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function getHttpRouteDiscardedResponseCause(value) {
|
|
21
|
+
if (!value || typeof value !== "object" && typeof value !== "function") return void 0;
|
|
22
|
+
try {
|
|
23
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, discardedResponseCauseSymbol);
|
|
24
|
+
return descriptor && "value" in descriptor ? descriptor.value : void 0;
|
|
25
|
+
} catch {
|
|
26
|
+
return void 0;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function isHttpRouteOutputValidationFailure(value) {
|
|
30
|
+
if (!value || typeof value !== "object" && typeof value !== "function") return false;
|
|
31
|
+
try {
|
|
32
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, outputValidationFailureSymbol);
|
|
33
|
+
return !!descriptor && "value" in descriptor && descriptor.value === true;
|
|
34
|
+
} catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function addDiscardedResponse(value, response) {
|
|
39
|
+
try {
|
|
40
|
+
Object.defineProperty(value, discardedResponseSymbol, {
|
|
41
|
+
configurable: false,
|
|
42
|
+
enumerable: false,
|
|
43
|
+
value: response,
|
|
44
|
+
writable: false
|
|
45
|
+
});
|
|
46
|
+
return true;
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function routeResultResponse(value) {
|
|
52
|
+
if (value instanceof Response) return value;
|
|
53
|
+
return value?.body instanceof Response ? value.body : void 0;
|
|
54
|
+
}
|
|
55
|
+
function markDroppedResponse(value, response) {
|
|
56
|
+
if (!response || routeResultResponse(value) === response) return value;
|
|
57
|
+
if (value && (typeof value === "object" || typeof value === "function")) {
|
|
58
|
+
addDiscardedResponse(value, response);
|
|
59
|
+
}
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
function markDiscardedResponseError(error, response) {
|
|
63
|
+
if (error && (typeof error === "object" || typeof error === "function")) {
|
|
64
|
+
if (addDiscardedResponse(error, response)) return error;
|
|
65
|
+
}
|
|
66
|
+
const wrapped = error instanceof HttpRouteOutputValidationError ? new HttpRouteOutputValidationError(error.message) : new Error("httpRoute output validation failed", { cause: error });
|
|
67
|
+
addDiscardedResponse(wrapped, response);
|
|
68
|
+
try {
|
|
69
|
+
Object.defineProperty(wrapped, discardedResponseCauseSymbol, {
|
|
70
|
+
configurable: false,
|
|
71
|
+
enumerable: false,
|
|
72
|
+
value: error,
|
|
73
|
+
writable: false
|
|
74
|
+
});
|
|
75
|
+
} catch {
|
|
76
|
+
}
|
|
77
|
+
return wrapped;
|
|
78
|
+
}
|
|
7
79
|
function hasStandardSchema(schema) {
|
|
8
80
|
return !!schema && typeof schema === "object" && "~standard" in schema && !!schema["~standard"] && typeof schema["~standard"].validate === "function";
|
|
9
81
|
}
|
|
@@ -65,10 +137,28 @@ async function buildInputFromRequest(method, req) {
|
|
|
65
137
|
}
|
|
66
138
|
async function maybeValidateRouteOutput(result, outputSchema) {
|
|
67
139
|
if (!outputSchema) return result;
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
140
|
+
const source = routeResultResponse(result);
|
|
141
|
+
try {
|
|
142
|
+
const isSuccessStatus = result instanceof Response ? result.status < 400 : result?.status === void 0 || result.status < 400;
|
|
143
|
+
if (!isSuccessStatus) return result;
|
|
144
|
+
const response = result instanceof Response ? result : void 0;
|
|
145
|
+
const validatedBody = await validateOutput(
|
|
146
|
+
outputSchema,
|
|
147
|
+
response ? response.body : result?.body
|
|
148
|
+
);
|
|
149
|
+
if (response) {
|
|
150
|
+
if (validatedBody === response.body) return result;
|
|
151
|
+
return markDroppedResponse(
|
|
152
|
+
{ status: response.status, headers: response.headers, body: validatedBody },
|
|
153
|
+
source
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
const normalized = { status: result?.status, headers: result?.headers, body: validatedBody };
|
|
157
|
+
return markDroppedResponse(normalized, source);
|
|
158
|
+
} catch (error) {
|
|
159
|
+
if (source) throw markDiscardedResponseError(error, source);
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
72
162
|
}
|
|
73
163
|
function composeRouteMiddlewares(middlewares, handler, inputSchema, outputSchema, inputValidationIndex, outputValidationIndex) {
|
|
74
164
|
return async (initialContext, initialInput, request) => {
|
|
@@ -210,15 +300,7 @@ var HttpRouteBuilderImpl = class _HttpRouteBuilderImpl {
|
|
|
210
300
|
const inputSchema = this.inputSchema;
|
|
211
301
|
const outputSchema = this.outputSchema;
|
|
212
302
|
const inputErrorMapper = this.inputErrorMapper;
|
|
213
|
-
const
|
|
214
|
-
this.middlewares,
|
|
215
|
-
handler,
|
|
216
|
-
inputSchema,
|
|
217
|
-
outputSchema,
|
|
218
|
-
this.inputValidationIndex,
|
|
219
|
-
this.outputValidationIndex
|
|
220
|
-
);
|
|
221
|
-
const wrappedHandler = async (ctx, req) => {
|
|
303
|
+
const invokeRoute = async (ctx, req) => {
|
|
222
304
|
let normalizedInput;
|
|
223
305
|
try {
|
|
224
306
|
normalizedInput = inputSchema ? await buildInputFromRequest(method, req) : void 0;
|
|
@@ -231,14 +313,37 @@ var HttpRouteBuilderImpl = class _HttpRouteBuilderImpl {
|
|
|
231
313
|
}
|
|
232
314
|
let result;
|
|
233
315
|
try {
|
|
234
|
-
result = await
|
|
316
|
+
result = await composeRouteMiddlewares(
|
|
317
|
+
this.middlewares,
|
|
318
|
+
handler,
|
|
319
|
+
inputSchema,
|
|
320
|
+
outputSchema,
|
|
321
|
+
this.inputValidationIndex,
|
|
322
|
+
this.outputValidationIndex
|
|
323
|
+
)(ctx, normalizedInput, req);
|
|
235
324
|
} catch (err) {
|
|
236
325
|
if (err instanceof HttpRouteInputValidationError) {
|
|
237
326
|
if (inputErrorMapper) return await inputErrorMapper(err.issues);
|
|
238
327
|
return { status: 400, body: { error: err.message } };
|
|
239
328
|
}
|
|
240
329
|
if (err instanceof HttpRouteOutputValidationError) {
|
|
241
|
-
|
|
330
|
+
const discardedResponse = getHttpRouteDiscardedResponse(err);
|
|
331
|
+
const failure = {
|
|
332
|
+
status: 500,
|
|
333
|
+
body: {
|
|
334
|
+
error: discardedResponse ? "Output validation failed" : `Output validation failed: ${err.message}`
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
if (discardedResponse) {
|
|
338
|
+
addDiscardedResponse(failure, discardedResponse);
|
|
339
|
+
Object.defineProperty(failure, outputValidationFailureSymbol, {
|
|
340
|
+
configurable: false,
|
|
341
|
+
enumerable: false,
|
|
342
|
+
value: true,
|
|
343
|
+
writable: false
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
return failure;
|
|
242
347
|
}
|
|
243
348
|
throw err;
|
|
244
349
|
}
|
|
@@ -248,7 +353,7 @@ var HttpRouteBuilderImpl = class _HttpRouteBuilderImpl {
|
|
|
248
353
|
method,
|
|
249
354
|
path: routePath,
|
|
250
355
|
isPublic,
|
|
251
|
-
handler:
|
|
356
|
+
handler: invokeRoute,
|
|
252
357
|
middlewares: [...this.middlewares],
|
|
253
358
|
inputValidationIndex: this.inputValidationIndex,
|
|
254
359
|
outputValidationIndex: this.outputValidationIndex,
|
|
@@ -1668,7 +1773,9 @@ async function validateWithSchema(schema, value, options) {
|
|
|
1668
1773
|
}
|
|
1669
1774
|
throw new GencowValidationError("Validation failed");
|
|
1670
1775
|
}
|
|
1671
|
-
throw new Error(
|
|
1776
|
+
throw new Error(
|
|
1777
|
+
"procedure.query / procedure.mutation / procedure.internal only supports Standard Schema v1 validators"
|
|
1778
|
+
);
|
|
1672
1779
|
}
|
|
1673
1780
|
function composeMiddlewares(middlewares, handler, inputSchema, outputSchema, inputValidationIndex, outputValidationIndex) {
|
|
1674
1781
|
return async (initialContext, initialInput) => {
|
|
@@ -1798,14 +1905,14 @@ var GencowProcedureBuilderImpl = class _GencowProcedureBuilderImpl {
|
|
|
1798
1905
|
if (!this.procedureName) {
|
|
1799
1906
|
throw new Error("Procedure name is required. Call .name(...) before .handler(...)");
|
|
1800
1907
|
}
|
|
1801
|
-
const run = composeMiddlewares(
|
|
1908
|
+
const run = (context, input) => composeMiddlewares(
|
|
1802
1909
|
this.middlewares,
|
|
1803
1910
|
handler,
|
|
1804
1911
|
this.inputSchema,
|
|
1805
1912
|
this.outputSchema,
|
|
1806
1913
|
this.inputValidationIndex,
|
|
1807
1914
|
this.outputValidationIndex
|
|
1808
|
-
);
|
|
1915
|
+
)(context, input);
|
|
1809
1916
|
return {
|
|
1810
1917
|
kind: this.kind,
|
|
1811
1918
|
name: this.procedureName,
|
|
@@ -6148,6 +6255,8 @@ export {
|
|
|
6148
6255
|
eqRlsContextColumn,
|
|
6149
6256
|
filterTenantRuntimeEnvVars,
|
|
6150
6257
|
formatBytes,
|
|
6258
|
+
getHttpRouteDiscardedResponse,
|
|
6259
|
+
getHttpRouteDiscardedResponseCause,
|
|
6151
6260
|
getJobAdmissionStatus,
|
|
6152
6261
|
getMinuteBucketStart,
|
|
6153
6262
|
getMsUntilNextMinute,
|
|
@@ -6167,6 +6276,7 @@ export {
|
|
|
6167
6276
|
hasMapSessionToContext,
|
|
6168
6277
|
inferTableNameFromColumn,
|
|
6169
6278
|
isCronJobsBuilder,
|
|
6279
|
+
isHttpRouteOutputValidationFailure,
|
|
6170
6280
|
isJobAdmissionError,
|
|
6171
6281
|
isJobAdmissionKillSwitchActive,
|
|
6172
6282
|
isReservedTenantRuntimeEnvKey,
|