@lunora/codegen 1.0.0-alpha.3 → 1.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +5 -5
- package/dist/packem_shared/{GENERATED_HEADER-CuLyj0WQ.mjs → GENERATED_HEADER-DF1hQcix.mjs} +10 -1
- package/dist/packem_shared/{OPENRPC_VERSION-BGUrsrt_.mjs → OPENRPC_VERSION-C7zKVeKi.mjs} +1 -1
- package/dist/packem_shared/{SCHEMA_SNAPSHOT_FILENAME-BQ_kCZ81.mjs → SCHEMA_SNAPSHOT_FILENAME-C5UlpWKF.mjs} +36 -17
- package/dist/packem_shared/{buildOpenApiDocument-CXwnbp4b.mjs → buildOpenApiDocument-Cns1EkCQ.mjs} +1 -1
- package/dist/packem_shared/{emitApp-CzSxVDaG.mjs → emitApp-Ci_hcJNO.mjs} +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -15,11 +15,11 @@ export { discoverRlsMetadata, default as discoverRlsProcedures } from './packem_
|
|
|
15
15
|
export { default as discoverSchema } from './packem_shared/discoverSchema-BBulgGbH.mjs';
|
|
16
16
|
export { default as discoverStorageRulesMetadata } from './packem_shared/discoverStorageRulesMetadata-DAqJUxUv.mjs';
|
|
17
17
|
export { WORKFLOWS_FILENAME, discoverWorkflows } from './packem_shared/WORKFLOWS_FILENAME-DRDQdhfq.mjs';
|
|
18
|
-
export { GENERATED_HEADER, emitApi, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers } from './packem_shared/GENERATED_HEADER-
|
|
19
|
-
export { emitApp } from './packem_shared/emitApp-
|
|
20
|
-
export { buildOpenApiDocument, emitOpenApi, emitOpenApiModule } from './packem_shared/buildOpenApiDocument-
|
|
21
|
-
export { OPENRPC_VERSION, buildOpenRpcDocument, emitOpenRpc, emitOpenRpcModule } from './packem_shared/OPENRPC_VERSION-
|
|
22
|
-
export { SCHEMA_SNAPSHOT_FILENAME, createCodegenProject, refreshCodegenProject, runCodegen } from './packem_shared/SCHEMA_SNAPSHOT_FILENAME-
|
|
18
|
+
export { GENERATED_HEADER, emitApi, emitContainers, emitCrons, emitDataModel, emitDrizzleSchema, emitFunctions, emitServer, emitShard, emitVectors, emitWorkflows, emitWranglerCronTriggers } from './packem_shared/GENERATED_HEADER-DF1hQcix.mjs';
|
|
19
|
+
export { emitApp } from './packem_shared/emitApp-Ci_hcJNO.mjs';
|
|
20
|
+
export { buildOpenApiDocument, emitOpenApi, emitOpenApiModule } from './packem_shared/buildOpenApiDocument-Cns1EkCQ.mjs';
|
|
21
|
+
export { OPENRPC_VERSION, buildOpenRpcDocument, emitOpenRpc, emitOpenRpcModule } from './packem_shared/OPENRPC_VERSION-C7zKVeKi.mjs';
|
|
22
|
+
export { SCHEMA_SNAPSHOT_FILENAME, createCodegenProject, refreshCodegenProject, runCodegen } from './packem_shared/SCHEMA_SNAPSHOT_FILENAME-C5UlpWKF.mjs';
|
|
23
23
|
export { SCHEMA_SNAPSHOT_VERSION, SchemaSnapshotParseError, buildSchemaSnapshot, diffSchemaSnapshots, evaluateSchemaDrift, parseSchemaSnapshot, serializeSchemaSnapshot } from './packem_shared/SCHEMA_SNAPSHOT_VERSION-DzLDbWk3.mjs';
|
|
24
24
|
export { schemaFromIr } from './packem_shared/schemaFromIr-DTYsLBaA.mjs';
|
|
25
25
|
export { LUNORA_ERROR_CODES, validatorIrToJsonSchema } from './packem_shared/LUNORA_ERROR_CODES-CySpQPD3.mjs';
|
|
@@ -2209,6 +2209,14 @@ ${facadeBlock}${paymentsBuild}
|
|
|
2209
2209
|
warn: (...args: unknown[]) => { this.recordUserLog(logFunctionPath, "warn", args, observability); },
|
|
2210
2210
|
};
|
|
2211
2211
|
|
|
2212
|
+
// \`ctx.now\`: the wall-clock instant (epoch ms) this function began,
|
|
2213
|
+
// captured ONCE so the whole handler body sees a single stable value.
|
|
2214
|
+
// Query/mutation handlers must be deterministic (they may be re-run on
|
|
2215
|
+
// OCC retry / subscription re-eval), so they must read time through
|
|
2216
|
+
// \`ctx.now\` instead of \`Date.now()\` — the \`nondeterministic_query_mutation\`
|
|
2217
|
+
// advisor flags the latter. Actions may still use ambient \`Date.now()\`.
|
|
2218
|
+
const now = Date.now();
|
|
2219
|
+
|
|
2212
2220
|
const ctx: Record<string, unknown> = {
|
|
2213
2221
|
auth: {
|
|
2214
2222
|
getIdentity: async () => identity ?? null,
|
|
@@ -2217,7 +2225,8 @@ ${facadeBlock}${paymentsBuild}
|
|
|
2217
2225
|
db,
|
|
2218
2226
|
fetch: globalThis.fetch.bind(globalThis),
|
|
2219
2227
|
ip: this.getCurrentIp(),
|
|
2220
|
-
log
|
|
2228
|
+
log,
|
|
2229
|
+
now,${ormContextField}
|
|
2221
2230
|
scheduler,
|
|
2222
2231
|
storage,${vectorsContextField}${aiContextField}${everyContextField}${paymentsContextField}${containersContextField}${workflowsContextField}
|
|
2223
2232
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GENERATED_HEADER } from './GENERATED_HEADER-
|
|
1
|
+
import { GENERATED_HEADER } from './GENERATED_HEADER-DF1hQcix.mjs';
|
|
2
2
|
import { s as sanitizeNamespace } from './paths-BRd6JHuF.mjs';
|
|
3
3
|
import { argsObjectSchema, LUNORA_ERROR_CODES } from './LUNORA_ERROR_CODES-CySpQPD3.mjs';
|
|
4
4
|
|
|
@@ -18,10 +18,10 @@ import discoverSchema from './discoverSchema-BBulgGbH.mjs';
|
|
|
18
18
|
import discoverStorageRulesMetadata from './discoverStorageRulesMetadata-DAqJUxUv.mjs';
|
|
19
19
|
import { e as enclosingExportName$1 } from './discover-ast-CT6BgBr4.mjs';
|
|
20
20
|
import { discoverWorkflows } from './WORKFLOWS_FILENAME-DRDQdhfq.mjs';
|
|
21
|
-
import { buildStorageColumns, emitDataModel, emitApi, emitServer, emitFunctions, emitShard, emitContainers, emitWorkflows, emitCrons, emitVectors, emitDrizzleSchema, emitSeed, emitWranglerCronTriggers } from './GENERATED_HEADER-
|
|
22
|
-
import { emitApp } from './emitApp-
|
|
23
|
-
import { buildOpenApiDocument, emitOpenApiModule } from './buildOpenApiDocument-
|
|
24
|
-
import { buildOpenRpcDocument, emitOpenRpcModule } from './OPENRPC_VERSION-
|
|
21
|
+
import { buildStorageColumns, emitDataModel, emitApi, emitServer, emitFunctions, emitShard, emitContainers, emitWorkflows, emitCrons, emitVectors, emitDrizzleSchema, emitSeed, emitWranglerCronTriggers } from './GENERATED_HEADER-DF1hQcix.mjs';
|
|
22
|
+
import { emitApp } from './emitApp-Ci_hcJNO.mjs';
|
|
23
|
+
import { buildOpenApiDocument, emitOpenApiModule } from './buildOpenApiDocument-Cns1EkCQ.mjs';
|
|
24
|
+
import { buildOpenRpcDocument, emitOpenRpcModule } from './OPENRPC_VERSION-C7zKVeKi.mjs';
|
|
25
25
|
import { buildSchemaSnapshot, serializeSchemaSnapshot } from './SCHEMA_SNAPSHOT_VERSION-DzLDbWk3.mjs';
|
|
26
26
|
|
|
27
27
|
const HTTP_VERBS = /* @__PURE__ */ new Set(["delete", "get", "head", "options", "patch", "post", "put"]);
|
|
@@ -367,26 +367,45 @@ const protectPublicFlags = (call) => {
|
|
|
367
367
|
}
|
|
368
368
|
return { usesCaptcha: Boolean(argument.getProperty("captcha")), usesRateLimit: Boolean(argument.getProperty("rateLimit")) };
|
|
369
369
|
};
|
|
370
|
+
const resolveUseArgumentCall = (argument) => {
|
|
371
|
+
if (Node.isCallExpression(argument)) {
|
|
372
|
+
return argument;
|
|
373
|
+
}
|
|
374
|
+
if (!Node.isIdentifier(argument)) {
|
|
375
|
+
return void 0;
|
|
376
|
+
}
|
|
377
|
+
const declaration = argument.getSourceFile().getVariableDeclaration(argument.getText());
|
|
378
|
+
const initializer = declaration?.getInitializer();
|
|
379
|
+
return initializer && Node.isCallExpression(initializer) ? initializer : void 0;
|
|
380
|
+
};
|
|
381
|
+
const NO_PROTECTIONS = { usesCaptcha: false, usesMask: false, usesRateLimit: false, usesRls: false };
|
|
382
|
+
const useStepProtections = (useArgument) => {
|
|
383
|
+
const argument = resolveUseArgumentCall(useArgument);
|
|
384
|
+
const name = argument ? calleeNameOf(argument) : void 0;
|
|
385
|
+
if (argument && name === "protectPublic") {
|
|
386
|
+
const bundle = protectPublicFlags(argument);
|
|
387
|
+
return { ...NO_PROTECTIONS, usesCaptcha: bundle.usesCaptcha, usesRateLimit: bundle.usesRateLimit };
|
|
388
|
+
}
|
|
389
|
+
if (name !== void 0 && name in MIDDLEWARE_FLAGS) {
|
|
390
|
+
return { ...NO_PROTECTIONS, [MIDDLEWARE_FLAGS[name]]: true };
|
|
391
|
+
}
|
|
392
|
+
return NO_PROTECTIONS;
|
|
393
|
+
};
|
|
370
394
|
const protectionsInChain = (receiver) => {
|
|
371
|
-
const protections = {
|
|
395
|
+
const protections = { ...NO_PROTECTIONS };
|
|
372
396
|
let node = receiver;
|
|
373
397
|
while (Node.isCallExpression(node)) {
|
|
374
398
|
const chainCallee = node.getExpression();
|
|
375
399
|
if (!Node.isPropertyAccessExpression(chainCallee)) {
|
|
376
400
|
break;
|
|
377
401
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
protections.usesCaptcha ||= bundle.usesCaptcha;
|
|
386
|
-
} else if (name !== void 0 && name in MIDDLEWARE_FLAGS) {
|
|
387
|
-
protections[MIDDLEWARE_FLAGS[name]] = true;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
402
|
+
const useArgument = chainCallee.getName() === "use" ? node.getArguments()[0] : void 0;
|
|
403
|
+
if (useArgument) {
|
|
404
|
+
const step = useStepProtections(useArgument);
|
|
405
|
+
protections.usesCaptcha ||= step.usesCaptcha;
|
|
406
|
+
protections.usesMask ||= step.usesMask;
|
|
407
|
+
protections.usesRateLimit ||= step.usesRateLimit;
|
|
408
|
+
protections.usesRls ||= step.usesRls;
|
|
390
409
|
}
|
|
391
410
|
node = chainCallee.getExpression();
|
|
392
411
|
}
|
package/dist/packem_shared/{buildOpenApiDocument-CXwnbp4b.mjs → buildOpenApiDocument-Cns1EkCQ.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GENERATED_HEADER } from './GENERATED_HEADER-
|
|
1
|
+
import { GENERATED_HEADER } from './GENERATED_HEADER-DF1hQcix.mjs';
|
|
2
2
|
import { s as sanitizeNamespace } from './paths-BRd6JHuF.mjs';
|
|
3
3
|
import { LUNORA_ERROR_CODES, objectSchema, argsObjectSchema, validatorIrToJsonSchema } from './LUNORA_ERROR_CODES-CySpQPD3.mjs';
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/codegen",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.4",
|
|
4
4
|
"description": "Code generator for Lunora: emits _generated/{api,server,dataModel}.ts from your schema",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@lunora/advisor": "1.0.0-alpha.
|
|
49
|
+
"@lunora/advisor": "1.0.0-alpha.3",
|
|
50
50
|
"@lunora/container": "1.0.0-alpha.1",
|
|
51
51
|
"@lunora/scheduler": "1.0.0-alpha.1",
|
|
52
52
|
"@lunora/values": "1.0.0-alpha.1",
|