@lunora/codegen 1.0.0-alpha.7 → 1.0.0-alpha.71

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.
Files changed (72) hide show
  1. package/LICENSE.md +6 -0
  2. package/__assets__/package-og.svg +1 -1
  3. package/dist/index.d.mts +2098 -736
  4. package/dist/index.d.ts +2098 -736
  5. package/dist/index.mjs +1 -29
  6. package/dist/packem_shared/AGENTS_FILENAME-BesaDYkL.mjs +1 -0
  7. package/dist/packem_shared/CONTAINERS_FILENAME-CFwdyaCI.mjs +1 -0
  8. package/dist/packem_shared/CodegenDiagnosticError-DPezpZTz.mjs +1 -0
  9. package/dist/packem_shared/FLAGS_FILENAME-C1GWerCB.mjs +1 -0
  10. package/dist/packem_shared/GENERATED_HEADER-DV-sQj-R.mjs +1 -0
  11. package/dist/packem_shared/LUNORA_ERROR_CODES-Um9hC1gr.mjs +1 -0
  12. package/dist/packem_shared/MUTATORS_FILENAME-BWPAtQ2T.mjs +1 -0
  13. package/dist/packem_shared/NOTIFY_FILENAME-DP6qvFBX.mjs +1 -0
  14. package/dist/packem_shared/OPENRPC_VERSION-CvVFqUlq.mjs +3 -0
  15. package/dist/packem_shared/QUEUES_FILENAME-CSE6i-ld.mjs +1 -0
  16. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-CDCj-7wp.mjs +3 -0
  17. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-Bpf1FGMG.mjs +15 -0
  18. package/dist/packem_shared/SHAPES_FILENAME-maut3z1K.mjs +1 -0
  19. package/dist/packem_shared/WORKFLOWS_FILENAME-Bk5upkGM.mjs +1 -0
  20. package/dist/packem_shared/buildOpenApiDocument-CXFC-wzM.mjs +3 -0
  21. package/dist/packem_shared/discover-ast-CezKqEhE.mjs +1 -0
  22. package/dist/packem_shared/discoverAuthApiCalls-Ba6W92HB.mjs +1 -0
  23. package/dist/packem_shared/discoverCrons-2nUpw6do.mjs +1 -0
  24. package/dist/packem_shared/discoverFunctions-zrIQk7J8.mjs +1 -0
  25. package/dist/packem_shared/discoverHttpRoutes-Bf_T_03b.mjs +1 -0
  26. package/dist/packem_shared/discoverInserts-DveVeP5h.mjs +1 -0
  27. package/dist/packem_shared/discoverMaskProcedures-BkBquCFR.mjs +1 -0
  28. package/dist/packem_shared/discoverMigrations-T2xb-1rn.mjs +1 -0
  29. package/dist/packem_shared/discoverNondeterministicCalls-BymnOR9k.mjs +1 -0
  30. package/dist/packem_shared/discoverQueries-DNRA-G2a.mjs +1 -0
  31. package/dist/packem_shared/discoverR2sqlCalls-YEjvGcEq.mjs +1 -0
  32. package/dist/packem_shared/discoverRlsMetadata-DO3qlLXX.mjs +1 -0
  33. package/dist/packem_shared/discoverSandboxUsage-JwrmSN9l.mjs +1 -0
  34. package/dist/packem_shared/discoverSchema-Cy4OQ0Cu.mjs +1 -0
  35. package/dist/packem_shared/discoverStorageRulesMetadata-CCztRKjw.mjs +1 -0
  36. package/dist/packem_shared/emit-D7VIjvlm.mjs +2152 -0
  37. package/dist/packem_shared/emitApp-CAeIj6e_.mjs +444 -0
  38. package/dist/packem_shared/formatAdvisories-DZvv-0MG.mjs +2 -0
  39. package/dist/packem_shared/module-specifiers-8FEEiUcv.mjs +1 -0
  40. package/dist/packem_shared/parse-validator-CSDlMEvE.mjs +1 -0
  41. package/dist/packem_shared/paths-BmX5O1sG.mjs +1 -0
  42. package/dist/packem_shared/redact-CQ8-to6l.mjs +1 -0
  43. package/dist/packem_shared/schemaFromIr-R1ZFzVyy.mjs +1 -0
  44. package/package.json +10 -7
  45. package/dist/packem_shared/CONTAINERS_FILENAME-0K-pjNb8.mjs +0 -224
  46. package/dist/packem_shared/CodegenDiagnosticError-54jWDxA9.mjs +0 -22
  47. package/dist/packem_shared/GENERATED_HEADER-DF1hQcix.mjs +0 -2495
  48. package/dist/packem_shared/LUNORA_ERROR_CODES-CySpQPD3.mjs +0 -61
  49. package/dist/packem_shared/OPENRPC_VERSION-C7zKVeKi.mjs +0 -60
  50. package/dist/packem_shared/SCHEMA_SNAPSHOT_FILENAME-g7kpX8hu.mjs +0 -922
  51. package/dist/packem_shared/SCHEMA_SNAPSHOT_VERSION-DzLDbWk3.mjs +0 -233
  52. package/dist/packem_shared/WORKFLOWS_FILENAME-DRDQdhfq.mjs +0 -84
  53. package/dist/packem_shared/buildOpenApiDocument-Cns1EkCQ.mjs +0 -183
  54. package/dist/packem_shared/discover-ast-CT6BgBr4.mjs +0 -13
  55. package/dist/packem_shared/discoverAuthApiCalls-C35R6z0T.mjs +0 -62
  56. package/dist/packem_shared/discoverCrons-BL6iGuJ3.mjs +0 -254
  57. package/dist/packem_shared/discoverFunctions-DEgAcRuD.mjs +0 -460
  58. package/dist/packem_shared/discoverHttpRoutes-C978pBiG.mjs +0 -131
  59. package/dist/packem_shared/discoverInserts-pLBFsSAV.mjs +0 -61
  60. package/dist/packem_shared/discoverMaskProcedures-B64zA740.mjs +0 -217
  61. package/dist/packem_shared/discoverMigrations-Doj_-BAA.mjs +0 -91
  62. package/dist/packem_shared/discoverNondeterministicCalls-4KiPQxQU.mjs +0 -122
  63. package/dist/packem_shared/discoverQueries-BkIi0dBD.mjs +0 -62
  64. package/dist/packem_shared/discoverR2sqlCalls-BpDqvcUn.mjs +0 -80
  65. package/dist/packem_shared/discoverRlsMetadata-DpRB1HMe.mjs +0 -280
  66. package/dist/packem_shared/discoverSchema-DYl0QfDH.mjs +0 -775
  67. package/dist/packem_shared/discoverStorageRulesMetadata-DAqJUxUv.mjs +0 -97
  68. package/dist/packem_shared/emitApp-Ci_hcJNO.mjs +0 -599
  69. package/dist/packem_shared/formatAdvisories-8NIv1k0I.mjs +0 -69
  70. package/dist/packem_shared/parse-validator-tuQtHrsr.mjs +0 -132
  71. package/dist/packem_shared/paths-BRd6JHuF.mjs +0 -11
  72. package/dist/packem_shared/schemaFromIr-DTYsLBaA.mjs +0 -57
@@ -1,61 +0,0 @@
1
- import { jsonSchemaFromNode, objectSchemaFromNodes } from '@lunora/values';
2
-
3
- const literalConst = (literalValue) => {
4
- if (literalValue === void 0) {
5
- return {};
6
- }
7
- const trimmed = literalValue.trim();
8
- if (trimmed === "true") {
9
- return { const: true };
10
- }
11
- if (trimmed === "false") {
12
- return { const: false };
13
- }
14
- if (trimmed === "null") {
15
- return { const: null, type: "null" };
16
- }
17
- if (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'")) {
18
- return { const: trimmed.slice(1, -1), type: "string" };
19
- }
20
- const asNumber = Number(trimmed);
21
- if (!Number.isNaN(asNumber)) {
22
- return { const: asNumber };
23
- }
24
- return { const: trimmed };
25
- };
26
- const irReader = {
27
- constraints: () => void 0,
28
- inner: (validator) => validator.inner,
29
- isNullable: (validator) => validator.column?.notNull === false,
30
- // `ValidatorIR.kind` is a loose `string` (build-time AST); narrow it to the
31
- // shared reader's `ValidatorKind`. Unknown kinds fall through the mapper's
32
- // `default` branch to an empty schema, exactly as before.
33
- kind: (validator) => validator.kind,
34
- literalSchema: (validator) => literalConst(validator.literalValue),
35
- members: (validator) => validator.members ?? [],
36
- shape: (validator) => validator.shape ?? {},
37
- tableName: (validator) => validator.tableName,
38
- valueChild: (validator) => validator.valueType
39
- };
40
- const validatorIrToJsonSchema = (validator) => jsonSchemaFromNode(validator, irReader);
41
- const objectSchema = (shape) => objectSchemaFromNodes(shape, irReader);
42
- const argsObjectSchema = (args) => objectSchema(args);
43
- const LUNORA_ERROR_CODES = [
44
- "BAD_REQUEST",
45
- "CONFLICT",
46
- "COUNT_RLS_UNSUPPORTED",
47
- "FORBIDDEN",
48
- "FUNCTION_NOT_FOUND",
49
- "INTERNAL",
50
- "INTERNAL_SERVER_ERROR",
51
- "METHOD_NOT_ALLOWED",
52
- "NOT_FOUND",
53
- "NOT_IMPLEMENTED",
54
- "PAYLOAD_TOO_LARGE",
55
- "TOO_MANY_REQUESTS",
56
- "UNAUTHORIZED",
57
- "UNPROCESSABLE",
58
- "VALIDATION_ERROR"
59
- ];
60
-
61
- export { LUNORA_ERROR_CODES, argsObjectSchema, literalConst, objectSchema, validatorIrToJsonSchema };
@@ -1,60 +0,0 @@
1
- import { GENERATED_HEADER } from './GENERATED_HEADER-DF1hQcix.mjs';
2
- import { s as sanitizeNamespace } from './paths-BRd6JHuF.mjs';
3
- import { argsObjectSchema, LUNORA_ERROR_CODES } from './LUNORA_ERROR_CODES-CySpQPD3.mjs';
4
-
5
- const OPENRPC_VERSION = "1.3.2";
6
- const inferredResultSchema = () => {
7
- return { description: "Result is TS-inferred from the function's return type (no `.output()` declared); best-effort — any JSON." };
8
- };
9
- const rpcMethod = (definition) => {
10
- const namespace = sanitizeNamespace(definition.filePath);
11
- const functionPath = `${namespace}:${definition.exportName}`;
12
- return {
13
- description: `Invoke the \`${definition.kind}\` \`${functionPath}\` over the Lunora RPC envelope (POST /_lunora/rpc, body \`{ "functionPath": "${functionPath}", "args": { … } }\`).`,
14
- errors: LUNORA_ERROR_CODES.map((code, index) => {
15
- return { code: -32e3 - index, data: { code }, message: code };
16
- }),
17
- name: functionPath,
18
- params: [
19
- {
20
- description: "The function's argument object (the RPC envelope's `args`).",
21
- name: "args",
22
- // A function with no declared args still takes an (empty) args
23
- // object; `required` reflects whether the function declares any
24
- // arguments at all.
25
- required: Object.keys(definition.args).length > 0,
26
- schema: argsObjectSchema(definition.args)
27
- }
28
- ],
29
- result: {
30
- name: "result",
31
- schema: inferredResultSchema()
32
- },
33
- summary: `${definition.kind}: ${functionPath}`,
34
- "x-lunora-function-kind": definition.kind,
35
- // OpenRPC has no first-class tag grouping; surface the file namespace as
36
- // an `x-tags` extension so tooling can group methods by source file.
37
- "x-tags": [{ name: namespace }]
38
- };
39
- };
40
- const buildOpenRpcDocument = (input) => {
41
- const version = input.version ?? "0.0.0";
42
- const rpcFunctions = input.functions.filter((definition) => definition.visibility !== "internal" && definition.kind !== "stream");
43
- const methods = rpcFunctions.map((definition) => rpcMethod(definition)).toSorted((a, b) => a.name.localeCompare(b.name));
44
- const document = {
45
- info: {
46
- description: "Auto-generated from @lunora/values-typed functions by @lunora/codegen. Do not edit — run `lunora codegen` to regenerate.",
47
- title: "Lunora RPC",
48
- version
49
- },
50
- methods,
51
- openrpc: OPENRPC_VERSION
52
- };
53
- return document;
54
- };
55
- const emitOpenRpc = (input) => `${JSON.stringify(buildOpenRpcDocument(input), void 0, 2)}
56
- `;
57
- const emitOpenRpcModule = (document_) => `${GENERATED_HEADER}export const openRpcSpec: Record<string, unknown> = ${JSON.stringify(document_, void 0, 4)};
58
- `;
59
-
60
- export { OPENRPC_VERSION, buildOpenRpcDocument, emitOpenRpc, emitOpenRpcModule };