@lunora/config 1.0.0-alpha.189 → 1.0.0-alpha.190
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as y}from"node:fs";import{discoverSchema as p,schemaFromIr as h}from"@lunora/codegen";import{seedPlan as k}from"@lunora/seed";import{Project as S}from"ts-morph";import{join as g}from"node:path";const P="/__lunora/seed",w=1e3,j=(o,t)=>typeof t=="bigint"?Number(t):t instanceof ArrayBuffer?[...new Uint8Array(t)]:t,N=o=>typeof o!="number"||!Number.isFinite(o)?10:Math.min(Math.max(1,Math.floor(o)),w),A=o=>{if(o.method!=="POST")return{body:{error:"method-not-allowed",ok:!1},status:405};const{body:t}=o;if(t==null||typeof t!="object")return{body:{error:"invalid-request",ok:!1},status:400};const{count:f,existingIds:c,seed:m,table:e}=t;if(typeof e!="string"||e.length===0)return{body:{error:"missing-table",ok:!1},status:400};const l=o.schemaDirectory??"lunora",s=g(o.projectRoot,l,"schema.ts");if(!y(s))return{body:{error:"schema-not-found",ok:!1},status:404};const d=new S({skipAddingFilesFromTsConfig:!0}),n=p(d,s);if(!n.tables.some(r=>r.name===e))return{body:{error:"unknown-table",ok:!1,table:e},status:404};const u=h(n),a=k(u,{existingIds:c??{},defaultCount:N(f),only:[e],seed:m??0}),i=a.filter(r=>r.table!==e).map(r=>r.table);if(i.length>0)return{body:{error:"fk-parents-empty",ok:!1,tables:i},status:409};const b=a.find(r=>r.table===e)?.rows??[];return{body:{ok:!0,rows:JSON.parse(JSON.stringify(b,j))},status:200}};export{P as SEED_ENDPOINT,A as handleSeedRequest};
|
|
@@ -270,6 +270,11 @@ interface SeedResponse {
|
|
|
270
270
|
* Handle a generate-rows request: statically lift the schema, generate `count`
|
|
271
271
|
* rows for `table` (linking foreign keys to the supplied existing ids rather
|
|
272
272
|
* than fabricating parents), and return them JSON-safe for the client to insert.
|
|
273
|
+
*
|
|
274
|
+
* Only the requested table's rows are ever returned, so a foreign key with no
|
|
275
|
+
* `existingIds` to resolve against is answered with `409
|
|
276
|
+
* fk-parents-empty` naming the parent tables — the endpoint refuses
|
|
277
|
+
* rather than hand back children whose parents it just dropped.
|
|
273
278
|
*/
|
|
274
279
|
declare const handleSeedRequest: (request: SeedRequest) => SeedResponse;
|
|
275
280
|
/**
|
|
@@ -270,6 +270,11 @@ interface SeedResponse {
|
|
|
270
270
|
* Handle a generate-rows request: statically lift the schema, generate `count`
|
|
271
271
|
* rows for `table` (linking foreign keys to the supplied existing ids rather
|
|
272
272
|
* than fabricating parents), and return them JSON-safe for the client to insert.
|
|
273
|
+
*
|
|
274
|
+
* Only the requested table's rows are ever returned, so a foreign key with no
|
|
275
|
+
* `existingIds` to resolve against is answered with `409
|
|
276
|
+
* fk-parents-empty` naming the parent tables — the endpoint refuses
|
|
277
|
+
* rather than hand back children whose parents it just dropped.
|
|
273
278
|
*/
|
|
274
279
|
declare const handleSeedRequest: (request: SeedRequest) => SeedResponse;
|
|
275
280
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseDevVariable as t,resolveAdminToken as r}from"../packem_shared/parseDevVariable-teAAahVD.mjs";import{applyStudioAssetCache as s,sendStudioDocument as d}from"../packem_shared/applyStudioAssetCache-DHQEJuuv.mjs";import{assetContentType as l,isStandaloneModulePath as p,loadStudioAssets as m,readStandaloneAsset as S,resolveStandaloneDirectory as i,studioAssetsStamp as f}from"../packem_shared/assetContentType-CUb5bpbI.mjs";import{POLICY_SCAFFOLD_ENDPOINT as D,handlePolicyScaffoldRequest as A}from"../packem_shared/POLICY_SCAFFOLD_ENDPOINT-DL4UFAeK.mjs";import{default as x}from"../packem_shared/renderStudioHtml-ByowDtMl.mjs";import{SCHEMA_EDIT_ENDPOINT as h,handleSchemaEditRequest as N}from"../packem_shared/SCHEMA_EDIT_ENDPOINT-IkAx-ScX.mjs";import{SEED_ENDPOINT as R,handleSeedRequest as _}from"../packem_shared/SEED_ENDPOINT-
|
|
1
|
+
import{parseDevVariable as t,resolveAdminToken as r}from"../packem_shared/parseDevVariable-teAAahVD.mjs";import{applyStudioAssetCache as s,sendStudioDocument as d}from"../packem_shared/applyStudioAssetCache-DHQEJuuv.mjs";import{assetContentType as l,isStandaloneModulePath as p,loadStudioAssets as m,readStandaloneAsset as S,resolveStandaloneDirectory as i,studioAssetsStamp as f}from"../packem_shared/assetContentType-CUb5bpbI.mjs";import{POLICY_SCAFFOLD_ENDPOINT as D,handlePolicyScaffoldRequest as A}from"../packem_shared/POLICY_SCAFFOLD_ENDPOINT-DL4UFAeK.mjs";import{default as x}from"../packem_shared/renderStudioHtml-ByowDtMl.mjs";import{SCHEMA_EDIT_ENDPOINT as h,handleSchemaEditRequest as N}from"../packem_shared/SCHEMA_EDIT_ENDPOINT-IkAx-ScX.mjs";import{SEED_ENDPOINT as R,handleSeedRequest as _}from"../packem_shared/SEED_ENDPOINT-2B56PN_H.mjs";import{serveJsonHandler as T}from"../packem_shared/serveJsonHandler-Dv0EdCb9.mjs";import{ALLOW_FORWARDED_ENV as I,headerValue as L,isLoopbackAddress as v,transportRejectionReason as y}from"../packem_shared/ALLOW_FORWARDED_ENV-BUndghJx.mjs";export{I as ALLOW_FORWARDED_ENV,D as POLICY_SCAFFOLD_ENDPOINT,h as SCHEMA_EDIT_ENDPOINT,R as SEED_ENDPOINT,s as applyStudioAssetCache,l as assetContentType,A as handlePolicyScaffoldRequest,N as handleSchemaEditRequest,_ as handleSeedRequest,L as headerValue,v as isLoopbackAddress,p as isStandaloneModulePath,m as loadStudioAssets,t as parseDevVariable,S as readStandaloneAsset,x as renderStudioHtml,r as resolveAdminToken,i as resolveStandaloneDirectory,d as sendStudioDocument,T as serveJsonHandler,f as studioAssetsStamp,y as transportRejectionReason};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/config",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.190",
|
|
4
4
|
"description": "Internal shared CLI + Vite config layer for Lunora: wrangler.jsonc validation, binding inference, and .dev.vars scaffolding",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bindings",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/codegen": "1.0.0-alpha.
|
|
58
|
-
"@lunora/container": "1.0.0-alpha.
|
|
57
|
+
"@lunora/codegen": "1.0.0-alpha.157",
|
|
58
|
+
"@lunora/container": "1.0.0-alpha.44",
|
|
59
59
|
"@lunora/errors": "1.0.0-alpha.31",
|
|
60
|
-
"@lunora/seed": "1.0.0-alpha.
|
|
60
|
+
"@lunora/seed": "1.0.0-alpha.107",
|
|
61
61
|
"@visulima/colorize": "2.1.1",
|
|
62
62
|
"@visulima/find-ai-runner": "1.0.1",
|
|
63
63
|
"@visulima/package": "5.0.12",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{existsSync as l}from"node:fs";import{discoverSchema as y,schemaFromIr as p}from"@lunora/codegen";import{seedPlan as b}from"@lunora/seed";import{Project as h}from"ts-morph";import{join as S}from"node:path";const O="/__lunora/seed",g=1e3,k=(t,o)=>typeof o=="bigint"?Number(o):o instanceof ArrayBuffer?[...new Uint8Array(o)]:o,w=t=>typeof t!="number"||!Number.isFinite(t)?10:Math.min(Math.max(1,Math.floor(t)),g),P=t=>{if(t.method!=="POST")return{body:{error:"method-not-allowed",ok:!1},status:405};const{body:o}=t;if(o==null||typeof o!="object")return{body:{error:"invalid-request",ok:!1},status:400};const{count:i,existingIds:a,seed:f,table:r}=o;if(typeof r!="string"||r.length===0)return{body:{error:"missing-table",ok:!1},status:400};const c=t.schemaDirectory??"lunora",s=S(t.projectRoot,c,"schema.ts");if(!l(s))return{body:{error:"schema-not-found",ok:!1},status:404};const m=new h({skipAddingFilesFromTsConfig:!0}),n=y(m,s);if(!n.tables.some(e=>e.name===r))return{body:{error:"unknown-table",ok:!1,table:r},status:404};const d=p(n),u=b(d,{existingIds:a??{},defaultCount:w(i),only:[r],seed:f??0}).find(e=>e.table===r)?.rows??[];return{body:{ok:!0,rows:JSON.parse(JSON.stringify(u,k))},status:200}};export{O as SEED_ENDPOINT,P as handleSeedRequest};
|