Spaces:
Running
Running
feat: explain seven TeaQL runtimes
Browse filesExplain that the browser executes TypeScript, list all seven supported TeaQL runtimes with language icons and source links, retain an exact tested source snapshot, and publish the rebuilt static app.
This view is limited to 50 files because it contains too many changes. See raw diff
- README.md +8 -2
- assets/{dynamic-search-BBmdgl4H.js → dynamic-search-Ch_QcWVU.js} +0 -0
- assets/{main-gHLGx1pH.js → main-Cg0XY2hs.js} +6 -4
- dist/assets/object-location-xgYMemK6.js → assets/object-location-CJfVWqJC.js +1 -1
- dist/assets/orders-CQOGX0kN.js → assets/orders-BIvSfQqM.js +0 -0
- assets/style-DVG2mb5q.css +1 -0
- assets/style-SCdXWqgK.css +0 -1
- assets/{workItems-DraVJWt7.js → workItems-B6je_A1X.js} +1 -1
- dist/assets/{dynamic-search-BBmdgl4H.js → dynamic-search-Ch_QcWVU.js} +0 -0
- dist/assets/{main-gHLGx1pH.js → main-Cg0XY2hs.js} +6 -4
- assets/object-location-xgYMemK6.js → dist/assets/object-location-CJfVWqJC.js +1 -1
- assets/orders-CQOGX0kN.js → dist/assets/orders-BIvSfQqM.js +0 -0
- dist/assets/style-DVG2mb5q.css +1 -0
- dist/assets/style-SCdXWqgK.css +0 -1
- dist/assets/{workItems-DraVJWt7.js → workItems-B6je_A1X.js} +1 -1
- dist/index.html +48 -3
- dist/orders.html +4 -4
- dist/work-items.html +3 -3
- index.html +48 -3
- orders.html +4 -4
- source/provenance.json +3 -3
- source/teaql-ts/.gitattributes +1 -0
- source/teaql-ts/.github/workflows/example-gate.yml +48 -0
- source/teaql-ts/.github/workflows/release.yml +32 -0
- source/teaql-ts/.gitignore +2 -0
- source/teaql-ts/README.md +1 -0
- source/teaql-ts/RUNTIME_GUIDE.md +363 -0
- source/teaql-ts/docs/releases/0.3.1.md +19 -0
- source/teaql-ts/examples/browser-sqlite/README.md +8 -2
- source/teaql-ts/examples/browser-sqlite/index.html +45 -0
- source/teaql-ts/examples/browser-sqlite/package-lock.json +52 -1
- source/teaql-ts/examples/browser-sqlite/scripts/smoke.mjs +24 -2
- source/teaql-ts/examples/browser-sqlite/src/generated/Q.ts +23 -43
- source/teaql-ts/examples/browser-sqlite/src/main.ts +16 -10
- source/teaql-ts/examples/browser-sqlite/src/style.css +49 -0
- source/teaql-ts/examples/conformance/.gitignore +2 -0
- source/teaql-ts/examples/conformance/README.md +11 -0
- source/teaql-ts/examples/conformance/evidence/2026-08-26.md +28 -0
- source/teaql-ts/examples/conformance/model.xml +16 -0
- source/teaql-ts/examples/conformance/package-lock.json +828 -0
- source/teaql-ts/examples/conformance/package.json +18 -0
- source/teaql-ts/examples/conformance/src/generated-bootstrap.ts +14 -0
- source/teaql-ts/examples/conformance/src/generated-search-models.ts +39 -0
- source/teaql-ts/examples/conformance/src/generated/E.ts +315 -0
- source/teaql-ts/examples/conformance/src/generated/Q.ts +20 -0
- source/teaql-ts/examples/conformance/src/generated/models/Platform.ts +262 -0
- source/teaql-ts/examples/conformance/src/generated/models/WorkItem.ts +228 -0
- source/teaql-ts/examples/conformance/src/generated/requests/PlatformRequest.ts +607 -0
- source/teaql-ts/examples/conformance/src/generated/requests/WorkItemRequest.ts +724 -0
- source/teaql-ts/examples/conformance/src/main.ts +88 -0
README.md
CHANGED
|
@@ -21,6 +21,12 @@ This Space demonstrates an auditable chain from a recognizable order-management
|
|
| 21 |
interface to generated TeaQL Q expressions, runtime TraceChain and the actual SQL
|
| 22 |
executed by SQLite/WASM in the browser.
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
The default page is the full order center. Its status cards, colors, order counts,
|
| 25 |
order totals, rows, item previews and pagination are produced by one generated Q
|
| 26 |
request whose search parameters change without changing the query shape. Results
|
|
@@ -40,7 +46,7 @@ cross-origin isolation.
|
|
| 40 |
|
| 41 |
The exact runtime, tests, model, generated Order library and browser application
|
| 42 |
source are retained under [`source/teaql-ts`](./source/teaql-ts). They correspond to
|
| 43 |
-
TeaQL TypeScript commit `
|
| 44 |
|
| 45 |
```bash
|
| 46 |
cd source/teaql-ts
|
|
@@ -55,7 +61,7 @@ npm run smoke
|
|
| 55 |
npm run smoke:orders
|
| 56 |
```
|
| 57 |
|
| 58 |
-
The validated runtime result was
|
| 59 |
tests skipped by the repository configuration. Both real-browser smoke suites pass.
|
| 60 |
|
| 61 |
Learn more at [teaql.io](https://teaql.io/) and inspect the upstream source at
|
|
|
|
| 21 |
interface to generated TeaQL Q expressions, runtime TraceChain and the actual SQL
|
| 22 |
executed by SQLite/WASM in the browser.
|
| 23 |
|
| 24 |
+
The executable on this page uses the TeaQL TypeScript runtime. TeaQL implements
|
| 25 |
+
the same model-driven Q and TraceChain contract across seven runtimes:
|
| 26 |
+
TypeScript, Java, Rust, Go, Python, .NET and Swift. The language strip on the
|
| 27 |
+
page links to each runtime source and marks TypeScript as the runtime currently
|
| 28 |
+
executing in the browser.
|
| 29 |
+
|
| 30 |
The default page is the full order center. Its status cards, colors, order counts,
|
| 31 |
order totals, rows, item previews and pagination are produced by one generated Q
|
| 32 |
request whose search parameters change without changing the query shape. Results
|
|
|
|
| 46 |
|
| 47 |
The exact runtime, tests, model, generated Order library and browser application
|
| 48 |
source are retained under [`source/teaql-ts`](./source/teaql-ts). They correspond to
|
| 49 |
+
TeaQL TypeScript commit `9341b0a1fe5f2c090a39a46f9c03c50e55e27341` on `main`.
|
| 50 |
|
| 51 |
```bash
|
| 52 |
cd source/teaql-ts
|
|
|
|
| 61 |
npm run smoke:orders
|
| 62 |
```
|
| 63 |
|
| 64 |
+
The validated runtime result was 57 passing suites and 608 passing tests, with six
|
| 65 |
tests skipped by the repository configuration. Both real-browser smoke suites pass.
|
| 66 |
|
| 67 |
Learn more at [teaql.io](https://teaql.io/) and inspect the upstream source at
|
assets/{dynamic-search-BBmdgl4H.js → dynamic-search-Ch_QcWVU.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
assets/{main-gHLGx1pH.js → main-Cg0XY2hs.js}
RENAMED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
-
import{S as T,m as Te,a as ie,e as de,O as R,B as Qe,b as $e,R as Re,U as Be,D as Fe,c as ke,M as We}from"./dynamic-search-BBmdgl4H.js";/* empty css */const C=t=>({columnName:t,modelName:t,logicalType:"integer",decode:"string"}),y=t=>({columnName:t,modelName:t,logicalType:"text",decode:"native"}),ze=t=>({columnName:t,modelName:t,logicalType:"date",decode:"date"}),K=t=>({columnName:t,modelName:t,logicalType:"datetime",decode:"date"}),I=(t,e="decimal")=>({columnName:t,modelName:t,logicalType:e,decode:"number"}),f=Object.freeze({PENDING_PAYMENT:"1001",PAID:"1002",SHIPPED:"1003",DELIVERED:"1004",CANCELLED:"1005"}),_e=[{entity:"OrderStatus",id:f.PENDING_PAYMENT,values:{name:"Pending payment",code:"PENDING_PAYMENT",color:"#D97706",displayOrder:10}},{entity:"OrderStatus",id:f.PAID,values:{name:"Paid",code:"PAID",color:"#2563EB",displayOrder:20}},{entity:"OrderStatus",id:f.SHIPPED,values:{name:"Shipped",code:"SHIPPED",color:"#16A34A",displayOrder:30}},{entity:"OrderStatus",id:f.DELIVERED,values:{name:"Delivered",code:"DELIVERED",color:"#047857",displayOrder:40}},{entity:"OrderStatus",id:f.CANCELLED,values:{name:"Cancelled",code:"CANCELLED",color:"#9F1239",displayOrder:50}}],ce={Platform:{table:"platform_data",columns:{id:C("id"),name:y("name"),code:y("code"),region:y("region"),currency:y("currency"),version:I("version","integer")},relations:{customerList:{targetEntity:"Customer",localKey:"id",foreignKey:"platformId",many:!0},orderList:{targetEntity:"CustomerOrder",localKey:"id",foreignKey:"platformId",many:!0}}},Customer:{table:"customer_data",columns:{id:C("id"),name:y("name"),email:y("email"),city:y("city"),tier:y("tier"),platformId:C("platform_id"),version:I("version","integer")},relations:{platform:{targetEntity:"Platform",localKey:"platformId",foreignKey:"id",many:!1},orderList:{targetEntity:"CustomerOrder",localKey:"id",foreignKey:"customerId",many:!0}}},CustomerOrder:{table:"customer_order_data",columns:{id:C("id"),orderNumber:y("order_number"),orderDate:ze("order_date"),status:C("status_id"),totalAmount:I("total_amount"),currency:y("currency"),customerId:C("customer_id"),platformId:C("platform_id"),version:I("version","integer")},relations:{platform:{targetEntity:"Platform",localKey:"platformId",foreignKey:"id",many:!1},customer:{targetEntity:"Customer",localKey:"customerId",foreignKey:"id",many:!1},status:{targetEntity:"OrderStatus",localKey:"status",foreignKey:"id",many:!1},itemList:{targetEntity:"OrderItem",localKey:"id",foreignKey:"orderId",many:!0},paymentList:{targetEntity:"Payment",localKey:"id",foreignKey:"orderId",many:!0},shipmentList:{targetEntity:"Shipment",localKey:"id",foreignKey:"orderId",many:!0}}},OrderStatus:{table:"order_status_data",columns:{id:C("id"),name:y("name"),code:y("code"),color:y("color"),displayOrder:I("display_order","integer"),version:I("version","integer")},relations:{orderList:{targetEntity:"CustomerOrder",localKey:"id",foreignKey:"status",many:!0}}},OrderItem:{table:"order_item_data",columns:{id:C("id"),orderId:C("order_id"),productName:y("product_name"),sku:y("sku"),quantity:I("quantity","integer"),unitPrice:I("unit_price"),lineAmount:I("line_amount"),version:I("version","integer")},relations:{order:{targetEntity:"CustomerOrder",localKey:"orderId",foreignKey:"id",many:!1}}},Payment:{table:"payment_data",columns:{id:C("id"),orderId:C("order_id"),provider:y("provider"),status:y("status"),amount:I("amount"),currency:y("currency"),transactionId:y("transaction_id"),paidAt:K("paid_at"),version:I("version","integer")},relations:{order:{targetEntity:"CustomerOrder",localKey:"orderId",foreignKey:"id",many:!1}}},Shipment:{table:"shipment_data",columns:{id:C("id"),orderId:C("order_id"),carrier:y("carrier"),status:y("status"),trackingNumber:y("tracking_number"),shipToCity:y("ship_to_city"),shippedAt:K("shipped_at"),deliveredAt:K("delivered_at"),version:I("version","integer")},relations:{order:{targetEntity:"CustomerOrder",localKey:"orderId",foreignKey:"id",many:!1}}}},he=[{entity:"Platform",id:"1",payload:{name:"TeaQL Store",code:"TEAQL-CN",region:"China",currency:"CNY"}},{entity:"Platform",id:"2",payload:{name:"TeaQL Global",code:"TEAQL-GLOBAL",region:"Global",currency:"USD"}},{entity:"Customer",id:"101",payload:{name:"Lin Xiao",email:"lin.xiao@example.com",city:"Shanghai",tier:"GOLD",platformId:"1"}},{entity:"Customer",id:"102",payload:{name:"Zhou Ran",email:"zhou.ran@example.com",city:"Hangzhou",tier:"SILVER",platformId:"1"}},{entity:"Customer",id:"103",payload:{name:"Maya Patel",email:"maya.patel@example.com",city:"Singapore",tier:"GOLD",platformId:"2"}},{entity:"Customer",id:"104",payload:{name:"Lucas Martin",email:"lucas.martin@example.com",city:"Paris",tier:"SILVER",platformId:"2"}},{entity:"Customer",id:"105",payload:{name:"Wang Ning",email:"wang.ning@example.com",city:"Chengdu",tier:"BRONZE",platformId:"1"}},{entity:"CustomerOrder",id:"1001",payload:{orderNumber:"TQL-2026-1001",orderDate:"2026-08-28",status:f.DELIVERED,totalAmount:499,currency:"CNY",customerId:"101",platformId:"1"}},{entity:"CustomerOrder",id:"1002",payload:{orderNumber:"TQL-2026-1002",orderDate:"2026-09-02",status:f.SHIPPED,totalAmount:1299,currency:"CNY",customerId:"102",platformId:"1"}},{entity:"CustomerOrder",id:"1003",payload:{orderNumber:"TQL-2026-1003",orderDate:"2026-09-06",status:f.PAID,totalAmount:328.8,currency:"CNY",customerId:"101",platformId:"1"}},{entity:"CustomerOrder",id:"1004",payload:{orderNumber:"TQL-2026-1004",orderDate:"2026-09-11",status:f.PENDING_PAYMENT,totalAmount:79.9,currency:"CNY",customerId:"105",platformId:"1"}},{entity:"CustomerOrder",id:"1005",payload:{orderNumber:"TQL-2026-1005",orderDate:"2026-09-14",status:f.DELIVERED,totalAmount:219,currency:"USD",customerId:"103",platformId:"2"}},{entity:"CustomerOrder",id:"1006",payload:{orderNumber:"TQL-2026-1006",orderDate:"2026-09-18",status:f.PAID,totalAmount:640,currency:"USD",customerId:"104",platformId:"2"}},{entity:"CustomerOrder",id:"1007",payload:{orderNumber:"TQL-2026-1007",orderDate:"2026-09-21",status:f.CANCELLED,totalAmount:159,currency:"CNY",customerId:"102",platformId:"1"}},{entity:"CustomerOrder",id:"1008",payload:{orderNumber:"TQL-2026-1008",orderDate:"2026-09-25",status:f.SHIPPED,totalAmount:268,currency:"CNY",customerId:"105",platformId:"1"}},{entity:"OrderItem",id:"2001",payload:{orderId:"1001",productName:"TeaQL Mechanical Keyboard",sku:"KB-TQL-87",quantity:1,unitPrice:299,lineAmount:299}},{entity:"OrderItem",id:"2002",payload:{orderId:"1001",productName:"Silent Wireless Mouse",sku:"MS-SILENT",quantity:2,unitPrice:100,lineAmount:200}},{entity:"OrderItem",id:"2003",payload:{orderId:"1002",productName:"27-inch Developer Monitor",sku:"MON-27-4K",quantity:1,unitPrice:1299,lineAmount:1299}},{entity:"OrderItem",id:"2004",payload:{orderId:"1003",productName:"White Porcelain Travel Tea Set",sku:"TEA-TRAVEL",quantity:1,unitPrice:168.8,lineAmount:168.8}},{entity:"OrderItem",id:"2005",payload:{orderId:"1003",productName:"Pre-Qingming Longjing Tea",sku:"TEA-LJ-100",quantity:2,unitPrice:80,lineAmount:160}},{entity:"OrderItem",id:"2006",payload:{orderId:"1004",productName:"Double-wall Glass Tumbler",sku:"CUP-GLASS",quantity:1,unitPrice:79.9,lineAmount:79.9}},{entity:"OrderItem",id:"2007",payload:{orderId:"1005",productName:"Travel Brew Kit",sku:"BREW-KIT",quantity:1,unitPrice:219,lineAmount:219}},{entity:"OrderItem",id:"2008",payload:{orderId:"1006",productName:"Desktop Studio Speaker",sku:"SPK-STUDIO",quantity:2,unitPrice:260,lineAmount:520}},{entity:"OrderItem",id:"2009",payload:{orderId:"1006",productName:"Speaker Stand",sku:"SPK-STAND",quantity:1,unitPrice:120,lineAmount:120}},{entity:"OrderItem",id:"2010",payload:{orderId:"1007",productName:"Desktop Reading Lamp",sku:"LAMP-DESK",quantity:1,unitPrice:159,lineAmount:159}},{entity:"OrderItem",id:"2011",payload:{orderId:"1008",productName:"TeaQL Portable Keyboard",sku:"KB-TQL-68",quantity:1,unitPrice:268,lineAmount:268}},{entity:"Payment",id:"3001",payload:{orderId:"1001",provider:"Alipay",status:"CAPTURED",amount:499,currency:"CNY",transactionId:"ALI-260828-01",paidAt:"2026-08-28T10:14:00Z"}},{entity:"Payment",id:"3002",payload:{orderId:"1002",provider:"WeChat Pay",status:"CAPTURED",amount:1299,currency:"CNY",transactionId:"WX-260902-08",paidAt:"2026-09-02T03:20:00Z"}},{entity:"Payment",id:"3003",payload:{orderId:"1003",provider:"Alipay",status:"CAPTURED",amount:328.8,currency:"CNY",transactionId:"ALI-260906-11",paidAt:"2026-09-06T11:42:00Z"}},{entity:"Payment",id:"3004",payload:{orderId:"1004",provider:"WeChat Pay",status:"PENDING",amount:79.9,currency:"CNY",transactionId:"WX-260911-02",paidAt:null}},{entity:"Payment",id:"3005",payload:{orderId:"1005",provider:"Stripe",status:"CAPTURED",amount:219,currency:"USD",transactionId:"PI-260914-05",paidAt:"2026-09-14T06:10:00Z"}},{entity:"Payment",id:"3006",payload:{orderId:"1006",provider:"Stripe",status:"CAPTURED",amount:640,currency:"USD",transactionId:"PI-260918-03",paidAt:"2026-09-18T15:08:00Z"}},{entity:"Payment",id:"3007",payload:{orderId:"1007",provider:"Alipay",status:"REFUNDED",amount:159,currency:"CNY",transactionId:"ALI-260921-07",paidAt:"2026-09-21T02:55:00Z"}},{entity:"Payment",id:"3008",payload:{orderId:"1008",provider:"WeChat Pay",status:"CAPTURED",amount:268,currency:"CNY",transactionId:"WX-260925-06",paidAt:"2026-09-25T08:31:00Z"}},{entity:"Shipment",id:"4001",payload:{orderId:"1001",carrier:"SF Express",status:"DELIVERED",trackingNumber:"SF2608281001",shipToCity:"Shanghai",shippedAt:"2026-08-29T02:00:00Z",deliveredAt:"2026-08-30T07:26:00Z"}},{entity:"Shipment",id:"4002",payload:{orderId:"1002",carrier:"JD Logistics",status:"IN_TRANSIT",trackingNumber:"JD2609021002",shipToCity:"Hangzhou",shippedAt:"2026-09-03T04:12:00Z",deliveredAt:null}},{entity:"Shipment",id:"4003",payload:{orderId:"1003",carrier:"SF Express",status:"READY",trackingNumber:"SF2609061003",shipToCity:"Shanghai",shippedAt:null,deliveredAt:null}},{entity:"Shipment",id:"4004",payload:{orderId:"1005",carrier:"DHL",status:"DELIVERED",trackingNumber:"DHL2609141005",shipToCity:"Singapore",shippedAt:"2026-09-15T01:10:00Z",deliveredAt:"2026-09-17T09:22:00Z"}},{entity:"Shipment",id:"4005",payload:{orderId:"1006",carrier:"DHL",status:"READY",trackingNumber:"DHL2609181006",shipToCity:"Paris",shippedAt:null,deliveredAt:null}},{entity:"Shipment",id:"4006",payload:{orderId:"1008",carrier:"SF Express",status:"IN_TRANSIT",trackingNumber:"SF2609251008",shipToCity:"Chengdu",shippedAt:"2026-09-26T03:18:00Z",deliveredAt:null}}],L=t=>`'${t.replaceAll("\\","\\\\").replaceAll("'","\\'").replaceAll(`
|
| 2 |
-
`,"\\n")}'`,U=t=>t.toQExpression().replace(/\s*\n\s*/g,""),
|
| 3 |
-
`)}toQuery(){const e=this.query.clone();return this.filters.length&&e.filter({$and:[...this.filters]}),e}async executeForList(e){this.ensureIntent();const r=this.service(e),n=this.toQuery(),o=await r.executeQuery(e.prepareQuery(n)),s=new ie(o);return n.facets.length&&(s.facets=await de(r,d=>e.prepareQuery(d),n,n.facets)),s}async executeForRows(e){return this.executeForList(e)}async executeForPage(e,r,n){this.ensureIntent();const o=this.service(e),s=this.toQuery(),d=await o.executeCount(s,this.pageTotalAlias,this.pageTotalAlias?{kind:"named-count",method:"countAs",alias:this.pageTotalAlias}:void 0),a=this.toQuery().offset(r).limit(n),c=new ie(await o.executeQuery(e.prepareQuery(a)),{totalCount:d});return this.pageTotalAlias&&(c.aggregations[this.pageTotalAlias]=d),s.facets.length&&(c.facets=await de(o,m=>e.prepareQuery(m),s,s.facets)),{data:c,totalCount:d,offset:r,limit:n}}addFilter(e){return this.filters.push(e),this}select(...e){return this.query.select(e),this}order(e,r){return this.query.order(r==="asc"?R.asc(e):R.desc(e)),this}group(e){return this.query.groupBy(e),this}aggregate(e,r,n){return this.query.aggregate(e,r,n),this}record(e){return this.qSteps.push(e),this}includePageTotalAs(e){return this.pageTotalAlias=e,this}service(e){return e.requireResource("dataService")}ensureIntent(){if(!this.auditComment.trim()||!this.queryPurpose.trim())throw new Error("Generated Q requests require comment() and purpose() before execution")}}class Ue extends D{constructor(){super("Platform","Q.platforms()")}selectId(){return this.select("id")}selectName(){return this.select("name")}selectCode(){return this.select("code")}withIdIs(e){return this.addFilter({id:{$eq:e}})}}class Ye extends D{constructor(){super("Customer","Q.customers()")}selectId(){return this.select("id")}selectName(){return this.select("name")}selectCity(){return this.select("city")}selectTier(){return this.select("tier")}selectPlatformWith(e){return this.query.relationQuery("platform",e.toQuery(),"platformId","id",!1),this}countOrderListAs(e){return this.query.relationAggregate("orderList",e,new T("CustomerOrder").aggregate("Count","id",e)),this}orderByNameAscending(){return this.order("name","asc")}}class Ge extends D{constructor(){super("OrderItem","Q.orderItems()")}selectId(){return this.select("id"),this.record("selectId()")}selectOrderId(){return this.select("orderId"),this.record("selectOrderId()")}selectProductName(){return this.select("productName"),this.record("selectProductName()")}selectSku(){return this.select("sku"),this.record("selectSku()")}selectQuantity(){return this.select("quantity"),this.record("selectQuantity()")}withProductNameContaining(e){return this.addFilter({productName:{$contains:e}})}orderByIdAscending(){return this.order("id","asc"),this.record("orderByIdAscending()")}groupByProductName(){return this.group("productName")}sumQuantityAs(e){return this.aggregate("Sum","quantity",e)}sumLineAmountAs(e){return this.aggregate("Sum","lineAmount",e)}countAs(e){return this.aggregate("Count","id",e)}}class je extends D{constructor(){super("OrderStatus","Q.orderStatuses()")}selectId(){return this.select("id"),this.record("selectId()")}selectName(){return this.select("name"),this.record("selectName()")}selectCode(){return this.select("code"),this.record("selectCode()")}selectColor(){return this.select("color"),this.record("selectColor()")}selectDisplayOrder(){return this.select("displayOrder"),this.record("selectDisplayOrder()")}withCodeIs(e){return this.addFilter({code:{$eq:e}})}countAs(e){return this.aggregate("Count","id",e),this.record(`countAs(${L(e)})`)}sumOrderTotalAmountAs(e){return this.aggregate("Sum","totalAmount",e),this.record(`sumOrderTotalAmountAs(${L(e)})`)}orderByDisplayOrderAscending(){return this.order("displayOrder","asc"),this.record("orderByDisplayOrderAscending()")}}class He extends D{constructor(){super("Payment","Q.payments()")}groupByCurrency(){return this.group("currency")}groupByProvider(){return this.group("provider")}groupByStatus(){return this.group("status")}countAs(e){return this.aggregate("Count","id",e)}sumAmountAs(e){return this.aggregate("Sum","amount",e)}orderByCurrencyAscending(){return this.order("currency","asc")}orderByProviderAscending(){return this.order("provider","asc")}orderByIdAscending(){return this.order("id","asc")}}class Ve extends D{constructor(){super("Shipment","Q.shipments()")}withStatusIn(...e){return this.addFilter({status:{$in:e}})}selectOrderWith(e){return this.query.relationQuery("order",e.toQuery(),"orderId","id",!1),this}orderByStatusAscending(){return this.order("status","asc")}orderByIdAscending(){return this.order("id","asc")}}class ue extends D{dynamicWarnings=[];countAlias;rowCountApplied=!1;constructor(e=!1){super("CustomerOrder",e?"Q.customerOrdersWithMinimalFields()":"Q.customerOrders()"),e?this.query.select(["id","version"]):this.query.select(["id","orderNumber","orderDate","status","totalAmount","currency","customerId","platformId","version"])}selectId(){return this.select("id")}selectOrderNumber(){return this.select("orderNumber"),this.record("selectOrderNumber()")}selectOrderDate(){return this.select("orderDate"),this.record("selectOrderDate()")}selectStatus(){return this.select("status")}selectTotalAmount(){return this.select("totalAmount")}selectCurrency(){return this.select("currency")}withOrderNumberIs(e){return this.addFilter({orderNumber:{$eq:e}})}withOrderNumberContaining(e){return this.addFilter({orderNumber:{$contains:e}})}withStatusMatching(e){return this.addFilter({status:{$inSubquery:{query:e.toQuery(),field:"id"}}})}withStatusIsPendingPayment(){return this.addFilter({status:{$eq:f.PENDING_PAYMENT}})}withStatusIsPaid(){return this.addFilter({status:{$eq:f.PAID}})}withStatusIsShipped(){return this.addFilter({status:{$eq:f.SHIPPED}})}withStatusIsDelivered(){return this.addFilter({status:{$eq:f.DELIVERED}})}withStatusIsCancelled(){return this.addFilter({status:{$eq:f.CANCELLED}})}withCurrencyIs(e){return this.addFilter({currency:{$eq:e}})}withTotalAmountGreaterThanOrEqualTo(e){return this.addFilter({totalAmount:{$gte:e}})}withOrderDateGreaterThanOrEqualTo(e){return this.addFilter({orderDate:{$gte:e}})}withPlatformIdIs(e){return this.addFilter({platformId:{$eq:e}})}withItemListMatching(e){return this.addFilter({id:{$inSubquery:{query:e.toQuery(),field:"orderId"}}})}filterByJson(e){const{query:r,warnings:n}=Te(this.toQuery(),Ke(e),Me,{filter:(o,s)=>o==="status.code"?{status:{$inSubquery:{query:new T("OrderStatus").filter({code:s}),field:"id"}}}:o==="itemList.productName"?{id:{$inSubquery:{query:new T("OrderItem").filter({productName:s}),field:"orderId"}}}:{[o]:s},order:(o,s)=>s==="asc"?R.asc(o):R.desc(o)});return this.dynamicWarnings=n,this.query.filterCondition=r.filterCondition,this.query.orderItems=[...r.orderItems],this.record("filterByJson(searchParams)"),this}warnings(){return this.dynamicWarnings}selectPlatformWith(e){return this.query.relationQuery("platform",e.toQuery(),"platformId","id",!1),this}selectCustomerWith(e){return this.query.relationQuery("customer",e.toQuery(),"customerId","id",!1),this}selectStatusWith(e){return this.query.select(["status"]),this.query.relationQuery("status",e.toQuery(),"status","id",!1,{kind:"relation-select",method:"selectStatusWith",relation:"status"}),this.record(`selectStatusWith(${U(e)})`)}selectItemListWith(e){return this.query.relationQuery("itemList",e.toQuery(),"id","orderId",!0,{kind:"relation-select",method:"selectItemListWith",relation:"itemList"}),this.record(`selectItemListWith(${U(e)})`)}selectPaymentListWith(e){return this.query.relationQuery("paymentList",e.toQuery(),"id","orderId",!0),this}selectShipmentListWith(e){return this.query.relationQuery("shipmentList",e.toQuery(),"id","orderId",!0),this}countItemListAs(e){return this.query.relationAggregate("itemList",e,new T("OrderItem").aggregate("Count","id",e).comment("count items"),!0,{kind:"relation-count",method:"countItemListAs",relation:"itemList",alias:e}),this.record(`countItemListAs(${L(e)})`)}facetByStatusAs(e,r,n=!0){const o=r.toQuery();return o.commentText||o.comment("load status facets"),this.query.facetBy(e,"status",{toQuery:()=>o},n,{kind:"facet",method:"facetByStatusAs",relation:"status",alias:e}),this.record(`facetByStatusAs(${L(e)}, ${U(r)})`)}orderByOrderDateDescending(){return this.order("orderDate","desc"),this.record("orderByOrderDateDescending()")}orderByOrderDateAscending(){return this.order("orderDate","asc")}orderByIdDescending(){return this.order("id","desc"),this.record("orderByIdDescending()")}orderByTotalAmountDescending(){return this.order("totalAmount","desc")}groupByCurrency(){return this.group("currency")}groupByStatus(){return this.group("status")}countAs(e){return this.countAlias=e,this.record(`countAs(${L(e)})`)}sumTotalAmountAs(e){return this.aggregate("Sum","totalAmount",e)}averageTotalAmountAs(e){return this.aggregate("Avg","totalAmount",e)}executeForList(e){return this.applyRowCount(),super.executeForList(e)}executeForRows(e){return this.applyRowCount(),super.executeForList(e)}executeForPage(e,r,n){return this.countAlias&&this.includePageTotalAs(this.countAlias),super.executeForPage(e,r,n)}applyRowCount(){!this.countAlias||this.rowCountApplied||(this.query.aggregate("Count","id",this.countAlias),this.rowCountApplied=!0)}}class u{static platforms(){return new Ue}static customers(){return new Ye}static customerOrders(){return new ue}static customerOrdersWithMinimalFields(){return new ue(!0)}static orderItems(){return new Ge}static orderStatuses(){return new je}static payments(){return new He}static shipments(){return new Ve}}const k=document.querySelector("#status"),B=document.querySelector("#persist"),Y=document.querySelector("#reset"),F=document.querySelector("#query-catalog"),b=document.querySelector("#result"),ge=document.querySelector("#result-title"),fe=document.querySelector("#result-description"),J=document.querySelector("#result-meta"),le=document.querySelector("#query-code"),Ze=document.querySelector("#query-params-block"),Je=document.querySelector("#query-params-code"),Xe=document.querySelector("#result-grid"),$=document.querySelector("#result-view-label"),et=document.querySelector("#sql-count"),me=document.querySelector("#sql-output"),X=document.querySelector("#expand-all"),tt=document.querySelector("#collapse-all"),Q=document.querySelector("#view-table"),H=document.querySelector("#view-tree"),Ae=Array.from(document.querySelectorAll("[data-locale]")),rt={heroTitle:{en:"Understand TeaQL queries through a familiar order model.",zh:"用一个熟悉的订单模型,看懂 TeaQL 查询。"},heroIntro:{en:"Platform, customer, order, item, payment, and shipment data all run in the browser. Order status is backed by a constant model. Choose a query below to inspect real SQLite/WASM results.",zh:"平台、用户、订单、明细、支付和物流数据都在浏览器中运行;订单状态由常数模型提供。选择下面的查询,查看真实的 SQLite/WASM 结果。"},platform:{en:"Platform",zh:"平台"},customer:{en:"Customer",zh:"用户"},order:{en:"Order",zh:"订单"},item:{en:"Item",zh:"明细"},payment:{en:"Payment",zh:"支付"},shipment:{en:"Shipment",zh:"物流"},constantModel:{en:"Constant model",zh:"常数模型"},persist:{en:"Persist locally with OPFS",zh:"使用 OPFS 保存在本地"},reset:{en:"Reset demo data",zh:"重置演示数据"},chooseQuery:{en:"Choose a query",zh:"选择一个查询"},queryIntro:{en:"Queries are grouped by purpose and share the same order dataset.",zh:"查询按用途分组,并共用同一份订单数据。"},table:{en:"Table",zh:"表格"},resultTree:{en:"Result Tree",zh:"结果树"},expandAll:{en:"Expand all",zh:"全部展开"},collapseAll:{en:"Collapse all",zh:"全部折叠"},waiting:{en:"Waiting for query…",zh:"等待查询…"},queryNote:{en:"The Q expression stays fixed; search, status cards, and pagination only update dynamic parameters. The underlying SelectQuery remains inside the generated request implementation.",zh:"Q 表达式保持不变;搜索、状态卡片和分页只更新动态参数。底层 SelectQuery 仍封装在生成的请求实现中。"},executionEvidence:{en:"EXECUTION EVIDENCE",zh:"执行证据"},evidenceTime:{en:"Time",zh:"时间"},identity:{en:"Identity",zh:"身份"},traceChain:{en:"Trace chain",zh:"追踪链"},sqlNote:{en:"One plain-text line per statement: time, identity, trace chain, and the SQL SQLite executed.",zh:"每条语句使用一行纯文本:时间、身份、追踪链,以及 SQLite 实际执行的 SQL。"},localData:{en:"Data stays in this browser",zh:"数据只保留在当前浏览器中"}},nt={基本查询:"Basic queries","从订单、用户和关联对象开始":"Start with orders, customers, and related objects",汇总查询:"Aggregations","分组、计数、求和与平均值":"Grouping, counts, sums, and averages",过滤查询:"Filtered queries","精确、范围与组合条件":"Exact, range, and combined predicates",动态查询:"Dynamic queries","由页面条件安全生成,不使用 eval":"Safely generated from page criteria without eval","综合:订单管理中心":"Comprehensive: Order management center","一个真实的综合查询页面:状态指标、搜索、商品预览和分页都由 TeaQL 查询驱动。":"A real composite query page: status metrics, search, product previews, and pagination are all driven by TeaQL.",最近订单:"Recent orders","按下单日期倒序浏览全部订单,并带出所属平台与用户。":"Browse all orders by date descending, including their platform and customer.",完整订单详情:"Complete order details","查看一个订单及其用户、商品明细、支付和物流,体现完整对象图。":"Inspect one order with its customer, items, payments, and shipments as a complete object graph.",用户与订单数:"Customers with order counts","列出用户,并通过关联汇总显示每位用户的订单数量。":"List customers and show each customer’s order count through a relation aggregate.",订单状态汇总:"Orders by status","按币种与订单状态统计订单数、总额和平均客单价。":"Aggregate order count, gross amount, and average order value by currency and status.",商品销售汇总:"Product sales summary","按商品汇总销量与销售额,找出最受欢迎的订单明细。":"Aggregate units and revenue by product to identify the most popular order items.",支付渠道对账:"Payment reconciliation","按币种、支付渠道和状态汇总笔数与金额。":"Aggregate transaction count and amount by currency, payment provider, and status.",待支付订单:"Orders awaiting payment","筛选尚未完成付款的订单,并带出对应支付记录。":"Find orders that have not completed payment and include their payment records.",国内大额订单:"High-value domestic orders","组合平台与金额条件,找出 TeaQL 商城中金额不低于 500 元的订单。":"Combine platform and amount filters to find TeaQL Store orders worth at least CNY 500.",运输中的包裹:"Active shipments","筛选待揽收和运输中的物流单,并关联订单信息。":"Find shipments that are ready or in transit and include their order information.","动态:已付款国内订单":"Dynamic: paid domestic orders","从动态条件对象生成查询:人民币、金额至少 250,且状态为已付款或已发货。":"Build a query from dynamic criteria: CNY, at least 250, and status PAID or SHIPPED.","动态:九月新订单":"Dynamic: new September orders","运行时传入日期范围与排序方式,查询 9 月 15 日之后的订单。":"Pass a date range and sort order at runtime to find orders after September 15.","动态:字段白名单":"Dynamic: field allowlist","未知字段会被报告并忽略;合法条件仍可安全执行。":"Unknown fields are reported and ignored while valid predicates still execute safely."};let i=localStorage.getItem("teaql-browser-locale")==="zh"?"zh":"en";function st(t){return rt[t]?.[i]??t}function O(t){return i==="en"?nt[t]??t:t}let E,W=window.location.hash.slice(1)||"order-center";window.location.hash||history.replaceState(null,"","#order-center");let w="tree",v,Se=0,ee;const A={search:"",page:0,pageSize:4},Ce=localStorage.getItem("teaql-browser-storage")==="opfs"?"opfs":"memory";B.checked=Ce==="opfs";async function G(t,e){const r=u.customerOrders().filterByJson(e).limit(20).comment("what: execute a validated browser search").purpose("why: demonstrate safe dynamic order discovery"),n=await r.executeForList(t.context);return{request:e,warnings:r.warnings(),data:n}}const ot=Object.fromEntries(Object.entries(f).map(([t,e])=>[e,t]));function te(t){const e=String(t.code??"");return e&&e in f?e:"color"in t?ot[String(t.id??"")]??"":""}function Ie(t){const e=t.trim();if(!e)return{filter:{}};const r=e.toUpperCase(),n=["PENDING_PAYMENT","PAID","SHIPPED","DELIVERED","CANCELLED"].find(o=>o.includes(r));return n?{filter:{"status.code":n}}:/^(TQL-|\d)/i.test(e)?{filter:{orderNumber:{$contains:r}}}:{filter:{"itemList.productName":{$contains:e}}}}async function at(t){const e=Ie(A.search),r=u.customerOrdersWithMinimalFields().filterByJson(e).countAs("totalOrders").facetByStatusAs("statusCounts",u.orderStatuses().selectName().selectColor().countAs("orderCount").sumOrderTotalAmountAs("orderTotalAmount").orderByDisplayOrderAscending().comment("load status facets")).selectOrderNumber().selectOrderDate().selectStatusWith(u.orderStatuses().selectName().selectColor().comment("load status")).selectItemListWith(u.orderItems().selectProductName().selectQuantity().orderByIdAscending().limit(3).comment("load item previews")).countItemListAs("itemCount").orderByOrderDateDescending().orderByIdDescending().comment("load order list").purpose("render order list page"),n=await r.executeForPage(t.context,A.page*A.pageSize,A.pageSize),o=n.data.facet("statusCounts")??[];return{orders:n.data,totalOrders:Number(n.data.aggregations.totalOrders??n.totalCount),filteredOrders:n.totalCount,statusFacets:o.map(s=>({code:te(s),name:String(s.name??""),color:String(s.color??""),orderCount:Number(s.orderCount??0),orderTotalAmount:Number(s.orderTotalAmount??0)})).filter(s=>s.code&&s.name),search:A.search,page:A.page,pageSize:A.pageSize,queryExpression:r.toQExpression("executeForPage(ctx, pageOffset, pageSize);")}}const we=[{label:"基本查询",description:"从订单、用户和关联对象开始",queries:[{id:"order-center",title:"综合:订单管理中心",description:"一个真实的综合查询页面:状态指标、搜索、商品预览和分页都由 TeaQL 查询驱动。",code:"",view:"dashboard",run:at},{id:"recent-orders",title:"最近���单",description:"按下单日期倒序浏览全部订单,并带出所属平台与用户。",code:`await Q.customerOrders()
|
|
|
|
|
|
|
| 4 |
.selectPlatformWith(Q.platforms().selectName())
|
| 5 |
.selectCustomerWith(Q.customers().selectName().selectCity().selectTier())
|
| 6 |
.selectStatusWith(Q.orderStatuses().selectName().selectColor())
|
|
@@ -99,4 +101,4 @@ const data = await request
|
|
| 99 |
.comment('what: execute a validated browser search')
|
| 100 |
.purpose('why: demonstrate safe dynamic order discovery')
|
| 101 |
.executeForList(ctx);
|
| 102 |
-
const warnings = request.warnings();`,run:t=>G(t,{filter:{status:"DELIVERED",internalNote:{$contains:"not queryable"}}})}]}],pe=we.flatMap(t=>t.queries);async function it(t){const e=new Worker(new URL("/assets/sqlite.worker-DS5P4U1E.js",import.meta.url),{type:"module"}),r=await Qe.open(e,{...ce},{storage:t,databaseName:"teaql-order-playground-v3.sqlite3"}),n=new $e().enableSelect();r.install(new Re(ce,{},{constants:_e})),r.setRuntimeTelemetrySink(n).setDiagnosticSQLLogSink(void 0);const o=Object.freeze({policyId:"browser-order-demo-seed",version:"1",fingerprint:"sha256:browser-order-demo-seed-v1"}),s=new Be().insertResource("dataService",r).withMutationPolicyRegistry(new Fe(()=>({identity:o,review:(d,a)=>a.operations.length>0?{verdict:"allow"}:{verdict:"deny",code:"EMPTY_GRAPH",message:"empty mutation graph"}}))).withMutationPolicyApprovalProvider(new ke(d=>({policy:d,approvedBy:"browser-demo-owner",approvedAt:new Date})));return r.setUserContext(s),await s.ensureSchema(),{client:r,context:s,evidence:n}}async function be(t){if((await u.customerOrders().selectId().limit(1).comment("what: detect existing order playground data").purpose("why: keep deterministic browser bootstrap idempotent").executeForList(t.context)).length)return;const r=new We("Seed deterministic order playground data");await t.client.executeGraphSave(r,async n=>{const o=he.map(s=>n.request({entity:s.entity,action:"Create",id:s.id,payload:s.payload}));for(const s of o)t.client.preflightMutation(s);for(const s of o)await t.client.executeMutation(s)})}function dt(){F.replaceChildren();for(const t of we){const e=document.createElement("section");e.className="query-group";const r=document.createElement("div");r.className="query-group-heading";const n=document.createElement("h2");n.textContent=O(t.label);const o=document.createElement("p");o.textContent=O(t.description),r.append(n,o);const s=document.createElement("div");s.className="query-links";for(const d of t.queries){const a=document.createElement("a");a.href=`#${d.id}`,a.dataset.queryId=d.id,a.textContent=O(d.title),a.addEventListener("click",c=>{c.preventDefault(),W=d.id,history.replaceState(null,"",`#${d.id}`),V(),E&&P(d,E).catch(N)}),s.append(a)}e.append(r,s),F.append(e)}V()}function V(){F.querySelectorAll("a[data-query-id]").forEach(t=>{const e=t.dataset.queryId===W;t.classList.toggle("active",e),e?t.setAttribute("aria-current","page"):t.removeAttribute("aria-current")})}async function P(t,e){const r=performance.now(),n=new Date;e.evidence.enableSelect(),b.classList.add("loading"),b.setAttribute("aria-busy","true"),ge.textContent=O(t.title),fe.textContent=O(t.description),le.textContent=t.code,Ze.classList.toggle("hidden",t.view!=="dashboard"),Je.textContent=t.view==="dashboard"?JSON.stringify({searchParams:Ie(A.search),pageOffset:A.page*A.pageSize,pageSize:A.pageSize},null,2):"",Xe.classList.toggle("dashboard-mode",t.view==="dashboard"),b.classList.toggle("dashboard-result",t.view==="dashboard"),X.closest(".tree-actions")?.classList.toggle("hidden",t.view==="dashboard"),$.textContent=t.view==="dashboard"?i==="en"?"Order management center":"订单管理中心":i==="en"?"Result tree":"结果树",J.textContent=i==="en"?"Running query…":"查询中…";try{const o=await t.run(e);t.view==="dashboard"&&(le.textContent=o.queryExpression),v={data:o,query:t,active:e},w=t.view==="dashboard"||Z(o)?"table":"tree",z();const s=Math.max(1,Math.round(performance.now()-r));Se=s,ee=n;const d=e.evidence.snapshot();Ee(d,n),Pe(o,t,s)}finally{b.classList.remove("loading"),b.removeAttribute("aria-busy")}}function Ee(t,e=ee){me.replaceChildren(),et.textContent=i==="en"?`${t.length} statement${t.length===1?"":"s"}`:`${t.length} 条语句`,t.forEach((r,n)=>{const o=document.createElement("tr");o.className="evidence-row";const s=[...r.tracePath].reverse().find(l=>l.kind==="relation"||l.kind==="request"||l.kind==="entity"),d=document.createElement("td");d.className="evidence-time",d.dataset.executedAt=e?.toISOString()??"",d.textContent=`${e?.toISOString()??"—"} · ${Math.max(.01,r.elapsedMicros/1e3).toFixed(2)} ms`;const a=document.createElement("td");a.textContent=`${v?.query.id??"query"} · #${n+1} · ${s?.name??"query"}`;const c=document.createElement("td");if(c.className="evidence-trace",r.traceChain?.length){const l=r.traceChain.find(g=>g.kind==="purpose"),S=r.traceChain.filter(g=>g.kind==="comment").map(g=>g.detail||g.name);c.textContent=`${l?.detail||l?.name||""}: ${S.join(" → ")}`}else c.textContent=r.tracePath.map(l=>l.detail||l.name).join(" → ");const m=document.createElement("td");m.className="evidence-sql";const h=r.parameters.length?r.parameters.map(l=>String(l)).join(", "):"none";m.textContent=`${r.parameterizedSQL} · bindings: ${h}`,o.append(d,a,c,m),me.append(o)})}function Z(t){return Array.isArray(t)&&t.every(e=>e!==null&&typeof e=="object"&&!Array.isArray(e))}function z(){if(!v)return;const{data:t,query:e,active:r}=v,n=e.view==="dashboard"||Z(t);if(n||(w="tree"),Q.disabled=!n,Q.classList.toggle("active",w==="table"),H.classList.toggle("active",w==="tree"),Q.setAttribute("aria-pressed",String(w==="table")),H.setAttribute("aria-pressed",String(w==="tree")),X.closest(".tree-actions")?.classList.toggle("hidden",w!=="tree"),w==="table"&&e.view==="dashboard"){$.textContent=i==="en"?"Result table":"结果表格",mt(t,r,e);return}if(w==="table"&&Z(t)){$.textContent=i==="en"?"Result table":"结果表格",ut(t);return}$.textContent=i==="en"?"Result tree":"结果树",Le(e.view==="dashboard"?ct(t):t)}function ct(t){return{orders:t.orders,totalOrders:t.totalOrders,filteredOrders:t.filteredOrders,statusFacets:t.statusFacets,search:t.search,page:t.page,pageSize:t.pageSize}}function ut(t){const e=document.createElement("div");if(e.className="result-table-shell",!t.length){const a=document.createElement("p");a.className="result-table-empty",a.textContent=i==="en"?"The query returned no records.":"查询没有返回记录。",e.append(a),b.replaceChildren(e);return}const r=[...new Set(t.flatMap(a=>Object.keys(a)))],n=document.createElement("table");n.className="result-table";const o=document.createElement("thead"),s=document.createElement("tr");for(const a of r){const c=document.createElement("th");c.scope="col",c.textContent=a,s.append(c)}o.append(s);const d=document.createElement("tbody");for(const a of t){const c=document.createElement("tr");for(const m of r){const h=document.createElement("td");h.textContent=lt(a[m]),c.append(h)}d.append(c)}n.append(o,d),e.append(n),b.replaceChildren(e)}function lt(t){if(t==null)return"—";if(Array.isArray(t))return i==="en"?`${t.length} items`:`${t.length} 项`;if(t instanceof Date)return t.toISOString();if(typeof t=="object"){const e=t,r=te(e);if(r)return Ne(r);const n=e.name??e.orderNumber??e.code??e.id;return n===void 0?i==="en"?`${Object.keys(e).length} fields`:`${Object.keys(e).length} 个字段`:String(n)}return String(t)}function mt(t,e,r){const n=document.createElement("div");n.className="order-center";const o=document.createElement("div");o.className="order-center-toolbar";const s=document.createElement("div"),d=document.createElement("h3");d.textContent=i==="en"?"Order Management Center":"订单管理中心";const a=document.createElement("p");a.textContent=i==="en"?"One generated Q expression describes the entire page":"一个生成式 Q 表达式描述整个页面",s.append(d,a);const c=document.createElement("form");c.className="order-search";const m=document.createElement("input");m.type="search",m.placeholder=i==="en"?"Order number, status, or product…":"订单号、状态或商品名称…",m.value=t.search,m.setAttribute("aria-label",i==="en"?"Search orders":"搜索订单");const h=document.createElement("button");h.type="submit",h.className="order-search-submit",h.setAttribute("aria-label",i==="en"?"Run order query":"执行订单查询"),h.title=i==="en"?"Search":"查询";const l=document.createElement("span");l.className="search-icon",l.setAttribute("aria-hidden","true"),h.append(l),c.append(m,h),c.addEventListener("submit",p=>{p.preventDefault(),A.search=m.value.trim(),A.page=0,P(r,e).catch(N)}),o.append(s,c);const S=document.createElement("div");S.className="order-metrics",S.append(ye(i==="en"?"All orders":"全部订单",t.totalOrders,"total","#2B66D9",!t.search,()=>{A.search="",A.page=0,P(r,e).catch(N)}));for(const p of t.statusFacets)S.append(ye(p.name,p.orderCount,p.code.toLowerCase(),p.color,t.search.toUpperCase()===p.code,()=>{A.search=p.code,A.page=0,P(r,e).catch(N)},`${i==="en"?"Total":"总额"} ${pt(p.orderTotalAmount)}`));const g=document.createElement("div");g.className="order-table";const _=document.createElement("div");_.className="order-row order-row-head";const xe=i==="en"?["Order number","Order date","Status","Product details"]:["订单号","订单日期","状态","商品明细"];for(const p of xe){const x=document.createElement("span");x.textContent=p,_.append(x)}if(g.append(_),!t.orders.length){const p=document.createElement("div");p.className="order-empty",p.textContent=i==="en"?"No matching orders. Try an order number, status code, or product name.":"没有匹配的订单,请尝试订单号、状态英文或商品名称。",g.append(p)}for(const p of t.orders)g.append(yt(p));const M=document.createElement("div");M.className="order-center-footer";const ne=document.createElement("p"),se=t.filteredOrders?t.page*t.pageSize+1:0,oe=Math.min(t.filteredOrders,(t.page+1)*t.pageSize);ne.textContent=i==="en"?`Showing ${se}–${oe} of ${t.filteredOrders} orders`:`显示 ${se}–${oe},共 ${t.filteredOrders} 条订单`;const q=document.createElement("div");q.className="pagination";const ae=Math.max(1,Math.ceil(t.filteredOrders/t.pageSize));q.append(j("‹",t.page-1,t.page===0,e,r));for(let p=0;p<ae;p+=1){const x=j(String(p+1),p,!1,e,r);x.classList.toggle("active",p===t.page),q.append(x)}q.append(j("›",t.page+1,t.page>=ae-1,e,r)),M.append(ne,q),n.append(o,S,g,M),b.replaceChildren(n)}function ye(t,e,r,n,o,s,d){const a=document.createElement("button");a.type="button",a.className=`metric-card metric-${r}`,n&&a.style.setProperty("--metric-color",n),a.classList.toggle("active",o);const c=document.createElement("span");c.textContent=t;const m=document.createElement("strong");if(m.textContent=String(e),a.append(c,m),d){const h=document.createElement("small");h.textContent=d,a.append(h)}return a.addEventListener("click",s),a}function pt(t){return new Intl.NumberFormat(i==="en"?"en-US":"zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}function yt(t){const e=document.createElement("div");e.className="order-row";const r=t.status??{},n=Array.isArray(t.itemList)?t.itemList:[];[String(t.orderNumber??""),String(t.orderDate??"")].forEach(l=>{const S=document.createElement("span");S.className="order-primary",S.textContent=l,e.append(S)});const s=document.createElement("span"),d=document.createElement("span"),a=te(r);d.className=`status-badge status-${a.toLowerCase()}`,d.textContent=Ne(a)||String(r.name??a);const c=String(r.color??"");c&&(d.style.color=c,d.style.backgroundColor=`${c}18`),s.append(d),e.append(s);const m=document.createElement("span");m.className="product-preview",n.forEach((l,S)=>{const g=document.createElement("span");g.className=`product-thumb product-tone-${S%3}`,g.textContent=String(l.productName??"?").slice(0,1),g.title=`${String(l.productName??"")} × ${String(l.quantity??1)}`,m.append(g)});const h=Number(t.itemCount??n.length)-n.length;if(h>0){const l=document.createElement("small");l.textContent=`+${h}`,m.append(l)}return e.append(m),e}function j(t,e,r,n,o){const s=document.createElement("button");return s.type="button",s.textContent=t,s.disabled=r,s.addEventListener("click",()=>{A.page=e,P(o,n).catch(N)}),s}function Ne(t){return(i==="en"?{PENDING_PAYMENT:"Pending payment",PAID:"Paid",SHIPPED:"Shipped",DELIVERED:"Delivered",CANCELLED:"Cancelled"}:{PENDING_PAYMENT:"待支付",PAID:"已支付",SHIPPED:"运输中",DELIVERED:"已完成",CANCELLED:"已取消"})[t]??t}function Le(t){b.replaceChildren(Oe(t,"result",0))}function Oe(t,e,r){if(t!==null&&typeof t=="object"){const d=Array.isArray(t)?t.map((S,g)=>[String(g),S]):Object.entries(t),a=document.createElement("details");a.className="tree-branch",a.open=r===0;const c=document.createElement("summary"),m=document.createElement("span");m.className="tree-key",m.textContent=e;const h=document.createElement("span");h.className="tree-preview",h.textContent=ht(t,d.length),c.append(m,h),a.append(c);const l=document.createElement("div");l.className="tree-children";for(const[S,g]of d)l.append(Oe(g,Array.isArray(t)?`#${Number(S)+1}`:S,r+1));return a.append(l),a}const n=document.createElement("div");n.className="tree-leaf";const o=document.createElement("span");o.className="tree-key",o.textContent=e;const s=document.createElement("span");return s.className=`tree-value tree-${t===null?"null":typeof t}`,s.textContent=t===null?"null":typeof t=="string"?`“${t}”`:String(t),n.append(o,s),n}function ht(t,e){if(Array.isArray(t))return i==="en"?`${e} items`:`${e} 项`;const r=t,n=r.orderNumber??r.name??r.productName??r.transactionId??r.trackingNumber;return n?String(n):i==="en"?`${e} fields`:`${e} 个字段`}function gt(t){return Array.isArray(t)?t.length:Array.isArray(t?.data)?t.data.length:1}function Pe(t,e,r){const n=e.view==="dashboard"?t.filteredOrders:gt(t),o=i==="en"?`${n} ${e.view==="dashboard"?`matching order${n===1?"":"s"}`:`result${n===1?"":"s"}`}`:`${n} 条${e.view==="dashboard"?"匹配订单":"结果"}`;J.textContent=`${o} · ${r} ms · ${i==="en"?"in-browser SQLite":"浏览器内 SQLite"}`}function De(t){const e=he.filter(r=>r.entity==="CustomerOrder").length;k.textContent=i==="en"?`${t.toUpperCase()} · ${e} orders · 7 entities · policy installed · ready`:`${t.toUpperCase()} · ${e} 个订单 · 7 个实体 · 已安装策略 · 就绪`}function ve(){document.documentElement.lang=i==="en"?"en":"zh-CN",document.title=i==="en"?"TeaQL Order Query Playground":"TeaQL 订单查询演练场";const t=document.querySelector('meta[name="description"]');if(t&&(t.content=i==="en"?"A TeaQL order-query playground running entirely in the browser":"完全运行在浏览器中的 TeaQL 订单查询演练场"),document.querySelectorAll("[data-i18n]").forEach(e=>{const r=e.dataset.i18n;r&&(e.textContent=st(r))}),Ae.forEach(e=>{const r=e.dataset.locale===i;e.classList.toggle("active",r),e.setAttribute("aria-pressed",String(r))}),document.querySelector(".language-switch")?.setAttribute("aria-label",i==="en"?"Language":"语言"),document.querySelector(".brand")?.setAttribute("aria-label",i==="en"?"TeaQL Playground home":"TeaQL 演练场首页"),document.querySelector(".model-map")?.setAttribute("aria-label",i==="en"?"Order domain model":"订单领域模型"),document.querySelector(".runtime-bar")?.setAttribute("aria-label",i==="en"?"Runtime settings":"运行时设置"),F.setAttribute("aria-label",i==="en"?"Example queries":"示例查询"),document.querySelector(".result-view-switch")?.setAttribute("aria-label",i==="en"?"Result views":"结果视图"),document.querySelector(".tree-actions")?.setAttribute("aria-label",i==="en"?"Result tree actions":"结果树操作"),dt(),v){const{data:e,query:r,active:n}=v;ge.textContent=O(r.title),fe.textContent=O(r.description),z(),Ee(n.evidence.snapshot(),ee),Pe(e,r,Se),De(B.checked?"opfs":"memory")}else k.textContent=i==="en"?"Starting SQLite/WASM…":"正在启动 SQLite/WASM…"}function re(){return pe.find(t=>t.id===W)??pe[0]}async function qe(t){k.textContent=i==="en"?`Opening ${t.toUpperCase()} SQLite/WASM…`:`正在打开 ${t.toUpperCase()} SQLite/WASM…`;const e=E;E=void 0,await e?.client.close();const r=await it(t);E=r,await be(r),await P(re(),r),De(t)}B.addEventListener("change",()=>{const t=B.checked?"opfs":"memory";localStorage.setItem("teaql-browser-storage",t),qe(t).catch(N)});Y.addEventListener("click",async()=>{if(E){Y.disabled=!0;try{await E.client.reset(E.context),await be(E),await P(re(),E)}catch(t){N(t)}finally{Y.disabled=!1}}});X.addEventListener("click",()=>{b.querySelectorAll("details").forEach(t=>{t.open=!0})});Q.addEventListener("click",()=>{Q.disabled||(w="table",z())});H.addEventListener("click",()=>{w="tree",z()});tt.addEventListener("click",()=>{b.querySelectorAll("details").forEach((t,e)=>{t.open=e===0})});Ae.forEach(t=>{t.addEventListener("click",()=>{i=t.dataset.locale==="zh"?"zh":"en",localStorage.setItem("teaql-browser-locale",i),ve()})});function N(t){const e=t instanceof Error?t:new Error(String(t));k.textContent=`${e.name}: ${e.message}`,J.textContent=i==="en"?"Query failed":"查询失败",Le({error:e.name,message:e.message})}ve();W=re().id;V();qe(Ce).catch(N);
|
|
|
|
| 1 |
+
import{S as x,m as Te,a as qe,e as xe,O as $,B as Qe,b as Re,R as $e,U as Be,D as Fe,c as ke,M as We}from"./dynamic-search-Ch_QcWVU.js";/* empty css */const C=t=>({columnName:t,modelName:t,logicalType:"integer",decode:"string"}),y=t=>({columnName:t,modelName:t,logicalType:"text",decode:"native"}),ze=t=>({columnName:t,modelName:t,logicalType:"date",decode:"date"}),K=t=>({columnName:t,modelName:t,logicalType:"datetime",decode:"date"}),I=(t,e="decimal")=>({columnName:t,modelName:t,logicalType:e,decode:"number"}),f=Object.freeze({PENDING_PAYMENT:"1001",PAID:"1002",SHIPPED:"1003",DELIVERED:"1004",CANCELLED:"1005"}),Me=[{entity:"OrderStatus",id:f.PENDING_PAYMENT,values:{name:"Pending payment",code:"PENDING_PAYMENT",color:"#D97706",displayOrder:10}},{entity:"OrderStatus",id:f.PAID,values:{name:"Paid",code:"PAID",color:"#2563EB",displayOrder:20}},{entity:"OrderStatus",id:f.SHIPPED,values:{name:"Shipped",code:"SHIPPED",color:"#16A34A",displayOrder:30}},{entity:"OrderStatus",id:f.DELIVERED,values:{name:"Delivered",code:"DELIVERED",color:"#047857",displayOrder:40}},{entity:"OrderStatus",id:f.CANCELLED,values:{name:"Cancelled",code:"CANCELLED",color:"#9F1239",displayOrder:50}}],ie={Platform:{table:"platform_data",columns:{id:C("id"),name:y("name"),code:y("code"),region:y("region"),currency:y("currency"),version:I("version","integer")},relations:{customerList:{targetEntity:"Customer",localKey:"id",foreignKey:"platformId",many:!0},orderList:{targetEntity:"CustomerOrder",localKey:"id",foreignKey:"platformId",many:!0}}},Customer:{table:"customer_data",columns:{id:C("id"),name:y("name"),email:y("email"),city:y("city"),tier:y("tier"),platformId:C("platform_id"),version:I("version","integer")},relations:{platform:{targetEntity:"Platform",localKey:"platformId",foreignKey:"id",many:!1},orderList:{targetEntity:"CustomerOrder",localKey:"id",foreignKey:"customerId",many:!0}}},CustomerOrder:{table:"customer_order_data",columns:{id:C("id"),orderNumber:y("order_number"),orderDate:ze("order_date"),status:C("status_id"),totalAmount:I("total_amount"),currency:y("currency"),customerId:C("customer_id"),platformId:C("platform_id"),version:I("version","integer")},relations:{platform:{targetEntity:"Platform",localKey:"platformId",foreignKey:"id",many:!1},customer:{targetEntity:"Customer",localKey:"customerId",foreignKey:"id",many:!1},status:{targetEntity:"OrderStatus",localKey:"status",foreignKey:"id",many:!1},itemList:{targetEntity:"OrderItem",localKey:"id",foreignKey:"orderId",many:!0},paymentList:{targetEntity:"Payment",localKey:"id",foreignKey:"orderId",many:!0},shipmentList:{targetEntity:"Shipment",localKey:"id",foreignKey:"orderId",many:!0}}},OrderStatus:{table:"order_status_data",columns:{id:C("id"),name:y("name"),code:y("code"),color:y("color"),displayOrder:I("display_order","integer"),version:I("version","integer")},relations:{orderList:{targetEntity:"CustomerOrder",localKey:"id",foreignKey:"status",many:!0}}},OrderItem:{table:"order_item_data",columns:{id:C("id"),orderId:C("order_id"),productName:y("product_name"),sku:y("sku"),quantity:I("quantity","integer"),unitPrice:I("unit_price"),lineAmount:I("line_amount"),version:I("version","integer")},relations:{order:{targetEntity:"CustomerOrder",localKey:"orderId",foreignKey:"id",many:!1}}},Payment:{table:"payment_data",columns:{id:C("id"),orderId:C("order_id"),provider:y("provider"),status:y("status"),amount:I("amount"),currency:y("currency"),transactionId:y("transaction_id"),paidAt:K("paid_at"),version:I("version","integer")},relations:{order:{targetEntity:"CustomerOrder",localKey:"orderId",foreignKey:"id",many:!1}}},Shipment:{table:"shipment_data",columns:{id:C("id"),orderId:C("order_id"),carrier:y("carrier"),status:y("status"),trackingNumber:y("tracking_number"),shipToCity:y("ship_to_city"),shippedAt:K("shipped_at"),deliveredAt:K("delivered_at"),version:I("version","integer")},relations:{order:{targetEntity:"CustomerOrder",localKey:"orderId",foreignKey:"id",many:!1}}}},pe=[{entity:"Platform",id:"1",payload:{name:"TeaQL Store",code:"TEAQL-CN",region:"China",currency:"CNY"}},{entity:"Platform",id:"2",payload:{name:"TeaQL Global",code:"TEAQL-GLOBAL",region:"Global",currency:"USD"}},{entity:"Customer",id:"101",payload:{name:"Lin Xiao",email:"lin.xiao@example.com",city:"Shanghai",tier:"GOLD",platformId:"1"}},{entity:"Customer",id:"102",payload:{name:"Zhou Ran",email:"zhou.ran@example.com",city:"Hangzhou",tier:"SILVER",platformId:"1"}},{entity:"Customer",id:"103",payload:{name:"Maya Patel",email:"maya.patel@example.com",city:"Singapore",tier:"GOLD",platformId:"2"}},{entity:"Customer",id:"104",payload:{name:"Lucas Martin",email:"lucas.martin@example.com",city:"Paris",tier:"SILVER",platformId:"2"}},{entity:"Customer",id:"105",payload:{name:"Wang Ning",email:"wang.ning@example.com",city:"Chengdu",tier:"BRONZE",platformId:"1"}},{entity:"CustomerOrder",id:"1001",payload:{orderNumber:"TQL-2026-1001",orderDate:"2026-08-28",status:f.DELIVERED,totalAmount:499,currency:"CNY",customerId:"101",platformId:"1"}},{entity:"CustomerOrder",id:"1002",payload:{orderNumber:"TQL-2026-1002",orderDate:"2026-09-02",status:f.SHIPPED,totalAmount:1299,currency:"CNY",customerId:"102",platformId:"1"}},{entity:"CustomerOrder",id:"1003",payload:{orderNumber:"TQL-2026-1003",orderDate:"2026-09-06",status:f.PAID,totalAmount:328.8,currency:"CNY",customerId:"101",platformId:"1"}},{entity:"CustomerOrder",id:"1004",payload:{orderNumber:"TQL-2026-1004",orderDate:"2026-09-11",status:f.PENDING_PAYMENT,totalAmount:79.9,currency:"CNY",customerId:"105",platformId:"1"}},{entity:"CustomerOrder",id:"1005",payload:{orderNumber:"TQL-2026-1005",orderDate:"2026-09-14",status:f.DELIVERED,totalAmount:219,currency:"USD",customerId:"103",platformId:"2"}},{entity:"CustomerOrder",id:"1006",payload:{orderNumber:"TQL-2026-1006",orderDate:"2026-09-18",status:f.PAID,totalAmount:640,currency:"USD",customerId:"104",platformId:"2"}},{entity:"CustomerOrder",id:"1007",payload:{orderNumber:"TQL-2026-1007",orderDate:"2026-09-21",status:f.CANCELLED,totalAmount:159,currency:"CNY",customerId:"102",platformId:"1"}},{entity:"CustomerOrder",id:"1008",payload:{orderNumber:"TQL-2026-1008",orderDate:"2026-09-25",status:f.SHIPPED,totalAmount:268,currency:"CNY",customerId:"105",platformId:"1"}},{entity:"OrderItem",id:"2001",payload:{orderId:"1001",productName:"TeaQL Mechanical Keyboard",sku:"KB-TQL-87",quantity:1,unitPrice:299,lineAmount:299}},{entity:"OrderItem",id:"2002",payload:{orderId:"1001",productName:"Silent Wireless Mouse",sku:"MS-SILENT",quantity:2,unitPrice:100,lineAmount:200}},{entity:"OrderItem",id:"2003",payload:{orderId:"1002",productName:"27-inch Developer Monitor",sku:"MON-27-4K",quantity:1,unitPrice:1299,lineAmount:1299}},{entity:"OrderItem",id:"2004",payload:{orderId:"1003",productName:"White Porcelain Travel Tea Set",sku:"TEA-TRAVEL",quantity:1,unitPrice:168.8,lineAmount:168.8}},{entity:"OrderItem",id:"2005",payload:{orderId:"1003",productName:"Pre-Qingming Longjing Tea",sku:"TEA-LJ-100",quantity:2,unitPrice:80,lineAmount:160}},{entity:"OrderItem",id:"2006",payload:{orderId:"1004",productName:"Double-wall Glass Tumbler",sku:"CUP-GLASS",quantity:1,unitPrice:79.9,lineAmount:79.9}},{entity:"OrderItem",id:"2007",payload:{orderId:"1005",productName:"Travel Brew Kit",sku:"BREW-KIT",quantity:1,unitPrice:219,lineAmount:219}},{entity:"OrderItem",id:"2008",payload:{orderId:"1006",productName:"Desktop Studio Speaker",sku:"SPK-STUDIO",quantity:2,unitPrice:260,lineAmount:520}},{entity:"OrderItem",id:"2009",payload:{orderId:"1006",productName:"Speaker Stand",sku:"SPK-STAND",quantity:1,unitPrice:120,lineAmount:120}},{entity:"OrderItem",id:"2010",payload:{orderId:"1007",productName:"Desktop Reading Lamp",sku:"LAMP-DESK",quantity:1,unitPrice:159,lineAmount:159}},{entity:"OrderItem",id:"2011",payload:{orderId:"1008",productName:"TeaQL Portable Keyboard",sku:"KB-TQL-68",quantity:1,unitPrice:268,lineAmount:268}},{entity:"Payment",id:"3001",payload:{orderId:"1001",provider:"Alipay",status:"CAPTURED",amount:499,currency:"CNY",transactionId:"ALI-260828-01",paidAt:"2026-08-28T10:14:00Z"}},{entity:"Payment",id:"3002",payload:{orderId:"1002",provider:"WeChat Pay",status:"CAPTURED",amount:1299,currency:"CNY",transactionId:"WX-260902-08",paidAt:"2026-09-02T03:20:00Z"}},{entity:"Payment",id:"3003",payload:{orderId:"1003",provider:"Alipay",status:"CAPTURED",amount:328.8,currency:"CNY",transactionId:"ALI-260906-11",paidAt:"2026-09-06T11:42:00Z"}},{entity:"Payment",id:"3004",payload:{orderId:"1004",provider:"WeChat Pay",status:"PENDING",amount:79.9,currency:"CNY",transactionId:"WX-260911-02",paidAt:null}},{entity:"Payment",id:"3005",payload:{orderId:"1005",provider:"Stripe",status:"CAPTURED",amount:219,currency:"USD",transactionId:"PI-260914-05",paidAt:"2026-09-14T06:10:00Z"}},{entity:"Payment",id:"3006",payload:{orderId:"1006",provider:"Stripe",status:"CAPTURED",amount:640,currency:"USD",transactionId:"PI-260918-03",paidAt:"2026-09-18T15:08:00Z"}},{entity:"Payment",id:"3007",payload:{orderId:"1007",provider:"Alipay",status:"REFUNDED",amount:159,currency:"CNY",transactionId:"ALI-260921-07",paidAt:"2026-09-21T02:55:00Z"}},{entity:"Payment",id:"3008",payload:{orderId:"1008",provider:"WeChat Pay",status:"CAPTURED",amount:268,currency:"CNY",transactionId:"WX-260925-06",paidAt:"2026-09-25T08:31:00Z"}},{entity:"Shipment",id:"4001",payload:{orderId:"1001",carrier:"SF Express",status:"DELIVERED",trackingNumber:"SF2608281001",shipToCity:"Shanghai",shippedAt:"2026-08-29T02:00:00Z",deliveredAt:"2026-08-30T07:26:00Z"}},{entity:"Shipment",id:"4002",payload:{orderId:"1002",carrier:"JD Logistics",status:"IN_TRANSIT",trackingNumber:"JD2609021002",shipToCity:"Hangzhou",shippedAt:"2026-09-03T04:12:00Z",deliveredAt:null}},{entity:"Shipment",id:"4003",payload:{orderId:"1003",carrier:"SF Express",status:"READY",trackingNumber:"SF2609061003",shipToCity:"Shanghai",shippedAt:null,deliveredAt:null}},{entity:"Shipment",id:"4004",payload:{orderId:"1005",carrier:"DHL",status:"DELIVERED",trackingNumber:"DHL2609141005",shipToCity:"Singapore",shippedAt:"2026-09-15T01:10:00Z",deliveredAt:"2026-09-17T09:22:00Z"}},{entity:"Shipment",id:"4005",payload:{orderId:"1006",carrier:"DHL",status:"READY",trackingNumber:"DHL2609181006",shipToCity:"Paris",shippedAt:null,deliveredAt:null}},{entity:"Shipment",id:"4006",payload:{orderId:"1008",carrier:"SF Express",status:"IN_TRANSIT",trackingNumber:"SF2609251008",shipToCity:"Chengdu",shippedAt:"2026-09-26T03:18:00Z",deliveredAt:null}}],L=t=>`'${t.replaceAll("\\","\\\\").replaceAll("'","\\'").replaceAll(`
|
| 2 |
+
`,"\\n")}'`,U=t=>t.toQExpression().replace(/\s*\n\s*/g,""),_e={CustomerOrder:{fields:{id:"integer",orderNumber:"string",orderDate:"date",status:"integer",totalAmount:"decimal",currency:"string",customerId:"integer",platformId:"integer"},relations:{status:"OrderStatus",itemList:"OrderItem"}},OrderStatus:{fields:{id:"integer",name:"string",code:"string",color:"string",displayOrder:"integer"},relations:{}},OrderItem:{fields:{id:"integer",orderId:"integer",productName:"string",sku:"string"},relations:{}}};function Ke(t){if(!t||typeof t!="object"||Array.isArray(t))return t;const e=structuredClone(t),r=e.filter;if(!r||typeof r!="object"||Array.isArray(r)||!("status"in r))return e;const n=r,s=n.status,o=a=>{const i=f[String(a)];return i===void 0?a:Number(i)};return s&&typeof s=="object"&&!Array.isArray(s)&&"$in"in s?n.status={$in:Array.isArray(s.$in)?s.$in.map(o):s.$in}:n.status=o(s),e}class P{query;filters=[];qRoot;qSteps=[];auditComment="";queryPurpose="";pageTotalAlias;constructor(e,r){this.query=new x(e),this.qRoot=r}comment(e){return this.auditComment=e,this.query.comment(e),this.record(`comment(${L(e)})`),this}purpose(e){return this.queryPurpose=e,this.query.purpose(e),this.record(`purpose(${L(e)})`),this}limit(e){return this.query.limit(e),this.record(`limit(${e})`),this}offset(e){return this.query.offset(e),this.record(`offset(${e})`),this}toQExpression(e){const r=e?[...this.qSteps,e]:this.qSteps;return[this.qRoot,...r.map(n=>` .${n}`)].join(`
|
| 3 |
+
`)}toQuery(){const e=this.query.clone();return this.filters.length&&e.filter({$and:[...this.filters]}),e}async executeForList(e){return this.executeList(e,this.pageTotalAlias!==void 0)}async executeForRows(e){return this.executeList(e,!1)}async executeList(e,r){this.ensureIntent();const n=this.service(e),s=this.toQuery(),o=r?await n.executeCount(s,this.pageTotalAlias,{kind:"named-count",method:"countAs",alias:this.pageTotalAlias}):void 0,a=s.clone();r&&(a.aggregateItems=a.aggregateItems.filter(l=>!(String(l.function).toLowerCase()==="count"&&l.alias===this.pageTotalAlias)));const i=await n.executeQuery(e.prepareQuery(a)),c=new qe(i,{totalCount:o});return r&&this.pageTotalAlias!==void 0&&(c.aggregations[this.pageTotalAlias]=o),s.facets.length&&(c.facets=await xe(n,l=>e.prepareQuery(l),s,s.facets)),c}addFilter(e){return this.filters.push(e),this}select(...e){return this.query.select(e),this}order(e,r){return this.query.order(r==="asc"?$.asc(e):$.desc(e)),this}group(e){return this.query.groupBy(e),this}aggregate(e,r,n){return this.query.aggregate(e,r,n),this}record(e){return this.qSteps.push(e),this}includePageTotalAs(e){return this.pageTotalAlias=e,this}service(e){return e.requireResource("dataService")}ensureIntent(){if(!this.auditComment.trim()||!this.queryPurpose.trim())throw new Error("Generated Q requests require comment() and purpose() before execution")}}class Ue extends P{constructor(){super("Platform","Q.platforms()")}selectId(){return this.select("id")}selectName(){return this.select("name")}selectCode(){return this.select("code")}withIdIs(e){return this.addFilter({id:{$eq:e}})}}class Ye extends P{constructor(){super("Customer","Q.customers()")}selectId(){return this.select("id")}selectName(){return this.select("name")}selectCity(){return this.select("city")}selectTier(){return this.select("tier")}selectPlatformWith(e){return this.query.relationQuery("platform",e.toQuery(),"platformId","id",!1),this}countOrderListAs(e){return this.query.relationAggregate("orderList",e,new x("CustomerOrder").aggregate("Count","id",e)),this}orderByNameAscending(){return this.order("name","asc")}}class Ge extends P{constructor(){super("OrderItem","Q.orderItems()")}selectId(){return this.select("id"),this.record("selectId()")}selectOrderId(){return this.select("orderId"),this.record("selectOrderId()")}selectProductName(){return this.select("productName"),this.record("selectProductName()")}selectSku(){return this.select("sku"),this.record("selectSku()")}selectQuantity(){return this.select("quantity"),this.record("selectQuantity()")}withProductNameContaining(e){return this.addFilter({productName:{$contains:e}})}orderByIdAscending(){return this.order("id","asc"),this.record("orderByIdAscending()")}groupByProductName(){return this.group("productName")}sumQuantityAs(e){return this.aggregate("Sum","quantity",e)}sumLineAmountAs(e){return this.aggregate("Sum","lineAmount",e)}countAs(e){return this.aggregate("Count","id",e)}}class je extends P{constructor(){super("OrderStatus","Q.orderStatuses()")}selectId(){return this.select("id"),this.record("selectId()")}selectName(){return this.select("name"),this.record("selectName()")}selectCode(){return this.select("code"),this.record("selectCode()")}selectColor(){return this.select("color"),this.record("selectColor()")}selectDisplayOrder(){return this.select("displayOrder"),this.record("selectDisplayOrder()")}withCodeIs(e){return this.addFilter({code:{$eq:e}})}countAs(e){return this.aggregate("Count","id",e),this.record(`countAs(${L(e)})`)}sumOrderTotalAmountAs(e){return this.aggregate("Sum","totalAmount",e),this.record(`sumOrderTotalAmountAs(${L(e)})`)}orderByDisplayOrderAscending(){return this.order("displayOrder","asc"),this.record("orderByDisplayOrderAscending()")}}class Ve extends P{constructor(){super("Payment","Q.payments()")}groupByCurrency(){return this.group("currency")}groupByProvider(){return this.group("provider")}groupByStatus(){return this.group("status")}countAs(e){return this.aggregate("Count","id",e)}sumAmountAs(e){return this.aggregate("Sum","amount",e)}orderByCurrencyAscending(){return this.order("currency","asc")}orderByProviderAscending(){return this.order("provider","asc")}orderByIdAscending(){return this.order("id","asc")}}class He extends P{constructor(){super("Shipment","Q.shipments()")}withStatusIn(...e){return this.addFilter({status:{$in:e}})}selectOrderWith(e){return this.query.relationQuery("order",e.toQuery(),"orderId","id",!1),this}orderByStatusAscending(){return this.order("status","asc")}orderByIdAscending(){return this.order("id","asc")}}class de extends P{dynamicWarnings=[];countAlias;rowCountApplied=!1;constructor(e=!1){super("CustomerOrder",e?"Q.customerOrdersWithMinimalFields()":"Q.customerOrders()"),e?this.query.select(["id","version"]):this.query.select(["id","orderNumber","orderDate","status","totalAmount","currency","customerId","platformId","version"])}selectId(){return this.select("id")}selectOrderNumber(){return this.select("orderNumber"),this.record("selectOrderNumber()")}selectOrderDate(){return this.select("orderDate"),this.record("selectOrderDate()")}selectStatus(){return this.select("status")}selectTotalAmount(){return this.select("totalAmount")}selectCurrency(){return this.select("currency")}withOrderNumberIs(e){return this.addFilter({orderNumber:{$eq:e}})}withOrderNumberContaining(e){return this.addFilter({orderNumber:{$contains:e}})}withStatusMatching(e){return this.addFilter({status:{$inSubquery:{query:e.toQuery(),field:"id"}}})}withStatusIsPendingPayment(){return this.addFilter({status:{$eq:f.PENDING_PAYMENT}})}withStatusIsPaid(){return this.addFilter({status:{$eq:f.PAID}})}withStatusIsShipped(){return this.addFilter({status:{$eq:f.SHIPPED}})}withStatusIsDelivered(){return this.addFilter({status:{$eq:f.DELIVERED}})}withStatusIsCancelled(){return this.addFilter({status:{$eq:f.CANCELLED}})}withCurrencyIs(e){return this.addFilter({currency:{$eq:e}})}withTotalAmountGreaterThanOrEqualTo(e){return this.addFilter({totalAmount:{$gte:e}})}withOrderDateGreaterThanOrEqualTo(e){return this.addFilter({orderDate:{$gte:e}})}withPlatformIdIs(e){return this.addFilter({platformId:{$eq:e}})}withItemListMatching(e){return this.addFilter({id:{$inSubquery:{query:e.toQuery(),field:"orderId"}}})}filterByJson(e){const{query:r,warnings:n}=Te(this.toQuery(),Ke(e),_e,{filter:(s,o)=>s==="status.code"?{status:{$inSubquery:{query:new x("OrderStatus").filter({code:o}),field:"id"}}}:s==="itemList.productName"?{id:{$inSubquery:{query:new x("OrderItem").filter({productName:o}),field:"orderId"}}}:{[s]:o},order:(s,o)=>o==="asc"?$.asc(s):$.desc(s)});return this.dynamicWarnings=n,this.query.filterCondition=r.filterCondition,this.query.orderItems=[...r.orderItems],this.record("filterByJson(searchParams)"),this}warnings(){return this.dynamicWarnings}selectPlatformWith(e){return this.query.relationQuery("platform",e.toQuery(),"platformId","id",!1),this}selectCustomerWith(e){return this.query.relationQuery("customer",e.toQuery(),"customerId","id",!1),this}selectStatusWith(e){return this.query.select(["status"]),this.query.relationQuery("status",e.toQuery(),"status","id",!1,{kind:"relation-select",method:"selectStatusWith",relation:"status"}),this.record(`selectStatusWith(${U(e)})`)}selectItemListWith(e){return this.query.relationQuery("itemList",e.toQuery(),"id","orderId",!0,{kind:"relation-select",method:"selectItemListWith",relation:"itemList"}),this.record(`selectItemListWith(${U(e)})`)}selectPaymentListWith(e){return this.query.relationQuery("paymentList",e.toQuery(),"id","orderId",!0),this}selectShipmentListWith(e){return this.query.relationQuery("shipmentList",e.toQuery(),"id","orderId",!0),this}countItemListAs(e){return this.query.relationAggregate("itemList",e,new x("OrderItem").aggregate("Count","id",e).comment("count items"),!0,{kind:"relation-count",method:"countItemListAs",relation:"itemList",alias:e}),this.record(`countItemListAs(${L(e)})`)}facetByStatusAs(e,r,n=!0){const s=r.toQuery();return s.commentText||s.comment("load status facets"),this.query.facetBy(e,"status",{toQuery:()=>s},n,{kind:"facet",method:"facetByStatusAs",relation:"status",alias:e}),this.record(`facetByStatusAs(${L(e)}, ${U(r)})`)}orderByOrderDateDescending(){return this.order("orderDate","desc"),this.record("orderByOrderDateDescending()")}orderByOrderDateAscending(){return this.order("orderDate","asc")}orderByIdDescending(){return this.order("id","desc"),this.record("orderByIdDescending()")}orderByTotalAmountDescending(){return this.order("totalAmount","desc")}groupByCurrency(){return this.group("currency")}groupByStatus(){return this.group("status")}countAs(e){return this.countAlias=e,this.record(`countAs(${L(e)})`)}sumTotalAmountAs(e){return this.aggregate("Sum","totalAmount",e)}averageTotalAmountAs(e){return this.aggregate("Avg","totalAmount",e)}executeForList(e){return this.countAlias&&this.includePageTotalAs(this.countAlias),super.executeForList(e)}executeForRows(e){return this.applyRowCount(),super.executeForRows(e)}applyRowCount(){!this.countAlias||this.rowCountApplied||(this.query.aggregate("Count","id",this.countAlias),this.rowCountApplied=!0)}}class u{static platforms(){return new Ue}static customers(){return new Ye}static customerOrders(){return new de}static customerOrdersWithMinimalFields(){return new de(!0)}static orderItems(){return new Ge}static orderStatuses(){return new je}static payments(){return new Ve}static shipments(){return new He}}const k=document.querySelector("#status"),B=document.querySelector("#persist"),Y=document.querySelector("#reset"),F=document.querySelector("#query-catalog"),b=document.querySelector("#result"),ye=document.querySelector("#result-title"),he=document.querySelector("#result-description"),J=document.querySelector("#result-meta"),ce=document.querySelector("#query-code"),Ze=document.querySelector("#query-params-block"),Je=document.querySelector("#query-params-code"),Xe=document.querySelector("#result-grid"),R=document.querySelector("#result-view-label"),et=document.querySelector("#sql-count"),ue=document.querySelector("#sql-output"),X=document.querySelector("#expand-all"),tt=document.querySelector("#collapse-all"),Q=document.querySelector("#view-table"),V=document.querySelector("#view-tree"),ge=Array.from(document.querySelectorAll("[data-locale]")),rt={heroTitle:{en:"Understand TeaQL queries through a familiar order model.",zh:"用一个熟悉的订单模型,看懂 TeaQL 查询。"},heroIntro:{en:"Platform, customer, order, item, payment, and shipment data all run in the browser. Order status is backed by a constant model. Choose a query below to inspect real SQLite/WASM results.",zh:"平台、用户、订单、明细、支付和物流数据都在浏览器中运行;订单状态由常数模型提供。选择下面的查询,查看真实的 SQLite/WASM 结果。"},runtimeCoverage:{en:"RUNTIME COVERAGE",zh:"RUNTIME 覆盖"},runtimeTitle:{en:"This demo runs TypeScript in your browser.",zh:"这个演示在浏览器中运行 TypeScript。"},runtimeIntro:{en:"The same model-driven Q and TraceChain contract is supported by seven TeaQL runtimes. Select a language to inspect its runtime source.",zh:"同一套模型驱动的 Q 与 TraceChain 契约支持七种 TeaQL runtime。选择一种语言,可以查看对应的 runtime 源码。"},currentBrowserRuntime:{en:"Current browser runtime",zh:"当前浏览器 runtime"},supportedRuntime:{en:"Supported runtime",zh:"已支持 runtime"},platform:{en:"Platform",zh:"平台"},customer:{en:"Customer",zh:"用户"},order:{en:"Order",zh:"订单"},item:{en:"Item",zh:"明细"},payment:{en:"Payment",zh:"支付"},shipment:{en:"Shipment",zh:"物流"},constantModel:{en:"Constant model",zh:"常数模型"},persist:{en:"Persist locally with OPFS",zh:"使用 OPFS 保存在本地"},reset:{en:"Reset demo data",zh:"重置演示数据"},chooseQuery:{en:"Choose a query",zh:"选择一个查询"},queryIntro:{en:"Queries are grouped by purpose and share the same order dataset.",zh:"查询按用途分组,并共用同一份订单数据。"},table:{en:"Table",zh:"表格"},resultTree:{en:"Result Tree",zh:"结果树"},expandAll:{en:"Expand all",zh:"全部展开"},collapseAll:{en:"Collapse all",zh:"全部折叠"},waiting:{en:"Waiting for query…",zh:"等待查询…"},queryNote:{en:"The Q expression stays fixed; search, status cards, and pagination only update dynamic parameters. The underlying SelectQuery remains inside the generated request implementation.",zh:"Q 表达式保持不变;搜索、状态卡片和分页只更新动态参数。底层 SelectQuery 仍封装在生成的请求实现中。"},executionEvidence:{en:"EXECUTION EVIDENCE",zh:"执行证据"},evidenceTime:{en:"Time",zh:"时间"},identity:{en:"Identity",zh:"身份"},traceChain:{en:"Trace chain",zh:"追踪链"},sqlNote:{en:"One plain-text line per statement: time, identity, trace chain, and the SQL SQLite executed.",zh:"每条语句使用一行纯文本:时间、身份、追踪链,以及 SQLite 实际执行的 SQL。"},localData:{en:"Data stays in this browser",zh:"数据只保留在当前浏览器中"}},nt={基本查询:"Basic queries","从订单、用户和关联对象开始":"Start with orders, customers, and related objects",汇总查询:"Aggregations","分组、计数、求和与平均值":"Grouping, counts, sums, and averages",过滤查询:"Filtered queries","精确、范围与组合条件":"Exact, range, and combined predicates",动态查询:"Dynamic queries","由页面条件安全生成,不使用 eval":"Safely generated from page criteria without eval","综合:订单管理中心":"Comprehensive: Order management center","一个真实的综合查询页面:状态指标、搜索、商品预览和分页都由 TeaQL 查询驱动。":"A real composite query page: status metrics, search, product previews, and pagination are all driven by TeaQL.",最近订单:"Recent orders","按下单日期倒序浏览全部订单,并带出所属平台与用户。":"Browse all orders by date descending, including their platform and customer.",完整订单详情:"Complete order details","查看一个订单及其用户、商品明细、支付和物流,体现完整对象图。":"Inspect one order with its customer, items, payments, and shipments as a complete object graph.",用户与订单数:"Customers with order counts","列出用户,并通过关联汇总显示每位用户的订单数量。":"List customers and show each customer’s order count through a relation aggregate.",订单状态汇总:"Orders by status","按币种与订单状态统计订单数、总额和平均客单价。":"Aggregate order count, gross amount, and average order value by currency and status.",商品销售汇总:"Product sales summary","按商品汇总销量与销售额,找出最受欢迎的订单明细。":"Aggregate units and revenue by product to identify the most popular order items.",支付渠道对账:"Payment reconciliation","按币种、支付渠道和状态汇总笔数与金额。":"Aggregate transaction count and amount by currency, payment provider, and status.",待支付订单:"Orders awaiting payment","筛选尚未完成付款的订单,并带出对应支付记录。":"Find orders that have not completed payment and include their payment records.",国内大额订单:"High-value domestic orders","组合平台与金额条件,找出 TeaQL 商城中金额不低于 500 元的订单。":"Combine platform and amount filters to find TeaQL Store orders worth at least CNY 500.",运输中的包裹:"Active shipments","筛选待揽收和运输中的物流单,并关联订单信息。":"Find shipments that are ready or in transit and include their order information.","动态:已付款国内订单":"Dynamic: paid domestic orders","从动态条件对象生成查询:人民币、金额至少 250,且状态为已付款或已发货。":"Build a query from dynamic criteria: CNY, at least 250, and status PAID or SHIPPED.","动态:九月新订单":"Dynamic: new September orders","运行时传入日期范围与排序方式,查询 9 月 15 日之后的订单。":"Pass a date range and sort order at runtime to find orders after September 15.","动态:字段白名单":"Dynamic: field allowlist","未知字段会被报告并忽略;合法条件仍可安全执行。":"Unknown fields are reported and ignored while valid predicates still execute safely."};let d=localStorage.getItem("teaql-browser-locale")==="zh"?"zh":"en";function st(t){return rt[t]?.[d]??t}function O(t){return d==="en"?nt[t]??t:t}let E,W=window.location.hash.slice(1)||"order-center";window.location.hash||history.replaceState(null,"","#order-center");let w="tree",v,fe=0,ee;const A={search:"",page:0,pageSize:4},Ae=localStorage.getItem("teaql-browser-storage")==="opfs"?"opfs":"memory";B.checked=Ae==="opfs";async function G(t,e){const r=u.customerOrders().filterByJson(e).limit(20).comment("what: execute a validated browser search").purpose("why: demonstrate safe dynamic order discovery"),n=await r.executeForList(t.context);return{request:e,warnings:r.warnings(),data:n}}const ot=Object.fromEntries(Object.entries(f).map(([t,e])=>[e,t]));function te(t){const e=String(t.code??"");return e&&e in f?e:"color"in t?ot[String(t.id??"")]??"":""}function Se(t){const e=t.trim();if(!e)return{filter:{}};const r=e.toUpperCase(),n=["PENDING_PAYMENT","PAID","SHIPPED","DELIVERED","CANCELLED"].find(s=>s.includes(r));return n?{filter:{"status.code":n}}:/^(TQL-|\d)/i.test(e)?{filter:{orderNumber:{$contains:r}}}:{filter:{"itemList.productName":{$contains:e}}}}async function at(t){const e=Se(A.search),r=u.customerOrdersWithMinimalFields().filterByJson(e).countAs("totalOrders").facetByStatusAs("statusCounts",u.orderStatuses().selectName().selectColor().countAs("orderCount").sumOrderTotalAmountAs("orderTotalAmount").orderByDisplayOrderAscending().comment("load status facets")).selectOrderNumber().selectOrderDate().selectStatusWith(u.orderStatuses().selectName().selectColor().comment("load status")).selectItemListWith(u.orderItems().selectProductName().selectQuantity().orderByIdAscending().limit(3).comment("load item previews")).countItemListAs("itemCount").orderByOrderDateDescending().orderByIdDescending().comment("load order list").purpose("render order list page"),n=r.toQExpression(`offset(pageOffset)
|
| 4 |
+
.limit(pageSize)
|
| 5 |
+
.executeForList(ctx);`),s=await r.offset(A.page*A.pageSize).limit(A.pageSize).executeForList(t.context),o=s.facet("statusCounts")??[];return{orders:s,totalOrders:Number(s.aggregations.totalOrders??s.totalCount),filteredOrders:s.totalCount??0,statusFacets:o.map(a=>({code:te(a),name:String(a.name??""),color:String(a.color??""),orderCount:Number(a.orderCount??0),orderTotalAmount:Number(a.orderTotalAmount??0)})).filter(a=>a.code&&a.name),search:A.search,page:A.page,pageSize:A.pageSize,queryExpression:n}}const Ce=[{label:"基本查询",description:"从订单、用户和关联对象开始",queries:[{id:"order-center",title:"综合:订单管理中心",description:"一个真实的综合查询页面:状态指标、搜索、商品预览和分页都由 TeaQL 查询驱动。",code:"",view:"dashboard",run:at},{id:"recent-orders",title:"最近订单",description:"按下单日期倒序浏览全部订单,并带出所属平台与用户。",code:`await Q.customerOrders()
|
| 6 |
.selectPlatformWith(Q.platforms().selectName())
|
| 7 |
.selectCustomerWith(Q.customers().selectName().selectCity().selectTier())
|
| 8 |
.selectStatusWith(Q.orderStatuses().selectName().selectColor())
|
|
|
|
| 101 |
.comment('what: execute a validated browser search')
|
| 102 |
.purpose('why: demonstrate safe dynamic order discovery')
|
| 103 |
.executeForList(ctx);
|
| 104 |
+
const warnings = request.warnings();`,run:t=>G(t,{filter:{status:"DELIVERED",internalNote:{$contains:"not queryable"}}})}]}],le=Ce.flatMap(t=>t.queries);async function it(t){const e=new Worker(new URL("/assets/sqlite.worker-DS5P4U1E.js",import.meta.url),{type:"module"}),r=await Qe.open(e,{...ie},{storage:t,databaseName:"teaql-order-playground-v3.sqlite3"}),n=new Re().enableSelect();r.install(new $e(ie,{},{constants:Me})),r.setRuntimeTelemetrySink(n).setDiagnosticSQLLogSink(void 0);const s=Object.freeze({policyId:"browser-order-demo-seed",version:"1",fingerprint:"sha256:browser-order-demo-seed-v1"}),o=new Be().insertResource("dataService",r).withMutationPolicyRegistry(new Fe(()=>({identity:s,review:(a,i)=>i.operations.length>0?{verdict:"allow"}:{verdict:"deny",code:"EMPTY_GRAPH",message:"empty mutation graph"}}))).withMutationPolicyApprovalProvider(new ke(a=>({policy:a,approvedBy:"browser-demo-owner",approvedAt:new Date})));return r.setUserContext(o),await o.ensureSchema(),{client:r,context:o,evidence:n}}async function Ie(t){if((await u.customerOrders().selectId().limit(1).comment("what: detect existing order playground data").purpose("why: keep deterministic browser bootstrap idempotent").executeForList(t.context)).length)return;const r=new We("Seed deterministic order playground data");await t.client.executeGraphSave(r,async n=>{const s=pe.map(o=>n.request({entity:o.entity,action:"Create",id:o.id,payload:o.payload}));for(const o of s)t.client.preflightMutation(o);for(const o of s)await t.client.executeMutation(o)})}function dt(){F.replaceChildren();for(const t of Ce){const e=document.createElement("section");e.className="query-group";const r=document.createElement("div");r.className="query-group-heading";const n=document.createElement("h2");n.textContent=O(t.label);const s=document.createElement("p");s.textContent=O(t.description),r.append(n,s);const o=document.createElement("div");o.className="query-links";for(const a of t.queries){const i=document.createElement("a");i.href=`#${a.id}`,i.dataset.queryId=a.id,i.textContent=O(a.title),i.addEventListener("click",c=>{c.preventDefault(),W=a.id,history.replaceState(null,"",`#${a.id}`),H(),E&&D(a,E).catch(N)}),o.append(i)}e.append(r,o),F.append(e)}H()}function H(){F.querySelectorAll("a[data-query-id]").forEach(t=>{const e=t.dataset.queryId===W;t.classList.toggle("active",e),e?t.setAttribute("aria-current","page"):t.removeAttribute("aria-current")})}async function D(t,e){const r=performance.now(),n=new Date;e.evidence.enableSelect(),b.classList.add("loading"),b.setAttribute("aria-busy","true"),ye.textContent=O(t.title),he.textContent=O(t.description),ce.textContent=t.code,Ze.classList.toggle("hidden",t.view!=="dashboard"),Je.textContent=t.view==="dashboard"?JSON.stringify({searchParams:Se(A.search),pageOffset:A.page*A.pageSize,pageSize:A.pageSize},null,2):"",Xe.classList.toggle("dashboard-mode",t.view==="dashboard"),b.classList.toggle("dashboard-result",t.view==="dashboard"),X.closest(".tree-actions")?.classList.toggle("hidden",t.view==="dashboard"),R.textContent=t.view==="dashboard"?d==="en"?"Order management center":"订单管理中心":d==="en"?"Result tree":"结果树",J.textContent=d==="en"?"Running query…":"查询中…";try{const s=await t.run(e);t.view==="dashboard"&&(ce.textContent=s.queryExpression),v={data:s,query:t,active:e},w=t.view==="dashboard"||Z(s)?"table":"tree",z();const o=Math.max(1,Math.round(performance.now()-r));fe=o,ee=n;const a=e.evidence.snapshot();we(a,n),Le(s,t,o)}finally{b.classList.remove("loading"),b.removeAttribute("aria-busy")}}function we(t,e=ee){ue.replaceChildren(),et.textContent=d==="en"?`${t.length} statement${t.length===1?"":"s"}`:`${t.length} 条语句`,t.forEach((r,n)=>{const s=document.createElement("tr");s.className="evidence-row";const o=[...r.tracePath].reverse().find(m=>m.kind==="relation"||m.kind==="request"||m.kind==="entity"),a=document.createElement("td");a.className="evidence-time",a.dataset.executedAt=e?.toISOString()??"",a.textContent=`${e?.toISOString()??"—"} · ${Math.max(.01,r.elapsedMicros/1e3).toFixed(2)} ms`;const i=document.createElement("td");i.textContent=`${v?.query.id??"query"} · #${n+1} · ${o?.name??"query"}`;const c=document.createElement("td");if(c.className="evidence-trace",r.traceChain?.length){const m=r.traceChain.find(g=>g.kind==="purpose"),S=r.traceChain.filter(g=>g.kind==="comment").map(g=>g.detail||g.name);c.textContent=`${m?.detail||m?.name||""}: ${S.join(" → ")}`}else c.textContent=r.tracePath.map(m=>m.detail||m.name).join(" → ");const l=document.createElement("td");l.className="evidence-sql";const h=r.parameters.length?r.parameters.map(m=>String(m)).join(", "):"none";l.textContent=`${r.parameterizedSQL} · bindings: ${h}`,s.append(a,i,c,l),ue.append(s)})}function Z(t){return Array.isArray(t)&&t.every(e=>e!==null&&typeof e=="object"&&!Array.isArray(e))}function z(){if(!v)return;const{data:t,query:e,active:r}=v,n=e.view==="dashboard"||Z(t);if(n||(w="tree"),Q.disabled=!n,Q.classList.toggle("active",w==="table"),V.classList.toggle("active",w==="tree"),Q.setAttribute("aria-pressed",String(w==="table")),V.setAttribute("aria-pressed",String(w==="tree")),X.closest(".tree-actions")?.classList.toggle("hidden",w!=="tree"),w==="table"&&e.view==="dashboard"){R.textContent=d==="en"?"Result table":"结果表格",mt(t,r,e);return}if(w==="table"&&Z(t)){R.textContent=d==="en"?"Result table":"结果表格",ut(t);return}R.textContent=d==="en"?"Result tree":"结果树",Ee(e.view==="dashboard"?ct(t):t)}function ct(t){return{orders:t.orders,totalOrders:t.totalOrders,filteredOrders:t.filteredOrders,statusFacets:t.statusFacets,search:t.search,page:t.page,pageSize:t.pageSize}}function ut(t){const e=document.createElement("div");if(e.className="result-table-shell",!t.length){const i=document.createElement("p");i.className="result-table-empty",i.textContent=d==="en"?"The query returned no records.":"查询没有返回记录。",e.append(i),b.replaceChildren(e);return}const r=[...new Set(t.flatMap(i=>Object.keys(i)))],n=document.createElement("table");n.className="result-table";const s=document.createElement("thead"),o=document.createElement("tr");for(const i of r){const c=document.createElement("th");c.scope="col",c.textContent=i,o.append(c)}s.append(o);const a=document.createElement("tbody");for(const i of t){const c=document.createElement("tr");for(const l of r){const h=document.createElement("td");h.textContent=lt(i[l]),c.append(h)}a.append(c)}n.append(s,a),e.append(n),b.replaceChildren(e)}function lt(t){if(t==null)return"—";if(Array.isArray(t))return d==="en"?`${t.length} items`:`${t.length} 项`;if(t instanceof Date)return t.toISOString();if(typeof t=="object"){const e=t,r=te(e);if(r)return be(r);const n=e.name??e.orderNumber??e.code??e.id;return n===void 0?d==="en"?`${Object.keys(e).length} fields`:`${Object.keys(e).length} 个字段`:String(n)}return String(t)}function mt(t,e,r){const n=document.createElement("div");n.className="order-center";const s=document.createElement("div");s.className="order-center-toolbar";const o=document.createElement("div"),a=document.createElement("h3");a.textContent=d==="en"?"Order Management Center":"订单管理中心";const i=document.createElement("p");i.textContent=d==="en"?"One generated Q expression describes the entire page":"一个生成式 Q 表达式描述整个页面",o.append(a,i);const c=document.createElement("form");c.className="order-search";const l=document.createElement("input");l.type="search",l.placeholder=d==="en"?"Order number, status, or product…":"订单号、状态或商品名称…",l.value=t.search,l.setAttribute("aria-label",d==="en"?"Search orders":"搜索订单");const h=document.createElement("button");h.type="submit",h.className="order-search-submit",h.setAttribute("aria-label",d==="en"?"Run order query":"执行订单查询"),h.title=d==="en"?"Search":"查询";const m=document.createElement("span");m.className="search-icon",m.setAttribute("aria-hidden","true"),h.append(m),c.append(l,h),c.addEventListener("submit",p=>{p.preventDefault(),A.search=l.value.trim(),A.page=0,D(r,e).catch(N)}),s.append(o,c);const S=document.createElement("div");S.className="order-metrics",S.append(me(d==="en"?"All orders":"全部订单",t.totalOrders,"total","#2B66D9",!t.search,()=>{A.search="",A.page=0,D(r,e).catch(N)}));for(const p of t.statusFacets)S.append(me(p.name,p.orderCount,p.code.toLowerCase(),p.color,t.search.toUpperCase()===p.code,()=>{A.search=p.code,A.page=0,D(r,e).catch(N)},`${d==="en"?"Total":"总额"} ${pt(p.orderTotalAmount)}`));const g=document.createElement("div");g.className="order-table";const M=document.createElement("div");M.className="order-row order-row-head";const ve=d==="en"?["Order number","Order date","Status","Product details"]:["订单号","订单日期","状态","商品明细"];for(const p of ve){const q=document.createElement("span");q.textContent=p,M.append(q)}if(g.append(M),!t.orders.length){const p=document.createElement("div");p.className="order-empty",p.textContent=d==="en"?"No matching orders. Try an order number, status code, or product name.":"没有匹配的订单,请尝试订单号、状态英文或商品名称。",g.append(p)}for(const p of t.orders)g.append(yt(p));const _=document.createElement("div");_.className="order-center-footer";const ne=document.createElement("p"),se=t.filteredOrders?t.page*t.pageSize+1:0,oe=Math.min(t.filteredOrders,(t.page+1)*t.pageSize);ne.textContent=d==="en"?`Showing ${se}–${oe} of ${t.filteredOrders} orders`:`显示 ${se}–${oe},共 ${t.filteredOrders} 条订单`;const T=document.createElement("div");T.className="pagination";const ae=Math.max(1,Math.ceil(t.filteredOrders/t.pageSize));T.append(j("‹",t.page-1,t.page===0,e,r));for(let p=0;p<ae;p+=1){const q=j(String(p+1),p,!1,e,r);q.classList.toggle("active",p===t.page),T.append(q)}T.append(j("›",t.page+1,t.page>=ae-1,e,r)),_.append(ne,T),n.append(s,S,g,_),b.replaceChildren(n)}function me(t,e,r,n,s,o,a){const i=document.createElement("button");i.type="button",i.className=`metric-card metric-${r}`,n&&i.style.setProperty("--metric-color",n),i.classList.toggle("active",s);const c=document.createElement("span");c.textContent=t;const l=document.createElement("strong");if(l.textContent=String(e),i.append(c,l),a){const h=document.createElement("small");h.textContent=a,i.append(h)}return i.addEventListener("click",o),i}function pt(t){return new Intl.NumberFormat(d==="en"?"en-US":"zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}function yt(t){const e=document.createElement("div");e.className="order-row";const r=t.status??{},n=Array.isArray(t.itemList)?t.itemList:[];[String(t.orderNumber??""),String(t.orderDate??"")].forEach(m=>{const S=document.createElement("span");S.className="order-primary",S.textContent=m,e.append(S)});const o=document.createElement("span"),a=document.createElement("span"),i=te(r);a.className=`status-badge status-${i.toLowerCase()}`,a.textContent=be(i)||String(r.name??i);const c=String(r.color??"");c&&(a.style.color=c,a.style.backgroundColor=`${c}18`),o.append(a),e.append(o);const l=document.createElement("span");l.className="product-preview",n.forEach((m,S)=>{const g=document.createElement("span");g.className=`product-thumb product-tone-${S%3}`,g.textContent=String(m.productName??"?").slice(0,1),g.title=`${String(m.productName??"")} × ${String(m.quantity??1)}`,l.append(g)});const h=Number(t.itemCount??n.length)-n.length;if(h>0){const m=document.createElement("small");m.textContent=`+${h}`,l.append(m)}return e.append(l),e}function j(t,e,r,n,s){const o=document.createElement("button");return o.type="button",o.textContent=t,o.disabled=r,o.addEventListener("click",()=>{A.page=e,D(s,n).catch(N)}),o}function be(t){return(d==="en"?{PENDING_PAYMENT:"Pending payment",PAID:"Paid",SHIPPED:"Shipped",DELIVERED:"Delivered",CANCELLED:"Cancelled"}:{PENDING_PAYMENT:"待支付",PAID:"已支付",SHIPPED:"运输中",DELIVERED:"已完成",CANCELLED:"已取消"})[t]??t}function Ee(t){b.replaceChildren(Ne(t,"result",0))}function Ne(t,e,r){if(t!==null&&typeof t=="object"){const a=Array.isArray(t)?t.map((S,g)=>[String(g),S]):Object.entries(t),i=document.createElement("details");i.className="tree-branch",i.open=r===0;const c=document.createElement("summary"),l=document.createElement("span");l.className="tree-key",l.textContent=e;const h=document.createElement("span");h.className="tree-preview",h.textContent=ht(t,a.length),c.append(l,h),i.append(c);const m=document.createElement("div");m.className="tree-children";for(const[S,g]of a)m.append(Ne(g,Array.isArray(t)?`#${Number(S)+1}`:S,r+1));return i.append(m),i}const n=document.createElement("div");n.className="tree-leaf";const s=document.createElement("span");s.className="tree-key",s.textContent=e;const o=document.createElement("span");return o.className=`tree-value tree-${t===null?"null":typeof t}`,o.textContent=t===null?"null":typeof t=="string"?`“${t}”`:String(t),n.append(s,o),n}function ht(t,e){if(Array.isArray(t))return d==="en"?`${e} items`:`${e} 项`;const r=t,n=r.orderNumber??r.name??r.productName??r.transactionId??r.trackingNumber;return n?String(n):d==="en"?`${e} fields`:`${e} 个字段`}function gt(t){return Array.isArray(t)?t.length:Array.isArray(t?.data)?t.data.length:1}function Le(t,e,r){const n=e.view==="dashboard"?t.filteredOrders:gt(t),s=d==="en"?`${n} ${e.view==="dashboard"?`matching order${n===1?"":"s"}`:`result${n===1?"":"s"}`}`:`${n} 条${e.view==="dashboard"?"匹配订单":"结果"}`;J.textContent=`${s} · ${r} ms · ${d==="en"?"in-browser SQLite":"浏览器内 SQLite"}`}function Oe(t){const e=pe.filter(r=>r.entity==="CustomerOrder").length;k.textContent=d==="en"?`${t.toUpperCase()} · ${e} orders · 7 entities · policy installed · ready`:`${t.toUpperCase()} · ${e} 个订单 · 7 个实体 · 已安装策略 · 就绪`}function De(){document.documentElement.lang=d==="en"?"en":"zh-CN",document.title=d==="en"?"TeaQL Order Query Playground":"TeaQL 订单查询演练场";const t=document.querySelector('meta[name="description"]');if(t&&(t.content=d==="en"?"A TeaQL order-query playground running entirely in the browser":"完全运行在浏览器中的 TeaQL 订单查询演练场"),document.querySelectorAll("[data-i18n]").forEach(e=>{const r=e.dataset.i18n;r&&(e.textContent=st(r))}),ge.forEach(e=>{const r=e.dataset.locale===d;e.classList.toggle("active",r),e.setAttribute("aria-pressed",String(r))}),document.querySelector(".language-switch")?.setAttribute("aria-label",d==="en"?"Language":"语言"),document.querySelector(".brand")?.setAttribute("aria-label",d==="en"?"TeaQL Playground home":"TeaQL 演练场首页"),document.querySelector(".model-map")?.setAttribute("aria-label",d==="en"?"Order domain model":"订单领域模型"),document.querySelector(".runtime-language-selector")?.setAttribute("aria-label",d==="en"?"TeaQL runtimes":"TeaQL 运行时"),document.querySelector(".runtime-bar")?.setAttribute("aria-label",d==="en"?"Runtime settings":"运行时设置"),F.setAttribute("aria-label",d==="en"?"Example queries":"示例查询"),document.querySelector(".result-view-switch")?.setAttribute("aria-label",d==="en"?"Result views":"结果视图"),document.querySelector(".tree-actions")?.setAttribute("aria-label",d==="en"?"Result tree actions":"结果树操作"),dt(),v){const{data:e,query:r,active:n}=v;ye.textContent=O(r.title),he.textContent=O(r.description),z(),we(n.evidence.snapshot(),ee),Le(e,r,fe),Oe(B.checked?"opfs":"memory")}else k.textContent=d==="en"?"Starting SQLite/WASM…":"正在启动 SQLite/WASM…"}function re(){return le.find(t=>t.id===W)??le[0]}async function Pe(t){k.textContent=d==="en"?`Opening ${t.toUpperCase()} SQLite/WASM…`:`正在打开 ${t.toUpperCase()} SQLite/WASM…`;const e=E;E=void 0,await e?.client.close();const r=await it(t);E=r,await Ie(r),await D(re(),r),Oe(t)}B.addEventListener("change",()=>{const t=B.checked?"opfs":"memory";localStorage.setItem("teaql-browser-storage",t),Pe(t).catch(N)});Y.addEventListener("click",async()=>{if(E){Y.disabled=!0;try{await E.client.reset(E.context),await Ie(E),await D(re(),E)}catch(t){N(t)}finally{Y.disabled=!1}}});X.addEventListener("click",()=>{b.querySelectorAll("details").forEach(t=>{t.open=!0})});Q.addEventListener("click",()=>{Q.disabled||(w="table",z())});V.addEventListener("click",()=>{w="tree",z()});tt.addEventListener("click",()=>{b.querySelectorAll("details").forEach((t,e)=>{t.open=e===0})});ge.forEach(t=>{t.addEventListener("click",()=>{d=t.dataset.locale==="zh"?"zh":"en",localStorage.setItem("teaql-browser-locale",d),De()})});function N(t){const e=t instanceof Error?t:new Error(String(t));k.textContent=`${e.name}: ${e.message}`,J.textContent=d==="en"?"Query failed":"查询失败",Ee({error:e.name,message:e.message})}De();W=re().id;H();Pe(Ae).catch(N);
|
dist/assets/object-location-xgYMemK6.js → assets/object-location-CJfVWqJC.js
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{f as u}from"./dynamic-search-
|
|
|
|
| 1 |
+
import{f as u}from"./dynamic-search-Ch_QcWVU.js";const i=n=>`${n.entity}\0${typeof n.id}:${String(n.id)}`;class V{constructor(){this.changes=new Map,this.originalVersions=new Map,this.newKeys=new Map,this.deletedKeys=new Map,this.traces=new Map}setTraceChain(s,e){this.traces.set(i(s),{key:Object.freeze({...s}),nodes:u(e)})}traceChain(s){return this.traces.get(i(s))?.nodes}set(s,e,t){if(!e.trim())throw new TypeError("field is required");const r=i(s),a=this.changes.get(r)??{key:Object.freeze({...s}),values:{}};a.values[e]=t,this.changes.set(r,a)}snapshot(){return[...this.changes.values()].map(s=>({key:Object.freeze({...s.key}),values:Object.freeze({...s.values})}))}change(s){return Object.freeze({...this.changes.get(i(s))?.values??{}})}mergeFrom(s){if(s!==this){for(const e of s.snapshotVersions())this.requireMatchingVersion(e.key,e.version);for(const e of s.snapshot())for(const[t,r]of Object.entries(e.values))this.set(e.key,t,r);for(const e of s.newKeys.values())this.markAsNew(e);for(const e of s.deletedKeys.values())this.markAsDeleted(e);for(const e of s.snapshotVersions())this.setOriginalVersion(e.key,e.version);for(const e of s.traces.values())this.setTraceChain(e.key,e.nodes)}}mergeEntityFrom(s,e){if(s===this)return;const t=s.originalVersion(e);t!==void 0&&this.requireMatchingVersion(e,t);for(const[a,c]of Object.entries(s.change(e)))this.set(e,a,c);s.isNew(e)&&this.markAsNew(e),s.isDeleted(e)&&this.markAsDeleted(e),t!==void 0&&this.setOriginalVersion(e,t);const r=s.traceChain(e);r&&this.setTraceChain(e,r)}hasPending(s){const e=i(s);return this.newKeys.has(e)||this.deletedKeys.has(e)||Object.keys(this.changes.get(e)?.values??{}).length>0}snapshotVersions(){return[...this.originalVersions.values()]}rekey(s,e){const t=i(s),r=i(e);if(t===r)return;const a=this.originalVersion(s);a!==void 0&&this.requireMatchingVersion(e,a);const c=this.changes.get(t);if(c){this.changes.delete(t);for(const[f,g]of Object.entries(c.values))this.set(e,f,g)}const h=this.originalVersions.get(t);h!==void 0&&(this.originalVersions.delete(t),this.originalVersions.set(r,{key:Object.freeze({...e}),version:h.version})),this.newKeys.delete(t)&&this.newKeys.set(r,Object.freeze({...e})),this.deletedKeys.delete(t)&&this.deletedKeys.set(r,Object.freeze({...e}));const l=this.traces.get(t);l&&(this.traces.delete(t),this.setTraceChain(e,l.nodes))}clearEntity(s){const e=i(s);this.changes.delete(e),this.newKeys.delete(e),this.deletedKeys.delete(e),this.traces.delete(e)}requireMatchingVersion(s,e){const t=this.originalVersion(s);if(t!==void 0&&t!==e)throw new Error("ENTITY_VERSION_CONFLICT: one graph cannot contain different loaded versions of the same typed entity")}setOriginalVersion(s,e){this.requireMatchingVersion(s,e),this.originalVersions.set(i(s),{key:Object.freeze({...s}),version:e})}acceptCommittedVersion(s,e){if(this.hasPending(s))throw new Error("ENTITY_COMMIT_PENDING: clear committed changes before accepting the persisted version");this.originalVersions.set(i(s),{key:Object.freeze({...s}),version:e})}originalVersion(s){return this.originalVersions.get(i(s))?.version}markAsNew(s){this.newKeys.set(i(s),Object.freeze({...s}))}isNew(s){return this.newKeys.has(i(s))}markAsDeleted(s){const e=i(s);this.changes.delete(e),this.deletedKeys.set(e,Object.freeze({...s}))}isDeleted(s){return this.deletedKeys.has(i(s))}clearCommitted(){this.changes.clear(),this.newKeys.clear(),this.deletedKeys.clear(),this.traces.clear()}}function d(n){const s=n.split("_");return s[0]+s.slice(1).map(e=>e?e[0].toUpperCase()+e.slice(1):"").join("")}function p(n,s){if(s==="snake_case")return n;const e=d(n);return s==="camelCase"||!e?e:e[0].toUpperCase()+e.slice(1)}function m(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}class o{constructor(s){this.segments=s}static root(){return new o([])}static property(s){return o.root().property(s)}property(s){return new o([...this.segments,{kind:"property",name:s}])}index(s){return new o([...this.segments,{kind:"index",index:s}])}prefixedBy(s){return new o([...s.segments,...this.segments])}modelPath(){return this.render(s=>s)}nativePath(){return this.render(d)}instancePath(s="camelCase"){return this.segments.map(e=>e.kind==="index"?String(e.index):m(p(e.name,s))).map(e=>`/${e}`).join("")}toString(){return this.nativePath()}render(s){let e="";for(const t of this.segments)t.kind==="index"?e+=`[${t.index}]`:e+=`${e?".":""}${s(t.name)}`;return e}}export{V as E,o as O};
|
dist/assets/orders-CQOGX0kN.js → assets/orders-BIvSfQqM.js
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
assets/style-DVG2mb5q.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
:root{font:16px/1.5 Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;color:#17231b;background:#f5f4ed;font-synthesis:none;--ink: #17231b;--muted: #677067;--paper: #fffef8;--line: #d8ddd3;--green: #145b37;--green-deep: #0e4329;--lime: #dff45c;--orange: #ef8354;--blue: #2b66d9}*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;min-width:320px;background:#f5f4ed}button,input{font:inherit}button,a{-webkit-tap-highlight-color:transparent}.page-shell{width:min(1440px,100%);margin:0 auto;padding:0 42px}.site-header{height:76px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line)}.brand,.docs-link{color:var(--ink);text-decoration:none;font-weight:750}.brand{display:inline-flex;align-items:center;gap:11px;letter-spacing:-.02em}.brand-mark{width:30px;height:30px;display:grid;place-items:center;border-radius:50%;color:var(--lime);background:var(--green-deep);font-family:Georgia,serif;font-style:italic}.docs-link{color:var(--green);font-size:14px}.header-actions{display:flex;align-items:center;gap:18px}.language-switch{display:flex;gap:3px;padding:3px;border:1px solid var(--line);border-radius:8px}.language-switch button{padding:3px 7px;border:0;border-radius:5px;color:var(--muted);background:transparent;font-size:11px;cursor:pointer}.language-switch button.active{color:#fff;background:var(--green)}.hero{min-height:460px;display:grid;grid-template-columns:minmax(0,1.1fr) minmax(440px,.9fr);align-items:center;gap:72px;padding:76px 0 66px}.eyebrow,.section-index,.query-card-label{margin:0 0 14px;color:var(--green);font-size:11px;font-weight:850;letter-spacing:.18em}h1{margin:0;max-width:820px;font-family:Georgia,"Noto Serif SC",serif;font-size:clamp(42px,5.6vw,78px);font-weight:500;line-height:1.08;letter-spacing:-.055em}.hero-intro{max-width:680px;margin:26px 0 0;color:var(--muted);font-size:18px}.model-map{position:relative;min-height:310px;padding:38px;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:12px;border:1px solid #bfc8bb;border-radius:28px;background:linear-gradient(145deg,#fdfdf8,#e9eee5);box-shadow:0 18px 48px #213c280f;overflow:hidden}.model-map:before{content:"DOMAIN MODEL";position:absolute;top:18px;left:22px;color:#708073;font-size:10px;font-weight:800;letter-spacing:.16em}.model-flow{width:100%;display:grid;grid-template-columns:1fr auto 1fr auto 1fr;align-items:center;gap:10px}.model-flow>span:not(.model-arrow),.model-leaves span{min-width:0;padding:15px 17px;border:1px solid #b8c2b7;border-radius:12px;background:#fffffadb;font:750 14px/1.2 ui-monospace,SFMono-Regular,Menlo,monospace;box-shadow:0 8px 22px #1e3a260d}.model-map small{display:block;margin-top:7px;color:var(--muted);font:12px/1.2 Inter,sans-serif}.model-flow>span.model-root{color:#fff;border-color:var(--green);background:var(--green)}.model-map .model-root small{color:#cce4d4}.model-arrow{color:#809087;font-size:22px;text-align:center}.model-arrow-split{height:22px;line-height:18px}.model-leaves{width:100%;display:grid;grid-template-columns:repeat(4,1fr);gap:10px}.runtime-language-panel{margin-bottom:28px;padding:24px;display:grid;grid-template-columns:minmax(240px,.72fr) minmax(0,1.8fr);align-items:center;gap:30px;border:1px solid var(--line);border-radius:18px;background:var(--paper)}.runtime-language-copy .section-index{margin-bottom:8px}.runtime-language-copy h2{margin:0;font-family:Georgia,"Noto Serif SC",serif;font-size:clamp(22px,2.4vw,31px);font-weight:500;line-height:1.15;letter-spacing:-.035em}.runtime-language-copy p:last-child{margin:11px 0 0;color:var(--muted);font-size:13px}.runtime-language-selector{display:grid;grid-template-columns:repeat(7,minmax(82px,1fr));gap:8px}.runtime-language{min-width:0;padding:13px 8px 11px;display:flex;align-items:center;flex-direction:column;gap:4px;border:1px solid #d7ddd5;border-radius:12px;color:var(--ink);background:#fafbf7;text-align:center;text-decoration:none;transition:border-color .16s ease,background .16s ease,transform .16s ease}.runtime-language:hover{border-color:#98aa9d;background:#fff;transform:translateY(-2px)}.runtime-language.active{color:#fff;border-color:var(--green);background:var(--green);box-shadow:0 8px 20px #145b3724}.runtime-language-icon{font-size:25px;line-height:1.1}.runtime-language strong{overflow:hidden;max-width:100%;font-size:11px;text-overflow:ellipsis;white-space:nowrap}.runtime-language small{color:#78837a;font-size:8px;line-height:1.25}.runtime-language.active small{color:#d5e7da}.runtime-bar{min-height:72px;padding:14px 18px 14px 22px;display:flex;align-items:center;justify-content:space-between;gap:24px;border-radius:14px;color:#e7f1e9;background:var(--green-deep)}#status{margin:0;color:#c8d9ce;font:12px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}.controls{display:flex;align-items:center;gap:18px}.toggle{display:inline-flex;align-items:center;gap:9px;font-size:13px;cursor:pointer}.toggle input{position:absolute;opacity:0;pointer-events:none}.toggle span{position:relative;width:38px;height:22px;border-radius:999px;background:#55705f;transition:background .2s ease}.toggle span:after{content:"";position:absolute;top:3px;left:3px;width:16px;height:16px;border-radius:50%;background:#fff;transition:transform .2s ease}.toggle input:checked+span{background:var(--lime)}.toggle input:checked+span:after{transform:translate(16px);background:var(--green-deep)}.secondary-button,.tree-actions button{border:1px solid currentColor;border-radius:8px;background:transparent;cursor:pointer}.secondary-button{padding:8px 12px;color:#fff;font-size:12px}.secondary-button:disabled{opacity:.45;cursor:wait}.query-browser{padding:96px 0 82px}.section-heading,.result-heading{display:flex;align-items:end;justify-content:space-between;gap:36px;margin-bottom:40px}.section-heading h2,.result-heading h2{margin:0;font-family:Georgia,"Noto Serif SC",serif;font-size:clamp(34px,4vw,52px);font-weight:500;letter-spacing:-.045em}.section-heading>p{max-width:420px;margin:0;color:var(--muted)}.query-group{display:grid;grid-template-columns:230px 1fr;gap:36px;padding:24px 0;border-top:1px solid var(--line)}.query-group:last-child{border-bottom:1px solid var(--line)}.query-group-heading h2{margin:0 0 4px;font-size:16px}.query-group-heading p{margin:0;color:var(--muted);font-size:12px}.query-links{display:flex;flex-wrap:wrap;align-items:center;gap:10px 24px}.query-links a{position:relative;padding:5px 0;color:#34443a;text-decoration-color:#a6b1a8;text-underline-offset:5px;font-weight:650;transition:color .16s ease}.query-links a:after{content:" ↗";color:#9aa49b;font-weight:400}.query-links a:hover{color:var(--green)}.query-links a.active{color:var(--green);text-decoration-color:var(--orange);text-decoration-thickness:2px}.result-panel{margin:0 -42px;padding:82px 42px 92px;color:#eef5f0;background:#111a15}.result-heading{align-items:center}.result-heading .section-index{color:var(--lime)}.result-heading h2{color:#fff}#result-description{max-width:620px;margin:10px 0 0;color:#9fb0a4}.result-actions{display:flex;align-items:center;gap:10px}.result-view-switch,.tree-actions{display:flex;gap:6px}.result-view-switch button,.tree-actions button{padding:8px 11px;border:1px solid #536159;border-radius:8px;color:#aebdb3;background:transparent;font-size:12px;cursor:pointer}.result-view-switch button.active{color:#17231b;border-color:var(--lime);background:var(--lime)}.result-view-switch button:disabled{opacity:.35;cursor:default}.tree-actions button:hover{color:var(--lime)}.result-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:18px;align-items:start}.tree-card,.query-card,.sql-card{border:1px solid #2f3d34;border-radius:14px;background:#17231b}.tree-card{min-height:520px;overflow:hidden}.tree-card-bar{min-height:48px;padding:0 18px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #2f3d34;color:#b8c9bd;font:11px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace;text-transform:uppercase;letter-spacing:.08em}#result-meta{margin:0;color:#829188;text-transform:none;letter-spacing:0}.json-tree{min-height:470px;max-height:680px;padding:18px 20px 28px;overflow:auto;font:13px/1.6 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.json-tree.loading{opacity:.55}.tree-actions.hidden{display:none}.result-table-shell{width:100%;min-height:470px;overflow:auto}.result-table{width:100%;border-collapse:collapse;white-space:nowrap}.result-table th,.result-table td{padding:11px 14px;border-bottom:1px solid #2f3d34;text-align:left;vertical-align:top}.result-table th{position:sticky;top:0;z-index:1;color:#8ea095;background:#131d17;font:700 10px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}.result-table td{color:#d9e5dc;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace}.result-table tbody tr:hover{background:#ffffff06}.result-table-empty{margin:0;padding:48px 20px;color:#7f9185;text-align:center}.tree-branch{margin:2px 0}.tree-branch>summary{min-height:29px;display:flex;align-items:center;gap:9px;list-style:none;cursor:pointer;border-radius:5px}.tree-branch>summary::-webkit-details-marker{display:none}.tree-branch>summary:before{content:"›";width:15px;color:#73887a;font-size:18px;line-height:1;transform-origin:center;transition:transform .12s ease}.tree-branch[open]>summary:before{transform:rotate(90deg)}.tree-branch>summary:hover{background:#ffffff09}.tree-children{margin-left:8px;padding-left:20px;border-left:1px solid #314238}.tree-leaf{min-height:28px;display:grid;grid-template-columns:minmax(110px,180px) 1fr;align-items:baseline;gap:12px;padding-left:23px}.tree-key{color:#bdd0c2;font-weight:700}.tree-preview{overflow:hidden;color:#718079;font-size:11px;text-overflow:ellipsis;white-space:nowrap}.tree-value{overflow-wrap:anywhere}.tree-string{color:#dff45c}.tree-number{color:#82b4ff}.tree-boolean{color:#f2a27f}.tree-null{color:#78847c;font-style:italic}.query-card,.sql-card{min-width:0;padding:22px}.query-card-label{color:var(--lime)}.query-card pre{max-height:430px;margin:0;padding:0;overflow:auto;color:#d5e2d8;background:transparent;font:12px/1.72 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;white-space:pre-wrap}.query-params{margin-top:24px;padding-top:18px;border-top:1px solid #2f3d34}.query-params.hidden{display:none}.query-params .query-card-label{margin-bottom:10px;color:#82b4ff}.query-params pre{max-height:220px;color:#b9caee}.query-note{margin:28px 0 0;padding-top:18px;border-top:1px solid #2f3d34;color:#829188;font-size:12px}.sql-card-heading{display:flex;align-items:center;justify-content:space-between;gap:16px}.sql-card-heading .query-card-label{margin-bottom:0}#sql-count{color:#7f9185;font:10px/1.3 ui-monospace,SFMono-Regular,Menlo,monospace}.execution-evidence-wrap{margin-top:18px;overflow-x:auto;border:1px solid #34433a;border-radius:8px}.execution-evidence{min-width:1500px;width:100%;border-collapse:collapse;color:#c7d5cb}.execution-evidence th,.execution-evidence td{padding:10px 12px;border-right:1px solid #34433a;border-bottom:1px solid #34433a;text-align:left;vertical-align:top;white-space:nowrap}.execution-evidence th:last-child,.execution-evidence td:last-child{border-right:0}.execution-evidence tbody tr:last-child td{border-bottom:0}.execution-evidence th{color:#7f9185;background:#131d17;font:700 10px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}.execution-evidence td{color:#cbd8ce;background:#101813;font:10px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace}.execution-evidence tbody tr:hover td{background:#141f18}.execution-evidence .evidence-trace{color:#b9caee}.execution-evidence .evidence-sql{color:#dff45c}.dashboard-result{max-height:none;padding:0;color:var(--ink);background:#f7f8f5;font:14px/1.45 Inter,system-ui,sans-serif}.order-center{min-width:880px;padding:24px}.order-center-toolbar{display:flex;align-items:end;justify-content:space-between;gap:24px;margin-bottom:20px}.order-center-toolbar h3{margin:0;color:#111d16;font:750 22px/1.2 Inter,system-ui,sans-serif;letter-spacing:-.025em}.order-center-toolbar p{margin:5px 0 0;color:#778078;font-size:12px}.order-search{width:min(390px,45%);display:flex;align-items:center;gap:6px}.order-search input{min-width:0;height:32px;flex:1;padding:6px 10px;border:1px solid #cfd5ce;border-radius:7px;outline:0;background:#fff;font-size:12px}.order-search input:focus{border-color:#8e9990}.order-search-submit{width:30px;height:30px;flex:0 0 30px;display:grid;place-items:center;padding:0;border:1px solid #cfd5ce;border-radius:7px;color:#536057;background:#fff;cursor:pointer}.order-search-submit:hover,.order-search-submit:focus-visible{color:var(--green);border-color:#93a097;outline:none}.search-icon{position:relative;width:13px;height:13px;display:block;border:1.5px solid currentColor;border-radius:50%}.search-icon:after{content:"";position:absolute;right:-3px;bottom:-2px;width:5px;height:1.5px;border-radius:1px;background:currentColor;transform:rotate(45deg);transform-origin:left center}.order-metrics{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:10px;margin-bottom:18px}.metric-card{padding:14px;display:grid;gap:8px;text-align:left;border:1px solid #dbe0da;border-radius:9px;color:#58625b;background:#fff;cursor:pointer}.metric-card strong{color:#16231a;font-size:23px;line-height:1}.metric-card small{color:#727b74;font-size:10px;font-variant-numeric:tabular-nums}.metric-card.active{border-color:var(--metric-color, var(--blue));box-shadow:inset 3px 0 0 var(--metric-color, var(--blue))}.order-table{overflow:hidden;border:1px solid #e0e4df;border-radius:10px;background:#fff}.order-row{min-width:720px;display:grid;grid-template-columns:1.05fr .85fr .75fr 2fr;align-items:center;gap:14px;min-height:68px;padding:10px 14px;border-top:1px solid #edf0ec}.order-row:first-child{border-top:0}.order-row-head{min-height:40px;color:#69736b;background:#f2f4f1;font-size:11px;font-weight:750}.order-primary{color:#26322a;font:650 12px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}.status-badge{display:inline-block;padding:4px 8px;border-radius:999px;color:#2b5e39;background:#e3f4e8;font-size:10px;white-space:nowrap}.status-pending_payment{color:#92580a;background:#fff0d8}.status-paid{color:#215b9d;background:#e2efff}.status-shipped{color:#1d6e38;background:#ddf5e4}.status-cancelled{color:#7b4650;background:#f6e6e9}.product-preview{display:flex;align-items:center;gap:5px}.product-thumb{width:32px;height:28px;display:grid;place-items:center;border:1px solid #cad4ca;border-radius:6px;color:#315139;background:linear-gradient(135deg,#e5eddf,#bdceb8);font:800 11px/1 Inter,sans-serif}.product-tone-1{color:#725333;background:linear-gradient(135deg,#f1e5d4,#d3b58d)}.product-tone-2{color:#3d526b;background:linear-gradient(135deg,#e1e9ef,#adbecd)}.product-preview small{color:#68736a;font-size:10px}.order-empty{padding:48px 20px;color:#7a847c;text-align:center}.order-center-footer{display:flex;align-items:center;justify-content:space-between;gap:20px;padding-top:16px}.order-center-footer p{margin:0;color:#7a847c;font-size:11px}.pagination{display:flex;gap:5px}.pagination button{min-width:31px;height:31px;border:1px solid #d8ddd7;border-radius:6px;color:#465149;background:#fff;cursor:pointer}.pagination button.active{color:#fff;border-color:var(--blue);background:var(--blue)}.pagination button:disabled{opacity:.4;cursor:default}footer{min-height:86px;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:12px}@media(max-width:980px){.page-shell{padding:0 24px}.hero{grid-template-columns:1fr;gap:46px;padding-top:58px}.model-map{min-height:260px}.runtime-language-panel{grid-template-columns:1fr}.runtime-language-selector{grid-template-columns:repeat(4,minmax(100px,1fr))}.result-panel{margin:0 -24px;padding-left:24px;padding-right:24px}.result-grid{grid-template-columns:1fr}}@media(max-width:680px){.page-shell{padding:0 16px}.site-header{height:64px}.header-actions{gap:9px}.docs-link{display:none}h1{font-size:43px}.hero{min-height:auto;padding:48px 0}.hero-intro{font-size:16px}.model-map{gap:9px;padding:52px 22px 22px}.model-flow{grid-template-columns:1fr}.model-flow>span:not(.model-arrow),.model-leaves span{width:100%}.model-flow .model-arrow{transform:rotate(90deg)}.model-leaves{grid-template-columns:1fr}.runtime-language-panel{padding:20px 16px;gap:20px}.runtime-language-selector{grid-template-columns:repeat(2,minmax(0,1fr))}.runtime-language:last-child{grid-column:1 / -1}.runtime-bar,.section-heading,.result-heading{align-items:flex-start;flex-direction:column}.runtime-bar{padding:18px}.controls{width:100%;justify-content:space-between}.query-browser{padding:70px 0 64px}.query-group{grid-template-columns:1fr;gap:14px}.query-links{gap:8px 18px}.result-panel{margin:0 -16px;padding:64px 16px}.result-actions{width:100%;align-items:stretch;flex-direction:column}.result-view-switch,.tree-actions{width:100%}.result-view-switch button,.tree-actions button{flex:1}.tree-leaf{grid-template-columns:minmax(90px,120px) 1fr;padding-left:15px}.json-tree{padding-left:12px;padding-right:12px}}
|
assets/style-SCdXWqgK.css
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
:root{font:16px/1.5 Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;color:#17231b;background:#f5f4ed;font-synthesis:none;--ink: #17231b;--muted: #677067;--paper: #fffef8;--line: #d8ddd3;--green: #145b37;--green-deep: #0e4329;--lime: #dff45c;--orange: #ef8354;--blue: #2b66d9}*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;min-width:320px;background:#f5f4ed}button,input{font:inherit}button,a{-webkit-tap-highlight-color:transparent}.page-shell{width:min(1440px,100%);margin:0 auto;padding:0 42px}.site-header{height:76px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line)}.brand,.docs-link{color:var(--ink);text-decoration:none;font-weight:750}.brand{display:inline-flex;align-items:center;gap:11px;letter-spacing:-.02em}.brand-mark{width:30px;height:30px;display:grid;place-items:center;border-radius:50%;color:var(--lime);background:var(--green-deep);font-family:Georgia,serif;font-style:italic}.docs-link{color:var(--green);font-size:14px}.header-actions{display:flex;align-items:center;gap:18px}.language-switch{display:flex;gap:3px;padding:3px;border:1px solid var(--line);border-radius:8px}.language-switch button{padding:3px 7px;border:0;border-radius:5px;color:var(--muted);background:transparent;font-size:11px;cursor:pointer}.language-switch button.active{color:#fff;background:var(--green)}.hero{min-height:460px;display:grid;grid-template-columns:minmax(0,1.1fr) minmax(440px,.9fr);align-items:center;gap:72px;padding:76px 0 66px}.eyebrow,.section-index,.query-card-label{margin:0 0 14px;color:var(--green);font-size:11px;font-weight:850;letter-spacing:.18em}h1{margin:0;max-width:820px;font-family:Georgia,"Noto Serif SC",serif;font-size:clamp(42px,5.6vw,78px);font-weight:500;line-height:1.08;letter-spacing:-.055em}.hero-intro{max-width:680px;margin:26px 0 0;color:var(--muted);font-size:18px}.model-map{position:relative;min-height:310px;padding:38px;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:12px;border:1px solid #bfc8bb;border-radius:28px;background:linear-gradient(145deg,#fdfdf8,#e9eee5);box-shadow:0 18px 48px #213c280f;overflow:hidden}.model-map:before{content:"DOMAIN MODEL";position:absolute;top:18px;left:22px;color:#708073;font-size:10px;font-weight:800;letter-spacing:.16em}.model-flow{width:100%;display:grid;grid-template-columns:1fr auto 1fr auto 1fr;align-items:center;gap:10px}.model-flow>span:not(.model-arrow),.model-leaves span{min-width:0;padding:15px 17px;border:1px solid #b8c2b7;border-radius:12px;background:#fffffadb;font:750 14px/1.2 ui-monospace,SFMono-Regular,Menlo,monospace;box-shadow:0 8px 22px #1e3a260d}.model-map small{display:block;margin-top:7px;color:var(--muted);font:12px/1.2 Inter,sans-serif}.model-flow>span.model-root{color:#fff;border-color:var(--green);background:var(--green)}.model-map .model-root small{color:#cce4d4}.model-arrow{color:#809087;font-size:22px;text-align:center}.model-arrow-split{height:22px;line-height:18px}.model-leaves{width:100%;display:grid;grid-template-columns:repeat(4,1fr);gap:10px}.runtime-bar{min-height:72px;padding:14px 18px 14px 22px;display:flex;align-items:center;justify-content:space-between;gap:24px;border-radius:14px;color:#e7f1e9;background:var(--green-deep)}#status{margin:0;color:#c8d9ce;font:12px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}.controls{display:flex;align-items:center;gap:18px}.toggle{display:inline-flex;align-items:center;gap:9px;font-size:13px;cursor:pointer}.toggle input{position:absolute;opacity:0;pointer-events:none}.toggle span{position:relative;width:38px;height:22px;border-radius:999px;background:#55705f;transition:background .2s ease}.toggle span:after{content:"";position:absolute;top:3px;left:3px;width:16px;height:16px;border-radius:50%;background:#fff;transition:transform .2s ease}.toggle input:checked+span{background:var(--lime)}.toggle input:checked+span:after{transform:translate(16px);background:var(--green-deep)}.secondary-button,.tree-actions button{border:1px solid currentColor;border-radius:8px;background:transparent;cursor:pointer}.secondary-button{padding:8px 12px;color:#fff;font-size:12px}.secondary-button:disabled{opacity:.45;cursor:wait}.query-browser{padding:96px 0 82px}.section-heading,.result-heading{display:flex;align-items:end;justify-content:space-between;gap:36px;margin-bottom:40px}.section-heading h2,.result-heading h2{margin:0;font-family:Georgia,"Noto Serif SC",serif;font-size:clamp(34px,4vw,52px);font-weight:500;letter-spacing:-.045em}.section-heading>p{max-width:420px;margin:0;color:var(--muted)}.query-group{display:grid;grid-template-columns:230px 1fr;gap:36px;padding:24px 0;border-top:1px solid var(--line)}.query-group:last-child{border-bottom:1px solid var(--line)}.query-group-heading h2{margin:0 0 4px;font-size:16px}.query-group-heading p{margin:0;color:var(--muted);font-size:12px}.query-links{display:flex;flex-wrap:wrap;align-items:center;gap:10px 24px}.query-links a{position:relative;padding:5px 0;color:#34443a;text-decoration-color:#a6b1a8;text-underline-offset:5px;font-weight:650;transition:color .16s ease}.query-links a:after{content:" ↗";color:#9aa49b;font-weight:400}.query-links a:hover{color:var(--green)}.query-links a.active{color:var(--green);text-decoration-color:var(--orange);text-decoration-thickness:2px}.result-panel{margin:0 -42px;padding:82px 42px 92px;color:#eef5f0;background:#111a15}.result-heading{align-items:center}.result-heading .section-index{color:var(--lime)}.result-heading h2{color:#fff}#result-description{max-width:620px;margin:10px 0 0;color:#9fb0a4}.result-actions{display:flex;align-items:center;gap:10px}.result-view-switch,.tree-actions{display:flex;gap:6px}.result-view-switch button,.tree-actions button{padding:8px 11px;border:1px solid #536159;border-radius:8px;color:#aebdb3;background:transparent;font-size:12px;cursor:pointer}.result-view-switch button.active{color:#17231b;border-color:var(--lime);background:var(--lime)}.result-view-switch button:disabled{opacity:.35;cursor:default}.tree-actions button:hover{color:var(--lime)}.result-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:18px;align-items:start}.tree-card,.query-card,.sql-card{border:1px solid #2f3d34;border-radius:14px;background:#17231b}.tree-card{min-height:520px;overflow:hidden}.tree-card-bar{min-height:48px;padding:0 18px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #2f3d34;color:#b8c9bd;font:11px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace;text-transform:uppercase;letter-spacing:.08em}#result-meta{margin:0;color:#829188;text-transform:none;letter-spacing:0}.json-tree{min-height:470px;max-height:680px;padding:18px 20px 28px;overflow:auto;font:13px/1.6 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.json-tree.loading{opacity:.55}.tree-actions.hidden{display:none}.result-table-shell{width:100%;min-height:470px;overflow:auto}.result-table{width:100%;border-collapse:collapse;white-space:nowrap}.result-table th,.result-table td{padding:11px 14px;border-bottom:1px solid #2f3d34;text-align:left;vertical-align:top}.result-table th{position:sticky;top:0;z-index:1;color:#8ea095;background:#131d17;font:700 10px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}.result-table td{color:#d9e5dc;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace}.result-table tbody tr:hover{background:#ffffff06}.result-table-empty{margin:0;padding:48px 20px;color:#7f9185;text-align:center}.tree-branch{margin:2px 0}.tree-branch>summary{min-height:29px;display:flex;align-items:center;gap:9px;list-style:none;cursor:pointer;border-radius:5px}.tree-branch>summary::-webkit-details-marker{display:none}.tree-branch>summary:before{content:"›";width:15px;color:#73887a;font-size:18px;line-height:1;transform-origin:center;transition:transform .12s ease}.tree-branch[open]>summary:before{transform:rotate(90deg)}.tree-branch>summary:hover{background:#ffffff09}.tree-children{margin-left:8px;padding-left:20px;border-left:1px solid #314238}.tree-leaf{min-height:28px;display:grid;grid-template-columns:minmax(110px,180px) 1fr;align-items:baseline;gap:12px;padding-left:23px}.tree-key{color:#bdd0c2;font-weight:700}.tree-preview{overflow:hidden;color:#718079;font-size:11px;text-overflow:ellipsis;white-space:nowrap}.tree-value{overflow-wrap:anywhere}.tree-string{color:#dff45c}.tree-number{color:#82b4ff}.tree-boolean{color:#f2a27f}.tree-null{color:#78847c;font-style:italic}.query-card,.sql-card{min-width:0;padding:22px}.query-card-label{color:var(--lime)}.query-card pre{max-height:430px;margin:0;padding:0;overflow:auto;color:#d5e2d8;background:transparent;font:12px/1.72 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;white-space:pre-wrap}.query-params{margin-top:24px;padding-top:18px;border-top:1px solid #2f3d34}.query-params.hidden{display:none}.query-params .query-card-label{margin-bottom:10px;color:#82b4ff}.query-params pre{max-height:220px;color:#b9caee}.query-note{margin:28px 0 0;padding-top:18px;border-top:1px solid #2f3d34;color:#829188;font-size:12px}.sql-card-heading{display:flex;align-items:center;justify-content:space-between;gap:16px}.sql-card-heading .query-card-label{margin-bottom:0}#sql-count{color:#7f9185;font:10px/1.3 ui-monospace,SFMono-Regular,Menlo,monospace}.execution-evidence-wrap{margin-top:18px;overflow-x:auto;border:1px solid #34433a;border-radius:8px}.execution-evidence{min-width:1500px;width:100%;border-collapse:collapse;color:#c7d5cb}.execution-evidence th,.execution-evidence td{padding:10px 12px;border-right:1px solid #34433a;border-bottom:1px solid #34433a;text-align:left;vertical-align:top;white-space:nowrap}.execution-evidence th:last-child,.execution-evidence td:last-child{border-right:0}.execution-evidence tbody tr:last-child td{border-bottom:0}.execution-evidence th{color:#7f9185;background:#131d17;font:700 10px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}.execution-evidence td{color:#cbd8ce;background:#101813;font:10px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace}.execution-evidence tbody tr:hover td{background:#141f18}.execution-evidence .evidence-trace{color:#b9caee}.execution-evidence .evidence-sql{color:#dff45c}.dashboard-result{max-height:none;padding:0;color:var(--ink);background:#f7f8f5;font:14px/1.45 Inter,system-ui,sans-serif}.order-center{min-width:880px;padding:24px}.order-center-toolbar{display:flex;align-items:end;justify-content:space-between;gap:24px;margin-bottom:20px}.order-center-toolbar h3{margin:0;color:#111d16;font:750 22px/1.2 Inter,system-ui,sans-serif;letter-spacing:-.025em}.order-center-toolbar p{margin:5px 0 0;color:#778078;font-size:12px}.order-search{width:min(390px,45%);display:flex;align-items:center;gap:6px}.order-search input{min-width:0;height:32px;flex:1;padding:6px 10px;border:1px solid #cfd5ce;border-radius:7px;outline:0;background:#fff;font-size:12px}.order-search input:focus{border-color:#8e9990}.order-search-submit{width:30px;height:30px;flex:0 0 30px;display:grid;place-items:center;padding:0;border:1px solid #cfd5ce;border-radius:7px;color:#536057;background:#fff;cursor:pointer}.order-search-submit:hover,.order-search-submit:focus-visible{color:var(--green);border-color:#93a097;outline:none}.search-icon{position:relative;width:13px;height:13px;display:block;border:1.5px solid currentColor;border-radius:50%}.search-icon:after{content:"";position:absolute;right:-3px;bottom:-2px;width:5px;height:1.5px;border-radius:1px;background:currentColor;transform:rotate(45deg);transform-origin:left center}.order-metrics{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:10px;margin-bottom:18px}.metric-card{padding:14px;display:grid;gap:8px;text-align:left;border:1px solid #dbe0da;border-radius:9px;color:#58625b;background:#fff;cursor:pointer}.metric-card strong{color:#16231a;font-size:23px;line-height:1}.metric-card small{color:#727b74;font-size:10px;font-variant-numeric:tabular-nums}.metric-card.active{border-color:var(--metric-color, var(--blue));box-shadow:inset 3px 0 0 var(--metric-color, var(--blue))}.order-table{overflow:hidden;border:1px solid #e0e4df;border-radius:10px;background:#fff}.order-row{min-width:720px;display:grid;grid-template-columns:1.05fr .85fr .75fr 2fr;align-items:center;gap:14px;min-height:68px;padding:10px 14px;border-top:1px solid #edf0ec}.order-row:first-child{border-top:0}.order-row-head{min-height:40px;color:#69736b;background:#f2f4f1;font-size:11px;font-weight:750}.order-primary{color:#26322a;font:650 12px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}.status-badge{display:inline-block;padding:4px 8px;border-radius:999px;color:#2b5e39;background:#e3f4e8;font-size:10px;white-space:nowrap}.status-pending_payment{color:#92580a;background:#fff0d8}.status-paid{color:#215b9d;background:#e2efff}.status-shipped{color:#1d6e38;background:#ddf5e4}.status-cancelled{color:#7b4650;background:#f6e6e9}.product-preview{display:flex;align-items:center;gap:5px}.product-thumb{width:32px;height:28px;display:grid;place-items:center;border:1px solid #cad4ca;border-radius:6px;color:#315139;background:linear-gradient(135deg,#e5eddf,#bdceb8);font:800 11px/1 Inter,sans-serif}.product-tone-1{color:#725333;background:linear-gradient(135deg,#f1e5d4,#d3b58d)}.product-tone-2{color:#3d526b;background:linear-gradient(135deg,#e1e9ef,#adbecd)}.product-preview small{color:#68736a;font-size:10px}.order-empty{padding:48px 20px;color:#7a847c;text-align:center}.order-center-footer{display:flex;align-items:center;justify-content:space-between;gap:20px;padding-top:16px}.order-center-footer p{margin:0;color:#7a847c;font-size:11px}.pagination{display:flex;gap:5px}.pagination button{min-width:31px;height:31px;border:1px solid #d8ddd7;border-radius:6px;color:#465149;background:#fff;cursor:pointer}.pagination button.active{color:#fff;border-color:var(--blue);background:var(--blue)}.pagination button:disabled{opacity:.4;cursor:default}footer{min-height:86px;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:12px}@media(max-width:980px){.page-shell{padding:0 24px}.hero{grid-template-columns:1fr;gap:46px;padding-top:58px}.model-map{min-height:260px}.result-panel{margin:0 -24px;padding-left:24px;padding-right:24px}.result-grid{grid-template-columns:1fr}}@media(max-width:680px){.page-shell{padding:0 16px}.site-header{height:64px}.header-actions{gap:9px}.docs-link{display:none}h1{font-size:43px}.hero{min-height:auto;padding:48px 0}.hero-intro{font-size:16px}.model-map{gap:9px;padding:52px 22px 22px}.model-flow{grid-template-columns:1fr}.model-flow>span:not(.model-arrow),.model-leaves span{width:100%}.model-flow .model-arrow{transform:rotate(90deg)}.model-leaves{grid-template-columns:1fr}.runtime-bar,.section-heading,.result-heading{align-items:flex-start;flex-direction:column}.runtime-bar{padding:18px}.controls{width:100%;justify-content:space-between}.query-browser{padding:70px 0 64px}.query-group{grid-template-columns:1fr;gap:14px}.query-links{gap:8px 18px}.result-panel{margin:0 -16px;padding:64px 16px}.result-actions{width:100%;align-items:stretch;flex-direction:column}.result-view-switch,.tree-actions{width:100%}.result-view-switch button,.tree-actions button{flex:1}.tree-leaf{grid-template-columns:minmax(90px,120px) 1fr;padding-left:15px}.json-tree{padding-left:12px;padding-right:12px}}
|
|
|
|
|
|
assets/{workItems-DraVJWt7.js → workItems-B6je_A1X.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{S as G,L as c,M as k,C as v,a as I,d as O,e as C,Q as K,R as U,B as z,U as H,D as J,c as Y}from"./dynamic-search-BBmdgl4H.js";import{E as $,O as g}from"./object-location-xgYMemK6.js";class L extends G{orderBy(t,e){return this.order({field:t,expr:null,direction:e==="desc"?"Desc":"Asc"})}relationQuery(t,e,i="id",r="id",s=!0,a){return super.relationQuery(t,e,i,r,s,a)}}class m{static teaqlTemporaryId=0;id;title;description;platform;version;constructor(t){if(Object.defineProperty(this,"_action",{value:t&&t.id?"Update":"Create",writable:!0,enumerable:!1}),Object.defineProperty(this,"_comment",{value:void 0,writable:!0,enumerable:!1}),Object.defineProperty(this,"_fullyLoaded",{value:!t||!t.id,writable:!0,enumerable:!1}),Object.defineProperty(this,"_loadedFields",{value:new Set(Object.keys(t||{})),writable:!0,enumerable:!1}),Object.defineProperty(this,"_root",{value:new $,writable:!0,enumerable:!1}),Object.defineProperty(this,"_ledgerId",{value:t?.id??--m.teaqlTemporaryId,writable:!0,enumerable:!1}),t){const i={...t};Object.assign(this,i),t.platform&&typeof t.platform=="object"&&(this.platform=t.platform instanceof y?t.platform:y.fromRecord(t.platform),this.markLoaded("platform"))}const e=this.teaqlEntityKey();this._action==="Create"?this._root.markAsNew(e):this.version!==void 0&&this._root.setOriginalVersion(e,Number(this.version)),c.captureFor(this,this.teaqlMutationPayload())}teaqlEntityKey(){return{entity:"WorkItem",id:this._ledgerId}}teaqlAttachRoot(t){return this._root!==t&&(t.mergeEntityFrom(this._root,this.teaqlEntityKey()),this._root=t),this}static fromRecord(t,e){const i=new m(t);return e?i.teaqlAttachRoot(e):i}isLoaded(t){return this._fullyLoaded||this._loadedFields.has(t)}markLoaded(...t){for(const e of t)this._loadedFields.add(e);return this}markLoadedOnly(...t){return this._fullyLoaded=!1,this._loadedFields=new Set(t),this}static refer(t){return new m({id:String(t)})}static teaqlBootstrapNew(t){return new m().updateId(String(t))}markForDeletion(){return this._action="Delete",this._root.markAsDeleted(this.teaqlEntityKey()),this}auditAs(t){return new k(t),this._comment=t,this}async save(t){const e=t.requireResource("dataService");return e.executeGraphSave(new k(this._comment),async i=>(this.teaqlPreflightGraph(t,e,i),this.teaqlSaveWithinGraph(t,e,i)))}teaqlPreflightGraph(t,e,i,r){r||new k(this._comment);const s=this._action,a=s!=="Update"||this._root.hasPending(this.teaqlEntityKey());if(s==="Update"&&a){const d=[{member:"id",canonical:"id"},{member:"title",canonical:"title"},{member:"description",canonical:"description"},{member:"platform",canonical:"platform"},{member:"version",canonical:"version"}].find(u=>!this.isLoaded(u.member));if(d)throw new v([{ruleId:"invalid_type",location:g.property(d.canonical),message:"Mutation requires a fully loaded entity"}])}const n=i.request({entity:"WorkItem",action:s,payload:s==="Update"?this._root.change(this.teaqlEntityKey()):this.teaqlMutationPayload(),id:this.id,version:this.version,comment:this._comment,ledgerKey:this.teaqlEntityKey(),ledgerRoot:this._root},r,this._comment).withLoadedSnapshot(c.forEntity(this)??new c);a&&e.preflightMutation(n),n.scopeFor(this.teaqlEntityKey())}async teaqlSaveWithinGraph(t,e,i,r){r||new k(this._comment);const s=this._action,a=this._root.change(this.teaqlEntityKey()),n={entity:"WorkItem",action:this._action,payload:s==="Update"?a:this.teaqlMutationPayload(),id:this.id,version:this.version,comment:this._comment,ledgerKey:this.teaqlEntityKey(),ledgerRoot:this._root},d=i.request(n,r,this._comment).withLoadedSnapshot(c.forEntity(this)??new c);if(s==="Update"&&!this._root.hasPending(this.teaqlEntityKey()))return d.scopeFor(this.teaqlEntityKey()),this;const u=await e.executeMutation(d);for(const[S,f]of Object.entries(n.payload))S!=="id"&&S!=="version"&&this._root.set(this.teaqlEntityKey(),S,f);if(!u.persistedRecord)throw new Error("Mutation did not return the authoritative persisted record");const h={payload:this.teaqlMutationPayload(),ledgerId:this._ledgerId,action:this._action,loadedFields:new Set(this._loadedFields),fullyLoaded:this._fullyLoaded,loadedSnapshot:c.forEntity(this)},l=this.teaqlEntityKey();Object.assign(this,u.persistedRecord),c.captureFor(this,this.teaqlMutationPayload()),this._ledgerId=this.id??this._ledgerId;const p=this.teaqlEntityKey();return this._root.rekey(l,p),e.afterGraphRollback(()=>{Object.assign(this,h.payload),this._ledgerId=h.ledgerId,this._action=h.action,this._loadedFields=h.loadedFields,this._fullyLoaded=h.fullyLoaded,c.restoreFor(this,h.loadedSnapshot),this._root.rekey(p,l)}),this._loadedFields=new Set(Object.keys(u.persistedRecord)),this._fullyLoaded=!1,n.action!=="Delete"&&(this._action="Update"),d.scopeFor(p),e.afterGraphCommit(()=>{this._root.clearEntity(p),this.version!==void 0&&this._root.acceptCommittedVersion(p,Number(this.version))}),this}teaqlMutationPayload(){return{id:this.id,title:this.title,description:this.description,platform:this.platform,version:this.version}}updateId(t){return this.id=t,this.markLoaded("id"),this._root.set(this.teaqlEntityKey(),"id",t),this}updateTitle(t){return this.title=t,this.markLoaded("title"),this._root.set(this.teaqlEntityKey(),"title",t),this}updateDescription(t){return this.description=t,this.markLoaded("description"),this._root.set(this.teaqlEntityKey(),"description",t),this}updateVersion(t){return this.version=t,this.markLoaded("version"),this._root.set(this.teaqlEntityKey(),"version",t),this}updatePlatform(t){return this.platform=t?.id??t,this.markLoaded("platform"),this._root.set(this.teaqlEntityKey(),"platform",this.platform),this}}class y{static teaqlTemporaryId=0;id;name;version;constructor(t){if(Object.defineProperty(this,"_action",{value:t&&t.id?"Update":"Create",writable:!0,enumerable:!1}),Object.defineProperty(this,"_comment",{value:void 0,writable:!0,enumerable:!1}),Object.defineProperty(this,"_fullyLoaded",{value:!t||!t.id,writable:!0,enumerable:!1}),Object.defineProperty(this,"_loadedFields",{value:new Set(Object.keys(t||{})),writable:!0,enumerable:!1}),Object.defineProperty(this,"_root",{value:new $,writable:!0,enumerable:!1}),Object.defineProperty(this,"_ledgerId",{value:t?.id??--y.teaqlTemporaryId,writable:!0,enumerable:!1}),Object.defineProperty(this,"_workItemList",{value:t?.id?I.empty():new I,writable:!0,enumerable:!1}),t){const i={...t};if(delete i.workItemList,Object.assign(this,i),Array.isArray(t.workItemList)){const r=t.workItemList;this._workItemList=new I(r.map(s=>s instanceof m?s:m.fromRecord(s)),{totalCount:r.totalCount,aggregations:r.aggregations,summary:r.summary,facets:r.facets,isLoaded:r.isLoaded??!0}),this.markLoaded("workItemList")}}const e=this.teaqlEntityKey();this._action==="Create"?this._root.markAsNew(e):this.version!==void 0&&this._root.setOriginalVersion(e,Number(this.version)),c.captureFor(this,this.teaqlMutationPayload())}teaqlEntityKey(){return{entity:"Platform",id:this._ledgerId}}teaqlAttachRoot(t){this._root!==t&&(t.mergeEntityFrom(this._root,this.teaqlEntityKey()),this._root=t);for(const e of this._workItemList)e.teaqlAttachRoot(t);return this}static fromRecord(t,e){const i=new y(t);return e?i.teaqlAttachRoot(e):i}isLoaded(t){return this._fullyLoaded||this._loadedFields.has(t)}markLoaded(...t){for(const e of t)this._loadedFields.add(e);return this}markLoadedOnly(...t){return this._fullyLoaded=!1,this._loadedFields=new Set(t),this}static refer(t){return new y({id:String(t)})}static teaqlBootstrapNew(t){return new y().updateId(String(t))}markForDeletion(){return this._action="Delete",this._root.markAsDeleted(this.teaqlEntityKey()),this}auditAs(t){return new k(t),this._comment=t,this}async save(t){const e=t.requireResource("dataService");return e.executeGraphSave(new k(this._comment),async i=>(this.teaqlPreflightGraph(t,e,i),this.teaqlSaveWithinGraph(t,e,i)))}teaqlPreflightGraph(t,e,i,r){r||new k(this._comment);const s=this._action,a=s!=="Update"||this._root.hasPending(this.teaqlEntityKey());if(s==="Update"&&a){const u=[{member:"id",canonical:"id"},{member:"name",canonical:"name"},{member:"version",canonical:"version"}].find(h=>!this.isLoaded(h.member));if(u)throw new v([{ruleId:"invalid_type",location:g.property(u.canonical),message:"Mutation requires a fully loaded entity"}])}const n=i.request({entity:"Platform",action:s,payload:s==="Update"?this._root.change(this.teaqlEntityKey()):this.teaqlMutationPayload(),id:this.id,version:this.version,comment:this._comment,ledgerKey:this.teaqlEntityKey(),ledgerRoot:this._root},r,this._comment).withLoadedSnapshot(c.forEntity(this)??new c);a&&e.preflightMutation(n);const d=n.scopeFor(this.teaqlEntityKey());for(const[u,h]of this._workItemList.entries()){h.teaqlAttachRoot(this._root);const l=h.platform;(this.id===void 0||!h.isLoaded("platform")||(typeof l=="object"&&l!==null?l.id:l)!==this.id)&&h.updatePlatform(this);try{h.teaqlPreflightGraph(t,e,i,d)}catch(p){if(!(p instanceof v))throw p;const S=g.property("work_item_list").index(u);throw new v(p.violations.map(f=>({...f,location:f.location.prefixedBy(S)})))}}}async teaqlSaveWithinGraph(t,e,i,r){r||new k(this._comment);const s=this._action,a=this._root.change(this.teaqlEntityKey()),n={entity:"Platform",action:this._action,payload:s==="Update"?a:this.teaqlMutationPayload(),id:this.id,version:this.version,comment:this._comment,ledgerKey:this.teaqlEntityKey(),ledgerRoot:this._root},d=i.request(n,r,this._comment).withLoadedSnapshot(c.forEntity(this)??new c);if(s==="Update"&&!this._root.hasPending(this.teaqlEntityKey())){const f=d.scopeFor(this.teaqlEntityKey());for(const[q,w]of this._workItemList.entries()){w.teaqlAttachRoot(this._root);const _=w.platform;(this.id===void 0||!w.isLoaded("platform")||(typeof _=="object"&&_!==null?_.id:_)!==this.id)&&w.updatePlatform(this);try{await w.teaqlSaveWithinGraph(t,e,i,f)}catch(N){if(!(N instanceof v))throw N;const P=g.property("work_item_list").index(q);throw new v(N.violations.map(B=>({...B,location:B.location.prefixedBy(P)})))}}return this}const u=await e.executeMutation(d);for(const[f,q]of Object.entries(n.payload))f!=="id"&&f!=="version"&&this._root.set(this.teaqlEntityKey(),f,q);if(!u.persistedRecord)throw new Error("Mutation did not return the authoritative persisted record");const h={payload:this.teaqlMutationPayload(),ledgerId:this._ledgerId,action:this._action,loadedFields:new Set(this._loadedFields),fullyLoaded:this._fullyLoaded,loadedSnapshot:c.forEntity(this)},l=this.teaqlEntityKey();Object.assign(this,u.persistedRecord),c.captureFor(this,this.teaqlMutationPayload()),this._ledgerId=this.id??this._ledgerId;const p=this.teaqlEntityKey();this._root.rekey(l,p),e.afterGraphRollback(()=>{Object.assign(this,h.payload),this._ledgerId=h.ledgerId,this._action=h.action,this._loadedFields=h.loadedFields,this._fullyLoaded=h.fullyLoaded,c.restoreFor(this,h.loadedSnapshot),this._root.rekey(p,l)}),this._loadedFields=new Set(Object.keys(u.persistedRecord)),this._fullyLoaded=!1,n.action!=="Delete"&&(this._action="Update");const S=d.scopeFor(p);for(const[f,q]of this._workItemList.entries()){q.teaqlAttachRoot(this._root);const w=q.platform;(this.id===void 0||!q.isLoaded("platform")||(typeof w=="object"&&w!==null?w.id:w)!==this.id)&&q.updatePlatform(this);try{await q.teaqlSaveWithinGraph(t,e,i,S)}catch(_){if(!(_ instanceof v))throw _;const N=g.property("work_item_list").index(f);throw new v(_.violations.map(P=>({...P,location:P.location.prefixedBy(N)})))}}return e.afterGraphCommit(()=>{this._root.clearEntity(p),this.version!==void 0&&this._root.acceptCommittedVersion(p,Number(this.version))}),this}teaqlMutationPayload(){return{id:this.id,name:this.name,version:this.version}}updateId(t){return this.id=t,this.markLoaded("id"),this._root.set(this.teaqlEntityKey(),"id",t),this}updateName(t){return this.name=t,this.markLoaded("name"),this._root.set(this.teaqlEntityKey(),"name",t),this}updateVersion(t){return this.version=t,this.markLoaded("version"),this._root.set(this.teaqlEntityKey(),"version",t),this}workItemList(){return this._workItemList}}const D=Object.freeze({Platform:Object.freeze({fields:Object.freeze({id:"integer",name:"string",version:"integer"}),queryFields:Object.freeze({id:"id",name:"name",version:"version"}),relations:Object.freeze({workItemList:"WorkItem"})}),WorkItem:Object.freeze({fields:Object.freeze({id:"integer",title:"string",description:"string",platform:"integer",version:"integer"}),queryFields:Object.freeze({id:"id",title:"title",description:"description",platform:"platform",version:"version"}),relations:Object.freeze({platform:"Platform"})})});class A{query;filters=[];_purpose;_comment;_pageCountAlias;_pageCountMethod;_dynamicSearchWarnings=[];constructor(t=!1){this.query=new L("Platform"),this.filters.push({version:{$gte:1}}),t?(this.selectId(),this.selectVersion()):this.selectSelfFields()}comment(t){return this.query.comment(t),this._comment=t,this}filterByJson(t,e){const i=this.query.clone();this.filters.length>0&&i.filter({$and:this.filters});const r=O(i,t,D,e);return this.query=r.query,this.filters=this.query.filterCondition?[this.query.filterCondition]:[],this._dynamicSearchWarnings.push(...r.warnings),this}get dynamicSearchWarnings(){return this._dynamicSearchWarnings.map(t=>({...t}))}purpose(t){return this.query.purpose(t),this._purpose=t,new X(e=>e.withQueryRequest(this.query,()=>this.executeForListInternal(e)),e=>e.withQueryRequest(this.query,()=>this.executeForRowsInternal(e)),(e,i)=>this.executeForStreamInternal(e,i),()=>this.limit(1),e=>this.comment(e),()=>this.ensureIntent())}optimizeForContinuousPageFetch(){return this.query.optimizeForContinuousPageFetch(),this}optimizeForContinuousPageFetchWith(t,e){return this.query.optimizeForContinuousPageFetchWith(t,e),this}optimizePaginationWithIdSet(){return this.query.optimizePaginationWithIdSet(),this}optimizePaginationWithIdSetConfig(t,e,i){return this.query.optimizePaginationWithIdSetConfig(t,e,i),this}topNProbeParentThreshold(t){return this.query.topNProbeParentThreshold(t),this}limit(t){return this.query.limit(t),this}offset(t){return this.query.offset(t),this}toQuery(){return this.filters.length>0&&this.query.filter({$and:this.filters}),this.query}withDeletedRows(){return this.filters=this.filters.filter(t=>!("version"in t)),this}deletedRowsOnly(){return this.withDeletedRows(),this.filters.push({version:{$lte:-1}}),this}selectSelfFields(){return this.query.select(["id","name","version"]),this}selectId(){return this.query.select(["id"]),this}selectName(){return this.query.select(["name"]),this}selectVersion(){return this.query.select(["version"]),this}selectWorkItemListWith(t){return this.query.relationQuery("workItemList",t.toQuery(),"id","platform",!0,{kind:"relation-select",method:"selectWorkItemListWith",relation:"workItemList"}),this}haveWorkItems(){return this.withWorkItemListMatching({toQuery:()=>new L("WorkItem")})}haveNoWorkItems(){return this.withoutWorkItemListMatching({toQuery:()=>new L("WorkItem")})}withWorkItemListMatching(t){return this.filters.push({id:{$inSubquery:{query:t.toQuery(),field:"platform"}}}),this}withoutWorkItemListMatching(t){return this.filters.push({id:{$notInSubquery:{query:t.toQuery(),field:"platform"}}}),this}countWorkItems(){return this.countWorkItemsAs("countWorkItems")}countWorkItemsAs(t){const e=new L("WorkItem").filter({version:{$gte:1}});return this.countWorkItemsWith(t,{toQuery:()=>e}),this.query.relationAggregates[this.query.relationAggregates.length-1].operation={kind:"relation-count",method:"countWorkItemsAs",relation:"workItemList",alias:t},this}countWorkItemsWith(t,e){const i=e.toQuery().clone();return i.aggregateItems=[],i.aggregate("Count","id",t),this.query.relationAggregate("workItemList",t,i,!0,{kind:"relation-count",method:"countWorkItemsWith",relation:"workItemList",alias:t}),this}withIdIs(t){return this.filters.push({id:{$eq:t}}),this}withIdIsNot(t){return this.filters.push({id:{$ne:t}}),this}withIdIn(...t){return this.filters.push({id:{$in:t}}),this}withIdNotIn(...t){return this.filters.push({id:{$notIn:t}}),this}withIdGreaterThan(t){return this.filters.push({id:{$gt:t}}),this}withIdGreaterThanOrEqualTo(t){return this.filters.push({id:{$gte:t}}),this}withIdLessThan(t){return this.filters.push({id:{$lt:t}}),this}withIdLessThanOrEqualTo(t){return this.filters.push({id:{$lte:t}}),this}withIdBetween(t,e){return this.filters.push({id:{$between:[t,e]}}),this}withIdIsKnown(){return this.filters.push({id:{$isNull:!1}}),this}withIdIsUnknown(){return this.filters.push({id:{$isNull:!0}}),this}withNameContaining(t){return this.filters.push({name:{$contains:t}}),this}withNameIs(t){return this.filters.push({name:{$eq:t}}),this}withNameIsNot(t){return this.filters.push({name:{$ne:t}}),this}withNameIn(...t){return this.filters.push({name:{$in:t}}),this}withNameNotIn(...t){return this.filters.push({name:{$notIn:t}}),this}withNameGreaterThan(t){return this.filters.push({name:{$gt:t}}),this}withNameGreaterThanOrEqualTo(t){return this.filters.push({name:{$gte:t}}),this}withNameLessThan(t){return this.filters.push({name:{$lt:t}}),this}withNameLessThanOrEqualTo(t){return this.filters.push({name:{$lte:t}}),this}withNameBetween(t,e){return this.filters.push({name:{$between:[t,e]}}),this}withNameIsKnown(){return this.filters.push({name:{$isNull:!1}}),this}withNameIsUnknown(){return this.filters.push({name:{$isNull:!0}}),this}withNameNotContaining(t){return this.filters.push({name:{$notContains:t}}),this}withNameStartingWith(t){return this.filters.push({name:{$startsWith:t}}),this}withNameNotStartingWith(t){return this.filters.push({name:{$notStartsWith:t}}),this}withNameEndingWith(t){return this.filters.push({name:{$endsWith:t}}),this}withNameNotEndingWith(t){return this.filters.push({name:{$notEndsWith:t}}),this}withNameSoundingLike(t){return this.filters.push({name:{$soundLike:t}}),this}withVersionIs(t){return this.filters.push({version:{$eq:t}}),this}withVersionIsNot(t){return this.filters.push({version:{$ne:t}}),this}withVersionIn(...t){return this.filters.push({version:{$in:t}}),this}withVersionNotIn(...t){return this.filters.push({version:{$notIn:t}}),this}withVersionGreaterThan(t){return this.filters.push({version:{$gt:t}}),this}withVersionGreaterThanOrEqualTo(t){return this.filters.push({version:{$gte:t}}),this}withVersionLessThan(t){return this.filters.push({version:{$lt:t}}),this}withVersionLessThanOrEqualTo(t){return this.filters.push({version:{$lte:t}}),this}withVersionBetween(t,e){return this.filters.push({version:{$between:[t,e]}}),this}withVersionIsKnown(){return this.filters.push({version:{$isNull:!1}}),this}withVersionIsUnknown(){return this.filters.push({version:{$isNull:!0}}),this}orderByIdAscending(){return this.query.orderBy("id","asc"),this}orderByIdDescending(){return this.query.orderBy("id","desc"),this}orderByNameAscending(){return this.query.orderBy("name","asc"),this}orderByNameDescending(){return this.query.orderBy("name","desc"),this}orderByVersionAscending(){return this.query.orderBy("version","asc"),this}orderByVersionDescending(){return this.query.orderBy("version","desc"),this}count(){return this.query.aggregate("Count","id","count"),this._pageCountAlias="count",this._pageCountMethod="count",this}countAs(t){return this.query.aggregate("Count","id",t),this._pageCountAlias=t,this._pageCountMethod="countAs",this}groupById(){return this.query.groupBy("id"),this}groupByIdAs(t){return this.query.groupBy("id"),this}groupByName(){return this.query.groupBy("name"),this}groupByNameAs(t){return this.query.groupBy("name"),this}groupByVersion(){return this.query.groupBy("version"),this}groupByVersionAs(t){return this.query.groupBy("version"),this}async executeForListInternal(t){if(this.ensureIntent(),this._pageCountAlias!==void 0)return this.executeCountedListInternal(t);this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService"),i=await e.executeQuery(t.prepareQuery(this.query)),r=this.query.aggregateItems.length>0&&this.query.groupByItems.length===0,s=r?[]:i.map(n=>n instanceof y?n:y.fromRecord(n,new $)),a=new I(s);return r&&i[0]&&Object.assign(a.aggregations,i[0]),this.query.facets.length>0&&(a.facets=await C(e,n=>t.prepareQuery(n),this.query,this.query.facets)),a}async executeForRowsInternal(t){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService");return new I(await e.executeQuery(t.prepareQuery(this.query)))}async executeCountedListInternal(t){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService"),i=t.prepareQuery(this.query),r=i.localIdSetPaginationOptions()!==void 0,s={kind:"named-count",method:this._pageCountMethod??"count",...this._pageCountMethod==="countAs"?{alias:this._pageCountAlias}:{}},a=r?void 0:await e.executeCount(i,this._pageCountAlias,s),n=i.clone();n.aggregateItems=n.aggregateItems.filter(l=>!(String(l.function).toLowerCase()==="count"&&l.alias===this._pageCountAlias));const d=await e.executeQuery(n),u=r&&t.idSetPaginationCountAccuracy==="EXACT"?t.idSetPaginationCount:a??await e.executeCount(i,this._pageCountAlias,s),h=new I(d.map(l=>l instanceof y?l:y.fromRecord(l,new $)));return h.totalCount=u,this._pageCountAlias!==void 0&&(h.aggregations[this._pageCountAlias]=u),this.query.facets.length>0&&(h.facets=await C(e,l=>t.prepareQuery(l),i,i.facets)),h}executeForStreamInternal(t,e){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const i=t.requireResource("dataService"),r=t.prepareQuery(this.query),s=i.executeForStream(r,e);return(async function*(){for await(const a of s)for(const n of a)yield n instanceof y?n:y.fromRecord(n,new $)})()}ensureIntent(){new K(this._comment,this._purpose)}}class X{constructor(t,e,i,r,s,a){this.execute=t,this.executeRows=e,this.stream=i,this.limitOne=r,this.addComment=s,this.ensureIntent=a}execute;executeRows;stream;limitOne;addComment;ensureIntent;comment(t){return this.addComment(t),this}newEntity(t){return this.ensureIntent(),new y}executeForList(t){return this.ensureIntent(),this.execute(t)}executeForRows(t){return this.ensureIntent(),this.executeRows(t)}executeForStream(t,e=1e3){return this.ensureIntent(),this.stream(t,e)}async executeForOne(t){return this.limitOne(),(await this.executeForList(t))[0]}}class x{query;filters=[];_purpose;_comment;_pageCountAlias;_pageCountMethod;_dynamicSearchWarnings=[];constructor(t=!1){this.query=new L("WorkItem"),this.filters.push({version:{$gte:1}}),t?(this.selectId(),this.selectVersion()):this.selectSelfFields()}comment(t){return this.query.comment(t),this._comment=t,this}filterByJson(t,e){const i=this.query.clone();this.filters.length>0&&i.filter({$and:this.filters});const r=O(i,t,D,e);return this.query=r.query,this.filters=this.query.filterCondition?[this.query.filterCondition]:[],this._dynamicSearchWarnings.push(...r.warnings),this}get dynamicSearchWarnings(){return this._dynamicSearchWarnings.map(t=>({...t}))}purpose(t){return this.query.purpose(t),this._purpose=t,new Z(e=>e.withQueryRequest(this.query,()=>this.executeForListInternal(e)),e=>e.withQueryRequest(this.query,()=>this.executeForRowsInternal(e)),(e,i)=>this.executeForStreamInternal(e,i),()=>this.limit(1),e=>this.comment(e),()=>this.ensureIntent())}optimizeForContinuousPageFetch(){return this.query.optimizeForContinuousPageFetch(),this}optimizeForContinuousPageFetchWith(t,e){return this.query.optimizeForContinuousPageFetchWith(t,e),this}optimizePaginationWithIdSet(){return this.query.optimizePaginationWithIdSet(),this}optimizePaginationWithIdSetConfig(t,e,i){return this.query.optimizePaginationWithIdSetConfig(t,e,i),this}topNProbeParentThreshold(t){return this.query.topNProbeParentThreshold(t),this}limit(t){return this.query.limit(t),this}offset(t){return this.query.offset(t),this}toQuery(){return this.filters.length>0&&this.query.filter({$and:this.filters}),this.query}withDeletedRows(){return this.filters=this.filters.filter(t=>!("version"in t)),this}deletedRowsOnly(){return this.withDeletedRows(),this.filters.push({version:{$lte:-1}}),this}selectSelfFields(){return this.query.select(["id","title","description","platform","version"]),this}selectId(){return this.query.select(["id"]),this}selectTitle(){return this.query.select(["title"]),this}selectDescription(){return this.query.select(["description"]),this}selectVersion(){return this.query.select(["version"]),this}selectPlatformWith(t){return this.query.select(["platform"]),this.query.relationQuery("platform",t.toQuery(),"platform","id",!1,{kind:"relation-select",method:"selectPlatformWith",relation:"platform"}),this}withPlatformMatching(t){return this.filters.push({platform:{$inSubquery:{query:t.toQuery(),field:"id"}}}),this}withoutPlatformMatching(t){return this.filters.push({platform:{$notInSubquery:{query:t.toQuery(),field:"id"}}}),this}withIdIs(t){return this.filters.push({id:{$eq:t}}),this}withIdIsNot(t){return this.filters.push({id:{$ne:t}}),this}withIdIn(...t){return this.filters.push({id:{$in:t}}),this}withIdNotIn(...t){return this.filters.push({id:{$notIn:t}}),this}withIdGreaterThan(t){return this.filters.push({id:{$gt:t}}),this}withIdGreaterThanOrEqualTo(t){return this.filters.push({id:{$gte:t}}),this}withIdLessThan(t){return this.filters.push({id:{$lt:t}}),this}withIdLessThanOrEqualTo(t){return this.filters.push({id:{$lte:t}}),this}withIdBetween(t,e){return this.filters.push({id:{$between:[t,e]}}),this}withIdIsKnown(){return this.filters.push({id:{$isNull:!1}}),this}withIdIsUnknown(){return this.filters.push({id:{$isNull:!0}}),this}withTitleContaining(t){return this.filters.push({title:{$contains:t}}),this}withTitleIs(t){return this.filters.push({title:{$eq:t}}),this}withTitleIsNot(t){return this.filters.push({title:{$ne:t}}),this}withTitleIn(...t){return this.filters.push({title:{$in:t}}),this}withTitleNotIn(...t){return this.filters.push({title:{$notIn:t}}),this}withTitleGreaterThan(t){return this.filters.push({title:{$gt:t}}),this}withTitleGreaterThanOrEqualTo(t){return this.filters.push({title:{$gte:t}}),this}withTitleLessThan(t){return this.filters.push({title:{$lt:t}}),this}withTitleLessThanOrEqualTo(t){return this.filters.push({title:{$lte:t}}),this}withTitleBetween(t,e){return this.filters.push({title:{$between:[t,e]}}),this}withTitleIsKnown(){return this.filters.push({title:{$isNull:!1}}),this}withTitleIsUnknown(){return this.filters.push({title:{$isNull:!0}}),this}withTitleNotContaining(t){return this.filters.push({title:{$notContains:t}}),this}withTitleStartingWith(t){return this.filters.push({title:{$startsWith:t}}),this}withTitleNotStartingWith(t){return this.filters.push({title:{$notStartsWith:t}}),this}withTitleEndingWith(t){return this.filters.push({title:{$endsWith:t}}),this}withTitleNotEndingWith(t){return this.filters.push({title:{$notEndsWith:t}}),this}withTitleSoundingLike(t){return this.filters.push({title:{$soundLike:t}}),this}withDescriptionContaining(t){return this.filters.push({description:{$contains:t}}),this}withDescriptionIs(t){return this.filters.push({description:{$eq:t}}),this}withDescriptionIsNot(t){return this.filters.push({description:{$ne:t}}),this}withDescriptionIn(...t){return this.filters.push({description:{$in:t}}),this}withDescriptionNotIn(...t){return this.filters.push({description:{$notIn:t}}),this}withDescriptionGreaterThan(t){return this.filters.push({description:{$gt:t}}),this}withDescriptionGreaterThanOrEqualTo(t){return this.filters.push({description:{$gte:t}}),this}withDescriptionLessThan(t){return this.filters.push({description:{$lt:t}}),this}withDescriptionLessThanOrEqualTo(t){return this.filters.push({description:{$lte:t}}),this}withDescriptionBetween(t,e){return this.filters.push({description:{$between:[t,e]}}),this}withDescriptionIsKnown(){return this.filters.push({description:{$isNull:!1}}),this}withDescriptionIsUnknown(){return this.filters.push({description:{$isNull:!0}}),this}withDescriptionNotContaining(t){return this.filters.push({description:{$notContains:t}}),this}withDescriptionStartingWith(t){return this.filters.push({description:{$startsWith:t}}),this}withDescriptionNotStartingWith(t){return this.filters.push({description:{$notStartsWith:t}}),this}withDescriptionEndingWith(t){return this.filters.push({description:{$endsWith:t}}),this}withDescriptionNotEndingWith(t){return this.filters.push({description:{$notEndsWith:t}}),this}withDescriptionSoundingLike(t){return this.filters.push({description:{$soundLike:t}}),this}filterByPlatform(t){return this.filters.push({platform:{$eq:t}}),this}filterByPlatformIn(...t){return this.filters.push({platform:{$in:t}}),this}withPlatformIsKnown(){return this.filters.push({platform:{$isNull:!1}}),this}withPlatformIsUnknown(){return this.filters.push({platform:{$isNull:!0}}),this}withVersionIs(t){return this.filters.push({version:{$eq:t}}),this}withVersionIsNot(t){return this.filters.push({version:{$ne:t}}),this}withVersionIn(...t){return this.filters.push({version:{$in:t}}),this}withVersionNotIn(...t){return this.filters.push({version:{$notIn:t}}),this}withVersionGreaterThan(t){return this.filters.push({version:{$gt:t}}),this}withVersionGreaterThanOrEqualTo(t){return this.filters.push({version:{$gte:t}}),this}withVersionLessThan(t){return this.filters.push({version:{$lt:t}}),this}withVersionLessThanOrEqualTo(t){return this.filters.push({version:{$lte:t}}),this}withVersionBetween(t,e){return this.filters.push({version:{$between:[t,e]}}),this}withVersionIsKnown(){return this.filters.push({version:{$isNull:!1}}),this}withVersionIsUnknown(){return this.filters.push({version:{$isNull:!0}}),this}orderByIdAscending(){return this.query.orderBy("id","asc"),this}orderByIdDescending(){return this.query.orderBy("id","desc"),this}orderByTitleAscending(){return this.query.orderBy("title","asc"),this}orderByTitleDescending(){return this.query.orderBy("title","desc"),this}orderByDescriptionAscending(){return this.query.orderBy("description","asc"),this}orderByDescriptionDescending(){return this.query.orderBy("description","desc"),this}orderByVersionAscending(){return this.query.orderBy("version","asc"),this}orderByVersionDescending(){return this.query.orderBy("version","desc"),this}count(){return this.query.aggregate("Count","id","count"),this._pageCountAlias="count",this._pageCountMethod="count",this}countAs(t){return this.query.aggregate("Count","id",t),this._pageCountAlias=t,this._pageCountMethod="countAs",this}groupById(){return this.query.groupBy("id"),this}groupByIdAs(t){return this.query.groupBy("id"),this}groupByTitle(){return this.query.groupBy("title"),this}groupByTitleAs(t){return this.query.groupBy("title"),this}groupByDescription(){return this.query.groupBy("description"),this}groupByDescriptionAs(t){return this.query.groupBy("description"),this}groupByPlatform(){return this.query.groupBy("platform"),this}groupByPlatformAs(t){return this.query.groupBy("platform"),this}groupByVersion(){return this.query.groupBy("version"),this}groupByVersionAs(t){return this.query.groupBy("version"),this}facetByPlatformAs(t,e,i=!0){return this.query.facetBy(t,"platform",e,i,{kind:"facet",method:"facetByPlatformAs",relation:"platform",alias:t}),this}async executeForListInternal(t){if(this.ensureIntent(),this._pageCountAlias!==void 0)return this.executeCountedListInternal(t);this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService"),i=await e.executeQuery(t.prepareQuery(this.query)),r=this.query.aggregateItems.length>0&&this.query.groupByItems.length===0,s=r?[]:i.map(n=>n instanceof m?n:m.fromRecord(n,new $)),a=new I(s);return r&&i[0]&&Object.assign(a.aggregations,i[0]),this.query.facets.length>0&&(a.facets=await C(e,n=>t.prepareQuery(n),this.query,this.query.facets)),a}async executeForRowsInternal(t){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService");return new I(await e.executeQuery(t.prepareQuery(this.query)))}async executeCountedListInternal(t){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService"),i=t.prepareQuery(this.query),r=i.localIdSetPaginationOptions()!==void 0,s={kind:"named-count",method:this._pageCountMethod??"count",...this._pageCountMethod==="countAs"?{alias:this._pageCountAlias}:{}},a=r?void 0:await e.executeCount(i,this._pageCountAlias,s),n=i.clone();n.aggregateItems=n.aggregateItems.filter(l=>!(String(l.function).toLowerCase()==="count"&&l.alias===this._pageCountAlias));const d=await e.executeQuery(n),u=r&&t.idSetPaginationCountAccuracy==="EXACT"?t.idSetPaginationCount:a??await e.executeCount(i,this._pageCountAlias,s),h=new I(d.map(l=>l instanceof m?l:m.fromRecord(l,new $)));return h.totalCount=u,this._pageCountAlias!==void 0&&(h.aggregations[this._pageCountAlias]=u),this.query.facets.length>0&&(h.facets=await C(e,l=>t.prepareQuery(l),i,i.facets)),h}executeForStreamInternal(t,e){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const i=t.requireResource("dataService"),r=t.prepareQuery(this.query),s=i.executeForStream(r,e);return(async function*(){for await(const a of s)for(const n of a)yield n instanceof m?n:m.fromRecord(n,new $)})()}ensureIntent(){new K(this._comment,this._purpose)}}class Z{constructor(t,e,i,r,s,a){this.execute=t,this.executeRows=e,this.stream=i,this.limitOne=r,this.addComment=s,this.ensureIntent=a}execute;executeRows;stream;limitOne;addComment;ensureIntent;comment(t){return this.addComment(t),this}newEntity(t){return this.ensureIntent(),new m}executeForList(t){return this.ensureIntent(),this.execute(t)}executeForRows(t){return this.ensureIntent(),this.executeRows(t)}executeForStream(t,e=1e3){return this.ensureIntent(),this.stream(t,e)}async executeForOne(t){return this.limitOne(),(await this.executeForList(t))[0]}}class R{static platforms(){return new A(!1)}static platformsWithMinimalFields(){return new A(!0)}static workItems(){return new x(!1)}static workItemsWithMinimalFields(){return new x(!0)}}const tt={Platform:{table:"platform_data",auditMaskFields:[],columns:{id:{columnName:"id",modelName:"id",logPolicy:"plain",logicalType:"integer",decode:"string",nullable:!1},name:{columnName:"name",modelName:"name",logPolicy:"plain",logicalType:"text",decode:"native",nullable:!1},version:{columnName:"version",modelName:"version",logPolicy:"plain",logicalType:"integer",decode:"number",nullable:!1}},relations:{workItemList:{targetEntity:"WorkItem",localKey:"id",foreignKey:"platform",many:!0}}},WorkItem:{table:"work_item_data",auditMaskFields:[],columns:{id:{columnName:"id",modelName:"id",logPolicy:"plain",logicalType:"integer",decode:"string",nullable:!1},title:{columnName:"title",modelName:"title",logPolicy:"plain",logicalType:"text",decode:"native",nullable:!1},description:{columnName:"description",modelName:"description",logPolicy:"plain",logicalType:"text",decode:"native",nullable:!0},platform:{columnName:"platform",modelName:"platform",logPolicy:"plain",logicalType:"integer",decode:"string",nullable:!1},version:{columnName:"version",modelName:"version",logPolicy:"plain",logicalType:"integer",decode:"number",nullable:!1}},relations:{platform:{targetEntity:"Platform",localKey:"platform",foreignKey:"id",many:!1}}}};async function et(o){let t=(await R.platforms().withIdIs("1").comment("what: locate generated Domain Root").purpose("why: idempotent runtime bootstrap").executeForList(o))[0];t||(t=y.teaqlBootstrapNew("1"),t.updateName("Runtime Example"),await t.auditAs("create generated Domain Root Platform").save(o)),o.withActiveRoot({entity:"Platform",id:t.id})}const it=new U(tt,{Platform:{checkAndFix(o,t,e){o.getResource("fixTime"),(t.action==="Create"&&t.payload.name===void 0||t.payload.name===null)&&e.push({ruleId:"required",location:g.property("name")}),t.payload.name!=null&&[...String(t.payload.name)].length>100&&e.push({ruleId:"max_length",location:g.property("name"),inputValue:t.payload.name,systemValue:100})}},WorkItem:{checkAndFix(o,t,e){o.getResource("fixTime"),(t.action==="Create"&&t.payload.title===void 0||t.payload.title===null)&&e.push({ruleId:"required",location:g.property("title")}),t.payload.title!=null&&!([...String(t.payload.title)].length>=1)&&e.push({ruleId:"min_length",location:g.property("title"),inputValue:t.payload.title,systemValue:1}),t.payload.title!=null&&[...String(t.payload.title)].length>80&&e.push({ruleId:"max_length",location:g.property("title"),inputValue:t.payload.title,systemValue:80}),t.payload.description!=null&&[...String(t.payload.description)].length>100&&e.push({ruleId:"max_length",location:g.property("description"),inputValue:t.payload.description,systemValue:100}),(t.action==="Create"&&t.payload.platform===void 0||t.payload.platform===null)&&e.push({ruleId:"required",location:g.property("platform")})}}},{defaultDomainRoot:{entity:"Platform",id:"1",values:{name:"Runtime Example"}},constants:[],ensure:et}),rt={Platform:{table:"platform_data",columns:{id:{columnName:"id",modelName:"id",logicalType:"integer",decode:"string",nullable:!1},name:{columnName:"name",modelName:"name",logicalType:"text",decode:"native",nullable:!1},version:{columnName:"version",modelName:"version",logicalType:"integer",decode:"number",nullable:!1}},relations:{workItemList:{targetEntity:"WorkItem",localKey:"id",foreignKey:"platform",many:!0}}},WorkItem:{table:"work_item_data",columns:{id:{columnName:"id",modelName:"id",logicalType:"integer",decode:"string",nullable:!1},title:{columnName:"title",modelName:"title",logicalType:"text",decode:"native",nullable:!1},description:{columnName:"description",modelName:"description",logicalType:"text",decode:"native",nullable:!0},platform:{columnName:"platform",modelName:"platform",logicalType:"integer",decode:"string",nullable:!1},version:{columnName:"version",modelName:"version",logicalType:"integer",decode:"number",nullable:!1}},relations:{platform:{targetEntity:"Platform",localKey:"platform",foreignKey:"id",many:!1}}}},F=document.querySelector("#status"),st=document.querySelector("#result"),T=document.querySelector("#persist"),E=document.querySelector("#reset");let b;const M=localStorage.getItem("teaql-browser-storage")==="opfs"?"opfs":"memory";T.checked=M==="opfs";async function nt(o){const t=new Worker(new URL("/assets/sqlite.worker-DS5P4U1E.js",import.meta.url),{type:"module"}),e=await z.open(t,{...rt},{storage:o,databaseName:"teaql-browser-example.sqlite3"});e.install(it);const i=Object.freeze({policyId:"browser-demo-seed",version:"1",fingerprint:"sha256:browser-demo-seed-v1"}),r=new H().insertResource("dataService",e).withMutationPolicyRegistry(new J(()=>({identity:i,review:(s,a)=>a.operations.length>0?{verdict:"allow"}:{verdict:"deny",code:"EMPTY_GRAPH",message:"empty mutation graph"}}))).withMutationPolicyApprovalProvider(new Y(s=>({policy:s,approvedBy:"browser-demo-owner",approvedAt:new Date})));return e.setUserContext(r),await r.ensureSchema(),{client:e,context:r}}async function Q({context:o}){if(!(await R.workItemsWithMinimalFields().comment("what: detect existing browser demo records").purpose("why: keep generated mutation bootstrap idempotent").executeForList(o)).length)for(const e of["Evaluate semantic model","Generate typed library","Verify browser runtime"])await new m().updateTitle(e).updatePlatform("1").auditAs("seed deterministic browser demo data").save(o)}async function V(o){const t=await R.workItems().selectTitle().orderByIdAscending().limit(20).comment("what: load browser-local work items").purpose("why: prove the generated Q API runs without a backend").executeForList(o.context);st.textContent=JSON.stringify(t,null,2),F.textContent=`${o.client.storage.toUpperCase()} · ${t.length} rows · policy installed · ready`}async function j(o){F.textContent=`Opening ${o.toUpperCase()} SQLite/WASM…`;const t=b;b=void 0,await t?.client.close();const e=await nt(o);b=e,await Q(e),await V(e)}T.addEventListener("change",()=>{const o=T.checked?"opfs":"memory";localStorage.setItem("teaql-browser-storage",o),j(o).catch(W)});E.addEventListener("click",async()=>{if(b){E.disabled=!0;try{await b.client.reset(b.context),await Q(b),await V(b)}catch(o){W(o)}finally{E.disabled=!1}}});function W(o){const t=o instanceof Error?o:new Error(String(o));F.textContent=`${t.name}: ${t.message}`}j(M).catch(W);
|
|
|
|
| 1 |
+
import{S as G,L as c,M as k,C as v,a as I,d as O,e as C,Q as K,R as U,B as z,U as H,D as J,c as Y}from"./dynamic-search-Ch_QcWVU.js";import{E as $,O as g}from"./object-location-CJfVWqJC.js";class L extends G{orderBy(t,e){return this.order({field:t,expr:null,direction:e==="desc"?"Desc":"Asc"})}relationQuery(t,e,i="id",r="id",s=!0,a){return super.relationQuery(t,e,i,r,s,a)}}class m{static teaqlTemporaryId=0;id;title;description;platform;version;constructor(t){if(Object.defineProperty(this,"_action",{value:t&&t.id?"Update":"Create",writable:!0,enumerable:!1}),Object.defineProperty(this,"_comment",{value:void 0,writable:!0,enumerable:!1}),Object.defineProperty(this,"_fullyLoaded",{value:!t||!t.id,writable:!0,enumerable:!1}),Object.defineProperty(this,"_loadedFields",{value:new Set(Object.keys(t||{})),writable:!0,enumerable:!1}),Object.defineProperty(this,"_root",{value:new $,writable:!0,enumerable:!1}),Object.defineProperty(this,"_ledgerId",{value:t?.id??--m.teaqlTemporaryId,writable:!0,enumerable:!1}),t){const i={...t};Object.assign(this,i),t.platform&&typeof t.platform=="object"&&(this.platform=t.platform instanceof y?t.platform:y.fromRecord(t.platform),this.markLoaded("platform"))}const e=this.teaqlEntityKey();this._action==="Create"?this._root.markAsNew(e):this.version!==void 0&&this._root.setOriginalVersion(e,Number(this.version)),c.captureFor(this,this.teaqlMutationPayload())}teaqlEntityKey(){return{entity:"WorkItem",id:this._ledgerId}}teaqlAttachRoot(t){return this._root!==t&&(t.mergeEntityFrom(this._root,this.teaqlEntityKey()),this._root=t),this}static fromRecord(t,e){const i=new m(t);return e?i.teaqlAttachRoot(e):i}isLoaded(t){return this._fullyLoaded||this._loadedFields.has(t)}markLoaded(...t){for(const e of t)this._loadedFields.add(e);return this}markLoadedOnly(...t){return this._fullyLoaded=!1,this._loadedFields=new Set(t),this}static refer(t){return new m({id:String(t)})}static teaqlBootstrapNew(t){return new m().updateId(String(t))}markForDeletion(){return this._action="Delete",this._root.markAsDeleted(this.teaqlEntityKey()),this}auditAs(t){return new k(t),this._comment=t,this}async save(t){const e=t.requireResource("dataService");return e.executeGraphSave(new k(this._comment),async i=>(this.teaqlPreflightGraph(t,e,i),this.teaqlSaveWithinGraph(t,e,i)))}teaqlPreflightGraph(t,e,i,r){r||new k(this._comment);const s=this._action,a=s!=="Update"||this._root.hasPending(this.teaqlEntityKey());if(s==="Update"&&a){const d=[{member:"id",canonical:"id"},{member:"title",canonical:"title"},{member:"description",canonical:"description"},{member:"platform",canonical:"platform"},{member:"version",canonical:"version"}].find(u=>!this.isLoaded(u.member));if(d)throw new v([{ruleId:"invalid_type",location:g.property(d.canonical),message:"Mutation requires a fully loaded entity"}])}const n=i.request({entity:"WorkItem",action:s,payload:s==="Update"?this._root.change(this.teaqlEntityKey()):this.teaqlMutationPayload(),id:this.id,version:this.version,comment:this._comment,ledgerKey:this.teaqlEntityKey(),ledgerRoot:this._root},r,this._comment).withLoadedSnapshot(c.forEntity(this)??new c);a&&e.preflightMutation(n),n.scopeFor(this.teaqlEntityKey())}async teaqlSaveWithinGraph(t,e,i,r){r||new k(this._comment);const s=this._action,a=this._root.change(this.teaqlEntityKey()),n={entity:"WorkItem",action:this._action,payload:s==="Update"?a:this.teaqlMutationPayload(),id:this.id,version:this.version,comment:this._comment,ledgerKey:this.teaqlEntityKey(),ledgerRoot:this._root},d=i.request(n,r,this._comment).withLoadedSnapshot(c.forEntity(this)??new c);if(s==="Update"&&!this._root.hasPending(this.teaqlEntityKey()))return d.scopeFor(this.teaqlEntityKey()),this;const u=await e.executeMutation(d);for(const[S,f]of Object.entries(n.payload))S!=="id"&&S!=="version"&&this._root.set(this.teaqlEntityKey(),S,f);if(!u.persistedRecord)throw new Error("Mutation did not return the authoritative persisted record");const h={payload:this.teaqlMutationPayload(),ledgerId:this._ledgerId,action:this._action,loadedFields:new Set(this._loadedFields),fullyLoaded:this._fullyLoaded,loadedSnapshot:c.forEntity(this)},l=this.teaqlEntityKey();Object.assign(this,u.persistedRecord),c.captureFor(this,this.teaqlMutationPayload()),this._ledgerId=this.id??this._ledgerId;const p=this.teaqlEntityKey();return this._root.rekey(l,p),e.afterGraphRollback(()=>{Object.assign(this,h.payload),this._ledgerId=h.ledgerId,this._action=h.action,this._loadedFields=h.loadedFields,this._fullyLoaded=h.fullyLoaded,c.restoreFor(this,h.loadedSnapshot),this._root.rekey(p,l)}),this._loadedFields=new Set(Object.keys(u.persistedRecord)),this._fullyLoaded=!1,n.action!=="Delete"&&(this._action="Update"),d.scopeFor(p),e.afterGraphCommit(()=>{this._root.clearEntity(p),this.version!==void 0&&this._root.acceptCommittedVersion(p,Number(this.version))}),this}teaqlMutationPayload(){return{id:this.id,title:this.title,description:this.description,platform:this.platform,version:this.version}}updateId(t){return this.id=t,this.markLoaded("id"),this._root.set(this.teaqlEntityKey(),"id",t),this}updateTitle(t){return this.title=t,this.markLoaded("title"),this._root.set(this.teaqlEntityKey(),"title",t),this}updateDescription(t){return this.description=t,this.markLoaded("description"),this._root.set(this.teaqlEntityKey(),"description",t),this}updateVersion(t){return this.version=t,this.markLoaded("version"),this._root.set(this.teaqlEntityKey(),"version",t),this}updatePlatform(t){return this.platform=t?.id??t,this.markLoaded("platform"),this._root.set(this.teaqlEntityKey(),"platform",this.platform),this}}class y{static teaqlTemporaryId=0;id;name;version;constructor(t){if(Object.defineProperty(this,"_action",{value:t&&t.id?"Update":"Create",writable:!0,enumerable:!1}),Object.defineProperty(this,"_comment",{value:void 0,writable:!0,enumerable:!1}),Object.defineProperty(this,"_fullyLoaded",{value:!t||!t.id,writable:!0,enumerable:!1}),Object.defineProperty(this,"_loadedFields",{value:new Set(Object.keys(t||{})),writable:!0,enumerable:!1}),Object.defineProperty(this,"_root",{value:new $,writable:!0,enumerable:!1}),Object.defineProperty(this,"_ledgerId",{value:t?.id??--y.teaqlTemporaryId,writable:!0,enumerable:!1}),Object.defineProperty(this,"_workItemList",{value:t?.id?I.empty():new I,writable:!0,enumerable:!1}),t){const i={...t};if(delete i.workItemList,Object.assign(this,i),Array.isArray(t.workItemList)){const r=t.workItemList;this._workItemList=new I(r.map(s=>s instanceof m?s:m.fromRecord(s)),{totalCount:r.totalCount,aggregations:r.aggregations,summary:r.summary,facets:r.facets,isLoaded:r.isLoaded??!0}),this.markLoaded("workItemList")}}const e=this.teaqlEntityKey();this._action==="Create"?this._root.markAsNew(e):this.version!==void 0&&this._root.setOriginalVersion(e,Number(this.version)),c.captureFor(this,this.teaqlMutationPayload())}teaqlEntityKey(){return{entity:"Platform",id:this._ledgerId}}teaqlAttachRoot(t){this._root!==t&&(t.mergeEntityFrom(this._root,this.teaqlEntityKey()),this._root=t);for(const e of this._workItemList)e.teaqlAttachRoot(t);return this}static fromRecord(t,e){const i=new y(t);return e?i.teaqlAttachRoot(e):i}isLoaded(t){return this._fullyLoaded||this._loadedFields.has(t)}markLoaded(...t){for(const e of t)this._loadedFields.add(e);return this}markLoadedOnly(...t){return this._fullyLoaded=!1,this._loadedFields=new Set(t),this}static refer(t){return new y({id:String(t)})}static teaqlBootstrapNew(t){return new y().updateId(String(t))}markForDeletion(){return this._action="Delete",this._root.markAsDeleted(this.teaqlEntityKey()),this}auditAs(t){return new k(t),this._comment=t,this}async save(t){const e=t.requireResource("dataService");return e.executeGraphSave(new k(this._comment),async i=>(this.teaqlPreflightGraph(t,e,i),this.teaqlSaveWithinGraph(t,e,i)))}teaqlPreflightGraph(t,e,i,r){r||new k(this._comment);const s=this._action,a=s!=="Update"||this._root.hasPending(this.teaqlEntityKey());if(s==="Update"&&a){const u=[{member:"id",canonical:"id"},{member:"name",canonical:"name"},{member:"version",canonical:"version"}].find(h=>!this.isLoaded(h.member));if(u)throw new v([{ruleId:"invalid_type",location:g.property(u.canonical),message:"Mutation requires a fully loaded entity"}])}const n=i.request({entity:"Platform",action:s,payload:s==="Update"?this._root.change(this.teaqlEntityKey()):this.teaqlMutationPayload(),id:this.id,version:this.version,comment:this._comment,ledgerKey:this.teaqlEntityKey(),ledgerRoot:this._root},r,this._comment).withLoadedSnapshot(c.forEntity(this)??new c);a&&e.preflightMutation(n);const d=n.scopeFor(this.teaqlEntityKey());for(const[u,h]of this._workItemList.entries()){h.teaqlAttachRoot(this._root);const l=h.platform;(this.id===void 0||!h.isLoaded("platform")||(typeof l=="object"&&l!==null?l.id:l)!==this.id)&&h.updatePlatform(this);try{h.teaqlPreflightGraph(t,e,i,d)}catch(p){if(!(p instanceof v))throw p;const S=g.property("work_item_list").index(u);throw new v(p.violations.map(f=>({...f,location:f.location.prefixedBy(S)})))}}}async teaqlSaveWithinGraph(t,e,i,r){r||new k(this._comment);const s=this._action,a=this._root.change(this.teaqlEntityKey()),n={entity:"Platform",action:this._action,payload:s==="Update"?a:this.teaqlMutationPayload(),id:this.id,version:this.version,comment:this._comment,ledgerKey:this.teaqlEntityKey(),ledgerRoot:this._root},d=i.request(n,r,this._comment).withLoadedSnapshot(c.forEntity(this)??new c);if(s==="Update"&&!this._root.hasPending(this.teaqlEntityKey())){const f=d.scopeFor(this.teaqlEntityKey());for(const[q,w]of this._workItemList.entries()){w.teaqlAttachRoot(this._root);const _=w.platform;(this.id===void 0||!w.isLoaded("platform")||(typeof _=="object"&&_!==null?_.id:_)!==this.id)&&w.updatePlatform(this);try{await w.teaqlSaveWithinGraph(t,e,i,f)}catch(N){if(!(N instanceof v))throw N;const P=g.property("work_item_list").index(q);throw new v(N.violations.map(B=>({...B,location:B.location.prefixedBy(P)})))}}return this}const u=await e.executeMutation(d);for(const[f,q]of Object.entries(n.payload))f!=="id"&&f!=="version"&&this._root.set(this.teaqlEntityKey(),f,q);if(!u.persistedRecord)throw new Error("Mutation did not return the authoritative persisted record");const h={payload:this.teaqlMutationPayload(),ledgerId:this._ledgerId,action:this._action,loadedFields:new Set(this._loadedFields),fullyLoaded:this._fullyLoaded,loadedSnapshot:c.forEntity(this)},l=this.teaqlEntityKey();Object.assign(this,u.persistedRecord),c.captureFor(this,this.teaqlMutationPayload()),this._ledgerId=this.id??this._ledgerId;const p=this.teaqlEntityKey();this._root.rekey(l,p),e.afterGraphRollback(()=>{Object.assign(this,h.payload),this._ledgerId=h.ledgerId,this._action=h.action,this._loadedFields=h.loadedFields,this._fullyLoaded=h.fullyLoaded,c.restoreFor(this,h.loadedSnapshot),this._root.rekey(p,l)}),this._loadedFields=new Set(Object.keys(u.persistedRecord)),this._fullyLoaded=!1,n.action!=="Delete"&&(this._action="Update");const S=d.scopeFor(p);for(const[f,q]of this._workItemList.entries()){q.teaqlAttachRoot(this._root);const w=q.platform;(this.id===void 0||!q.isLoaded("platform")||(typeof w=="object"&&w!==null?w.id:w)!==this.id)&&q.updatePlatform(this);try{await q.teaqlSaveWithinGraph(t,e,i,S)}catch(_){if(!(_ instanceof v))throw _;const N=g.property("work_item_list").index(f);throw new v(_.violations.map(P=>({...P,location:P.location.prefixedBy(N)})))}}return e.afterGraphCommit(()=>{this._root.clearEntity(p),this.version!==void 0&&this._root.acceptCommittedVersion(p,Number(this.version))}),this}teaqlMutationPayload(){return{id:this.id,name:this.name,version:this.version}}updateId(t){return this.id=t,this.markLoaded("id"),this._root.set(this.teaqlEntityKey(),"id",t),this}updateName(t){return this.name=t,this.markLoaded("name"),this._root.set(this.teaqlEntityKey(),"name",t),this}updateVersion(t){return this.version=t,this.markLoaded("version"),this._root.set(this.teaqlEntityKey(),"version",t),this}workItemList(){return this._workItemList}}const D=Object.freeze({Platform:Object.freeze({fields:Object.freeze({id:"integer",name:"string",version:"integer"}),queryFields:Object.freeze({id:"id",name:"name",version:"version"}),relations:Object.freeze({workItemList:"WorkItem"})}),WorkItem:Object.freeze({fields:Object.freeze({id:"integer",title:"string",description:"string",platform:"integer",version:"integer"}),queryFields:Object.freeze({id:"id",title:"title",description:"description",platform:"platform",version:"version"}),relations:Object.freeze({platform:"Platform"})})});class A{query;filters=[];_purpose;_comment;_pageCountAlias;_pageCountMethod;_dynamicSearchWarnings=[];constructor(t=!1){this.query=new L("Platform"),this.filters.push({version:{$gte:1}}),t?(this.selectId(),this.selectVersion()):this.selectSelfFields()}comment(t){return this.query.comment(t),this._comment=t,this}filterByJson(t,e){const i=this.query.clone();this.filters.length>0&&i.filter({$and:this.filters});const r=O(i,t,D,e);return this.query=r.query,this.filters=this.query.filterCondition?[this.query.filterCondition]:[],this._dynamicSearchWarnings.push(...r.warnings),this}get dynamicSearchWarnings(){return this._dynamicSearchWarnings.map(t=>({...t}))}purpose(t){return this.query.purpose(t),this._purpose=t,new X(e=>e.withQueryRequest(this.query,()=>this.executeForListInternal(e)),e=>e.withQueryRequest(this.query,()=>this.executeForRowsInternal(e)),(e,i)=>this.executeForStreamInternal(e,i),()=>this.limit(1),e=>this.comment(e),()=>this.ensureIntent())}optimizeForContinuousPageFetch(){return this.query.optimizeForContinuousPageFetch(),this}optimizeForContinuousPageFetchWith(t,e){return this.query.optimizeForContinuousPageFetchWith(t,e),this}optimizePaginationWithIdSet(){return this.query.optimizePaginationWithIdSet(),this}optimizePaginationWithIdSetConfig(t,e,i){return this.query.optimizePaginationWithIdSetConfig(t,e,i),this}topNProbeParentThreshold(t){return this.query.topNProbeParentThreshold(t),this}limit(t){return this.query.limit(t),this}offset(t){return this.query.offset(t),this}toQuery(){return this.filters.length>0&&this.query.filter({$and:this.filters}),this.query}withDeletedRows(){return this.filters=this.filters.filter(t=>!("version"in t)),this}deletedRowsOnly(){return this.withDeletedRows(),this.filters.push({version:{$lte:-1}}),this}selectSelfFields(){return this.query.select(["id","name","version"]),this}selectId(){return this.query.select(["id"]),this}selectName(){return this.query.select(["name"]),this}selectVersion(){return this.query.select(["version"]),this}selectWorkItemListWith(t){return this.query.relationQuery("workItemList",t.toQuery(),"id","platform",!0,{kind:"relation-select",method:"selectWorkItemListWith",relation:"workItemList"}),this}haveWorkItems(){return this.withWorkItemListMatching({toQuery:()=>new L("WorkItem")})}haveNoWorkItems(){return this.withoutWorkItemListMatching({toQuery:()=>new L("WorkItem")})}withWorkItemListMatching(t){return this.filters.push({id:{$inSubquery:{query:t.toQuery(),field:"platform"}}}),this}withoutWorkItemListMatching(t){return this.filters.push({id:{$notInSubquery:{query:t.toQuery(),field:"platform"}}}),this}countWorkItems(){return this.countWorkItemsAs("countWorkItems")}countWorkItemsAs(t){const e=new L("WorkItem").filter({version:{$gte:1}});return this.countWorkItemsWith(t,{toQuery:()=>e}),this.query.relationAggregates[this.query.relationAggregates.length-1].operation={kind:"relation-count",method:"countWorkItemsAs",relation:"workItemList",alias:t},this}countWorkItemsWith(t,e){const i=e.toQuery().clone();return i.aggregateItems=[],i.aggregate("Count","id",t),this.query.relationAggregate("workItemList",t,i,!0,{kind:"relation-count",method:"countWorkItemsWith",relation:"workItemList",alias:t}),this}withIdIs(t){return this.filters.push({id:{$eq:t}}),this}withIdIsNot(t){return this.filters.push({id:{$ne:t}}),this}withIdIn(...t){return this.filters.push({id:{$in:t}}),this}withIdNotIn(...t){return this.filters.push({id:{$notIn:t}}),this}withIdGreaterThan(t){return this.filters.push({id:{$gt:t}}),this}withIdGreaterThanOrEqualTo(t){return this.filters.push({id:{$gte:t}}),this}withIdLessThan(t){return this.filters.push({id:{$lt:t}}),this}withIdLessThanOrEqualTo(t){return this.filters.push({id:{$lte:t}}),this}withIdBetween(t,e){return this.filters.push({id:{$between:[t,e]}}),this}withIdIsKnown(){return this.filters.push({id:{$isNull:!1}}),this}withIdIsUnknown(){return this.filters.push({id:{$isNull:!0}}),this}withNameContaining(t){return this.filters.push({name:{$contains:t}}),this}withNameIs(t){return this.filters.push({name:{$eq:t}}),this}withNameIsNot(t){return this.filters.push({name:{$ne:t}}),this}withNameIn(...t){return this.filters.push({name:{$in:t}}),this}withNameNotIn(...t){return this.filters.push({name:{$notIn:t}}),this}withNameGreaterThan(t){return this.filters.push({name:{$gt:t}}),this}withNameGreaterThanOrEqualTo(t){return this.filters.push({name:{$gte:t}}),this}withNameLessThan(t){return this.filters.push({name:{$lt:t}}),this}withNameLessThanOrEqualTo(t){return this.filters.push({name:{$lte:t}}),this}withNameBetween(t,e){return this.filters.push({name:{$between:[t,e]}}),this}withNameIsKnown(){return this.filters.push({name:{$isNull:!1}}),this}withNameIsUnknown(){return this.filters.push({name:{$isNull:!0}}),this}withNameNotContaining(t){return this.filters.push({name:{$notContains:t}}),this}withNameStartingWith(t){return this.filters.push({name:{$startsWith:t}}),this}withNameNotStartingWith(t){return this.filters.push({name:{$notStartsWith:t}}),this}withNameEndingWith(t){return this.filters.push({name:{$endsWith:t}}),this}withNameNotEndingWith(t){return this.filters.push({name:{$notEndsWith:t}}),this}withNameSoundingLike(t){return this.filters.push({name:{$soundLike:t}}),this}withVersionIs(t){return this.filters.push({version:{$eq:t}}),this}withVersionIsNot(t){return this.filters.push({version:{$ne:t}}),this}withVersionIn(...t){return this.filters.push({version:{$in:t}}),this}withVersionNotIn(...t){return this.filters.push({version:{$notIn:t}}),this}withVersionGreaterThan(t){return this.filters.push({version:{$gt:t}}),this}withVersionGreaterThanOrEqualTo(t){return this.filters.push({version:{$gte:t}}),this}withVersionLessThan(t){return this.filters.push({version:{$lt:t}}),this}withVersionLessThanOrEqualTo(t){return this.filters.push({version:{$lte:t}}),this}withVersionBetween(t,e){return this.filters.push({version:{$between:[t,e]}}),this}withVersionIsKnown(){return this.filters.push({version:{$isNull:!1}}),this}withVersionIsUnknown(){return this.filters.push({version:{$isNull:!0}}),this}orderByIdAscending(){return this.query.orderBy("id","asc"),this}orderByIdDescending(){return this.query.orderBy("id","desc"),this}orderByNameAscending(){return this.query.orderBy("name","asc"),this}orderByNameDescending(){return this.query.orderBy("name","desc"),this}orderByVersionAscending(){return this.query.orderBy("version","asc"),this}orderByVersionDescending(){return this.query.orderBy("version","desc"),this}count(){return this.query.aggregate("Count","id","count"),this._pageCountAlias="count",this._pageCountMethod="count",this}countAs(t){return this.query.aggregate("Count","id",t),this._pageCountAlias=t,this._pageCountMethod="countAs",this}groupById(){return this.query.groupBy("id"),this}groupByIdAs(t){return this.query.groupBy("id"),this}groupByName(){return this.query.groupBy("name"),this}groupByNameAs(t){return this.query.groupBy("name"),this}groupByVersion(){return this.query.groupBy("version"),this}groupByVersionAs(t){return this.query.groupBy("version"),this}async executeForListInternal(t){if(this.ensureIntent(),this._pageCountAlias!==void 0)return this.executeCountedListInternal(t);this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService"),i=await e.executeQuery(t.prepareQuery(this.query)),r=this.query.aggregateItems.length>0&&this.query.groupByItems.length===0,s=r?[]:i.map(n=>n instanceof y?n:y.fromRecord(n,new $)),a=new I(s);return r&&i[0]&&Object.assign(a.aggregations,i[0]),this.query.facets.length>0&&(a.facets=await C(e,n=>t.prepareQuery(n),this.query,this.query.facets)),a}async executeForRowsInternal(t){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService");return new I(await e.executeQuery(t.prepareQuery(this.query)))}async executeCountedListInternal(t){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService"),i=t.prepareQuery(this.query),r=i.localIdSetPaginationOptions()!==void 0,s={kind:"named-count",method:this._pageCountMethod??"count",...this._pageCountMethod==="countAs"?{alias:this._pageCountAlias}:{}},a=r?void 0:await e.executeCount(i,this._pageCountAlias,s),n=i.clone();n.aggregateItems=n.aggregateItems.filter(l=>!(String(l.function).toLowerCase()==="count"&&l.alias===this._pageCountAlias));const d=await e.executeQuery(n),u=r&&t.idSetPaginationCountAccuracy==="EXACT"?t.idSetPaginationCount:a??await e.executeCount(i,this._pageCountAlias,s),h=new I(d.map(l=>l instanceof y?l:y.fromRecord(l,new $)));return h.totalCount=u,this._pageCountAlias!==void 0&&(h.aggregations[this._pageCountAlias]=u),this.query.facets.length>0&&(h.facets=await C(e,l=>t.prepareQuery(l),i,i.facets)),h}executeForStreamInternal(t,e){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const i=t.requireResource("dataService"),r=t.prepareQuery(this.query),s=i.executeForStream(r,e);return(async function*(){for await(const a of s)for(const n of a)yield n instanceof y?n:y.fromRecord(n,new $)})()}ensureIntent(){new K(this._comment,this._purpose)}}class X{constructor(t,e,i,r,s,a){this.execute=t,this.executeRows=e,this.stream=i,this.limitOne=r,this.addComment=s,this.ensureIntent=a}execute;executeRows;stream;limitOne;addComment;ensureIntent;comment(t){return this.addComment(t),this}newEntity(t){return this.ensureIntent(),new y}executeForList(t){return this.ensureIntent(),this.execute(t)}executeForRows(t){return this.ensureIntent(),this.executeRows(t)}executeForStream(t,e=1e3){return this.ensureIntent(),this.stream(t,e)}async executeForOne(t){return this.limitOne(),(await this.executeForList(t))[0]}}class x{query;filters=[];_purpose;_comment;_pageCountAlias;_pageCountMethod;_dynamicSearchWarnings=[];constructor(t=!1){this.query=new L("WorkItem"),this.filters.push({version:{$gte:1}}),t?(this.selectId(),this.selectVersion()):this.selectSelfFields()}comment(t){return this.query.comment(t),this._comment=t,this}filterByJson(t,e){const i=this.query.clone();this.filters.length>0&&i.filter({$and:this.filters});const r=O(i,t,D,e);return this.query=r.query,this.filters=this.query.filterCondition?[this.query.filterCondition]:[],this._dynamicSearchWarnings.push(...r.warnings),this}get dynamicSearchWarnings(){return this._dynamicSearchWarnings.map(t=>({...t}))}purpose(t){return this.query.purpose(t),this._purpose=t,new Z(e=>e.withQueryRequest(this.query,()=>this.executeForListInternal(e)),e=>e.withQueryRequest(this.query,()=>this.executeForRowsInternal(e)),(e,i)=>this.executeForStreamInternal(e,i),()=>this.limit(1),e=>this.comment(e),()=>this.ensureIntent())}optimizeForContinuousPageFetch(){return this.query.optimizeForContinuousPageFetch(),this}optimizeForContinuousPageFetchWith(t,e){return this.query.optimizeForContinuousPageFetchWith(t,e),this}optimizePaginationWithIdSet(){return this.query.optimizePaginationWithIdSet(),this}optimizePaginationWithIdSetConfig(t,e,i){return this.query.optimizePaginationWithIdSetConfig(t,e,i),this}topNProbeParentThreshold(t){return this.query.topNProbeParentThreshold(t),this}limit(t){return this.query.limit(t),this}offset(t){return this.query.offset(t),this}toQuery(){return this.filters.length>0&&this.query.filter({$and:this.filters}),this.query}withDeletedRows(){return this.filters=this.filters.filter(t=>!("version"in t)),this}deletedRowsOnly(){return this.withDeletedRows(),this.filters.push({version:{$lte:-1}}),this}selectSelfFields(){return this.query.select(["id","title","description","platform","version"]),this}selectId(){return this.query.select(["id"]),this}selectTitle(){return this.query.select(["title"]),this}selectDescription(){return this.query.select(["description"]),this}selectVersion(){return this.query.select(["version"]),this}selectPlatformWith(t){return this.query.select(["platform"]),this.query.relationQuery("platform",t.toQuery(),"platform","id",!1,{kind:"relation-select",method:"selectPlatformWith",relation:"platform"}),this}withPlatformMatching(t){return this.filters.push({platform:{$inSubquery:{query:t.toQuery(),field:"id"}}}),this}withoutPlatformMatching(t){return this.filters.push({platform:{$notInSubquery:{query:t.toQuery(),field:"id"}}}),this}withIdIs(t){return this.filters.push({id:{$eq:t}}),this}withIdIsNot(t){return this.filters.push({id:{$ne:t}}),this}withIdIn(...t){return this.filters.push({id:{$in:t}}),this}withIdNotIn(...t){return this.filters.push({id:{$notIn:t}}),this}withIdGreaterThan(t){return this.filters.push({id:{$gt:t}}),this}withIdGreaterThanOrEqualTo(t){return this.filters.push({id:{$gte:t}}),this}withIdLessThan(t){return this.filters.push({id:{$lt:t}}),this}withIdLessThanOrEqualTo(t){return this.filters.push({id:{$lte:t}}),this}withIdBetween(t,e){return this.filters.push({id:{$between:[t,e]}}),this}withIdIsKnown(){return this.filters.push({id:{$isNull:!1}}),this}withIdIsUnknown(){return this.filters.push({id:{$isNull:!0}}),this}withTitleContaining(t){return this.filters.push({title:{$contains:t}}),this}withTitleIs(t){return this.filters.push({title:{$eq:t}}),this}withTitleIsNot(t){return this.filters.push({title:{$ne:t}}),this}withTitleIn(...t){return this.filters.push({title:{$in:t}}),this}withTitleNotIn(...t){return this.filters.push({title:{$notIn:t}}),this}withTitleGreaterThan(t){return this.filters.push({title:{$gt:t}}),this}withTitleGreaterThanOrEqualTo(t){return this.filters.push({title:{$gte:t}}),this}withTitleLessThan(t){return this.filters.push({title:{$lt:t}}),this}withTitleLessThanOrEqualTo(t){return this.filters.push({title:{$lte:t}}),this}withTitleBetween(t,e){return this.filters.push({title:{$between:[t,e]}}),this}withTitleIsKnown(){return this.filters.push({title:{$isNull:!1}}),this}withTitleIsUnknown(){return this.filters.push({title:{$isNull:!0}}),this}withTitleNotContaining(t){return this.filters.push({title:{$notContains:t}}),this}withTitleStartingWith(t){return this.filters.push({title:{$startsWith:t}}),this}withTitleNotStartingWith(t){return this.filters.push({title:{$notStartsWith:t}}),this}withTitleEndingWith(t){return this.filters.push({title:{$endsWith:t}}),this}withTitleNotEndingWith(t){return this.filters.push({title:{$notEndsWith:t}}),this}withTitleSoundingLike(t){return this.filters.push({title:{$soundLike:t}}),this}withDescriptionContaining(t){return this.filters.push({description:{$contains:t}}),this}withDescriptionIs(t){return this.filters.push({description:{$eq:t}}),this}withDescriptionIsNot(t){return this.filters.push({description:{$ne:t}}),this}withDescriptionIn(...t){return this.filters.push({description:{$in:t}}),this}withDescriptionNotIn(...t){return this.filters.push({description:{$notIn:t}}),this}withDescriptionGreaterThan(t){return this.filters.push({description:{$gt:t}}),this}withDescriptionGreaterThanOrEqualTo(t){return this.filters.push({description:{$gte:t}}),this}withDescriptionLessThan(t){return this.filters.push({description:{$lt:t}}),this}withDescriptionLessThanOrEqualTo(t){return this.filters.push({description:{$lte:t}}),this}withDescriptionBetween(t,e){return this.filters.push({description:{$between:[t,e]}}),this}withDescriptionIsKnown(){return this.filters.push({description:{$isNull:!1}}),this}withDescriptionIsUnknown(){return this.filters.push({description:{$isNull:!0}}),this}withDescriptionNotContaining(t){return this.filters.push({description:{$notContains:t}}),this}withDescriptionStartingWith(t){return this.filters.push({description:{$startsWith:t}}),this}withDescriptionNotStartingWith(t){return this.filters.push({description:{$notStartsWith:t}}),this}withDescriptionEndingWith(t){return this.filters.push({description:{$endsWith:t}}),this}withDescriptionNotEndingWith(t){return this.filters.push({description:{$notEndsWith:t}}),this}withDescriptionSoundingLike(t){return this.filters.push({description:{$soundLike:t}}),this}filterByPlatform(t){return this.filters.push({platform:{$eq:t}}),this}filterByPlatformIn(...t){return this.filters.push({platform:{$in:t}}),this}withPlatformIsKnown(){return this.filters.push({platform:{$isNull:!1}}),this}withPlatformIsUnknown(){return this.filters.push({platform:{$isNull:!0}}),this}withVersionIs(t){return this.filters.push({version:{$eq:t}}),this}withVersionIsNot(t){return this.filters.push({version:{$ne:t}}),this}withVersionIn(...t){return this.filters.push({version:{$in:t}}),this}withVersionNotIn(...t){return this.filters.push({version:{$notIn:t}}),this}withVersionGreaterThan(t){return this.filters.push({version:{$gt:t}}),this}withVersionGreaterThanOrEqualTo(t){return this.filters.push({version:{$gte:t}}),this}withVersionLessThan(t){return this.filters.push({version:{$lt:t}}),this}withVersionLessThanOrEqualTo(t){return this.filters.push({version:{$lte:t}}),this}withVersionBetween(t,e){return this.filters.push({version:{$between:[t,e]}}),this}withVersionIsKnown(){return this.filters.push({version:{$isNull:!1}}),this}withVersionIsUnknown(){return this.filters.push({version:{$isNull:!0}}),this}orderByIdAscending(){return this.query.orderBy("id","asc"),this}orderByIdDescending(){return this.query.orderBy("id","desc"),this}orderByTitleAscending(){return this.query.orderBy("title","asc"),this}orderByTitleDescending(){return this.query.orderBy("title","desc"),this}orderByDescriptionAscending(){return this.query.orderBy("description","asc"),this}orderByDescriptionDescending(){return this.query.orderBy("description","desc"),this}orderByVersionAscending(){return this.query.orderBy("version","asc"),this}orderByVersionDescending(){return this.query.orderBy("version","desc"),this}count(){return this.query.aggregate("Count","id","count"),this._pageCountAlias="count",this._pageCountMethod="count",this}countAs(t){return this.query.aggregate("Count","id",t),this._pageCountAlias=t,this._pageCountMethod="countAs",this}groupById(){return this.query.groupBy("id"),this}groupByIdAs(t){return this.query.groupBy("id"),this}groupByTitle(){return this.query.groupBy("title"),this}groupByTitleAs(t){return this.query.groupBy("title"),this}groupByDescription(){return this.query.groupBy("description"),this}groupByDescriptionAs(t){return this.query.groupBy("description"),this}groupByPlatform(){return this.query.groupBy("platform"),this}groupByPlatformAs(t){return this.query.groupBy("platform"),this}groupByVersion(){return this.query.groupBy("version"),this}groupByVersionAs(t){return this.query.groupBy("version"),this}facetByPlatformAs(t,e,i=!0){return this.query.facetBy(t,"platform",e,i,{kind:"facet",method:"facetByPlatformAs",relation:"platform",alias:t}),this}async executeForListInternal(t){if(this.ensureIntent(),this._pageCountAlias!==void 0)return this.executeCountedListInternal(t);this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService"),i=await e.executeQuery(t.prepareQuery(this.query)),r=this.query.aggregateItems.length>0&&this.query.groupByItems.length===0,s=r?[]:i.map(n=>n instanceof m?n:m.fromRecord(n,new $)),a=new I(s);return r&&i[0]&&Object.assign(a.aggregations,i[0]),this.query.facets.length>0&&(a.facets=await C(e,n=>t.prepareQuery(n),this.query,this.query.facets)),a}async executeForRowsInternal(t){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService");return new I(await e.executeQuery(t.prepareQuery(this.query)))}async executeCountedListInternal(t){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService"),i=t.prepareQuery(this.query),r=i.localIdSetPaginationOptions()!==void 0,s={kind:"named-count",method:this._pageCountMethod??"count",...this._pageCountMethod==="countAs"?{alias:this._pageCountAlias}:{}},a=r?void 0:await e.executeCount(i,this._pageCountAlias,s),n=i.clone();n.aggregateItems=n.aggregateItems.filter(l=>!(String(l.function).toLowerCase()==="count"&&l.alias===this._pageCountAlias));const d=await e.executeQuery(n),u=r&&t.idSetPaginationCountAccuracy==="EXACT"?t.idSetPaginationCount:a??await e.executeCount(i,this._pageCountAlias,s),h=new I(d.map(l=>l instanceof m?l:m.fromRecord(l,new $)));return h.totalCount=u,this._pageCountAlias!==void 0&&(h.aggregations[this._pageCountAlias]=u),this.query.facets.length>0&&(h.facets=await C(e,l=>t.prepareQuery(l),i,i.facets)),h}executeForStreamInternal(t,e){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const i=t.requireResource("dataService"),r=t.prepareQuery(this.query),s=i.executeForStream(r,e);return(async function*(){for await(const a of s)for(const n of a)yield n instanceof m?n:m.fromRecord(n,new $)})()}ensureIntent(){new K(this._comment,this._purpose)}}class Z{constructor(t,e,i,r,s,a){this.execute=t,this.executeRows=e,this.stream=i,this.limitOne=r,this.addComment=s,this.ensureIntent=a}execute;executeRows;stream;limitOne;addComment;ensureIntent;comment(t){return this.addComment(t),this}newEntity(t){return this.ensureIntent(),new m}executeForList(t){return this.ensureIntent(),this.execute(t)}executeForRows(t){return this.ensureIntent(),this.executeRows(t)}executeForStream(t,e=1e3){return this.ensureIntent(),this.stream(t,e)}async executeForOne(t){return this.limitOne(),(await this.executeForList(t))[0]}}class R{static platforms(){return new A(!1)}static platformsWithMinimalFields(){return new A(!0)}static workItems(){return new x(!1)}static workItemsWithMinimalFields(){return new x(!0)}}const tt={Platform:{table:"platform_data",auditMaskFields:[],columns:{id:{columnName:"id",modelName:"id",logPolicy:"plain",logicalType:"integer",decode:"string",nullable:!1},name:{columnName:"name",modelName:"name",logPolicy:"plain",logicalType:"text",decode:"native",nullable:!1},version:{columnName:"version",modelName:"version",logPolicy:"plain",logicalType:"integer",decode:"number",nullable:!1}},relations:{workItemList:{targetEntity:"WorkItem",localKey:"id",foreignKey:"platform",many:!0}}},WorkItem:{table:"work_item_data",auditMaskFields:[],columns:{id:{columnName:"id",modelName:"id",logPolicy:"plain",logicalType:"integer",decode:"string",nullable:!1},title:{columnName:"title",modelName:"title",logPolicy:"plain",logicalType:"text",decode:"native",nullable:!1},description:{columnName:"description",modelName:"description",logPolicy:"plain",logicalType:"text",decode:"native",nullable:!0},platform:{columnName:"platform",modelName:"platform",logPolicy:"plain",logicalType:"integer",decode:"string",nullable:!1},version:{columnName:"version",modelName:"version",logPolicy:"plain",logicalType:"integer",decode:"number",nullable:!1}},relations:{platform:{targetEntity:"Platform",localKey:"platform",foreignKey:"id",many:!1}}}};async function et(o){let t=(await R.platforms().withIdIs("1").comment("what: locate generated Domain Root").purpose("why: idempotent runtime bootstrap").executeForList(o))[0];t||(t=y.teaqlBootstrapNew("1"),t.updateName("Runtime Example"),await t.auditAs("create generated Domain Root Platform").save(o)),o.withActiveRoot({entity:"Platform",id:t.id})}const it=new U(tt,{Platform:{checkAndFix(o,t,e){o.getResource("fixTime"),(t.action==="Create"&&t.payload.name===void 0||t.payload.name===null)&&e.push({ruleId:"required",location:g.property("name")}),t.payload.name!=null&&[...String(t.payload.name)].length>100&&e.push({ruleId:"max_length",location:g.property("name"),inputValue:t.payload.name,systemValue:100})}},WorkItem:{checkAndFix(o,t,e){o.getResource("fixTime"),(t.action==="Create"&&t.payload.title===void 0||t.payload.title===null)&&e.push({ruleId:"required",location:g.property("title")}),t.payload.title!=null&&!([...String(t.payload.title)].length>=1)&&e.push({ruleId:"min_length",location:g.property("title"),inputValue:t.payload.title,systemValue:1}),t.payload.title!=null&&[...String(t.payload.title)].length>80&&e.push({ruleId:"max_length",location:g.property("title"),inputValue:t.payload.title,systemValue:80}),t.payload.description!=null&&[...String(t.payload.description)].length>100&&e.push({ruleId:"max_length",location:g.property("description"),inputValue:t.payload.description,systemValue:100}),(t.action==="Create"&&t.payload.platform===void 0||t.payload.platform===null)&&e.push({ruleId:"required",location:g.property("platform")})}}},{defaultDomainRoot:{entity:"Platform",id:"1",values:{name:"Runtime Example"}},constants:[],ensure:et}),rt={Platform:{table:"platform_data",columns:{id:{columnName:"id",modelName:"id",logicalType:"integer",decode:"string",nullable:!1},name:{columnName:"name",modelName:"name",logicalType:"text",decode:"native",nullable:!1},version:{columnName:"version",modelName:"version",logicalType:"integer",decode:"number",nullable:!1}},relations:{workItemList:{targetEntity:"WorkItem",localKey:"id",foreignKey:"platform",many:!0}}},WorkItem:{table:"work_item_data",columns:{id:{columnName:"id",modelName:"id",logicalType:"integer",decode:"string",nullable:!1},title:{columnName:"title",modelName:"title",logicalType:"text",decode:"native",nullable:!1},description:{columnName:"description",modelName:"description",logicalType:"text",decode:"native",nullable:!0},platform:{columnName:"platform",modelName:"platform",logicalType:"integer",decode:"string",nullable:!1},version:{columnName:"version",modelName:"version",logicalType:"integer",decode:"number",nullable:!1}},relations:{platform:{targetEntity:"Platform",localKey:"platform",foreignKey:"id",many:!1}}}},F=document.querySelector("#status"),st=document.querySelector("#result"),T=document.querySelector("#persist"),E=document.querySelector("#reset");let b;const M=localStorage.getItem("teaql-browser-storage")==="opfs"?"opfs":"memory";T.checked=M==="opfs";async function nt(o){const t=new Worker(new URL("/assets/sqlite.worker-DS5P4U1E.js",import.meta.url),{type:"module"}),e=await z.open(t,{...rt},{storage:o,databaseName:"teaql-browser-example.sqlite3"});e.install(it);const i=Object.freeze({policyId:"browser-demo-seed",version:"1",fingerprint:"sha256:browser-demo-seed-v1"}),r=new H().insertResource("dataService",e).withMutationPolicyRegistry(new J(()=>({identity:i,review:(s,a)=>a.operations.length>0?{verdict:"allow"}:{verdict:"deny",code:"EMPTY_GRAPH",message:"empty mutation graph"}}))).withMutationPolicyApprovalProvider(new Y(s=>({policy:s,approvedBy:"browser-demo-owner",approvedAt:new Date})));return e.setUserContext(r),await r.ensureSchema(),{client:e,context:r}}async function Q({context:o}){if(!(await R.workItemsWithMinimalFields().comment("what: detect existing browser demo records").purpose("why: keep generated mutation bootstrap idempotent").executeForList(o)).length)for(const e of["Evaluate semantic model","Generate typed library","Verify browser runtime"])await new m().updateTitle(e).updatePlatform("1").auditAs("seed deterministic browser demo data").save(o)}async function V(o){const t=await R.workItems().selectTitle().orderByIdAscending().limit(20).comment("what: load browser-local work items").purpose("why: prove the generated Q API runs without a backend").executeForList(o.context);st.textContent=JSON.stringify(t,null,2),F.textContent=`${o.client.storage.toUpperCase()} · ${t.length} rows · policy installed · ready`}async function j(o){F.textContent=`Opening ${o.toUpperCase()} SQLite/WASM…`;const t=b;b=void 0,await t?.client.close();const e=await nt(o);b=e,await Q(e),await V(e)}T.addEventListener("change",()=>{const o=T.checked?"opfs":"memory";localStorage.setItem("teaql-browser-storage",o),j(o).catch(W)});E.addEventListener("click",async()=>{if(b){E.disabled=!0;try{await b.client.reset(b.context),await Q(b),await V(b)}catch(o){W(o)}finally{E.disabled=!1}}});function W(o){const t=o instanceof Error?o:new Error(String(o));F.textContent=`${t.name}: ${t.message}`}j(M).catch(W);
|
dist/assets/{dynamic-search-BBmdgl4H.js → dynamic-search-Ch_QcWVU.js}
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dist/assets/{main-gHLGx1pH.js → main-Cg0XY2hs.js}
RENAMED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
-
import{S as T,m as Te,a as ie,e as de,O as R,B as Qe,b as $e,R as Re,U as Be,D as Fe,c as ke,M as We}from"./dynamic-search-BBmdgl4H.js";/* empty css */const C=t=>({columnName:t,modelName:t,logicalType:"integer",decode:"string"}),y=t=>({columnName:t,modelName:t,logicalType:"text",decode:"native"}),ze=t=>({columnName:t,modelName:t,logicalType:"date",decode:"date"}),K=t=>({columnName:t,modelName:t,logicalType:"datetime",decode:"date"}),I=(t,e="decimal")=>({columnName:t,modelName:t,logicalType:e,decode:"number"}),f=Object.freeze({PENDING_PAYMENT:"1001",PAID:"1002",SHIPPED:"1003",DELIVERED:"1004",CANCELLED:"1005"}),_e=[{entity:"OrderStatus",id:f.PENDING_PAYMENT,values:{name:"Pending payment",code:"PENDING_PAYMENT",color:"#D97706",displayOrder:10}},{entity:"OrderStatus",id:f.PAID,values:{name:"Paid",code:"PAID",color:"#2563EB",displayOrder:20}},{entity:"OrderStatus",id:f.SHIPPED,values:{name:"Shipped",code:"SHIPPED",color:"#16A34A",displayOrder:30}},{entity:"OrderStatus",id:f.DELIVERED,values:{name:"Delivered",code:"DELIVERED",color:"#047857",displayOrder:40}},{entity:"OrderStatus",id:f.CANCELLED,values:{name:"Cancelled",code:"CANCELLED",color:"#9F1239",displayOrder:50}}],ce={Platform:{table:"platform_data",columns:{id:C("id"),name:y("name"),code:y("code"),region:y("region"),currency:y("currency"),version:I("version","integer")},relations:{customerList:{targetEntity:"Customer",localKey:"id",foreignKey:"platformId",many:!0},orderList:{targetEntity:"CustomerOrder",localKey:"id",foreignKey:"platformId",many:!0}}},Customer:{table:"customer_data",columns:{id:C("id"),name:y("name"),email:y("email"),city:y("city"),tier:y("tier"),platformId:C("platform_id"),version:I("version","integer")},relations:{platform:{targetEntity:"Platform",localKey:"platformId",foreignKey:"id",many:!1},orderList:{targetEntity:"CustomerOrder",localKey:"id",foreignKey:"customerId",many:!0}}},CustomerOrder:{table:"customer_order_data",columns:{id:C("id"),orderNumber:y("order_number"),orderDate:ze("order_date"),status:C("status_id"),totalAmount:I("total_amount"),currency:y("currency"),customerId:C("customer_id"),platformId:C("platform_id"),version:I("version","integer")},relations:{platform:{targetEntity:"Platform",localKey:"platformId",foreignKey:"id",many:!1},customer:{targetEntity:"Customer",localKey:"customerId",foreignKey:"id",many:!1},status:{targetEntity:"OrderStatus",localKey:"status",foreignKey:"id",many:!1},itemList:{targetEntity:"OrderItem",localKey:"id",foreignKey:"orderId",many:!0},paymentList:{targetEntity:"Payment",localKey:"id",foreignKey:"orderId",many:!0},shipmentList:{targetEntity:"Shipment",localKey:"id",foreignKey:"orderId",many:!0}}},OrderStatus:{table:"order_status_data",columns:{id:C("id"),name:y("name"),code:y("code"),color:y("color"),displayOrder:I("display_order","integer"),version:I("version","integer")},relations:{orderList:{targetEntity:"CustomerOrder",localKey:"id",foreignKey:"status",many:!0}}},OrderItem:{table:"order_item_data",columns:{id:C("id"),orderId:C("order_id"),productName:y("product_name"),sku:y("sku"),quantity:I("quantity","integer"),unitPrice:I("unit_price"),lineAmount:I("line_amount"),version:I("version","integer")},relations:{order:{targetEntity:"CustomerOrder",localKey:"orderId",foreignKey:"id",many:!1}}},Payment:{table:"payment_data",columns:{id:C("id"),orderId:C("order_id"),provider:y("provider"),status:y("status"),amount:I("amount"),currency:y("currency"),transactionId:y("transaction_id"),paidAt:K("paid_at"),version:I("version","integer")},relations:{order:{targetEntity:"CustomerOrder",localKey:"orderId",foreignKey:"id",many:!1}}},Shipment:{table:"shipment_data",columns:{id:C("id"),orderId:C("order_id"),carrier:y("carrier"),status:y("status"),trackingNumber:y("tracking_number"),shipToCity:y("ship_to_city"),shippedAt:K("shipped_at"),deliveredAt:K("delivered_at"),version:I("version","integer")},relations:{order:{targetEntity:"CustomerOrder",localKey:"orderId",foreignKey:"id",many:!1}}}},he=[{entity:"Platform",id:"1",payload:{name:"TeaQL Store",code:"TEAQL-CN",region:"China",currency:"CNY"}},{entity:"Platform",id:"2",payload:{name:"TeaQL Global",code:"TEAQL-GLOBAL",region:"Global",currency:"USD"}},{entity:"Customer",id:"101",payload:{name:"Lin Xiao",email:"lin.xiao@example.com",city:"Shanghai",tier:"GOLD",platformId:"1"}},{entity:"Customer",id:"102",payload:{name:"Zhou Ran",email:"zhou.ran@example.com",city:"Hangzhou",tier:"SILVER",platformId:"1"}},{entity:"Customer",id:"103",payload:{name:"Maya Patel",email:"maya.patel@example.com",city:"Singapore",tier:"GOLD",platformId:"2"}},{entity:"Customer",id:"104",payload:{name:"Lucas Martin",email:"lucas.martin@example.com",city:"Paris",tier:"SILVER",platformId:"2"}},{entity:"Customer",id:"105",payload:{name:"Wang Ning",email:"wang.ning@example.com",city:"Chengdu",tier:"BRONZE",platformId:"1"}},{entity:"CustomerOrder",id:"1001",payload:{orderNumber:"TQL-2026-1001",orderDate:"2026-08-28",status:f.DELIVERED,totalAmount:499,currency:"CNY",customerId:"101",platformId:"1"}},{entity:"CustomerOrder",id:"1002",payload:{orderNumber:"TQL-2026-1002",orderDate:"2026-09-02",status:f.SHIPPED,totalAmount:1299,currency:"CNY",customerId:"102",platformId:"1"}},{entity:"CustomerOrder",id:"1003",payload:{orderNumber:"TQL-2026-1003",orderDate:"2026-09-06",status:f.PAID,totalAmount:328.8,currency:"CNY",customerId:"101",platformId:"1"}},{entity:"CustomerOrder",id:"1004",payload:{orderNumber:"TQL-2026-1004",orderDate:"2026-09-11",status:f.PENDING_PAYMENT,totalAmount:79.9,currency:"CNY",customerId:"105",platformId:"1"}},{entity:"CustomerOrder",id:"1005",payload:{orderNumber:"TQL-2026-1005",orderDate:"2026-09-14",status:f.DELIVERED,totalAmount:219,currency:"USD",customerId:"103",platformId:"2"}},{entity:"CustomerOrder",id:"1006",payload:{orderNumber:"TQL-2026-1006",orderDate:"2026-09-18",status:f.PAID,totalAmount:640,currency:"USD",customerId:"104",platformId:"2"}},{entity:"CustomerOrder",id:"1007",payload:{orderNumber:"TQL-2026-1007",orderDate:"2026-09-21",status:f.CANCELLED,totalAmount:159,currency:"CNY",customerId:"102",platformId:"1"}},{entity:"CustomerOrder",id:"1008",payload:{orderNumber:"TQL-2026-1008",orderDate:"2026-09-25",status:f.SHIPPED,totalAmount:268,currency:"CNY",customerId:"105",platformId:"1"}},{entity:"OrderItem",id:"2001",payload:{orderId:"1001",productName:"TeaQL Mechanical Keyboard",sku:"KB-TQL-87",quantity:1,unitPrice:299,lineAmount:299}},{entity:"OrderItem",id:"2002",payload:{orderId:"1001",productName:"Silent Wireless Mouse",sku:"MS-SILENT",quantity:2,unitPrice:100,lineAmount:200}},{entity:"OrderItem",id:"2003",payload:{orderId:"1002",productName:"27-inch Developer Monitor",sku:"MON-27-4K",quantity:1,unitPrice:1299,lineAmount:1299}},{entity:"OrderItem",id:"2004",payload:{orderId:"1003",productName:"White Porcelain Travel Tea Set",sku:"TEA-TRAVEL",quantity:1,unitPrice:168.8,lineAmount:168.8}},{entity:"OrderItem",id:"2005",payload:{orderId:"1003",productName:"Pre-Qingming Longjing Tea",sku:"TEA-LJ-100",quantity:2,unitPrice:80,lineAmount:160}},{entity:"OrderItem",id:"2006",payload:{orderId:"1004",productName:"Double-wall Glass Tumbler",sku:"CUP-GLASS",quantity:1,unitPrice:79.9,lineAmount:79.9}},{entity:"OrderItem",id:"2007",payload:{orderId:"1005",productName:"Travel Brew Kit",sku:"BREW-KIT",quantity:1,unitPrice:219,lineAmount:219}},{entity:"OrderItem",id:"2008",payload:{orderId:"1006",productName:"Desktop Studio Speaker",sku:"SPK-STUDIO",quantity:2,unitPrice:260,lineAmount:520}},{entity:"OrderItem",id:"2009",payload:{orderId:"1006",productName:"Speaker Stand",sku:"SPK-STAND",quantity:1,unitPrice:120,lineAmount:120}},{entity:"OrderItem",id:"2010",payload:{orderId:"1007",productName:"Desktop Reading Lamp",sku:"LAMP-DESK",quantity:1,unitPrice:159,lineAmount:159}},{entity:"OrderItem",id:"2011",payload:{orderId:"1008",productName:"TeaQL Portable Keyboard",sku:"KB-TQL-68",quantity:1,unitPrice:268,lineAmount:268}},{entity:"Payment",id:"3001",payload:{orderId:"1001",provider:"Alipay",status:"CAPTURED",amount:499,currency:"CNY",transactionId:"ALI-260828-01",paidAt:"2026-08-28T10:14:00Z"}},{entity:"Payment",id:"3002",payload:{orderId:"1002",provider:"WeChat Pay",status:"CAPTURED",amount:1299,currency:"CNY",transactionId:"WX-260902-08",paidAt:"2026-09-02T03:20:00Z"}},{entity:"Payment",id:"3003",payload:{orderId:"1003",provider:"Alipay",status:"CAPTURED",amount:328.8,currency:"CNY",transactionId:"ALI-260906-11",paidAt:"2026-09-06T11:42:00Z"}},{entity:"Payment",id:"3004",payload:{orderId:"1004",provider:"WeChat Pay",status:"PENDING",amount:79.9,currency:"CNY",transactionId:"WX-260911-02",paidAt:null}},{entity:"Payment",id:"3005",payload:{orderId:"1005",provider:"Stripe",status:"CAPTURED",amount:219,currency:"USD",transactionId:"PI-260914-05",paidAt:"2026-09-14T06:10:00Z"}},{entity:"Payment",id:"3006",payload:{orderId:"1006",provider:"Stripe",status:"CAPTURED",amount:640,currency:"USD",transactionId:"PI-260918-03",paidAt:"2026-09-18T15:08:00Z"}},{entity:"Payment",id:"3007",payload:{orderId:"1007",provider:"Alipay",status:"REFUNDED",amount:159,currency:"CNY",transactionId:"ALI-260921-07",paidAt:"2026-09-21T02:55:00Z"}},{entity:"Payment",id:"3008",payload:{orderId:"1008",provider:"WeChat Pay",status:"CAPTURED",amount:268,currency:"CNY",transactionId:"WX-260925-06",paidAt:"2026-09-25T08:31:00Z"}},{entity:"Shipment",id:"4001",payload:{orderId:"1001",carrier:"SF Express",status:"DELIVERED",trackingNumber:"SF2608281001",shipToCity:"Shanghai",shippedAt:"2026-08-29T02:00:00Z",deliveredAt:"2026-08-30T07:26:00Z"}},{entity:"Shipment",id:"4002",payload:{orderId:"1002",carrier:"JD Logistics",status:"IN_TRANSIT",trackingNumber:"JD2609021002",shipToCity:"Hangzhou",shippedAt:"2026-09-03T04:12:00Z",deliveredAt:null}},{entity:"Shipment",id:"4003",payload:{orderId:"1003",carrier:"SF Express",status:"READY",trackingNumber:"SF2609061003",shipToCity:"Shanghai",shippedAt:null,deliveredAt:null}},{entity:"Shipment",id:"4004",payload:{orderId:"1005",carrier:"DHL",status:"DELIVERED",trackingNumber:"DHL2609141005",shipToCity:"Singapore",shippedAt:"2026-09-15T01:10:00Z",deliveredAt:"2026-09-17T09:22:00Z"}},{entity:"Shipment",id:"4005",payload:{orderId:"1006",carrier:"DHL",status:"READY",trackingNumber:"DHL2609181006",shipToCity:"Paris",shippedAt:null,deliveredAt:null}},{entity:"Shipment",id:"4006",payload:{orderId:"1008",carrier:"SF Express",status:"IN_TRANSIT",trackingNumber:"SF2609251008",shipToCity:"Chengdu",shippedAt:"2026-09-26T03:18:00Z",deliveredAt:null}}],L=t=>`'${t.replaceAll("\\","\\\\").replaceAll("'","\\'").replaceAll(`
|
| 2 |
-
`,"\\n")}'`,U=t=>t.toQExpression().replace(/\s*\n\s*/g,""),
|
| 3 |
-
`)}toQuery(){const e=this.query.clone();return this.filters.length&&e.filter({$and:[...this.filters]}),e}async executeForList(e){this.ensureIntent();const r=this.service(e),n=this.toQuery(),o=await r.executeQuery(e.prepareQuery(n)),s=new ie(o);return n.facets.length&&(s.facets=await de(r,d=>e.prepareQuery(d),n,n.facets)),s}async executeForRows(e){return this.executeForList(e)}async executeForPage(e,r,n){this.ensureIntent();const o=this.service(e),s=this.toQuery(),d=await o.executeCount(s,this.pageTotalAlias,this.pageTotalAlias?{kind:"named-count",method:"countAs",alias:this.pageTotalAlias}:void 0),a=this.toQuery().offset(r).limit(n),c=new ie(await o.executeQuery(e.prepareQuery(a)),{totalCount:d});return this.pageTotalAlias&&(c.aggregations[this.pageTotalAlias]=d),s.facets.length&&(c.facets=await de(o,m=>e.prepareQuery(m),s,s.facets)),{data:c,totalCount:d,offset:r,limit:n}}addFilter(e){return this.filters.push(e),this}select(...e){return this.query.select(e),this}order(e,r){return this.query.order(r==="asc"?R.asc(e):R.desc(e)),this}group(e){return this.query.groupBy(e),this}aggregate(e,r,n){return this.query.aggregate(e,r,n),this}record(e){return this.qSteps.push(e),this}includePageTotalAs(e){return this.pageTotalAlias=e,this}service(e){return e.requireResource("dataService")}ensureIntent(){if(!this.auditComment.trim()||!this.queryPurpose.trim())throw new Error("Generated Q requests require comment() and purpose() before execution")}}class Ue extends D{constructor(){super("Platform","Q.platforms()")}selectId(){return this.select("id")}selectName(){return this.select("name")}selectCode(){return this.select("code")}withIdIs(e){return this.addFilter({id:{$eq:e}})}}class Ye extends D{constructor(){super("Customer","Q.customers()")}selectId(){return this.select("id")}selectName(){return this.select("name")}selectCity(){return this.select("city")}selectTier(){return this.select("tier")}selectPlatformWith(e){return this.query.relationQuery("platform",e.toQuery(),"platformId","id",!1),this}countOrderListAs(e){return this.query.relationAggregate("orderList",e,new T("CustomerOrder").aggregate("Count","id",e)),this}orderByNameAscending(){return this.order("name","asc")}}class Ge extends D{constructor(){super("OrderItem","Q.orderItems()")}selectId(){return this.select("id"),this.record("selectId()")}selectOrderId(){return this.select("orderId"),this.record("selectOrderId()")}selectProductName(){return this.select("productName"),this.record("selectProductName()")}selectSku(){return this.select("sku"),this.record("selectSku()")}selectQuantity(){return this.select("quantity"),this.record("selectQuantity()")}withProductNameContaining(e){return this.addFilter({productName:{$contains:e}})}orderByIdAscending(){return this.order("id","asc"),this.record("orderByIdAscending()")}groupByProductName(){return this.group("productName")}sumQuantityAs(e){return this.aggregate("Sum","quantity",e)}sumLineAmountAs(e){return this.aggregate("Sum","lineAmount",e)}countAs(e){return this.aggregate("Count","id",e)}}class je extends D{constructor(){super("OrderStatus","Q.orderStatuses()")}selectId(){return this.select("id"),this.record("selectId()")}selectName(){return this.select("name"),this.record("selectName()")}selectCode(){return this.select("code"),this.record("selectCode()")}selectColor(){return this.select("color"),this.record("selectColor()")}selectDisplayOrder(){return this.select("displayOrder"),this.record("selectDisplayOrder()")}withCodeIs(e){return this.addFilter({code:{$eq:e}})}countAs(e){return this.aggregate("Count","id",e),this.record(`countAs(${L(e)})`)}sumOrderTotalAmountAs(e){return this.aggregate("Sum","totalAmount",e),this.record(`sumOrderTotalAmountAs(${L(e)})`)}orderByDisplayOrderAscending(){return this.order("displayOrder","asc"),this.record("orderByDisplayOrderAscending()")}}class He extends D{constructor(){super("Payment","Q.payments()")}groupByCurrency(){return this.group("currency")}groupByProvider(){return this.group("provider")}groupByStatus(){return this.group("status")}countAs(e){return this.aggregate("Count","id",e)}sumAmountAs(e){return this.aggregate("Sum","amount",e)}orderByCurrencyAscending(){return this.order("currency","asc")}orderByProviderAscending(){return this.order("provider","asc")}orderByIdAscending(){return this.order("id","asc")}}class Ve extends D{constructor(){super("Shipment","Q.shipments()")}withStatusIn(...e){return this.addFilter({status:{$in:e}})}selectOrderWith(e){return this.query.relationQuery("order",e.toQuery(),"orderId","id",!1),this}orderByStatusAscending(){return this.order("status","asc")}orderByIdAscending(){return this.order("id","asc")}}class ue extends D{dynamicWarnings=[];countAlias;rowCountApplied=!1;constructor(e=!1){super("CustomerOrder",e?"Q.customerOrdersWithMinimalFields()":"Q.customerOrders()"),e?this.query.select(["id","version"]):this.query.select(["id","orderNumber","orderDate","status","totalAmount","currency","customerId","platformId","version"])}selectId(){return this.select("id")}selectOrderNumber(){return this.select("orderNumber"),this.record("selectOrderNumber()")}selectOrderDate(){return this.select("orderDate"),this.record("selectOrderDate()")}selectStatus(){return this.select("status")}selectTotalAmount(){return this.select("totalAmount")}selectCurrency(){return this.select("currency")}withOrderNumberIs(e){return this.addFilter({orderNumber:{$eq:e}})}withOrderNumberContaining(e){return this.addFilter({orderNumber:{$contains:e}})}withStatusMatching(e){return this.addFilter({status:{$inSubquery:{query:e.toQuery(),field:"id"}}})}withStatusIsPendingPayment(){return this.addFilter({status:{$eq:f.PENDING_PAYMENT}})}withStatusIsPaid(){return this.addFilter({status:{$eq:f.PAID}})}withStatusIsShipped(){return this.addFilter({status:{$eq:f.SHIPPED}})}withStatusIsDelivered(){return this.addFilter({status:{$eq:f.DELIVERED}})}withStatusIsCancelled(){return this.addFilter({status:{$eq:f.CANCELLED}})}withCurrencyIs(e){return this.addFilter({currency:{$eq:e}})}withTotalAmountGreaterThanOrEqualTo(e){return this.addFilter({totalAmount:{$gte:e}})}withOrderDateGreaterThanOrEqualTo(e){return this.addFilter({orderDate:{$gte:e}})}withPlatformIdIs(e){return this.addFilter({platformId:{$eq:e}})}withItemListMatching(e){return this.addFilter({id:{$inSubquery:{query:e.toQuery(),field:"orderId"}}})}filterByJson(e){const{query:r,warnings:n}=Te(this.toQuery(),Ke(e),Me,{filter:(o,s)=>o==="status.code"?{status:{$inSubquery:{query:new T("OrderStatus").filter({code:s}),field:"id"}}}:o==="itemList.productName"?{id:{$inSubquery:{query:new T("OrderItem").filter({productName:s}),field:"orderId"}}}:{[o]:s},order:(o,s)=>s==="asc"?R.asc(o):R.desc(o)});return this.dynamicWarnings=n,this.query.filterCondition=r.filterCondition,this.query.orderItems=[...r.orderItems],this.record("filterByJson(searchParams)"),this}warnings(){return this.dynamicWarnings}selectPlatformWith(e){return this.query.relationQuery("platform",e.toQuery(),"platformId","id",!1),this}selectCustomerWith(e){return this.query.relationQuery("customer",e.toQuery(),"customerId","id",!1),this}selectStatusWith(e){return this.query.select(["status"]),this.query.relationQuery("status",e.toQuery(),"status","id",!1,{kind:"relation-select",method:"selectStatusWith",relation:"status"}),this.record(`selectStatusWith(${U(e)})`)}selectItemListWith(e){return this.query.relationQuery("itemList",e.toQuery(),"id","orderId",!0,{kind:"relation-select",method:"selectItemListWith",relation:"itemList"}),this.record(`selectItemListWith(${U(e)})`)}selectPaymentListWith(e){return this.query.relationQuery("paymentList",e.toQuery(),"id","orderId",!0),this}selectShipmentListWith(e){return this.query.relationQuery("shipmentList",e.toQuery(),"id","orderId",!0),this}countItemListAs(e){return this.query.relationAggregate("itemList",e,new T("OrderItem").aggregate("Count","id",e).comment("count items"),!0,{kind:"relation-count",method:"countItemListAs",relation:"itemList",alias:e}),this.record(`countItemListAs(${L(e)})`)}facetByStatusAs(e,r,n=!0){const o=r.toQuery();return o.commentText||o.comment("load status facets"),this.query.facetBy(e,"status",{toQuery:()=>o},n,{kind:"facet",method:"facetByStatusAs",relation:"status",alias:e}),this.record(`facetByStatusAs(${L(e)}, ${U(r)})`)}orderByOrderDateDescending(){return this.order("orderDate","desc"),this.record("orderByOrderDateDescending()")}orderByOrderDateAscending(){return this.order("orderDate","asc")}orderByIdDescending(){return this.order("id","desc"),this.record("orderByIdDescending()")}orderByTotalAmountDescending(){return this.order("totalAmount","desc")}groupByCurrency(){return this.group("currency")}groupByStatus(){return this.group("status")}countAs(e){return this.countAlias=e,this.record(`countAs(${L(e)})`)}sumTotalAmountAs(e){return this.aggregate("Sum","totalAmount",e)}averageTotalAmountAs(e){return this.aggregate("Avg","totalAmount",e)}executeForList(e){return this.applyRowCount(),super.executeForList(e)}executeForRows(e){return this.applyRowCount(),super.executeForList(e)}executeForPage(e,r,n){return this.countAlias&&this.includePageTotalAs(this.countAlias),super.executeForPage(e,r,n)}applyRowCount(){!this.countAlias||this.rowCountApplied||(this.query.aggregate("Count","id",this.countAlias),this.rowCountApplied=!0)}}class u{static platforms(){return new Ue}static customers(){return new Ye}static customerOrders(){return new ue}static customerOrdersWithMinimalFields(){return new ue(!0)}static orderItems(){return new Ge}static orderStatuses(){return new je}static payments(){return new He}static shipments(){return new Ve}}const k=document.querySelector("#status"),B=document.querySelector("#persist"),Y=document.querySelector("#reset"),F=document.querySelector("#query-catalog"),b=document.querySelector("#result"),ge=document.querySelector("#result-title"),fe=document.querySelector("#result-description"),J=document.querySelector("#result-meta"),le=document.querySelector("#query-code"),Ze=document.querySelector("#query-params-block"),Je=document.querySelector("#query-params-code"),Xe=document.querySelector("#result-grid"),$=document.querySelector("#result-view-label"),et=document.querySelector("#sql-count"),me=document.querySelector("#sql-output"),X=document.querySelector("#expand-all"),tt=document.querySelector("#collapse-all"),Q=document.querySelector("#view-table"),H=document.querySelector("#view-tree"),Ae=Array.from(document.querySelectorAll("[data-locale]")),rt={heroTitle:{en:"Understand TeaQL queries through a familiar order model.",zh:"用一个熟悉的订单模型,看懂 TeaQL 查询。"},heroIntro:{en:"Platform, customer, order, item, payment, and shipment data all run in the browser. Order status is backed by a constant model. Choose a query below to inspect real SQLite/WASM results.",zh:"平台、用户、订单、明细、支付和物流数据都在浏览器中运行;订单状态由常数模型提供。选择下面的查询,查看真实的 SQLite/WASM 结果。"},platform:{en:"Platform",zh:"平台"},customer:{en:"Customer",zh:"用户"},order:{en:"Order",zh:"订单"},item:{en:"Item",zh:"明细"},payment:{en:"Payment",zh:"支付"},shipment:{en:"Shipment",zh:"物流"},constantModel:{en:"Constant model",zh:"常数模型"},persist:{en:"Persist locally with OPFS",zh:"使用 OPFS 保存在本地"},reset:{en:"Reset demo data",zh:"重置演示数据"},chooseQuery:{en:"Choose a query",zh:"选择一个查询"},queryIntro:{en:"Queries are grouped by purpose and share the same order dataset.",zh:"查询按用途分组,并共用同一份订单数据。"},table:{en:"Table",zh:"表格"},resultTree:{en:"Result Tree",zh:"结果树"},expandAll:{en:"Expand all",zh:"全部展开"},collapseAll:{en:"Collapse all",zh:"全部折叠"},waiting:{en:"Waiting for query…",zh:"等待查询…"},queryNote:{en:"The Q expression stays fixed; search, status cards, and pagination only update dynamic parameters. The underlying SelectQuery remains inside the generated request implementation.",zh:"Q 表达式保持不变;搜索、状态卡片和分页只更新动态参数。底层 SelectQuery 仍封装在生成的请求实现中。"},executionEvidence:{en:"EXECUTION EVIDENCE",zh:"执行证据"},evidenceTime:{en:"Time",zh:"时间"},identity:{en:"Identity",zh:"身份"},traceChain:{en:"Trace chain",zh:"追踪链"},sqlNote:{en:"One plain-text line per statement: time, identity, trace chain, and the SQL SQLite executed.",zh:"每条语句使用一行纯文本:时间、身份、追踪链,以及 SQLite 实际执行的 SQL。"},localData:{en:"Data stays in this browser",zh:"数据只保留在当前浏览器中"}},nt={基本查询:"Basic queries","从订单、用户和关联对象开始":"Start with orders, customers, and related objects",汇总查询:"Aggregations","分组、计数、求和与平均值":"Grouping, counts, sums, and averages",过滤查询:"Filtered queries","精确、范围与组合条件":"Exact, range, and combined predicates",动态查询:"Dynamic queries","由页面条件安全生成,不使用 eval":"Safely generated from page criteria without eval","综合:订单管理中心":"Comprehensive: Order management center","一个真实的综合查询页面:状态指标、搜索、商品预览和分页都由 TeaQL 查询驱动。":"A real composite query page: status metrics, search, product previews, and pagination are all driven by TeaQL.",最近订单:"Recent orders","按下单日期倒序浏览全部订单,并带出所属平台与用户。":"Browse all orders by date descending, including their platform and customer.",完整订单详情:"Complete order details","查看一个订单及其用户、商品明细、支付和物流,体现完整对象图。":"Inspect one order with its customer, items, payments, and shipments as a complete object graph.",用户与订单数:"Customers with order counts","列出用户,并通过关联汇总显示每位用户的订单数量。":"List customers and show each customer’s order count through a relation aggregate.",订单状态汇总:"Orders by status","按币种与订单状态统计订单数、总额和平均客单价。":"Aggregate order count, gross amount, and average order value by currency and status.",商品销售汇总:"Product sales summary","按商品汇总销量与销售额,找出最受欢迎的订单明细。":"Aggregate units and revenue by product to identify the most popular order items.",支付渠道对账:"Payment reconciliation","按币种、支付渠道和状态汇总笔数与金额。":"Aggregate transaction count and amount by currency, payment provider, and status.",待支付订单:"Orders awaiting payment","筛选尚未完成付款的订单,并带出对应支付记录。":"Find orders that have not completed payment and include their payment records.",国内大额订单:"High-value domestic orders","组合平台与金额条件,找出 TeaQL 商城中金额不低于 500 元的订单。":"Combine platform and amount filters to find TeaQL Store orders worth at least CNY 500.",运输中的包裹:"Active shipments","筛选待揽收和运输中的物流单,并关联订单信息。":"Find shipments that are ready or in transit and include their order information.","动态:已付款国内订单":"Dynamic: paid domestic orders","从动态条件对象生成查询:人民币、金额至少 250,且状态为已付款或已发货。":"Build a query from dynamic criteria: CNY, at least 250, and status PAID or SHIPPED.","动态:九月新订单":"Dynamic: new September orders","运行时传入日期范围与排序方式,查询 9 月 15 日之后的订单。":"Pass a date range and sort order at runtime to find orders after September 15.","动态:字段白名单":"Dynamic: field allowlist","未知字段会被报告并忽略;合法条件仍可安全执行。":"Unknown fields are reported and ignored while valid predicates still execute safely."};let i=localStorage.getItem("teaql-browser-locale")==="zh"?"zh":"en";function st(t){return rt[t]?.[i]??t}function O(t){return i==="en"?nt[t]??t:t}let E,W=window.location.hash.slice(1)||"order-center";window.location.hash||history.replaceState(null,"","#order-center");let w="tree",v,Se=0,ee;const A={search:"",page:0,pageSize:4},Ce=localStorage.getItem("teaql-browser-storage")==="opfs"?"opfs":"memory";B.checked=Ce==="opfs";async function G(t,e){const r=u.customerOrders().filterByJson(e).limit(20).comment("what: execute a validated browser search").purpose("why: demonstrate safe dynamic order discovery"),n=await r.executeForList(t.context);return{request:e,warnings:r.warnings(),data:n}}const ot=Object.fromEntries(Object.entries(f).map(([t,e])=>[e,t]));function te(t){const e=String(t.code??"");return e&&e in f?e:"color"in t?ot[String(t.id??"")]??"":""}function Ie(t){const e=t.trim();if(!e)return{filter:{}};const r=e.toUpperCase(),n=["PENDING_PAYMENT","PAID","SHIPPED","DELIVERED","CANCELLED"].find(o=>o.includes(r));return n?{filter:{"status.code":n}}:/^(TQL-|\d)/i.test(e)?{filter:{orderNumber:{$contains:r}}}:{filter:{"itemList.productName":{$contains:e}}}}async function at(t){const e=Ie(A.search),r=u.customerOrdersWithMinimalFields().filterByJson(e).countAs("totalOrders").facetByStatusAs("statusCounts",u.orderStatuses().selectName().selectColor().countAs("orderCount").sumOrderTotalAmountAs("orderTotalAmount").orderByDisplayOrderAscending().comment("load status facets")).selectOrderNumber().selectOrderDate().selectStatusWith(u.orderStatuses().selectName().selectColor().comment("load status")).selectItemListWith(u.orderItems().selectProductName().selectQuantity().orderByIdAscending().limit(3).comment("load item previews")).countItemListAs("itemCount").orderByOrderDateDescending().orderByIdDescending().comment("load order list").purpose("render order list page"),n=await r.executeForPage(t.context,A.page*A.pageSize,A.pageSize),o=n.data.facet("statusCounts")??[];return{orders:n.data,totalOrders:Number(n.data.aggregations.totalOrders??n.totalCount),filteredOrders:n.totalCount,statusFacets:o.map(s=>({code:te(s),name:String(s.name??""),color:String(s.color??""),orderCount:Number(s.orderCount??0),orderTotalAmount:Number(s.orderTotalAmount??0)})).filter(s=>s.code&&s.name),search:A.search,page:A.page,pageSize:A.pageSize,queryExpression:r.toQExpression("executeForPage(ctx, pageOffset, pageSize);")}}const we=[{label:"基本查询",description:"从订单、用户和关联对象开始",queries:[{id:"order-center",title:"综合:订单管理中心",description:"一个真实的综合查询页面:状态指标、搜索、商品预览和分页都由 TeaQL 查询驱动。",code:"",view:"dashboard",run:at},{id:"recent-orders",title:"最近���单",description:"按下单日期倒序浏览全部订单,并带出所属平台与用户。",code:`await Q.customerOrders()
|
|
|
|
|
|
|
| 4 |
.selectPlatformWith(Q.platforms().selectName())
|
| 5 |
.selectCustomerWith(Q.customers().selectName().selectCity().selectTier())
|
| 6 |
.selectStatusWith(Q.orderStatuses().selectName().selectColor())
|
|
@@ -99,4 +101,4 @@ const data = await request
|
|
| 99 |
.comment('what: execute a validated browser search')
|
| 100 |
.purpose('why: demonstrate safe dynamic order discovery')
|
| 101 |
.executeForList(ctx);
|
| 102 |
-
const warnings = request.warnings();`,run:t=>G(t,{filter:{status:"DELIVERED",internalNote:{$contains:"not queryable"}}})}]}],pe=we.flatMap(t=>t.queries);async function it(t){const e=new Worker(new URL("/assets/sqlite.worker-DS5P4U1E.js",import.meta.url),{type:"module"}),r=await Qe.open(e,{...ce},{storage:t,databaseName:"teaql-order-playground-v3.sqlite3"}),n=new $e().enableSelect();r.install(new Re(ce,{},{constants:_e})),r.setRuntimeTelemetrySink(n).setDiagnosticSQLLogSink(void 0);const o=Object.freeze({policyId:"browser-order-demo-seed",version:"1",fingerprint:"sha256:browser-order-demo-seed-v1"}),s=new Be().insertResource("dataService",r).withMutationPolicyRegistry(new Fe(()=>({identity:o,review:(d,a)=>a.operations.length>0?{verdict:"allow"}:{verdict:"deny",code:"EMPTY_GRAPH",message:"empty mutation graph"}}))).withMutationPolicyApprovalProvider(new ke(d=>({policy:d,approvedBy:"browser-demo-owner",approvedAt:new Date})));return r.setUserContext(s),await s.ensureSchema(),{client:r,context:s,evidence:n}}async function be(t){if((await u.customerOrders().selectId().limit(1).comment("what: detect existing order playground data").purpose("why: keep deterministic browser bootstrap idempotent").executeForList(t.context)).length)return;const r=new We("Seed deterministic order playground data");await t.client.executeGraphSave(r,async n=>{const o=he.map(s=>n.request({entity:s.entity,action:"Create",id:s.id,payload:s.payload}));for(const s of o)t.client.preflightMutation(s);for(const s of o)await t.client.executeMutation(s)})}function dt(){F.replaceChildren();for(const t of we){const e=document.createElement("section");e.className="query-group";const r=document.createElement("div");r.className="query-group-heading";const n=document.createElement("h2");n.textContent=O(t.label);const o=document.createElement("p");o.textContent=O(t.description),r.append(n,o);const s=document.createElement("div");s.className="query-links";for(const d of t.queries){const a=document.createElement("a");a.href=`#${d.id}`,a.dataset.queryId=d.id,a.textContent=O(d.title),a.addEventListener("click",c=>{c.preventDefault(),W=d.id,history.replaceState(null,"",`#${d.id}`),V(),E&&P(d,E).catch(N)}),s.append(a)}e.append(r,s),F.append(e)}V()}function V(){F.querySelectorAll("a[data-query-id]").forEach(t=>{const e=t.dataset.queryId===W;t.classList.toggle("active",e),e?t.setAttribute("aria-current","page"):t.removeAttribute("aria-current")})}async function P(t,e){const r=performance.now(),n=new Date;e.evidence.enableSelect(),b.classList.add("loading"),b.setAttribute("aria-busy","true"),ge.textContent=O(t.title),fe.textContent=O(t.description),le.textContent=t.code,Ze.classList.toggle("hidden",t.view!=="dashboard"),Je.textContent=t.view==="dashboard"?JSON.stringify({searchParams:Ie(A.search),pageOffset:A.page*A.pageSize,pageSize:A.pageSize},null,2):"",Xe.classList.toggle("dashboard-mode",t.view==="dashboard"),b.classList.toggle("dashboard-result",t.view==="dashboard"),X.closest(".tree-actions")?.classList.toggle("hidden",t.view==="dashboard"),$.textContent=t.view==="dashboard"?i==="en"?"Order management center":"订单管理中心":i==="en"?"Result tree":"结果树",J.textContent=i==="en"?"Running query…":"查询中…";try{const o=await t.run(e);t.view==="dashboard"&&(le.textContent=o.queryExpression),v={data:o,query:t,active:e},w=t.view==="dashboard"||Z(o)?"table":"tree",z();const s=Math.max(1,Math.round(performance.now()-r));Se=s,ee=n;const d=e.evidence.snapshot();Ee(d,n),Pe(o,t,s)}finally{b.classList.remove("loading"),b.removeAttribute("aria-busy")}}function Ee(t,e=ee){me.replaceChildren(),et.textContent=i==="en"?`${t.length} statement${t.length===1?"":"s"}`:`${t.length} 条语句`,t.forEach((r,n)=>{const o=document.createElement("tr");o.className="evidence-row";const s=[...r.tracePath].reverse().find(l=>l.kind==="relation"||l.kind==="request"||l.kind==="entity"),d=document.createElement("td");d.className="evidence-time",d.dataset.executedAt=e?.toISOString()??"",d.textContent=`${e?.toISOString()??"—"} · ${Math.max(.01,r.elapsedMicros/1e3).toFixed(2)} ms`;const a=document.createElement("td");a.textContent=`${v?.query.id??"query"} · #${n+1} · ${s?.name??"query"}`;const c=document.createElement("td");if(c.className="evidence-trace",r.traceChain?.length){const l=r.traceChain.find(g=>g.kind==="purpose"),S=r.traceChain.filter(g=>g.kind==="comment").map(g=>g.detail||g.name);c.textContent=`${l?.detail||l?.name||""}: ${S.join(" → ")}`}else c.textContent=r.tracePath.map(l=>l.detail||l.name).join(" → ");const m=document.createElement("td");m.className="evidence-sql";const h=r.parameters.length?r.parameters.map(l=>String(l)).join(", "):"none";m.textContent=`${r.parameterizedSQL} · bindings: ${h}`,o.append(d,a,c,m),me.append(o)})}function Z(t){return Array.isArray(t)&&t.every(e=>e!==null&&typeof e=="object"&&!Array.isArray(e))}function z(){if(!v)return;const{data:t,query:e,active:r}=v,n=e.view==="dashboard"||Z(t);if(n||(w="tree"),Q.disabled=!n,Q.classList.toggle("active",w==="table"),H.classList.toggle("active",w==="tree"),Q.setAttribute("aria-pressed",String(w==="table")),H.setAttribute("aria-pressed",String(w==="tree")),X.closest(".tree-actions")?.classList.toggle("hidden",w!=="tree"),w==="table"&&e.view==="dashboard"){$.textContent=i==="en"?"Result table":"结果表格",mt(t,r,e);return}if(w==="table"&&Z(t)){$.textContent=i==="en"?"Result table":"结果表格",ut(t);return}$.textContent=i==="en"?"Result tree":"结果树",Le(e.view==="dashboard"?ct(t):t)}function ct(t){return{orders:t.orders,totalOrders:t.totalOrders,filteredOrders:t.filteredOrders,statusFacets:t.statusFacets,search:t.search,page:t.page,pageSize:t.pageSize}}function ut(t){const e=document.createElement("div");if(e.className="result-table-shell",!t.length){const a=document.createElement("p");a.className="result-table-empty",a.textContent=i==="en"?"The query returned no records.":"查询没有返回记录。",e.append(a),b.replaceChildren(e);return}const r=[...new Set(t.flatMap(a=>Object.keys(a)))],n=document.createElement("table");n.className="result-table";const o=document.createElement("thead"),s=document.createElement("tr");for(const a of r){const c=document.createElement("th");c.scope="col",c.textContent=a,s.append(c)}o.append(s);const d=document.createElement("tbody");for(const a of t){const c=document.createElement("tr");for(const m of r){const h=document.createElement("td");h.textContent=lt(a[m]),c.append(h)}d.append(c)}n.append(o,d),e.append(n),b.replaceChildren(e)}function lt(t){if(t==null)return"—";if(Array.isArray(t))return i==="en"?`${t.length} items`:`${t.length} 项`;if(t instanceof Date)return t.toISOString();if(typeof t=="object"){const e=t,r=te(e);if(r)return Ne(r);const n=e.name??e.orderNumber??e.code??e.id;return n===void 0?i==="en"?`${Object.keys(e).length} fields`:`${Object.keys(e).length} 个字段`:String(n)}return String(t)}function mt(t,e,r){const n=document.createElement("div");n.className="order-center";const o=document.createElement("div");o.className="order-center-toolbar";const s=document.createElement("div"),d=document.createElement("h3");d.textContent=i==="en"?"Order Management Center":"订单管理中心";const a=document.createElement("p");a.textContent=i==="en"?"One generated Q expression describes the entire page":"一个生成式 Q 表达式描述整个页面",s.append(d,a);const c=document.createElement("form");c.className="order-search";const m=document.createElement("input");m.type="search",m.placeholder=i==="en"?"Order number, status, or product…":"订单号、状态或商品名称…",m.value=t.search,m.setAttribute("aria-label",i==="en"?"Search orders":"搜索订单");const h=document.createElement("button");h.type="submit",h.className="order-search-submit",h.setAttribute("aria-label",i==="en"?"Run order query":"执行订单查询"),h.title=i==="en"?"Search":"查询";const l=document.createElement("span");l.className="search-icon",l.setAttribute("aria-hidden","true"),h.append(l),c.append(m,h),c.addEventListener("submit",p=>{p.preventDefault(),A.search=m.value.trim(),A.page=0,P(r,e).catch(N)}),o.append(s,c);const S=document.createElement("div");S.className="order-metrics",S.append(ye(i==="en"?"All orders":"全部订单",t.totalOrders,"total","#2B66D9",!t.search,()=>{A.search="",A.page=0,P(r,e).catch(N)}));for(const p of t.statusFacets)S.append(ye(p.name,p.orderCount,p.code.toLowerCase(),p.color,t.search.toUpperCase()===p.code,()=>{A.search=p.code,A.page=0,P(r,e).catch(N)},`${i==="en"?"Total":"总额"} ${pt(p.orderTotalAmount)}`));const g=document.createElement("div");g.className="order-table";const _=document.createElement("div");_.className="order-row order-row-head";const xe=i==="en"?["Order number","Order date","Status","Product details"]:["订单号","订单日期","状态","商品明细"];for(const p of xe){const x=document.createElement("span");x.textContent=p,_.append(x)}if(g.append(_),!t.orders.length){const p=document.createElement("div");p.className="order-empty",p.textContent=i==="en"?"No matching orders. Try an order number, status code, or product name.":"没有匹配的订单,请尝试订单号、状态英文或商品名称。",g.append(p)}for(const p of t.orders)g.append(yt(p));const M=document.createElement("div");M.className="order-center-footer";const ne=document.createElement("p"),se=t.filteredOrders?t.page*t.pageSize+1:0,oe=Math.min(t.filteredOrders,(t.page+1)*t.pageSize);ne.textContent=i==="en"?`Showing ${se}–${oe} of ${t.filteredOrders} orders`:`显示 ${se}–${oe},共 ${t.filteredOrders} 条订单`;const q=document.createElement("div");q.className="pagination";const ae=Math.max(1,Math.ceil(t.filteredOrders/t.pageSize));q.append(j("‹",t.page-1,t.page===0,e,r));for(let p=0;p<ae;p+=1){const x=j(String(p+1),p,!1,e,r);x.classList.toggle("active",p===t.page),q.append(x)}q.append(j("›",t.page+1,t.page>=ae-1,e,r)),M.append(ne,q),n.append(o,S,g,M),b.replaceChildren(n)}function ye(t,e,r,n,o,s,d){const a=document.createElement("button");a.type="button",a.className=`metric-card metric-${r}`,n&&a.style.setProperty("--metric-color",n),a.classList.toggle("active",o);const c=document.createElement("span");c.textContent=t;const m=document.createElement("strong");if(m.textContent=String(e),a.append(c,m),d){const h=document.createElement("small");h.textContent=d,a.append(h)}return a.addEventListener("click",s),a}function pt(t){return new Intl.NumberFormat(i==="en"?"en-US":"zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}function yt(t){const e=document.createElement("div");e.className="order-row";const r=t.status??{},n=Array.isArray(t.itemList)?t.itemList:[];[String(t.orderNumber??""),String(t.orderDate??"")].forEach(l=>{const S=document.createElement("span");S.className="order-primary",S.textContent=l,e.append(S)});const s=document.createElement("span"),d=document.createElement("span"),a=te(r);d.className=`status-badge status-${a.toLowerCase()}`,d.textContent=Ne(a)||String(r.name??a);const c=String(r.color??"");c&&(d.style.color=c,d.style.backgroundColor=`${c}18`),s.append(d),e.append(s);const m=document.createElement("span");m.className="product-preview",n.forEach((l,S)=>{const g=document.createElement("span");g.className=`product-thumb product-tone-${S%3}`,g.textContent=String(l.productName??"?").slice(0,1),g.title=`${String(l.productName??"")} × ${String(l.quantity??1)}`,m.append(g)});const h=Number(t.itemCount??n.length)-n.length;if(h>0){const l=document.createElement("small");l.textContent=`+${h}`,m.append(l)}return e.append(m),e}function j(t,e,r,n,o){const s=document.createElement("button");return s.type="button",s.textContent=t,s.disabled=r,s.addEventListener("click",()=>{A.page=e,P(o,n).catch(N)}),s}function Ne(t){return(i==="en"?{PENDING_PAYMENT:"Pending payment",PAID:"Paid",SHIPPED:"Shipped",DELIVERED:"Delivered",CANCELLED:"Cancelled"}:{PENDING_PAYMENT:"待支付",PAID:"已支付",SHIPPED:"运输中",DELIVERED:"已完成",CANCELLED:"已取消"})[t]??t}function Le(t){b.replaceChildren(Oe(t,"result",0))}function Oe(t,e,r){if(t!==null&&typeof t=="object"){const d=Array.isArray(t)?t.map((S,g)=>[String(g),S]):Object.entries(t),a=document.createElement("details");a.className="tree-branch",a.open=r===0;const c=document.createElement("summary"),m=document.createElement("span");m.className="tree-key",m.textContent=e;const h=document.createElement("span");h.className="tree-preview",h.textContent=ht(t,d.length),c.append(m,h),a.append(c);const l=document.createElement("div");l.className="tree-children";for(const[S,g]of d)l.append(Oe(g,Array.isArray(t)?`#${Number(S)+1}`:S,r+1));return a.append(l),a}const n=document.createElement("div");n.className="tree-leaf";const o=document.createElement("span");o.className="tree-key",o.textContent=e;const s=document.createElement("span");return s.className=`tree-value tree-${t===null?"null":typeof t}`,s.textContent=t===null?"null":typeof t=="string"?`“${t}”`:String(t),n.append(o,s),n}function ht(t,e){if(Array.isArray(t))return i==="en"?`${e} items`:`${e} 项`;const r=t,n=r.orderNumber??r.name??r.productName??r.transactionId??r.trackingNumber;return n?String(n):i==="en"?`${e} fields`:`${e} 个字段`}function gt(t){return Array.isArray(t)?t.length:Array.isArray(t?.data)?t.data.length:1}function Pe(t,e,r){const n=e.view==="dashboard"?t.filteredOrders:gt(t),o=i==="en"?`${n} ${e.view==="dashboard"?`matching order${n===1?"":"s"}`:`result${n===1?"":"s"}`}`:`${n} 条${e.view==="dashboard"?"匹配订单":"结果"}`;J.textContent=`${o} · ${r} ms · ${i==="en"?"in-browser SQLite":"浏览器内 SQLite"}`}function De(t){const e=he.filter(r=>r.entity==="CustomerOrder").length;k.textContent=i==="en"?`${t.toUpperCase()} · ${e} orders · 7 entities · policy installed · ready`:`${t.toUpperCase()} · ${e} 个订单 · 7 个实体 · 已安装策略 · 就绪`}function ve(){document.documentElement.lang=i==="en"?"en":"zh-CN",document.title=i==="en"?"TeaQL Order Query Playground":"TeaQL 订单查询演练场";const t=document.querySelector('meta[name="description"]');if(t&&(t.content=i==="en"?"A TeaQL order-query playground running entirely in the browser":"完全运行在浏览器中的 TeaQL 订单查询演练场"),document.querySelectorAll("[data-i18n]").forEach(e=>{const r=e.dataset.i18n;r&&(e.textContent=st(r))}),Ae.forEach(e=>{const r=e.dataset.locale===i;e.classList.toggle("active",r),e.setAttribute("aria-pressed",String(r))}),document.querySelector(".language-switch")?.setAttribute("aria-label",i==="en"?"Language":"语言"),document.querySelector(".brand")?.setAttribute("aria-label",i==="en"?"TeaQL Playground home":"TeaQL 演练场首页"),document.querySelector(".model-map")?.setAttribute("aria-label",i==="en"?"Order domain model":"订单领域模型"),document.querySelector(".runtime-bar")?.setAttribute("aria-label",i==="en"?"Runtime settings":"运行时设置"),F.setAttribute("aria-label",i==="en"?"Example queries":"示例查询"),document.querySelector(".result-view-switch")?.setAttribute("aria-label",i==="en"?"Result views":"结果视图"),document.querySelector(".tree-actions")?.setAttribute("aria-label",i==="en"?"Result tree actions":"结果树操作"),dt(),v){const{data:e,query:r,active:n}=v;ge.textContent=O(r.title),fe.textContent=O(r.description),z(),Ee(n.evidence.snapshot(),ee),Pe(e,r,Se),De(B.checked?"opfs":"memory")}else k.textContent=i==="en"?"Starting SQLite/WASM…":"正在启动 SQLite/WASM…"}function re(){return pe.find(t=>t.id===W)??pe[0]}async function qe(t){k.textContent=i==="en"?`Opening ${t.toUpperCase()} SQLite/WASM…`:`正在打开 ${t.toUpperCase()} SQLite/WASM…`;const e=E;E=void 0,await e?.client.close();const r=await it(t);E=r,await be(r),await P(re(),r),De(t)}B.addEventListener("change",()=>{const t=B.checked?"opfs":"memory";localStorage.setItem("teaql-browser-storage",t),qe(t).catch(N)});Y.addEventListener("click",async()=>{if(E){Y.disabled=!0;try{await E.client.reset(E.context),await be(E),await P(re(),E)}catch(t){N(t)}finally{Y.disabled=!1}}});X.addEventListener("click",()=>{b.querySelectorAll("details").forEach(t=>{t.open=!0})});Q.addEventListener("click",()=>{Q.disabled||(w="table",z())});H.addEventListener("click",()=>{w="tree",z()});tt.addEventListener("click",()=>{b.querySelectorAll("details").forEach((t,e)=>{t.open=e===0})});Ae.forEach(t=>{t.addEventListener("click",()=>{i=t.dataset.locale==="zh"?"zh":"en",localStorage.setItem("teaql-browser-locale",i),ve()})});function N(t){const e=t instanceof Error?t:new Error(String(t));k.textContent=`${e.name}: ${e.message}`,J.textContent=i==="en"?"Query failed":"查询失败",Le({error:e.name,message:e.message})}ve();W=re().id;V();qe(Ce).catch(N);
|
|
|
|
| 1 |
+
import{S as x,m as Te,a as qe,e as xe,O as $,B as Qe,b as Re,R as $e,U as Be,D as Fe,c as ke,M as We}from"./dynamic-search-Ch_QcWVU.js";/* empty css */const C=t=>({columnName:t,modelName:t,logicalType:"integer",decode:"string"}),y=t=>({columnName:t,modelName:t,logicalType:"text",decode:"native"}),ze=t=>({columnName:t,modelName:t,logicalType:"date",decode:"date"}),K=t=>({columnName:t,modelName:t,logicalType:"datetime",decode:"date"}),I=(t,e="decimal")=>({columnName:t,modelName:t,logicalType:e,decode:"number"}),f=Object.freeze({PENDING_PAYMENT:"1001",PAID:"1002",SHIPPED:"1003",DELIVERED:"1004",CANCELLED:"1005"}),Me=[{entity:"OrderStatus",id:f.PENDING_PAYMENT,values:{name:"Pending payment",code:"PENDING_PAYMENT",color:"#D97706",displayOrder:10}},{entity:"OrderStatus",id:f.PAID,values:{name:"Paid",code:"PAID",color:"#2563EB",displayOrder:20}},{entity:"OrderStatus",id:f.SHIPPED,values:{name:"Shipped",code:"SHIPPED",color:"#16A34A",displayOrder:30}},{entity:"OrderStatus",id:f.DELIVERED,values:{name:"Delivered",code:"DELIVERED",color:"#047857",displayOrder:40}},{entity:"OrderStatus",id:f.CANCELLED,values:{name:"Cancelled",code:"CANCELLED",color:"#9F1239",displayOrder:50}}],ie={Platform:{table:"platform_data",columns:{id:C("id"),name:y("name"),code:y("code"),region:y("region"),currency:y("currency"),version:I("version","integer")},relations:{customerList:{targetEntity:"Customer",localKey:"id",foreignKey:"platformId",many:!0},orderList:{targetEntity:"CustomerOrder",localKey:"id",foreignKey:"platformId",many:!0}}},Customer:{table:"customer_data",columns:{id:C("id"),name:y("name"),email:y("email"),city:y("city"),tier:y("tier"),platformId:C("platform_id"),version:I("version","integer")},relations:{platform:{targetEntity:"Platform",localKey:"platformId",foreignKey:"id",many:!1},orderList:{targetEntity:"CustomerOrder",localKey:"id",foreignKey:"customerId",many:!0}}},CustomerOrder:{table:"customer_order_data",columns:{id:C("id"),orderNumber:y("order_number"),orderDate:ze("order_date"),status:C("status_id"),totalAmount:I("total_amount"),currency:y("currency"),customerId:C("customer_id"),platformId:C("platform_id"),version:I("version","integer")},relations:{platform:{targetEntity:"Platform",localKey:"platformId",foreignKey:"id",many:!1},customer:{targetEntity:"Customer",localKey:"customerId",foreignKey:"id",many:!1},status:{targetEntity:"OrderStatus",localKey:"status",foreignKey:"id",many:!1},itemList:{targetEntity:"OrderItem",localKey:"id",foreignKey:"orderId",many:!0},paymentList:{targetEntity:"Payment",localKey:"id",foreignKey:"orderId",many:!0},shipmentList:{targetEntity:"Shipment",localKey:"id",foreignKey:"orderId",many:!0}}},OrderStatus:{table:"order_status_data",columns:{id:C("id"),name:y("name"),code:y("code"),color:y("color"),displayOrder:I("display_order","integer"),version:I("version","integer")},relations:{orderList:{targetEntity:"CustomerOrder",localKey:"id",foreignKey:"status",many:!0}}},OrderItem:{table:"order_item_data",columns:{id:C("id"),orderId:C("order_id"),productName:y("product_name"),sku:y("sku"),quantity:I("quantity","integer"),unitPrice:I("unit_price"),lineAmount:I("line_amount"),version:I("version","integer")},relations:{order:{targetEntity:"CustomerOrder",localKey:"orderId",foreignKey:"id",many:!1}}},Payment:{table:"payment_data",columns:{id:C("id"),orderId:C("order_id"),provider:y("provider"),status:y("status"),amount:I("amount"),currency:y("currency"),transactionId:y("transaction_id"),paidAt:K("paid_at"),version:I("version","integer")},relations:{order:{targetEntity:"CustomerOrder",localKey:"orderId",foreignKey:"id",many:!1}}},Shipment:{table:"shipment_data",columns:{id:C("id"),orderId:C("order_id"),carrier:y("carrier"),status:y("status"),trackingNumber:y("tracking_number"),shipToCity:y("ship_to_city"),shippedAt:K("shipped_at"),deliveredAt:K("delivered_at"),version:I("version","integer")},relations:{order:{targetEntity:"CustomerOrder",localKey:"orderId",foreignKey:"id",many:!1}}}},pe=[{entity:"Platform",id:"1",payload:{name:"TeaQL Store",code:"TEAQL-CN",region:"China",currency:"CNY"}},{entity:"Platform",id:"2",payload:{name:"TeaQL Global",code:"TEAQL-GLOBAL",region:"Global",currency:"USD"}},{entity:"Customer",id:"101",payload:{name:"Lin Xiao",email:"lin.xiao@example.com",city:"Shanghai",tier:"GOLD",platformId:"1"}},{entity:"Customer",id:"102",payload:{name:"Zhou Ran",email:"zhou.ran@example.com",city:"Hangzhou",tier:"SILVER",platformId:"1"}},{entity:"Customer",id:"103",payload:{name:"Maya Patel",email:"maya.patel@example.com",city:"Singapore",tier:"GOLD",platformId:"2"}},{entity:"Customer",id:"104",payload:{name:"Lucas Martin",email:"lucas.martin@example.com",city:"Paris",tier:"SILVER",platformId:"2"}},{entity:"Customer",id:"105",payload:{name:"Wang Ning",email:"wang.ning@example.com",city:"Chengdu",tier:"BRONZE",platformId:"1"}},{entity:"CustomerOrder",id:"1001",payload:{orderNumber:"TQL-2026-1001",orderDate:"2026-08-28",status:f.DELIVERED,totalAmount:499,currency:"CNY",customerId:"101",platformId:"1"}},{entity:"CustomerOrder",id:"1002",payload:{orderNumber:"TQL-2026-1002",orderDate:"2026-09-02",status:f.SHIPPED,totalAmount:1299,currency:"CNY",customerId:"102",platformId:"1"}},{entity:"CustomerOrder",id:"1003",payload:{orderNumber:"TQL-2026-1003",orderDate:"2026-09-06",status:f.PAID,totalAmount:328.8,currency:"CNY",customerId:"101",platformId:"1"}},{entity:"CustomerOrder",id:"1004",payload:{orderNumber:"TQL-2026-1004",orderDate:"2026-09-11",status:f.PENDING_PAYMENT,totalAmount:79.9,currency:"CNY",customerId:"105",platformId:"1"}},{entity:"CustomerOrder",id:"1005",payload:{orderNumber:"TQL-2026-1005",orderDate:"2026-09-14",status:f.DELIVERED,totalAmount:219,currency:"USD",customerId:"103",platformId:"2"}},{entity:"CustomerOrder",id:"1006",payload:{orderNumber:"TQL-2026-1006",orderDate:"2026-09-18",status:f.PAID,totalAmount:640,currency:"USD",customerId:"104",platformId:"2"}},{entity:"CustomerOrder",id:"1007",payload:{orderNumber:"TQL-2026-1007",orderDate:"2026-09-21",status:f.CANCELLED,totalAmount:159,currency:"CNY",customerId:"102",platformId:"1"}},{entity:"CustomerOrder",id:"1008",payload:{orderNumber:"TQL-2026-1008",orderDate:"2026-09-25",status:f.SHIPPED,totalAmount:268,currency:"CNY",customerId:"105",platformId:"1"}},{entity:"OrderItem",id:"2001",payload:{orderId:"1001",productName:"TeaQL Mechanical Keyboard",sku:"KB-TQL-87",quantity:1,unitPrice:299,lineAmount:299}},{entity:"OrderItem",id:"2002",payload:{orderId:"1001",productName:"Silent Wireless Mouse",sku:"MS-SILENT",quantity:2,unitPrice:100,lineAmount:200}},{entity:"OrderItem",id:"2003",payload:{orderId:"1002",productName:"27-inch Developer Monitor",sku:"MON-27-4K",quantity:1,unitPrice:1299,lineAmount:1299}},{entity:"OrderItem",id:"2004",payload:{orderId:"1003",productName:"White Porcelain Travel Tea Set",sku:"TEA-TRAVEL",quantity:1,unitPrice:168.8,lineAmount:168.8}},{entity:"OrderItem",id:"2005",payload:{orderId:"1003",productName:"Pre-Qingming Longjing Tea",sku:"TEA-LJ-100",quantity:2,unitPrice:80,lineAmount:160}},{entity:"OrderItem",id:"2006",payload:{orderId:"1004",productName:"Double-wall Glass Tumbler",sku:"CUP-GLASS",quantity:1,unitPrice:79.9,lineAmount:79.9}},{entity:"OrderItem",id:"2007",payload:{orderId:"1005",productName:"Travel Brew Kit",sku:"BREW-KIT",quantity:1,unitPrice:219,lineAmount:219}},{entity:"OrderItem",id:"2008",payload:{orderId:"1006",productName:"Desktop Studio Speaker",sku:"SPK-STUDIO",quantity:2,unitPrice:260,lineAmount:520}},{entity:"OrderItem",id:"2009",payload:{orderId:"1006",productName:"Speaker Stand",sku:"SPK-STAND",quantity:1,unitPrice:120,lineAmount:120}},{entity:"OrderItem",id:"2010",payload:{orderId:"1007",productName:"Desktop Reading Lamp",sku:"LAMP-DESK",quantity:1,unitPrice:159,lineAmount:159}},{entity:"OrderItem",id:"2011",payload:{orderId:"1008",productName:"TeaQL Portable Keyboard",sku:"KB-TQL-68",quantity:1,unitPrice:268,lineAmount:268}},{entity:"Payment",id:"3001",payload:{orderId:"1001",provider:"Alipay",status:"CAPTURED",amount:499,currency:"CNY",transactionId:"ALI-260828-01",paidAt:"2026-08-28T10:14:00Z"}},{entity:"Payment",id:"3002",payload:{orderId:"1002",provider:"WeChat Pay",status:"CAPTURED",amount:1299,currency:"CNY",transactionId:"WX-260902-08",paidAt:"2026-09-02T03:20:00Z"}},{entity:"Payment",id:"3003",payload:{orderId:"1003",provider:"Alipay",status:"CAPTURED",amount:328.8,currency:"CNY",transactionId:"ALI-260906-11",paidAt:"2026-09-06T11:42:00Z"}},{entity:"Payment",id:"3004",payload:{orderId:"1004",provider:"WeChat Pay",status:"PENDING",amount:79.9,currency:"CNY",transactionId:"WX-260911-02",paidAt:null}},{entity:"Payment",id:"3005",payload:{orderId:"1005",provider:"Stripe",status:"CAPTURED",amount:219,currency:"USD",transactionId:"PI-260914-05",paidAt:"2026-09-14T06:10:00Z"}},{entity:"Payment",id:"3006",payload:{orderId:"1006",provider:"Stripe",status:"CAPTURED",amount:640,currency:"USD",transactionId:"PI-260918-03",paidAt:"2026-09-18T15:08:00Z"}},{entity:"Payment",id:"3007",payload:{orderId:"1007",provider:"Alipay",status:"REFUNDED",amount:159,currency:"CNY",transactionId:"ALI-260921-07",paidAt:"2026-09-21T02:55:00Z"}},{entity:"Payment",id:"3008",payload:{orderId:"1008",provider:"WeChat Pay",status:"CAPTURED",amount:268,currency:"CNY",transactionId:"WX-260925-06",paidAt:"2026-09-25T08:31:00Z"}},{entity:"Shipment",id:"4001",payload:{orderId:"1001",carrier:"SF Express",status:"DELIVERED",trackingNumber:"SF2608281001",shipToCity:"Shanghai",shippedAt:"2026-08-29T02:00:00Z",deliveredAt:"2026-08-30T07:26:00Z"}},{entity:"Shipment",id:"4002",payload:{orderId:"1002",carrier:"JD Logistics",status:"IN_TRANSIT",trackingNumber:"JD2609021002",shipToCity:"Hangzhou",shippedAt:"2026-09-03T04:12:00Z",deliveredAt:null}},{entity:"Shipment",id:"4003",payload:{orderId:"1003",carrier:"SF Express",status:"READY",trackingNumber:"SF2609061003",shipToCity:"Shanghai",shippedAt:null,deliveredAt:null}},{entity:"Shipment",id:"4004",payload:{orderId:"1005",carrier:"DHL",status:"DELIVERED",trackingNumber:"DHL2609141005",shipToCity:"Singapore",shippedAt:"2026-09-15T01:10:00Z",deliveredAt:"2026-09-17T09:22:00Z"}},{entity:"Shipment",id:"4005",payload:{orderId:"1006",carrier:"DHL",status:"READY",trackingNumber:"DHL2609181006",shipToCity:"Paris",shippedAt:null,deliveredAt:null}},{entity:"Shipment",id:"4006",payload:{orderId:"1008",carrier:"SF Express",status:"IN_TRANSIT",trackingNumber:"SF2609251008",shipToCity:"Chengdu",shippedAt:"2026-09-26T03:18:00Z",deliveredAt:null}}],L=t=>`'${t.replaceAll("\\","\\\\").replaceAll("'","\\'").replaceAll(`
|
| 2 |
+
`,"\\n")}'`,U=t=>t.toQExpression().replace(/\s*\n\s*/g,""),_e={CustomerOrder:{fields:{id:"integer",orderNumber:"string",orderDate:"date",status:"integer",totalAmount:"decimal",currency:"string",customerId:"integer",platformId:"integer"},relations:{status:"OrderStatus",itemList:"OrderItem"}},OrderStatus:{fields:{id:"integer",name:"string",code:"string",color:"string",displayOrder:"integer"},relations:{}},OrderItem:{fields:{id:"integer",orderId:"integer",productName:"string",sku:"string"},relations:{}}};function Ke(t){if(!t||typeof t!="object"||Array.isArray(t))return t;const e=structuredClone(t),r=e.filter;if(!r||typeof r!="object"||Array.isArray(r)||!("status"in r))return e;const n=r,s=n.status,o=a=>{const i=f[String(a)];return i===void 0?a:Number(i)};return s&&typeof s=="object"&&!Array.isArray(s)&&"$in"in s?n.status={$in:Array.isArray(s.$in)?s.$in.map(o):s.$in}:n.status=o(s),e}class P{query;filters=[];qRoot;qSteps=[];auditComment="";queryPurpose="";pageTotalAlias;constructor(e,r){this.query=new x(e),this.qRoot=r}comment(e){return this.auditComment=e,this.query.comment(e),this.record(`comment(${L(e)})`),this}purpose(e){return this.queryPurpose=e,this.query.purpose(e),this.record(`purpose(${L(e)})`),this}limit(e){return this.query.limit(e),this.record(`limit(${e})`),this}offset(e){return this.query.offset(e),this.record(`offset(${e})`),this}toQExpression(e){const r=e?[...this.qSteps,e]:this.qSteps;return[this.qRoot,...r.map(n=>` .${n}`)].join(`
|
| 3 |
+
`)}toQuery(){const e=this.query.clone();return this.filters.length&&e.filter({$and:[...this.filters]}),e}async executeForList(e){return this.executeList(e,this.pageTotalAlias!==void 0)}async executeForRows(e){return this.executeList(e,!1)}async executeList(e,r){this.ensureIntent();const n=this.service(e),s=this.toQuery(),o=r?await n.executeCount(s,this.pageTotalAlias,{kind:"named-count",method:"countAs",alias:this.pageTotalAlias}):void 0,a=s.clone();r&&(a.aggregateItems=a.aggregateItems.filter(l=>!(String(l.function).toLowerCase()==="count"&&l.alias===this.pageTotalAlias)));const i=await n.executeQuery(e.prepareQuery(a)),c=new qe(i,{totalCount:o});return r&&this.pageTotalAlias!==void 0&&(c.aggregations[this.pageTotalAlias]=o),s.facets.length&&(c.facets=await xe(n,l=>e.prepareQuery(l),s,s.facets)),c}addFilter(e){return this.filters.push(e),this}select(...e){return this.query.select(e),this}order(e,r){return this.query.order(r==="asc"?$.asc(e):$.desc(e)),this}group(e){return this.query.groupBy(e),this}aggregate(e,r,n){return this.query.aggregate(e,r,n),this}record(e){return this.qSteps.push(e),this}includePageTotalAs(e){return this.pageTotalAlias=e,this}service(e){return e.requireResource("dataService")}ensureIntent(){if(!this.auditComment.trim()||!this.queryPurpose.trim())throw new Error("Generated Q requests require comment() and purpose() before execution")}}class Ue extends P{constructor(){super("Platform","Q.platforms()")}selectId(){return this.select("id")}selectName(){return this.select("name")}selectCode(){return this.select("code")}withIdIs(e){return this.addFilter({id:{$eq:e}})}}class Ye extends P{constructor(){super("Customer","Q.customers()")}selectId(){return this.select("id")}selectName(){return this.select("name")}selectCity(){return this.select("city")}selectTier(){return this.select("tier")}selectPlatformWith(e){return this.query.relationQuery("platform",e.toQuery(),"platformId","id",!1),this}countOrderListAs(e){return this.query.relationAggregate("orderList",e,new x("CustomerOrder").aggregate("Count","id",e)),this}orderByNameAscending(){return this.order("name","asc")}}class Ge extends P{constructor(){super("OrderItem","Q.orderItems()")}selectId(){return this.select("id"),this.record("selectId()")}selectOrderId(){return this.select("orderId"),this.record("selectOrderId()")}selectProductName(){return this.select("productName"),this.record("selectProductName()")}selectSku(){return this.select("sku"),this.record("selectSku()")}selectQuantity(){return this.select("quantity"),this.record("selectQuantity()")}withProductNameContaining(e){return this.addFilter({productName:{$contains:e}})}orderByIdAscending(){return this.order("id","asc"),this.record("orderByIdAscending()")}groupByProductName(){return this.group("productName")}sumQuantityAs(e){return this.aggregate("Sum","quantity",e)}sumLineAmountAs(e){return this.aggregate("Sum","lineAmount",e)}countAs(e){return this.aggregate("Count","id",e)}}class je extends P{constructor(){super("OrderStatus","Q.orderStatuses()")}selectId(){return this.select("id"),this.record("selectId()")}selectName(){return this.select("name"),this.record("selectName()")}selectCode(){return this.select("code"),this.record("selectCode()")}selectColor(){return this.select("color"),this.record("selectColor()")}selectDisplayOrder(){return this.select("displayOrder"),this.record("selectDisplayOrder()")}withCodeIs(e){return this.addFilter({code:{$eq:e}})}countAs(e){return this.aggregate("Count","id",e),this.record(`countAs(${L(e)})`)}sumOrderTotalAmountAs(e){return this.aggregate("Sum","totalAmount",e),this.record(`sumOrderTotalAmountAs(${L(e)})`)}orderByDisplayOrderAscending(){return this.order("displayOrder","asc"),this.record("orderByDisplayOrderAscending()")}}class Ve extends P{constructor(){super("Payment","Q.payments()")}groupByCurrency(){return this.group("currency")}groupByProvider(){return this.group("provider")}groupByStatus(){return this.group("status")}countAs(e){return this.aggregate("Count","id",e)}sumAmountAs(e){return this.aggregate("Sum","amount",e)}orderByCurrencyAscending(){return this.order("currency","asc")}orderByProviderAscending(){return this.order("provider","asc")}orderByIdAscending(){return this.order("id","asc")}}class He extends P{constructor(){super("Shipment","Q.shipments()")}withStatusIn(...e){return this.addFilter({status:{$in:e}})}selectOrderWith(e){return this.query.relationQuery("order",e.toQuery(),"orderId","id",!1),this}orderByStatusAscending(){return this.order("status","asc")}orderByIdAscending(){return this.order("id","asc")}}class de extends P{dynamicWarnings=[];countAlias;rowCountApplied=!1;constructor(e=!1){super("CustomerOrder",e?"Q.customerOrdersWithMinimalFields()":"Q.customerOrders()"),e?this.query.select(["id","version"]):this.query.select(["id","orderNumber","orderDate","status","totalAmount","currency","customerId","platformId","version"])}selectId(){return this.select("id")}selectOrderNumber(){return this.select("orderNumber"),this.record("selectOrderNumber()")}selectOrderDate(){return this.select("orderDate"),this.record("selectOrderDate()")}selectStatus(){return this.select("status")}selectTotalAmount(){return this.select("totalAmount")}selectCurrency(){return this.select("currency")}withOrderNumberIs(e){return this.addFilter({orderNumber:{$eq:e}})}withOrderNumberContaining(e){return this.addFilter({orderNumber:{$contains:e}})}withStatusMatching(e){return this.addFilter({status:{$inSubquery:{query:e.toQuery(),field:"id"}}})}withStatusIsPendingPayment(){return this.addFilter({status:{$eq:f.PENDING_PAYMENT}})}withStatusIsPaid(){return this.addFilter({status:{$eq:f.PAID}})}withStatusIsShipped(){return this.addFilter({status:{$eq:f.SHIPPED}})}withStatusIsDelivered(){return this.addFilter({status:{$eq:f.DELIVERED}})}withStatusIsCancelled(){return this.addFilter({status:{$eq:f.CANCELLED}})}withCurrencyIs(e){return this.addFilter({currency:{$eq:e}})}withTotalAmountGreaterThanOrEqualTo(e){return this.addFilter({totalAmount:{$gte:e}})}withOrderDateGreaterThanOrEqualTo(e){return this.addFilter({orderDate:{$gte:e}})}withPlatformIdIs(e){return this.addFilter({platformId:{$eq:e}})}withItemListMatching(e){return this.addFilter({id:{$inSubquery:{query:e.toQuery(),field:"orderId"}}})}filterByJson(e){const{query:r,warnings:n}=Te(this.toQuery(),Ke(e),_e,{filter:(s,o)=>s==="status.code"?{status:{$inSubquery:{query:new x("OrderStatus").filter({code:o}),field:"id"}}}:s==="itemList.productName"?{id:{$inSubquery:{query:new x("OrderItem").filter({productName:o}),field:"orderId"}}}:{[s]:o},order:(s,o)=>o==="asc"?$.asc(s):$.desc(s)});return this.dynamicWarnings=n,this.query.filterCondition=r.filterCondition,this.query.orderItems=[...r.orderItems],this.record("filterByJson(searchParams)"),this}warnings(){return this.dynamicWarnings}selectPlatformWith(e){return this.query.relationQuery("platform",e.toQuery(),"platformId","id",!1),this}selectCustomerWith(e){return this.query.relationQuery("customer",e.toQuery(),"customerId","id",!1),this}selectStatusWith(e){return this.query.select(["status"]),this.query.relationQuery("status",e.toQuery(),"status","id",!1,{kind:"relation-select",method:"selectStatusWith",relation:"status"}),this.record(`selectStatusWith(${U(e)})`)}selectItemListWith(e){return this.query.relationQuery("itemList",e.toQuery(),"id","orderId",!0,{kind:"relation-select",method:"selectItemListWith",relation:"itemList"}),this.record(`selectItemListWith(${U(e)})`)}selectPaymentListWith(e){return this.query.relationQuery("paymentList",e.toQuery(),"id","orderId",!0),this}selectShipmentListWith(e){return this.query.relationQuery("shipmentList",e.toQuery(),"id","orderId",!0),this}countItemListAs(e){return this.query.relationAggregate("itemList",e,new x("OrderItem").aggregate("Count","id",e).comment("count items"),!0,{kind:"relation-count",method:"countItemListAs",relation:"itemList",alias:e}),this.record(`countItemListAs(${L(e)})`)}facetByStatusAs(e,r,n=!0){const s=r.toQuery();return s.commentText||s.comment("load status facets"),this.query.facetBy(e,"status",{toQuery:()=>s},n,{kind:"facet",method:"facetByStatusAs",relation:"status",alias:e}),this.record(`facetByStatusAs(${L(e)}, ${U(r)})`)}orderByOrderDateDescending(){return this.order("orderDate","desc"),this.record("orderByOrderDateDescending()")}orderByOrderDateAscending(){return this.order("orderDate","asc")}orderByIdDescending(){return this.order("id","desc"),this.record("orderByIdDescending()")}orderByTotalAmountDescending(){return this.order("totalAmount","desc")}groupByCurrency(){return this.group("currency")}groupByStatus(){return this.group("status")}countAs(e){return this.countAlias=e,this.record(`countAs(${L(e)})`)}sumTotalAmountAs(e){return this.aggregate("Sum","totalAmount",e)}averageTotalAmountAs(e){return this.aggregate("Avg","totalAmount",e)}executeForList(e){return this.countAlias&&this.includePageTotalAs(this.countAlias),super.executeForList(e)}executeForRows(e){return this.applyRowCount(),super.executeForRows(e)}applyRowCount(){!this.countAlias||this.rowCountApplied||(this.query.aggregate("Count","id",this.countAlias),this.rowCountApplied=!0)}}class u{static platforms(){return new Ue}static customers(){return new Ye}static customerOrders(){return new de}static customerOrdersWithMinimalFields(){return new de(!0)}static orderItems(){return new Ge}static orderStatuses(){return new je}static payments(){return new Ve}static shipments(){return new He}}const k=document.querySelector("#status"),B=document.querySelector("#persist"),Y=document.querySelector("#reset"),F=document.querySelector("#query-catalog"),b=document.querySelector("#result"),ye=document.querySelector("#result-title"),he=document.querySelector("#result-description"),J=document.querySelector("#result-meta"),ce=document.querySelector("#query-code"),Ze=document.querySelector("#query-params-block"),Je=document.querySelector("#query-params-code"),Xe=document.querySelector("#result-grid"),R=document.querySelector("#result-view-label"),et=document.querySelector("#sql-count"),ue=document.querySelector("#sql-output"),X=document.querySelector("#expand-all"),tt=document.querySelector("#collapse-all"),Q=document.querySelector("#view-table"),V=document.querySelector("#view-tree"),ge=Array.from(document.querySelectorAll("[data-locale]")),rt={heroTitle:{en:"Understand TeaQL queries through a familiar order model.",zh:"用一个熟悉的订单模型,看懂 TeaQL 查询。"},heroIntro:{en:"Platform, customer, order, item, payment, and shipment data all run in the browser. Order status is backed by a constant model. Choose a query below to inspect real SQLite/WASM results.",zh:"平台、用户、订单、明细、支付和物流数据都在浏览器中运行;订单状态由常数模型提供。选择下面的查询,查看真实的 SQLite/WASM 结果。"},runtimeCoverage:{en:"RUNTIME COVERAGE",zh:"RUNTIME 覆盖"},runtimeTitle:{en:"This demo runs TypeScript in your browser.",zh:"这个演示在浏览器中运行 TypeScript。"},runtimeIntro:{en:"The same model-driven Q and TraceChain contract is supported by seven TeaQL runtimes. Select a language to inspect its runtime source.",zh:"同一套模型驱动的 Q 与 TraceChain 契约支持七种 TeaQL runtime。选择一种语言,可以查看对应的 runtime 源码。"},currentBrowserRuntime:{en:"Current browser runtime",zh:"当前浏览器 runtime"},supportedRuntime:{en:"Supported runtime",zh:"已支持 runtime"},platform:{en:"Platform",zh:"平台"},customer:{en:"Customer",zh:"用户"},order:{en:"Order",zh:"订单"},item:{en:"Item",zh:"明细"},payment:{en:"Payment",zh:"支付"},shipment:{en:"Shipment",zh:"物流"},constantModel:{en:"Constant model",zh:"常数模型"},persist:{en:"Persist locally with OPFS",zh:"使用 OPFS 保存在本地"},reset:{en:"Reset demo data",zh:"重置演示数据"},chooseQuery:{en:"Choose a query",zh:"选择一个查询"},queryIntro:{en:"Queries are grouped by purpose and share the same order dataset.",zh:"查询按用途分组,并共用同一份订单数据。"},table:{en:"Table",zh:"表格"},resultTree:{en:"Result Tree",zh:"结果树"},expandAll:{en:"Expand all",zh:"全部展开"},collapseAll:{en:"Collapse all",zh:"全部折叠"},waiting:{en:"Waiting for query…",zh:"等待查询…"},queryNote:{en:"The Q expression stays fixed; search, status cards, and pagination only update dynamic parameters. The underlying SelectQuery remains inside the generated request implementation.",zh:"Q 表达式保持不变;搜索、状态卡片和分页只更新动态参数。底层 SelectQuery 仍封装在生成的请求实现中。"},executionEvidence:{en:"EXECUTION EVIDENCE",zh:"执行证据"},evidenceTime:{en:"Time",zh:"时间"},identity:{en:"Identity",zh:"身份"},traceChain:{en:"Trace chain",zh:"追踪链"},sqlNote:{en:"One plain-text line per statement: time, identity, trace chain, and the SQL SQLite executed.",zh:"每条语句使用一行纯文本:时间、身份、追踪链,以及 SQLite 实际执行的 SQL。"},localData:{en:"Data stays in this browser",zh:"数据只保留在当前浏览器中"}},nt={基本查询:"Basic queries","从订单、用户和关联对象开始":"Start with orders, customers, and related objects",汇总查询:"Aggregations","分组、计数、求和与平均值":"Grouping, counts, sums, and averages",过滤查询:"Filtered queries","精确、范围与组合条件":"Exact, range, and combined predicates",动态查询:"Dynamic queries","由页面条件安全生成,不使用 eval":"Safely generated from page criteria without eval","综合:订单管理中心":"Comprehensive: Order management center","一个真实的综合查询页面:状态指标、搜索、商品预览和分页都由 TeaQL 查询驱动。":"A real composite query page: status metrics, search, product previews, and pagination are all driven by TeaQL.",最近订单:"Recent orders","按下单日期倒序浏览全部订单,并带出所属平台与用户。":"Browse all orders by date descending, including their platform and customer.",完整订单详情:"Complete order details","查看一个订单及其用户、商品明细、支付和物流,体现完整对象图。":"Inspect one order with its customer, items, payments, and shipments as a complete object graph.",用户与订单数:"Customers with order counts","列出用户,并通过关联汇总显示每位用户的订单数量。":"List customers and show each customer’s order count through a relation aggregate.",订单状态汇总:"Orders by status","按币种与订单状态统计订单数、总额和平均客单价。":"Aggregate order count, gross amount, and average order value by currency and status.",商品销售汇总:"Product sales summary","按商品汇总销量与销售额,找出最受欢迎的订单明细。":"Aggregate units and revenue by product to identify the most popular order items.",支付渠道对账:"Payment reconciliation","按币种、支付渠道和状态汇总笔数与金额。":"Aggregate transaction count and amount by currency, payment provider, and status.",待支付订单:"Orders awaiting payment","筛选尚未完成付款的订单,并带出对应支付记录。":"Find orders that have not completed payment and include their payment records.",国内大额订单:"High-value domestic orders","组合平台与金额条件,找出 TeaQL 商城中金额不低于 500 元的订单。":"Combine platform and amount filters to find TeaQL Store orders worth at least CNY 500.",运输中的包裹:"Active shipments","筛选待揽收和运输中的物流单,并关联订单信息。":"Find shipments that are ready or in transit and include their order information.","动态:已付款国内订单":"Dynamic: paid domestic orders","从动态条件对象生成查询:人民币、金额至少 250,且状态为已付款或已发货。":"Build a query from dynamic criteria: CNY, at least 250, and status PAID or SHIPPED.","动态:九月新订单":"Dynamic: new September orders","运行时传入日期范围与排序方式,查询 9 月 15 日之后的订单。":"Pass a date range and sort order at runtime to find orders after September 15.","动态:字段白名单":"Dynamic: field allowlist","未知字段会被报告并忽略;合法条件仍可安全执行。":"Unknown fields are reported and ignored while valid predicates still execute safely."};let d=localStorage.getItem("teaql-browser-locale")==="zh"?"zh":"en";function st(t){return rt[t]?.[d]??t}function O(t){return d==="en"?nt[t]??t:t}let E,W=window.location.hash.slice(1)||"order-center";window.location.hash||history.replaceState(null,"","#order-center");let w="tree",v,fe=0,ee;const A={search:"",page:0,pageSize:4},Ae=localStorage.getItem("teaql-browser-storage")==="opfs"?"opfs":"memory";B.checked=Ae==="opfs";async function G(t,e){const r=u.customerOrders().filterByJson(e).limit(20).comment("what: execute a validated browser search").purpose("why: demonstrate safe dynamic order discovery"),n=await r.executeForList(t.context);return{request:e,warnings:r.warnings(),data:n}}const ot=Object.fromEntries(Object.entries(f).map(([t,e])=>[e,t]));function te(t){const e=String(t.code??"");return e&&e in f?e:"color"in t?ot[String(t.id??"")]??"":""}function Se(t){const e=t.trim();if(!e)return{filter:{}};const r=e.toUpperCase(),n=["PENDING_PAYMENT","PAID","SHIPPED","DELIVERED","CANCELLED"].find(s=>s.includes(r));return n?{filter:{"status.code":n}}:/^(TQL-|\d)/i.test(e)?{filter:{orderNumber:{$contains:r}}}:{filter:{"itemList.productName":{$contains:e}}}}async function at(t){const e=Se(A.search),r=u.customerOrdersWithMinimalFields().filterByJson(e).countAs("totalOrders").facetByStatusAs("statusCounts",u.orderStatuses().selectName().selectColor().countAs("orderCount").sumOrderTotalAmountAs("orderTotalAmount").orderByDisplayOrderAscending().comment("load status facets")).selectOrderNumber().selectOrderDate().selectStatusWith(u.orderStatuses().selectName().selectColor().comment("load status")).selectItemListWith(u.orderItems().selectProductName().selectQuantity().orderByIdAscending().limit(3).comment("load item previews")).countItemListAs("itemCount").orderByOrderDateDescending().orderByIdDescending().comment("load order list").purpose("render order list page"),n=r.toQExpression(`offset(pageOffset)
|
| 4 |
+
.limit(pageSize)
|
| 5 |
+
.executeForList(ctx);`),s=await r.offset(A.page*A.pageSize).limit(A.pageSize).executeForList(t.context),o=s.facet("statusCounts")??[];return{orders:s,totalOrders:Number(s.aggregations.totalOrders??s.totalCount),filteredOrders:s.totalCount??0,statusFacets:o.map(a=>({code:te(a),name:String(a.name??""),color:String(a.color??""),orderCount:Number(a.orderCount??0),orderTotalAmount:Number(a.orderTotalAmount??0)})).filter(a=>a.code&&a.name),search:A.search,page:A.page,pageSize:A.pageSize,queryExpression:n}}const Ce=[{label:"基本查询",description:"从订单、用户和关联对象开始",queries:[{id:"order-center",title:"综合:订单管理中心",description:"一个真实的综合查询页面:状态指标、搜索、商品预览和分页都由 TeaQL 查询驱动。",code:"",view:"dashboard",run:at},{id:"recent-orders",title:"最近订单",description:"按下单日期倒序浏览全部订单,并带出所属平台与用户。",code:`await Q.customerOrders()
|
| 6 |
.selectPlatformWith(Q.platforms().selectName())
|
| 7 |
.selectCustomerWith(Q.customers().selectName().selectCity().selectTier())
|
| 8 |
.selectStatusWith(Q.orderStatuses().selectName().selectColor())
|
|
|
|
| 101 |
.comment('what: execute a validated browser search')
|
| 102 |
.purpose('why: demonstrate safe dynamic order discovery')
|
| 103 |
.executeForList(ctx);
|
| 104 |
+
const warnings = request.warnings();`,run:t=>G(t,{filter:{status:"DELIVERED",internalNote:{$contains:"not queryable"}}})}]}],le=Ce.flatMap(t=>t.queries);async function it(t){const e=new Worker(new URL("/assets/sqlite.worker-DS5P4U1E.js",import.meta.url),{type:"module"}),r=await Qe.open(e,{...ie},{storage:t,databaseName:"teaql-order-playground-v3.sqlite3"}),n=new Re().enableSelect();r.install(new $e(ie,{},{constants:Me})),r.setRuntimeTelemetrySink(n).setDiagnosticSQLLogSink(void 0);const s=Object.freeze({policyId:"browser-order-demo-seed",version:"1",fingerprint:"sha256:browser-order-demo-seed-v1"}),o=new Be().insertResource("dataService",r).withMutationPolicyRegistry(new Fe(()=>({identity:s,review:(a,i)=>i.operations.length>0?{verdict:"allow"}:{verdict:"deny",code:"EMPTY_GRAPH",message:"empty mutation graph"}}))).withMutationPolicyApprovalProvider(new ke(a=>({policy:a,approvedBy:"browser-demo-owner",approvedAt:new Date})));return r.setUserContext(o),await o.ensureSchema(),{client:r,context:o,evidence:n}}async function Ie(t){if((await u.customerOrders().selectId().limit(1).comment("what: detect existing order playground data").purpose("why: keep deterministic browser bootstrap idempotent").executeForList(t.context)).length)return;const r=new We("Seed deterministic order playground data");await t.client.executeGraphSave(r,async n=>{const s=pe.map(o=>n.request({entity:o.entity,action:"Create",id:o.id,payload:o.payload}));for(const o of s)t.client.preflightMutation(o);for(const o of s)await t.client.executeMutation(o)})}function dt(){F.replaceChildren();for(const t of Ce){const e=document.createElement("section");e.className="query-group";const r=document.createElement("div");r.className="query-group-heading";const n=document.createElement("h2");n.textContent=O(t.label);const s=document.createElement("p");s.textContent=O(t.description),r.append(n,s);const o=document.createElement("div");o.className="query-links";for(const a of t.queries){const i=document.createElement("a");i.href=`#${a.id}`,i.dataset.queryId=a.id,i.textContent=O(a.title),i.addEventListener("click",c=>{c.preventDefault(),W=a.id,history.replaceState(null,"",`#${a.id}`),H(),E&&D(a,E).catch(N)}),o.append(i)}e.append(r,o),F.append(e)}H()}function H(){F.querySelectorAll("a[data-query-id]").forEach(t=>{const e=t.dataset.queryId===W;t.classList.toggle("active",e),e?t.setAttribute("aria-current","page"):t.removeAttribute("aria-current")})}async function D(t,e){const r=performance.now(),n=new Date;e.evidence.enableSelect(),b.classList.add("loading"),b.setAttribute("aria-busy","true"),ye.textContent=O(t.title),he.textContent=O(t.description),ce.textContent=t.code,Ze.classList.toggle("hidden",t.view!=="dashboard"),Je.textContent=t.view==="dashboard"?JSON.stringify({searchParams:Se(A.search),pageOffset:A.page*A.pageSize,pageSize:A.pageSize},null,2):"",Xe.classList.toggle("dashboard-mode",t.view==="dashboard"),b.classList.toggle("dashboard-result",t.view==="dashboard"),X.closest(".tree-actions")?.classList.toggle("hidden",t.view==="dashboard"),R.textContent=t.view==="dashboard"?d==="en"?"Order management center":"订单管理中心":d==="en"?"Result tree":"结果树",J.textContent=d==="en"?"Running query…":"查询中…";try{const s=await t.run(e);t.view==="dashboard"&&(ce.textContent=s.queryExpression),v={data:s,query:t,active:e},w=t.view==="dashboard"||Z(s)?"table":"tree",z();const o=Math.max(1,Math.round(performance.now()-r));fe=o,ee=n;const a=e.evidence.snapshot();we(a,n),Le(s,t,o)}finally{b.classList.remove("loading"),b.removeAttribute("aria-busy")}}function we(t,e=ee){ue.replaceChildren(),et.textContent=d==="en"?`${t.length} statement${t.length===1?"":"s"}`:`${t.length} 条语句`,t.forEach((r,n)=>{const s=document.createElement("tr");s.className="evidence-row";const o=[...r.tracePath].reverse().find(m=>m.kind==="relation"||m.kind==="request"||m.kind==="entity"),a=document.createElement("td");a.className="evidence-time",a.dataset.executedAt=e?.toISOString()??"",a.textContent=`${e?.toISOString()??"—"} · ${Math.max(.01,r.elapsedMicros/1e3).toFixed(2)} ms`;const i=document.createElement("td");i.textContent=`${v?.query.id??"query"} · #${n+1} · ${o?.name??"query"}`;const c=document.createElement("td");if(c.className="evidence-trace",r.traceChain?.length){const m=r.traceChain.find(g=>g.kind==="purpose"),S=r.traceChain.filter(g=>g.kind==="comment").map(g=>g.detail||g.name);c.textContent=`${m?.detail||m?.name||""}: ${S.join(" → ")}`}else c.textContent=r.tracePath.map(m=>m.detail||m.name).join(" → ");const l=document.createElement("td");l.className="evidence-sql";const h=r.parameters.length?r.parameters.map(m=>String(m)).join(", "):"none";l.textContent=`${r.parameterizedSQL} · bindings: ${h}`,s.append(a,i,c,l),ue.append(s)})}function Z(t){return Array.isArray(t)&&t.every(e=>e!==null&&typeof e=="object"&&!Array.isArray(e))}function z(){if(!v)return;const{data:t,query:e,active:r}=v,n=e.view==="dashboard"||Z(t);if(n||(w="tree"),Q.disabled=!n,Q.classList.toggle("active",w==="table"),V.classList.toggle("active",w==="tree"),Q.setAttribute("aria-pressed",String(w==="table")),V.setAttribute("aria-pressed",String(w==="tree")),X.closest(".tree-actions")?.classList.toggle("hidden",w!=="tree"),w==="table"&&e.view==="dashboard"){R.textContent=d==="en"?"Result table":"结果表格",mt(t,r,e);return}if(w==="table"&&Z(t)){R.textContent=d==="en"?"Result table":"结果表格",ut(t);return}R.textContent=d==="en"?"Result tree":"结果树",Ee(e.view==="dashboard"?ct(t):t)}function ct(t){return{orders:t.orders,totalOrders:t.totalOrders,filteredOrders:t.filteredOrders,statusFacets:t.statusFacets,search:t.search,page:t.page,pageSize:t.pageSize}}function ut(t){const e=document.createElement("div");if(e.className="result-table-shell",!t.length){const i=document.createElement("p");i.className="result-table-empty",i.textContent=d==="en"?"The query returned no records.":"查询没有返回记录。",e.append(i),b.replaceChildren(e);return}const r=[...new Set(t.flatMap(i=>Object.keys(i)))],n=document.createElement("table");n.className="result-table";const s=document.createElement("thead"),o=document.createElement("tr");for(const i of r){const c=document.createElement("th");c.scope="col",c.textContent=i,o.append(c)}s.append(o);const a=document.createElement("tbody");for(const i of t){const c=document.createElement("tr");for(const l of r){const h=document.createElement("td");h.textContent=lt(i[l]),c.append(h)}a.append(c)}n.append(s,a),e.append(n),b.replaceChildren(e)}function lt(t){if(t==null)return"—";if(Array.isArray(t))return d==="en"?`${t.length} items`:`${t.length} 项`;if(t instanceof Date)return t.toISOString();if(typeof t=="object"){const e=t,r=te(e);if(r)return be(r);const n=e.name??e.orderNumber??e.code??e.id;return n===void 0?d==="en"?`${Object.keys(e).length} fields`:`${Object.keys(e).length} 个字段`:String(n)}return String(t)}function mt(t,e,r){const n=document.createElement("div");n.className="order-center";const s=document.createElement("div");s.className="order-center-toolbar";const o=document.createElement("div"),a=document.createElement("h3");a.textContent=d==="en"?"Order Management Center":"订单管理中心";const i=document.createElement("p");i.textContent=d==="en"?"One generated Q expression describes the entire page":"一个生成式 Q 表达式描述整个页面",o.append(a,i);const c=document.createElement("form");c.className="order-search";const l=document.createElement("input");l.type="search",l.placeholder=d==="en"?"Order number, status, or product…":"订单号、状态或商品名称…",l.value=t.search,l.setAttribute("aria-label",d==="en"?"Search orders":"搜索订单");const h=document.createElement("button");h.type="submit",h.className="order-search-submit",h.setAttribute("aria-label",d==="en"?"Run order query":"执行订单查询"),h.title=d==="en"?"Search":"查询";const m=document.createElement("span");m.className="search-icon",m.setAttribute("aria-hidden","true"),h.append(m),c.append(l,h),c.addEventListener("submit",p=>{p.preventDefault(),A.search=l.value.trim(),A.page=0,D(r,e).catch(N)}),s.append(o,c);const S=document.createElement("div");S.className="order-metrics",S.append(me(d==="en"?"All orders":"全部订单",t.totalOrders,"total","#2B66D9",!t.search,()=>{A.search="",A.page=0,D(r,e).catch(N)}));for(const p of t.statusFacets)S.append(me(p.name,p.orderCount,p.code.toLowerCase(),p.color,t.search.toUpperCase()===p.code,()=>{A.search=p.code,A.page=0,D(r,e).catch(N)},`${d==="en"?"Total":"总额"} ${pt(p.orderTotalAmount)}`));const g=document.createElement("div");g.className="order-table";const M=document.createElement("div");M.className="order-row order-row-head";const ve=d==="en"?["Order number","Order date","Status","Product details"]:["订单号","订单日期","状态","商品明细"];for(const p of ve){const q=document.createElement("span");q.textContent=p,M.append(q)}if(g.append(M),!t.orders.length){const p=document.createElement("div");p.className="order-empty",p.textContent=d==="en"?"No matching orders. Try an order number, status code, or product name.":"没有匹配的订单,请尝试订单号、状态英文或商品名称。",g.append(p)}for(const p of t.orders)g.append(yt(p));const _=document.createElement("div");_.className="order-center-footer";const ne=document.createElement("p"),se=t.filteredOrders?t.page*t.pageSize+1:0,oe=Math.min(t.filteredOrders,(t.page+1)*t.pageSize);ne.textContent=d==="en"?`Showing ${se}–${oe} of ${t.filteredOrders} orders`:`显示 ${se}–${oe},共 ${t.filteredOrders} 条订单`;const T=document.createElement("div");T.className="pagination";const ae=Math.max(1,Math.ceil(t.filteredOrders/t.pageSize));T.append(j("‹",t.page-1,t.page===0,e,r));for(let p=0;p<ae;p+=1){const q=j(String(p+1),p,!1,e,r);q.classList.toggle("active",p===t.page),T.append(q)}T.append(j("›",t.page+1,t.page>=ae-1,e,r)),_.append(ne,T),n.append(s,S,g,_),b.replaceChildren(n)}function me(t,e,r,n,s,o,a){const i=document.createElement("button");i.type="button",i.className=`metric-card metric-${r}`,n&&i.style.setProperty("--metric-color",n),i.classList.toggle("active",s);const c=document.createElement("span");c.textContent=t;const l=document.createElement("strong");if(l.textContent=String(e),i.append(c,l),a){const h=document.createElement("small");h.textContent=a,i.append(h)}return i.addEventListener("click",o),i}function pt(t){return new Intl.NumberFormat(d==="en"?"en-US":"zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2}).format(t)}function yt(t){const e=document.createElement("div");e.className="order-row";const r=t.status??{},n=Array.isArray(t.itemList)?t.itemList:[];[String(t.orderNumber??""),String(t.orderDate??"")].forEach(m=>{const S=document.createElement("span");S.className="order-primary",S.textContent=m,e.append(S)});const o=document.createElement("span"),a=document.createElement("span"),i=te(r);a.className=`status-badge status-${i.toLowerCase()}`,a.textContent=be(i)||String(r.name??i);const c=String(r.color??"");c&&(a.style.color=c,a.style.backgroundColor=`${c}18`),o.append(a),e.append(o);const l=document.createElement("span");l.className="product-preview",n.forEach((m,S)=>{const g=document.createElement("span");g.className=`product-thumb product-tone-${S%3}`,g.textContent=String(m.productName??"?").slice(0,1),g.title=`${String(m.productName??"")} × ${String(m.quantity??1)}`,l.append(g)});const h=Number(t.itemCount??n.length)-n.length;if(h>0){const m=document.createElement("small");m.textContent=`+${h}`,l.append(m)}return e.append(l),e}function j(t,e,r,n,s){const o=document.createElement("button");return o.type="button",o.textContent=t,o.disabled=r,o.addEventListener("click",()=>{A.page=e,D(s,n).catch(N)}),o}function be(t){return(d==="en"?{PENDING_PAYMENT:"Pending payment",PAID:"Paid",SHIPPED:"Shipped",DELIVERED:"Delivered",CANCELLED:"Cancelled"}:{PENDING_PAYMENT:"待支付",PAID:"已支付",SHIPPED:"运输中",DELIVERED:"已完成",CANCELLED:"已取消"})[t]??t}function Ee(t){b.replaceChildren(Ne(t,"result",0))}function Ne(t,e,r){if(t!==null&&typeof t=="object"){const a=Array.isArray(t)?t.map((S,g)=>[String(g),S]):Object.entries(t),i=document.createElement("details");i.className="tree-branch",i.open=r===0;const c=document.createElement("summary"),l=document.createElement("span");l.className="tree-key",l.textContent=e;const h=document.createElement("span");h.className="tree-preview",h.textContent=ht(t,a.length),c.append(l,h),i.append(c);const m=document.createElement("div");m.className="tree-children";for(const[S,g]of a)m.append(Ne(g,Array.isArray(t)?`#${Number(S)+1}`:S,r+1));return i.append(m),i}const n=document.createElement("div");n.className="tree-leaf";const s=document.createElement("span");s.className="tree-key",s.textContent=e;const o=document.createElement("span");return o.className=`tree-value tree-${t===null?"null":typeof t}`,o.textContent=t===null?"null":typeof t=="string"?`“${t}”`:String(t),n.append(s,o),n}function ht(t,e){if(Array.isArray(t))return d==="en"?`${e} items`:`${e} 项`;const r=t,n=r.orderNumber??r.name??r.productName??r.transactionId??r.trackingNumber;return n?String(n):d==="en"?`${e} fields`:`${e} 个字段`}function gt(t){return Array.isArray(t)?t.length:Array.isArray(t?.data)?t.data.length:1}function Le(t,e,r){const n=e.view==="dashboard"?t.filteredOrders:gt(t),s=d==="en"?`${n} ${e.view==="dashboard"?`matching order${n===1?"":"s"}`:`result${n===1?"":"s"}`}`:`${n} 条${e.view==="dashboard"?"匹配订单":"结果"}`;J.textContent=`${s} · ${r} ms · ${d==="en"?"in-browser SQLite":"浏览器内 SQLite"}`}function Oe(t){const e=pe.filter(r=>r.entity==="CustomerOrder").length;k.textContent=d==="en"?`${t.toUpperCase()} · ${e} orders · 7 entities · policy installed · ready`:`${t.toUpperCase()} · ${e} 个订单 · 7 个实体 · 已安装策略 · 就绪`}function De(){document.documentElement.lang=d==="en"?"en":"zh-CN",document.title=d==="en"?"TeaQL Order Query Playground":"TeaQL 订单查询演练场";const t=document.querySelector('meta[name="description"]');if(t&&(t.content=d==="en"?"A TeaQL order-query playground running entirely in the browser":"完全运行在浏览器中的 TeaQL 订单查询演练场"),document.querySelectorAll("[data-i18n]").forEach(e=>{const r=e.dataset.i18n;r&&(e.textContent=st(r))}),ge.forEach(e=>{const r=e.dataset.locale===d;e.classList.toggle("active",r),e.setAttribute("aria-pressed",String(r))}),document.querySelector(".language-switch")?.setAttribute("aria-label",d==="en"?"Language":"语言"),document.querySelector(".brand")?.setAttribute("aria-label",d==="en"?"TeaQL Playground home":"TeaQL 演练场首页"),document.querySelector(".model-map")?.setAttribute("aria-label",d==="en"?"Order domain model":"订单领域模型"),document.querySelector(".runtime-language-selector")?.setAttribute("aria-label",d==="en"?"TeaQL runtimes":"TeaQL 运行时"),document.querySelector(".runtime-bar")?.setAttribute("aria-label",d==="en"?"Runtime settings":"运行时设置"),F.setAttribute("aria-label",d==="en"?"Example queries":"示例查询"),document.querySelector(".result-view-switch")?.setAttribute("aria-label",d==="en"?"Result views":"结果视图"),document.querySelector(".tree-actions")?.setAttribute("aria-label",d==="en"?"Result tree actions":"结果树操作"),dt(),v){const{data:e,query:r,active:n}=v;ye.textContent=O(r.title),he.textContent=O(r.description),z(),we(n.evidence.snapshot(),ee),Le(e,r,fe),Oe(B.checked?"opfs":"memory")}else k.textContent=d==="en"?"Starting SQLite/WASM…":"正在启动 SQLite/WASM…"}function re(){return le.find(t=>t.id===W)??le[0]}async function Pe(t){k.textContent=d==="en"?`Opening ${t.toUpperCase()} SQLite/WASM…`:`正在打开 ${t.toUpperCase()} SQLite/WASM…`;const e=E;E=void 0,await e?.client.close();const r=await it(t);E=r,await Ie(r),await D(re(),r),Oe(t)}B.addEventListener("change",()=>{const t=B.checked?"opfs":"memory";localStorage.setItem("teaql-browser-storage",t),Pe(t).catch(N)});Y.addEventListener("click",async()=>{if(E){Y.disabled=!0;try{await E.client.reset(E.context),await Ie(E),await D(re(),E)}catch(t){N(t)}finally{Y.disabled=!1}}});X.addEventListener("click",()=>{b.querySelectorAll("details").forEach(t=>{t.open=!0})});Q.addEventListener("click",()=>{Q.disabled||(w="table",z())});V.addEventListener("click",()=>{w="tree",z()});tt.addEventListener("click",()=>{b.querySelectorAll("details").forEach((t,e)=>{t.open=e===0})});ge.forEach(t=>{t.addEventListener("click",()=>{d=t.dataset.locale==="zh"?"zh":"en",localStorage.setItem("teaql-browser-locale",d),De()})});function N(t){const e=t instanceof Error?t:new Error(String(t));k.textContent=`${e.name}: ${e.message}`,J.textContent=d==="en"?"Query failed":"查询失败",Ee({error:e.name,message:e.message})}De();W=re().id;H();Pe(Ae).catch(N);
|
assets/object-location-xgYMemK6.js → dist/assets/object-location-CJfVWqJC.js
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{f as u}from"./dynamic-search-
|
|
|
|
| 1 |
+
import{f as u}from"./dynamic-search-Ch_QcWVU.js";const i=n=>`${n.entity}\0${typeof n.id}:${String(n.id)}`;class V{constructor(){this.changes=new Map,this.originalVersions=new Map,this.newKeys=new Map,this.deletedKeys=new Map,this.traces=new Map}setTraceChain(s,e){this.traces.set(i(s),{key:Object.freeze({...s}),nodes:u(e)})}traceChain(s){return this.traces.get(i(s))?.nodes}set(s,e,t){if(!e.trim())throw new TypeError("field is required");const r=i(s),a=this.changes.get(r)??{key:Object.freeze({...s}),values:{}};a.values[e]=t,this.changes.set(r,a)}snapshot(){return[...this.changes.values()].map(s=>({key:Object.freeze({...s.key}),values:Object.freeze({...s.values})}))}change(s){return Object.freeze({...this.changes.get(i(s))?.values??{}})}mergeFrom(s){if(s!==this){for(const e of s.snapshotVersions())this.requireMatchingVersion(e.key,e.version);for(const e of s.snapshot())for(const[t,r]of Object.entries(e.values))this.set(e.key,t,r);for(const e of s.newKeys.values())this.markAsNew(e);for(const e of s.deletedKeys.values())this.markAsDeleted(e);for(const e of s.snapshotVersions())this.setOriginalVersion(e.key,e.version);for(const e of s.traces.values())this.setTraceChain(e.key,e.nodes)}}mergeEntityFrom(s,e){if(s===this)return;const t=s.originalVersion(e);t!==void 0&&this.requireMatchingVersion(e,t);for(const[a,c]of Object.entries(s.change(e)))this.set(e,a,c);s.isNew(e)&&this.markAsNew(e),s.isDeleted(e)&&this.markAsDeleted(e),t!==void 0&&this.setOriginalVersion(e,t);const r=s.traceChain(e);r&&this.setTraceChain(e,r)}hasPending(s){const e=i(s);return this.newKeys.has(e)||this.deletedKeys.has(e)||Object.keys(this.changes.get(e)?.values??{}).length>0}snapshotVersions(){return[...this.originalVersions.values()]}rekey(s,e){const t=i(s),r=i(e);if(t===r)return;const a=this.originalVersion(s);a!==void 0&&this.requireMatchingVersion(e,a);const c=this.changes.get(t);if(c){this.changes.delete(t);for(const[f,g]of Object.entries(c.values))this.set(e,f,g)}const h=this.originalVersions.get(t);h!==void 0&&(this.originalVersions.delete(t),this.originalVersions.set(r,{key:Object.freeze({...e}),version:h.version})),this.newKeys.delete(t)&&this.newKeys.set(r,Object.freeze({...e})),this.deletedKeys.delete(t)&&this.deletedKeys.set(r,Object.freeze({...e}));const l=this.traces.get(t);l&&(this.traces.delete(t),this.setTraceChain(e,l.nodes))}clearEntity(s){const e=i(s);this.changes.delete(e),this.newKeys.delete(e),this.deletedKeys.delete(e),this.traces.delete(e)}requireMatchingVersion(s,e){const t=this.originalVersion(s);if(t!==void 0&&t!==e)throw new Error("ENTITY_VERSION_CONFLICT: one graph cannot contain different loaded versions of the same typed entity")}setOriginalVersion(s,e){this.requireMatchingVersion(s,e),this.originalVersions.set(i(s),{key:Object.freeze({...s}),version:e})}acceptCommittedVersion(s,e){if(this.hasPending(s))throw new Error("ENTITY_COMMIT_PENDING: clear committed changes before accepting the persisted version");this.originalVersions.set(i(s),{key:Object.freeze({...s}),version:e})}originalVersion(s){return this.originalVersions.get(i(s))?.version}markAsNew(s){this.newKeys.set(i(s),Object.freeze({...s}))}isNew(s){return this.newKeys.has(i(s))}markAsDeleted(s){const e=i(s);this.changes.delete(e),this.deletedKeys.set(e,Object.freeze({...s}))}isDeleted(s){return this.deletedKeys.has(i(s))}clearCommitted(){this.changes.clear(),this.newKeys.clear(),this.deletedKeys.clear(),this.traces.clear()}}function d(n){const s=n.split("_");return s[0]+s.slice(1).map(e=>e?e[0].toUpperCase()+e.slice(1):"").join("")}function p(n,s){if(s==="snake_case")return n;const e=d(n);return s==="camelCase"||!e?e:e[0].toUpperCase()+e.slice(1)}function m(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}class o{constructor(s){this.segments=s}static root(){return new o([])}static property(s){return o.root().property(s)}property(s){return new o([...this.segments,{kind:"property",name:s}])}index(s){return new o([...this.segments,{kind:"index",index:s}])}prefixedBy(s){return new o([...s.segments,...this.segments])}modelPath(){return this.render(s=>s)}nativePath(){return this.render(d)}instancePath(s="camelCase"){return this.segments.map(e=>e.kind==="index"?String(e.index):m(p(e.name,s))).map(e=>`/${e}`).join("")}toString(){return this.nativePath()}render(s){let e="";for(const t of this.segments)t.kind==="index"?e+=`[${t.index}]`:e+=`${e?".":""}${s(t.name)}`;return e}}export{V as E,o as O};
|
assets/orders-CQOGX0kN.js → dist/assets/orders-BIvSfQqM.js
RENAMED
|
The diff for this file is too large to render.
See raw diff
|
|
|
dist/assets/style-DVG2mb5q.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
:root{font:16px/1.5 Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;color:#17231b;background:#f5f4ed;font-synthesis:none;--ink: #17231b;--muted: #677067;--paper: #fffef8;--line: #d8ddd3;--green: #145b37;--green-deep: #0e4329;--lime: #dff45c;--orange: #ef8354;--blue: #2b66d9}*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;min-width:320px;background:#f5f4ed}button,input{font:inherit}button,a{-webkit-tap-highlight-color:transparent}.page-shell{width:min(1440px,100%);margin:0 auto;padding:0 42px}.site-header{height:76px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line)}.brand,.docs-link{color:var(--ink);text-decoration:none;font-weight:750}.brand{display:inline-flex;align-items:center;gap:11px;letter-spacing:-.02em}.brand-mark{width:30px;height:30px;display:grid;place-items:center;border-radius:50%;color:var(--lime);background:var(--green-deep);font-family:Georgia,serif;font-style:italic}.docs-link{color:var(--green);font-size:14px}.header-actions{display:flex;align-items:center;gap:18px}.language-switch{display:flex;gap:3px;padding:3px;border:1px solid var(--line);border-radius:8px}.language-switch button{padding:3px 7px;border:0;border-radius:5px;color:var(--muted);background:transparent;font-size:11px;cursor:pointer}.language-switch button.active{color:#fff;background:var(--green)}.hero{min-height:460px;display:grid;grid-template-columns:minmax(0,1.1fr) minmax(440px,.9fr);align-items:center;gap:72px;padding:76px 0 66px}.eyebrow,.section-index,.query-card-label{margin:0 0 14px;color:var(--green);font-size:11px;font-weight:850;letter-spacing:.18em}h1{margin:0;max-width:820px;font-family:Georgia,"Noto Serif SC",serif;font-size:clamp(42px,5.6vw,78px);font-weight:500;line-height:1.08;letter-spacing:-.055em}.hero-intro{max-width:680px;margin:26px 0 0;color:var(--muted);font-size:18px}.model-map{position:relative;min-height:310px;padding:38px;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:12px;border:1px solid #bfc8bb;border-radius:28px;background:linear-gradient(145deg,#fdfdf8,#e9eee5);box-shadow:0 18px 48px #213c280f;overflow:hidden}.model-map:before{content:"DOMAIN MODEL";position:absolute;top:18px;left:22px;color:#708073;font-size:10px;font-weight:800;letter-spacing:.16em}.model-flow{width:100%;display:grid;grid-template-columns:1fr auto 1fr auto 1fr;align-items:center;gap:10px}.model-flow>span:not(.model-arrow),.model-leaves span{min-width:0;padding:15px 17px;border:1px solid #b8c2b7;border-radius:12px;background:#fffffadb;font:750 14px/1.2 ui-monospace,SFMono-Regular,Menlo,monospace;box-shadow:0 8px 22px #1e3a260d}.model-map small{display:block;margin-top:7px;color:var(--muted);font:12px/1.2 Inter,sans-serif}.model-flow>span.model-root{color:#fff;border-color:var(--green);background:var(--green)}.model-map .model-root small{color:#cce4d4}.model-arrow{color:#809087;font-size:22px;text-align:center}.model-arrow-split{height:22px;line-height:18px}.model-leaves{width:100%;display:grid;grid-template-columns:repeat(4,1fr);gap:10px}.runtime-language-panel{margin-bottom:28px;padding:24px;display:grid;grid-template-columns:minmax(240px,.72fr) minmax(0,1.8fr);align-items:center;gap:30px;border:1px solid var(--line);border-radius:18px;background:var(--paper)}.runtime-language-copy .section-index{margin-bottom:8px}.runtime-language-copy h2{margin:0;font-family:Georgia,"Noto Serif SC",serif;font-size:clamp(22px,2.4vw,31px);font-weight:500;line-height:1.15;letter-spacing:-.035em}.runtime-language-copy p:last-child{margin:11px 0 0;color:var(--muted);font-size:13px}.runtime-language-selector{display:grid;grid-template-columns:repeat(7,minmax(82px,1fr));gap:8px}.runtime-language{min-width:0;padding:13px 8px 11px;display:flex;align-items:center;flex-direction:column;gap:4px;border:1px solid #d7ddd5;border-radius:12px;color:var(--ink);background:#fafbf7;text-align:center;text-decoration:none;transition:border-color .16s ease,background .16s ease,transform .16s ease}.runtime-language:hover{border-color:#98aa9d;background:#fff;transform:translateY(-2px)}.runtime-language.active{color:#fff;border-color:var(--green);background:var(--green);box-shadow:0 8px 20px #145b3724}.runtime-language-icon{font-size:25px;line-height:1.1}.runtime-language strong{overflow:hidden;max-width:100%;font-size:11px;text-overflow:ellipsis;white-space:nowrap}.runtime-language small{color:#78837a;font-size:8px;line-height:1.25}.runtime-language.active small{color:#d5e7da}.runtime-bar{min-height:72px;padding:14px 18px 14px 22px;display:flex;align-items:center;justify-content:space-between;gap:24px;border-radius:14px;color:#e7f1e9;background:var(--green-deep)}#status{margin:0;color:#c8d9ce;font:12px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}.controls{display:flex;align-items:center;gap:18px}.toggle{display:inline-flex;align-items:center;gap:9px;font-size:13px;cursor:pointer}.toggle input{position:absolute;opacity:0;pointer-events:none}.toggle span{position:relative;width:38px;height:22px;border-radius:999px;background:#55705f;transition:background .2s ease}.toggle span:after{content:"";position:absolute;top:3px;left:3px;width:16px;height:16px;border-radius:50%;background:#fff;transition:transform .2s ease}.toggle input:checked+span{background:var(--lime)}.toggle input:checked+span:after{transform:translate(16px);background:var(--green-deep)}.secondary-button,.tree-actions button{border:1px solid currentColor;border-radius:8px;background:transparent;cursor:pointer}.secondary-button{padding:8px 12px;color:#fff;font-size:12px}.secondary-button:disabled{opacity:.45;cursor:wait}.query-browser{padding:96px 0 82px}.section-heading,.result-heading{display:flex;align-items:end;justify-content:space-between;gap:36px;margin-bottom:40px}.section-heading h2,.result-heading h2{margin:0;font-family:Georgia,"Noto Serif SC",serif;font-size:clamp(34px,4vw,52px);font-weight:500;letter-spacing:-.045em}.section-heading>p{max-width:420px;margin:0;color:var(--muted)}.query-group{display:grid;grid-template-columns:230px 1fr;gap:36px;padding:24px 0;border-top:1px solid var(--line)}.query-group:last-child{border-bottom:1px solid var(--line)}.query-group-heading h2{margin:0 0 4px;font-size:16px}.query-group-heading p{margin:0;color:var(--muted);font-size:12px}.query-links{display:flex;flex-wrap:wrap;align-items:center;gap:10px 24px}.query-links a{position:relative;padding:5px 0;color:#34443a;text-decoration-color:#a6b1a8;text-underline-offset:5px;font-weight:650;transition:color .16s ease}.query-links a:after{content:" ↗";color:#9aa49b;font-weight:400}.query-links a:hover{color:var(--green)}.query-links a.active{color:var(--green);text-decoration-color:var(--orange);text-decoration-thickness:2px}.result-panel{margin:0 -42px;padding:82px 42px 92px;color:#eef5f0;background:#111a15}.result-heading{align-items:center}.result-heading .section-index{color:var(--lime)}.result-heading h2{color:#fff}#result-description{max-width:620px;margin:10px 0 0;color:#9fb0a4}.result-actions{display:flex;align-items:center;gap:10px}.result-view-switch,.tree-actions{display:flex;gap:6px}.result-view-switch button,.tree-actions button{padding:8px 11px;border:1px solid #536159;border-radius:8px;color:#aebdb3;background:transparent;font-size:12px;cursor:pointer}.result-view-switch button.active{color:#17231b;border-color:var(--lime);background:var(--lime)}.result-view-switch button:disabled{opacity:.35;cursor:default}.tree-actions button:hover{color:var(--lime)}.result-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:18px;align-items:start}.tree-card,.query-card,.sql-card{border:1px solid #2f3d34;border-radius:14px;background:#17231b}.tree-card{min-height:520px;overflow:hidden}.tree-card-bar{min-height:48px;padding:0 18px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #2f3d34;color:#b8c9bd;font:11px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace;text-transform:uppercase;letter-spacing:.08em}#result-meta{margin:0;color:#829188;text-transform:none;letter-spacing:0}.json-tree{min-height:470px;max-height:680px;padding:18px 20px 28px;overflow:auto;font:13px/1.6 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.json-tree.loading{opacity:.55}.tree-actions.hidden{display:none}.result-table-shell{width:100%;min-height:470px;overflow:auto}.result-table{width:100%;border-collapse:collapse;white-space:nowrap}.result-table th,.result-table td{padding:11px 14px;border-bottom:1px solid #2f3d34;text-align:left;vertical-align:top}.result-table th{position:sticky;top:0;z-index:1;color:#8ea095;background:#131d17;font:700 10px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}.result-table td{color:#d9e5dc;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace}.result-table tbody tr:hover{background:#ffffff06}.result-table-empty{margin:0;padding:48px 20px;color:#7f9185;text-align:center}.tree-branch{margin:2px 0}.tree-branch>summary{min-height:29px;display:flex;align-items:center;gap:9px;list-style:none;cursor:pointer;border-radius:5px}.tree-branch>summary::-webkit-details-marker{display:none}.tree-branch>summary:before{content:"›";width:15px;color:#73887a;font-size:18px;line-height:1;transform-origin:center;transition:transform .12s ease}.tree-branch[open]>summary:before{transform:rotate(90deg)}.tree-branch>summary:hover{background:#ffffff09}.tree-children{margin-left:8px;padding-left:20px;border-left:1px solid #314238}.tree-leaf{min-height:28px;display:grid;grid-template-columns:minmax(110px,180px) 1fr;align-items:baseline;gap:12px;padding-left:23px}.tree-key{color:#bdd0c2;font-weight:700}.tree-preview{overflow:hidden;color:#718079;font-size:11px;text-overflow:ellipsis;white-space:nowrap}.tree-value{overflow-wrap:anywhere}.tree-string{color:#dff45c}.tree-number{color:#82b4ff}.tree-boolean{color:#f2a27f}.tree-null{color:#78847c;font-style:italic}.query-card,.sql-card{min-width:0;padding:22px}.query-card-label{color:var(--lime)}.query-card pre{max-height:430px;margin:0;padding:0;overflow:auto;color:#d5e2d8;background:transparent;font:12px/1.72 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;white-space:pre-wrap}.query-params{margin-top:24px;padding-top:18px;border-top:1px solid #2f3d34}.query-params.hidden{display:none}.query-params .query-card-label{margin-bottom:10px;color:#82b4ff}.query-params pre{max-height:220px;color:#b9caee}.query-note{margin:28px 0 0;padding-top:18px;border-top:1px solid #2f3d34;color:#829188;font-size:12px}.sql-card-heading{display:flex;align-items:center;justify-content:space-between;gap:16px}.sql-card-heading .query-card-label{margin-bottom:0}#sql-count{color:#7f9185;font:10px/1.3 ui-monospace,SFMono-Regular,Menlo,monospace}.execution-evidence-wrap{margin-top:18px;overflow-x:auto;border:1px solid #34433a;border-radius:8px}.execution-evidence{min-width:1500px;width:100%;border-collapse:collapse;color:#c7d5cb}.execution-evidence th,.execution-evidence td{padding:10px 12px;border-right:1px solid #34433a;border-bottom:1px solid #34433a;text-align:left;vertical-align:top;white-space:nowrap}.execution-evidence th:last-child,.execution-evidence td:last-child{border-right:0}.execution-evidence tbody tr:last-child td{border-bottom:0}.execution-evidence th{color:#7f9185;background:#131d17;font:700 10px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}.execution-evidence td{color:#cbd8ce;background:#101813;font:10px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace}.execution-evidence tbody tr:hover td{background:#141f18}.execution-evidence .evidence-trace{color:#b9caee}.execution-evidence .evidence-sql{color:#dff45c}.dashboard-result{max-height:none;padding:0;color:var(--ink);background:#f7f8f5;font:14px/1.45 Inter,system-ui,sans-serif}.order-center{min-width:880px;padding:24px}.order-center-toolbar{display:flex;align-items:end;justify-content:space-between;gap:24px;margin-bottom:20px}.order-center-toolbar h3{margin:0;color:#111d16;font:750 22px/1.2 Inter,system-ui,sans-serif;letter-spacing:-.025em}.order-center-toolbar p{margin:5px 0 0;color:#778078;font-size:12px}.order-search{width:min(390px,45%);display:flex;align-items:center;gap:6px}.order-search input{min-width:0;height:32px;flex:1;padding:6px 10px;border:1px solid #cfd5ce;border-radius:7px;outline:0;background:#fff;font-size:12px}.order-search input:focus{border-color:#8e9990}.order-search-submit{width:30px;height:30px;flex:0 0 30px;display:grid;place-items:center;padding:0;border:1px solid #cfd5ce;border-radius:7px;color:#536057;background:#fff;cursor:pointer}.order-search-submit:hover,.order-search-submit:focus-visible{color:var(--green);border-color:#93a097;outline:none}.search-icon{position:relative;width:13px;height:13px;display:block;border:1.5px solid currentColor;border-radius:50%}.search-icon:after{content:"";position:absolute;right:-3px;bottom:-2px;width:5px;height:1.5px;border-radius:1px;background:currentColor;transform:rotate(45deg);transform-origin:left center}.order-metrics{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:10px;margin-bottom:18px}.metric-card{padding:14px;display:grid;gap:8px;text-align:left;border:1px solid #dbe0da;border-radius:9px;color:#58625b;background:#fff;cursor:pointer}.metric-card strong{color:#16231a;font-size:23px;line-height:1}.metric-card small{color:#727b74;font-size:10px;font-variant-numeric:tabular-nums}.metric-card.active{border-color:var(--metric-color, var(--blue));box-shadow:inset 3px 0 0 var(--metric-color, var(--blue))}.order-table{overflow:hidden;border:1px solid #e0e4df;border-radius:10px;background:#fff}.order-row{min-width:720px;display:grid;grid-template-columns:1.05fr .85fr .75fr 2fr;align-items:center;gap:14px;min-height:68px;padding:10px 14px;border-top:1px solid #edf0ec}.order-row:first-child{border-top:0}.order-row-head{min-height:40px;color:#69736b;background:#f2f4f1;font-size:11px;font-weight:750}.order-primary{color:#26322a;font:650 12px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}.status-badge{display:inline-block;padding:4px 8px;border-radius:999px;color:#2b5e39;background:#e3f4e8;font-size:10px;white-space:nowrap}.status-pending_payment{color:#92580a;background:#fff0d8}.status-paid{color:#215b9d;background:#e2efff}.status-shipped{color:#1d6e38;background:#ddf5e4}.status-cancelled{color:#7b4650;background:#f6e6e9}.product-preview{display:flex;align-items:center;gap:5px}.product-thumb{width:32px;height:28px;display:grid;place-items:center;border:1px solid #cad4ca;border-radius:6px;color:#315139;background:linear-gradient(135deg,#e5eddf,#bdceb8);font:800 11px/1 Inter,sans-serif}.product-tone-1{color:#725333;background:linear-gradient(135deg,#f1e5d4,#d3b58d)}.product-tone-2{color:#3d526b;background:linear-gradient(135deg,#e1e9ef,#adbecd)}.product-preview small{color:#68736a;font-size:10px}.order-empty{padding:48px 20px;color:#7a847c;text-align:center}.order-center-footer{display:flex;align-items:center;justify-content:space-between;gap:20px;padding-top:16px}.order-center-footer p{margin:0;color:#7a847c;font-size:11px}.pagination{display:flex;gap:5px}.pagination button{min-width:31px;height:31px;border:1px solid #d8ddd7;border-radius:6px;color:#465149;background:#fff;cursor:pointer}.pagination button.active{color:#fff;border-color:var(--blue);background:var(--blue)}.pagination button:disabled{opacity:.4;cursor:default}footer{min-height:86px;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:12px}@media(max-width:980px){.page-shell{padding:0 24px}.hero{grid-template-columns:1fr;gap:46px;padding-top:58px}.model-map{min-height:260px}.runtime-language-panel{grid-template-columns:1fr}.runtime-language-selector{grid-template-columns:repeat(4,minmax(100px,1fr))}.result-panel{margin:0 -24px;padding-left:24px;padding-right:24px}.result-grid{grid-template-columns:1fr}}@media(max-width:680px){.page-shell{padding:0 16px}.site-header{height:64px}.header-actions{gap:9px}.docs-link{display:none}h1{font-size:43px}.hero{min-height:auto;padding:48px 0}.hero-intro{font-size:16px}.model-map{gap:9px;padding:52px 22px 22px}.model-flow{grid-template-columns:1fr}.model-flow>span:not(.model-arrow),.model-leaves span{width:100%}.model-flow .model-arrow{transform:rotate(90deg)}.model-leaves{grid-template-columns:1fr}.runtime-language-panel{padding:20px 16px;gap:20px}.runtime-language-selector{grid-template-columns:repeat(2,minmax(0,1fr))}.runtime-language:last-child{grid-column:1 / -1}.runtime-bar,.section-heading,.result-heading{align-items:flex-start;flex-direction:column}.runtime-bar{padding:18px}.controls{width:100%;justify-content:space-between}.query-browser{padding:70px 0 64px}.query-group{grid-template-columns:1fr;gap:14px}.query-links{gap:8px 18px}.result-panel{margin:0 -16px;padding:64px 16px}.result-actions{width:100%;align-items:stretch;flex-direction:column}.result-view-switch,.tree-actions{width:100%}.result-view-switch button,.tree-actions button{flex:1}.tree-leaf{grid-template-columns:minmax(90px,120px) 1fr;padding-left:15px}.json-tree{padding-left:12px;padding-right:12px}}
|
dist/assets/style-SCdXWqgK.css
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
:root{font:16px/1.5 Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;color:#17231b;background:#f5f4ed;font-synthesis:none;--ink: #17231b;--muted: #677067;--paper: #fffef8;--line: #d8ddd3;--green: #145b37;--green-deep: #0e4329;--lime: #dff45c;--orange: #ef8354;--blue: #2b66d9}*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;min-width:320px;background:#f5f4ed}button,input{font:inherit}button,a{-webkit-tap-highlight-color:transparent}.page-shell{width:min(1440px,100%);margin:0 auto;padding:0 42px}.site-header{height:76px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line)}.brand,.docs-link{color:var(--ink);text-decoration:none;font-weight:750}.brand{display:inline-flex;align-items:center;gap:11px;letter-spacing:-.02em}.brand-mark{width:30px;height:30px;display:grid;place-items:center;border-radius:50%;color:var(--lime);background:var(--green-deep);font-family:Georgia,serif;font-style:italic}.docs-link{color:var(--green);font-size:14px}.header-actions{display:flex;align-items:center;gap:18px}.language-switch{display:flex;gap:3px;padding:3px;border:1px solid var(--line);border-radius:8px}.language-switch button{padding:3px 7px;border:0;border-radius:5px;color:var(--muted);background:transparent;font-size:11px;cursor:pointer}.language-switch button.active{color:#fff;background:var(--green)}.hero{min-height:460px;display:grid;grid-template-columns:minmax(0,1.1fr) minmax(440px,.9fr);align-items:center;gap:72px;padding:76px 0 66px}.eyebrow,.section-index,.query-card-label{margin:0 0 14px;color:var(--green);font-size:11px;font-weight:850;letter-spacing:.18em}h1{margin:0;max-width:820px;font-family:Georgia,"Noto Serif SC",serif;font-size:clamp(42px,5.6vw,78px);font-weight:500;line-height:1.08;letter-spacing:-.055em}.hero-intro{max-width:680px;margin:26px 0 0;color:var(--muted);font-size:18px}.model-map{position:relative;min-height:310px;padding:38px;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:12px;border:1px solid #bfc8bb;border-radius:28px;background:linear-gradient(145deg,#fdfdf8,#e9eee5);box-shadow:0 18px 48px #213c280f;overflow:hidden}.model-map:before{content:"DOMAIN MODEL";position:absolute;top:18px;left:22px;color:#708073;font-size:10px;font-weight:800;letter-spacing:.16em}.model-flow{width:100%;display:grid;grid-template-columns:1fr auto 1fr auto 1fr;align-items:center;gap:10px}.model-flow>span:not(.model-arrow),.model-leaves span{min-width:0;padding:15px 17px;border:1px solid #b8c2b7;border-radius:12px;background:#fffffadb;font:750 14px/1.2 ui-monospace,SFMono-Regular,Menlo,monospace;box-shadow:0 8px 22px #1e3a260d}.model-map small{display:block;margin-top:7px;color:var(--muted);font:12px/1.2 Inter,sans-serif}.model-flow>span.model-root{color:#fff;border-color:var(--green);background:var(--green)}.model-map .model-root small{color:#cce4d4}.model-arrow{color:#809087;font-size:22px;text-align:center}.model-arrow-split{height:22px;line-height:18px}.model-leaves{width:100%;display:grid;grid-template-columns:repeat(4,1fr);gap:10px}.runtime-bar{min-height:72px;padding:14px 18px 14px 22px;display:flex;align-items:center;justify-content:space-between;gap:24px;border-radius:14px;color:#e7f1e9;background:var(--green-deep)}#status{margin:0;color:#c8d9ce;font:12px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}.controls{display:flex;align-items:center;gap:18px}.toggle{display:inline-flex;align-items:center;gap:9px;font-size:13px;cursor:pointer}.toggle input{position:absolute;opacity:0;pointer-events:none}.toggle span{position:relative;width:38px;height:22px;border-radius:999px;background:#55705f;transition:background .2s ease}.toggle span:after{content:"";position:absolute;top:3px;left:3px;width:16px;height:16px;border-radius:50%;background:#fff;transition:transform .2s ease}.toggle input:checked+span{background:var(--lime)}.toggle input:checked+span:after{transform:translate(16px);background:var(--green-deep)}.secondary-button,.tree-actions button{border:1px solid currentColor;border-radius:8px;background:transparent;cursor:pointer}.secondary-button{padding:8px 12px;color:#fff;font-size:12px}.secondary-button:disabled{opacity:.45;cursor:wait}.query-browser{padding:96px 0 82px}.section-heading,.result-heading{display:flex;align-items:end;justify-content:space-between;gap:36px;margin-bottom:40px}.section-heading h2,.result-heading h2{margin:0;font-family:Georgia,"Noto Serif SC",serif;font-size:clamp(34px,4vw,52px);font-weight:500;letter-spacing:-.045em}.section-heading>p{max-width:420px;margin:0;color:var(--muted)}.query-group{display:grid;grid-template-columns:230px 1fr;gap:36px;padding:24px 0;border-top:1px solid var(--line)}.query-group:last-child{border-bottom:1px solid var(--line)}.query-group-heading h2{margin:0 0 4px;font-size:16px}.query-group-heading p{margin:0;color:var(--muted);font-size:12px}.query-links{display:flex;flex-wrap:wrap;align-items:center;gap:10px 24px}.query-links a{position:relative;padding:5px 0;color:#34443a;text-decoration-color:#a6b1a8;text-underline-offset:5px;font-weight:650;transition:color .16s ease}.query-links a:after{content:" ↗";color:#9aa49b;font-weight:400}.query-links a:hover{color:var(--green)}.query-links a.active{color:var(--green);text-decoration-color:var(--orange);text-decoration-thickness:2px}.result-panel{margin:0 -42px;padding:82px 42px 92px;color:#eef5f0;background:#111a15}.result-heading{align-items:center}.result-heading .section-index{color:var(--lime)}.result-heading h2{color:#fff}#result-description{max-width:620px;margin:10px 0 0;color:#9fb0a4}.result-actions{display:flex;align-items:center;gap:10px}.result-view-switch,.tree-actions{display:flex;gap:6px}.result-view-switch button,.tree-actions button{padding:8px 11px;border:1px solid #536159;border-radius:8px;color:#aebdb3;background:transparent;font-size:12px;cursor:pointer}.result-view-switch button.active{color:#17231b;border-color:var(--lime);background:var(--lime)}.result-view-switch button:disabled{opacity:.35;cursor:default}.tree-actions button:hover{color:var(--lime)}.result-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:18px;align-items:start}.tree-card,.query-card,.sql-card{border:1px solid #2f3d34;border-radius:14px;background:#17231b}.tree-card{min-height:520px;overflow:hidden}.tree-card-bar{min-height:48px;padding:0 18px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid #2f3d34;color:#b8c9bd;font:11px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace;text-transform:uppercase;letter-spacing:.08em}#result-meta{margin:0;color:#829188;text-transform:none;letter-spacing:0}.json-tree{min-height:470px;max-height:680px;padding:18px 20px 28px;overflow:auto;font:13px/1.6 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.json-tree.loading{opacity:.55}.tree-actions.hidden{display:none}.result-table-shell{width:100%;min-height:470px;overflow:auto}.result-table{width:100%;border-collapse:collapse;white-space:nowrap}.result-table th,.result-table td{padding:11px 14px;border-bottom:1px solid #2f3d34;text-align:left;vertical-align:top}.result-table th{position:sticky;top:0;z-index:1;color:#8ea095;background:#131d17;font:700 10px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}.result-table td{color:#d9e5dc;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace}.result-table tbody tr:hover{background:#ffffff06}.result-table-empty{margin:0;padding:48px 20px;color:#7f9185;text-align:center}.tree-branch{margin:2px 0}.tree-branch>summary{min-height:29px;display:flex;align-items:center;gap:9px;list-style:none;cursor:pointer;border-radius:5px}.tree-branch>summary::-webkit-details-marker{display:none}.tree-branch>summary:before{content:"›";width:15px;color:#73887a;font-size:18px;line-height:1;transform-origin:center;transition:transform .12s ease}.tree-branch[open]>summary:before{transform:rotate(90deg)}.tree-branch>summary:hover{background:#ffffff09}.tree-children{margin-left:8px;padding-left:20px;border-left:1px solid #314238}.tree-leaf{min-height:28px;display:grid;grid-template-columns:minmax(110px,180px) 1fr;align-items:baseline;gap:12px;padding-left:23px}.tree-key{color:#bdd0c2;font-weight:700}.tree-preview{overflow:hidden;color:#718079;font-size:11px;text-overflow:ellipsis;white-space:nowrap}.tree-value{overflow-wrap:anywhere}.tree-string{color:#dff45c}.tree-number{color:#82b4ff}.tree-boolean{color:#f2a27f}.tree-null{color:#78847c;font-style:italic}.query-card,.sql-card{min-width:0;padding:22px}.query-card-label{color:var(--lime)}.query-card pre{max-height:430px;margin:0;padding:0;overflow:auto;color:#d5e2d8;background:transparent;font:12px/1.72 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;white-space:pre-wrap}.query-params{margin-top:24px;padding-top:18px;border-top:1px solid #2f3d34}.query-params.hidden{display:none}.query-params .query-card-label{margin-bottom:10px;color:#82b4ff}.query-params pre{max-height:220px;color:#b9caee}.query-note{margin:28px 0 0;padding-top:18px;border-top:1px solid #2f3d34;color:#829188;font-size:12px}.sql-card-heading{display:flex;align-items:center;justify-content:space-between;gap:16px}.sql-card-heading .query-card-label{margin-bottom:0}#sql-count{color:#7f9185;font:10px/1.3 ui-monospace,SFMono-Regular,Menlo,monospace}.execution-evidence-wrap{margin-top:18px;overflow-x:auto;border:1px solid #34433a;border-radius:8px}.execution-evidence{min-width:1500px;width:100%;border-collapse:collapse;color:#c7d5cb}.execution-evidence th,.execution-evidence td{padding:10px 12px;border-right:1px solid #34433a;border-bottom:1px solid #34433a;text-align:left;vertical-align:top;white-space:nowrap}.execution-evidence th:last-child,.execution-evidence td:last-child{border-right:0}.execution-evidence tbody tr:last-child td{border-bottom:0}.execution-evidence th{color:#7f9185;background:#131d17;font:700 10px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}.execution-evidence td{color:#cbd8ce;background:#101813;font:10px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace}.execution-evidence tbody tr:hover td{background:#141f18}.execution-evidence .evidence-trace{color:#b9caee}.execution-evidence .evidence-sql{color:#dff45c}.dashboard-result{max-height:none;padding:0;color:var(--ink);background:#f7f8f5;font:14px/1.45 Inter,system-ui,sans-serif}.order-center{min-width:880px;padding:24px}.order-center-toolbar{display:flex;align-items:end;justify-content:space-between;gap:24px;margin-bottom:20px}.order-center-toolbar h3{margin:0;color:#111d16;font:750 22px/1.2 Inter,system-ui,sans-serif;letter-spacing:-.025em}.order-center-toolbar p{margin:5px 0 0;color:#778078;font-size:12px}.order-search{width:min(390px,45%);display:flex;align-items:center;gap:6px}.order-search input{min-width:0;height:32px;flex:1;padding:6px 10px;border:1px solid #cfd5ce;border-radius:7px;outline:0;background:#fff;font-size:12px}.order-search input:focus{border-color:#8e9990}.order-search-submit{width:30px;height:30px;flex:0 0 30px;display:grid;place-items:center;padding:0;border:1px solid #cfd5ce;border-radius:7px;color:#536057;background:#fff;cursor:pointer}.order-search-submit:hover,.order-search-submit:focus-visible{color:var(--green);border-color:#93a097;outline:none}.search-icon{position:relative;width:13px;height:13px;display:block;border:1.5px solid currentColor;border-radius:50%}.search-icon:after{content:"";position:absolute;right:-3px;bottom:-2px;width:5px;height:1.5px;border-radius:1px;background:currentColor;transform:rotate(45deg);transform-origin:left center}.order-metrics{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:10px;margin-bottom:18px}.metric-card{padding:14px;display:grid;gap:8px;text-align:left;border:1px solid #dbe0da;border-radius:9px;color:#58625b;background:#fff;cursor:pointer}.metric-card strong{color:#16231a;font-size:23px;line-height:1}.metric-card small{color:#727b74;font-size:10px;font-variant-numeric:tabular-nums}.metric-card.active{border-color:var(--metric-color, var(--blue));box-shadow:inset 3px 0 0 var(--metric-color, var(--blue))}.order-table{overflow:hidden;border:1px solid #e0e4df;border-radius:10px;background:#fff}.order-row{min-width:720px;display:grid;grid-template-columns:1.05fr .85fr .75fr 2fr;align-items:center;gap:14px;min-height:68px;padding:10px 14px;border-top:1px solid #edf0ec}.order-row:first-child{border-top:0}.order-row-head{min-height:40px;color:#69736b;background:#f2f4f1;font-size:11px;font-weight:750}.order-primary{color:#26322a;font:650 12px/1.4 ui-monospace,SFMono-Regular,Menlo,monospace}.status-badge{display:inline-block;padding:4px 8px;border-radius:999px;color:#2b5e39;background:#e3f4e8;font-size:10px;white-space:nowrap}.status-pending_payment{color:#92580a;background:#fff0d8}.status-paid{color:#215b9d;background:#e2efff}.status-shipped{color:#1d6e38;background:#ddf5e4}.status-cancelled{color:#7b4650;background:#f6e6e9}.product-preview{display:flex;align-items:center;gap:5px}.product-thumb{width:32px;height:28px;display:grid;place-items:center;border:1px solid #cad4ca;border-radius:6px;color:#315139;background:linear-gradient(135deg,#e5eddf,#bdceb8);font:800 11px/1 Inter,sans-serif}.product-tone-1{color:#725333;background:linear-gradient(135deg,#f1e5d4,#d3b58d)}.product-tone-2{color:#3d526b;background:linear-gradient(135deg,#e1e9ef,#adbecd)}.product-preview small{color:#68736a;font-size:10px}.order-empty{padding:48px 20px;color:#7a847c;text-align:center}.order-center-footer{display:flex;align-items:center;justify-content:space-between;gap:20px;padding-top:16px}.order-center-footer p{margin:0;color:#7a847c;font-size:11px}.pagination{display:flex;gap:5px}.pagination button{min-width:31px;height:31px;border:1px solid #d8ddd7;border-radius:6px;color:#465149;background:#fff;cursor:pointer}.pagination button.active{color:#fff;border-color:var(--blue);background:var(--blue)}.pagination button:disabled{opacity:.4;cursor:default}footer{min-height:86px;display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:12px}@media(max-width:980px){.page-shell{padding:0 24px}.hero{grid-template-columns:1fr;gap:46px;padding-top:58px}.model-map{min-height:260px}.result-panel{margin:0 -24px;padding-left:24px;padding-right:24px}.result-grid{grid-template-columns:1fr}}@media(max-width:680px){.page-shell{padding:0 16px}.site-header{height:64px}.header-actions{gap:9px}.docs-link{display:none}h1{font-size:43px}.hero{min-height:auto;padding:48px 0}.hero-intro{font-size:16px}.model-map{gap:9px;padding:52px 22px 22px}.model-flow{grid-template-columns:1fr}.model-flow>span:not(.model-arrow),.model-leaves span{width:100%}.model-flow .model-arrow{transform:rotate(90deg)}.model-leaves{grid-template-columns:1fr}.runtime-bar,.section-heading,.result-heading{align-items:flex-start;flex-direction:column}.runtime-bar{padding:18px}.controls{width:100%;justify-content:space-between}.query-browser{padding:70px 0 64px}.query-group{grid-template-columns:1fr;gap:14px}.query-links{gap:8px 18px}.result-panel{margin:0 -16px;padding:64px 16px}.result-actions{width:100%;align-items:stretch;flex-direction:column}.result-view-switch,.tree-actions{width:100%}.result-view-switch button,.tree-actions button{flex:1}.tree-leaf{grid-template-columns:minmax(90px,120px) 1fr;padding-left:15px}.json-tree{padding-left:12px;padding-right:12px}}
|
|
|
|
|
|
dist/assets/{workItems-DraVJWt7.js → workItems-B6je_A1X.js}
RENAMED
|
@@ -1 +1 @@
|
|
| 1 |
-
import{S as G,L as c,M as k,C as v,a as I,d as O,e as C,Q as K,R as U,B as z,U as H,D as J,c as Y}from"./dynamic-search-BBmdgl4H.js";import{E as $,O as g}from"./object-location-xgYMemK6.js";class L extends G{orderBy(t,e){return this.order({field:t,expr:null,direction:e==="desc"?"Desc":"Asc"})}relationQuery(t,e,i="id",r="id",s=!0,a){return super.relationQuery(t,e,i,r,s,a)}}class m{static teaqlTemporaryId=0;id;title;description;platform;version;constructor(t){if(Object.defineProperty(this,"_action",{value:t&&t.id?"Update":"Create",writable:!0,enumerable:!1}),Object.defineProperty(this,"_comment",{value:void 0,writable:!0,enumerable:!1}),Object.defineProperty(this,"_fullyLoaded",{value:!t||!t.id,writable:!0,enumerable:!1}),Object.defineProperty(this,"_loadedFields",{value:new Set(Object.keys(t||{})),writable:!0,enumerable:!1}),Object.defineProperty(this,"_root",{value:new $,writable:!0,enumerable:!1}),Object.defineProperty(this,"_ledgerId",{value:t?.id??--m.teaqlTemporaryId,writable:!0,enumerable:!1}),t){const i={...t};Object.assign(this,i),t.platform&&typeof t.platform=="object"&&(this.platform=t.platform instanceof y?t.platform:y.fromRecord(t.platform),this.markLoaded("platform"))}const e=this.teaqlEntityKey();this._action==="Create"?this._root.markAsNew(e):this.version!==void 0&&this._root.setOriginalVersion(e,Number(this.version)),c.captureFor(this,this.teaqlMutationPayload())}teaqlEntityKey(){return{entity:"WorkItem",id:this._ledgerId}}teaqlAttachRoot(t){return this._root!==t&&(t.mergeEntityFrom(this._root,this.teaqlEntityKey()),this._root=t),this}static fromRecord(t,e){const i=new m(t);return e?i.teaqlAttachRoot(e):i}isLoaded(t){return this._fullyLoaded||this._loadedFields.has(t)}markLoaded(...t){for(const e of t)this._loadedFields.add(e);return this}markLoadedOnly(...t){return this._fullyLoaded=!1,this._loadedFields=new Set(t),this}static refer(t){return new m({id:String(t)})}static teaqlBootstrapNew(t){return new m().updateId(String(t))}markForDeletion(){return this._action="Delete",this._root.markAsDeleted(this.teaqlEntityKey()),this}auditAs(t){return new k(t),this._comment=t,this}async save(t){const e=t.requireResource("dataService");return e.executeGraphSave(new k(this._comment),async i=>(this.teaqlPreflightGraph(t,e,i),this.teaqlSaveWithinGraph(t,e,i)))}teaqlPreflightGraph(t,e,i,r){r||new k(this._comment);const s=this._action,a=s!=="Update"||this._root.hasPending(this.teaqlEntityKey());if(s==="Update"&&a){const d=[{member:"id",canonical:"id"},{member:"title",canonical:"title"},{member:"description",canonical:"description"},{member:"platform",canonical:"platform"},{member:"version",canonical:"version"}].find(u=>!this.isLoaded(u.member));if(d)throw new v([{ruleId:"invalid_type",location:g.property(d.canonical),message:"Mutation requires a fully loaded entity"}])}const n=i.request({entity:"WorkItem",action:s,payload:s==="Update"?this._root.change(this.teaqlEntityKey()):this.teaqlMutationPayload(),id:this.id,version:this.version,comment:this._comment,ledgerKey:this.teaqlEntityKey(),ledgerRoot:this._root},r,this._comment).withLoadedSnapshot(c.forEntity(this)??new c);a&&e.preflightMutation(n),n.scopeFor(this.teaqlEntityKey())}async teaqlSaveWithinGraph(t,e,i,r){r||new k(this._comment);const s=this._action,a=this._root.change(this.teaqlEntityKey()),n={entity:"WorkItem",action:this._action,payload:s==="Update"?a:this.teaqlMutationPayload(),id:this.id,version:this.version,comment:this._comment,ledgerKey:this.teaqlEntityKey(),ledgerRoot:this._root},d=i.request(n,r,this._comment).withLoadedSnapshot(c.forEntity(this)??new c);if(s==="Update"&&!this._root.hasPending(this.teaqlEntityKey()))return d.scopeFor(this.teaqlEntityKey()),this;const u=await e.executeMutation(d);for(const[S,f]of Object.entries(n.payload))S!=="id"&&S!=="version"&&this._root.set(this.teaqlEntityKey(),S,f);if(!u.persistedRecord)throw new Error("Mutation did not return the authoritative persisted record");const h={payload:this.teaqlMutationPayload(),ledgerId:this._ledgerId,action:this._action,loadedFields:new Set(this._loadedFields),fullyLoaded:this._fullyLoaded,loadedSnapshot:c.forEntity(this)},l=this.teaqlEntityKey();Object.assign(this,u.persistedRecord),c.captureFor(this,this.teaqlMutationPayload()),this._ledgerId=this.id??this._ledgerId;const p=this.teaqlEntityKey();return this._root.rekey(l,p),e.afterGraphRollback(()=>{Object.assign(this,h.payload),this._ledgerId=h.ledgerId,this._action=h.action,this._loadedFields=h.loadedFields,this._fullyLoaded=h.fullyLoaded,c.restoreFor(this,h.loadedSnapshot),this._root.rekey(p,l)}),this._loadedFields=new Set(Object.keys(u.persistedRecord)),this._fullyLoaded=!1,n.action!=="Delete"&&(this._action="Update"),d.scopeFor(p),e.afterGraphCommit(()=>{this._root.clearEntity(p),this.version!==void 0&&this._root.acceptCommittedVersion(p,Number(this.version))}),this}teaqlMutationPayload(){return{id:this.id,title:this.title,description:this.description,platform:this.platform,version:this.version}}updateId(t){return this.id=t,this.markLoaded("id"),this._root.set(this.teaqlEntityKey(),"id",t),this}updateTitle(t){return this.title=t,this.markLoaded("title"),this._root.set(this.teaqlEntityKey(),"title",t),this}updateDescription(t){return this.description=t,this.markLoaded("description"),this._root.set(this.teaqlEntityKey(),"description",t),this}updateVersion(t){return this.version=t,this.markLoaded("version"),this._root.set(this.teaqlEntityKey(),"version",t),this}updatePlatform(t){return this.platform=t?.id??t,this.markLoaded("platform"),this._root.set(this.teaqlEntityKey(),"platform",this.platform),this}}class y{static teaqlTemporaryId=0;id;name;version;constructor(t){if(Object.defineProperty(this,"_action",{value:t&&t.id?"Update":"Create",writable:!0,enumerable:!1}),Object.defineProperty(this,"_comment",{value:void 0,writable:!0,enumerable:!1}),Object.defineProperty(this,"_fullyLoaded",{value:!t||!t.id,writable:!0,enumerable:!1}),Object.defineProperty(this,"_loadedFields",{value:new Set(Object.keys(t||{})),writable:!0,enumerable:!1}),Object.defineProperty(this,"_root",{value:new $,writable:!0,enumerable:!1}),Object.defineProperty(this,"_ledgerId",{value:t?.id??--y.teaqlTemporaryId,writable:!0,enumerable:!1}),Object.defineProperty(this,"_workItemList",{value:t?.id?I.empty():new I,writable:!0,enumerable:!1}),t){const i={...t};if(delete i.workItemList,Object.assign(this,i),Array.isArray(t.workItemList)){const r=t.workItemList;this._workItemList=new I(r.map(s=>s instanceof m?s:m.fromRecord(s)),{totalCount:r.totalCount,aggregations:r.aggregations,summary:r.summary,facets:r.facets,isLoaded:r.isLoaded??!0}),this.markLoaded("workItemList")}}const e=this.teaqlEntityKey();this._action==="Create"?this._root.markAsNew(e):this.version!==void 0&&this._root.setOriginalVersion(e,Number(this.version)),c.captureFor(this,this.teaqlMutationPayload())}teaqlEntityKey(){return{entity:"Platform",id:this._ledgerId}}teaqlAttachRoot(t){this._root!==t&&(t.mergeEntityFrom(this._root,this.teaqlEntityKey()),this._root=t);for(const e of this._workItemList)e.teaqlAttachRoot(t);return this}static fromRecord(t,e){const i=new y(t);return e?i.teaqlAttachRoot(e):i}isLoaded(t){return this._fullyLoaded||this._loadedFields.has(t)}markLoaded(...t){for(const e of t)this._loadedFields.add(e);return this}markLoadedOnly(...t){return this._fullyLoaded=!1,this._loadedFields=new Set(t),this}static refer(t){return new y({id:String(t)})}static teaqlBootstrapNew(t){return new y().updateId(String(t))}markForDeletion(){return this._action="Delete",this._root.markAsDeleted(this.teaqlEntityKey()),this}auditAs(t){return new k(t),this._comment=t,this}async save(t){const e=t.requireResource("dataService");return e.executeGraphSave(new k(this._comment),async i=>(this.teaqlPreflightGraph(t,e,i),this.teaqlSaveWithinGraph(t,e,i)))}teaqlPreflightGraph(t,e,i,r){r||new k(this._comment);const s=this._action,a=s!=="Update"||this._root.hasPending(this.teaqlEntityKey());if(s==="Update"&&a){const u=[{member:"id",canonical:"id"},{member:"name",canonical:"name"},{member:"version",canonical:"version"}].find(h=>!this.isLoaded(h.member));if(u)throw new v([{ruleId:"invalid_type",location:g.property(u.canonical),message:"Mutation requires a fully loaded entity"}])}const n=i.request({entity:"Platform",action:s,payload:s==="Update"?this._root.change(this.teaqlEntityKey()):this.teaqlMutationPayload(),id:this.id,version:this.version,comment:this._comment,ledgerKey:this.teaqlEntityKey(),ledgerRoot:this._root},r,this._comment).withLoadedSnapshot(c.forEntity(this)??new c);a&&e.preflightMutation(n);const d=n.scopeFor(this.teaqlEntityKey());for(const[u,h]of this._workItemList.entries()){h.teaqlAttachRoot(this._root);const l=h.platform;(this.id===void 0||!h.isLoaded("platform")||(typeof l=="object"&&l!==null?l.id:l)!==this.id)&&h.updatePlatform(this);try{h.teaqlPreflightGraph(t,e,i,d)}catch(p){if(!(p instanceof v))throw p;const S=g.property("work_item_list").index(u);throw new v(p.violations.map(f=>({...f,location:f.location.prefixedBy(S)})))}}}async teaqlSaveWithinGraph(t,e,i,r){r||new k(this._comment);const s=this._action,a=this._root.change(this.teaqlEntityKey()),n={entity:"Platform",action:this._action,payload:s==="Update"?a:this.teaqlMutationPayload(),id:this.id,version:this.version,comment:this._comment,ledgerKey:this.teaqlEntityKey(),ledgerRoot:this._root},d=i.request(n,r,this._comment).withLoadedSnapshot(c.forEntity(this)??new c);if(s==="Update"&&!this._root.hasPending(this.teaqlEntityKey())){const f=d.scopeFor(this.teaqlEntityKey());for(const[q,w]of this._workItemList.entries()){w.teaqlAttachRoot(this._root);const _=w.platform;(this.id===void 0||!w.isLoaded("platform")||(typeof _=="object"&&_!==null?_.id:_)!==this.id)&&w.updatePlatform(this);try{await w.teaqlSaveWithinGraph(t,e,i,f)}catch(N){if(!(N instanceof v))throw N;const P=g.property("work_item_list").index(q);throw new v(N.violations.map(B=>({...B,location:B.location.prefixedBy(P)})))}}return this}const u=await e.executeMutation(d);for(const[f,q]of Object.entries(n.payload))f!=="id"&&f!=="version"&&this._root.set(this.teaqlEntityKey(),f,q);if(!u.persistedRecord)throw new Error("Mutation did not return the authoritative persisted record");const h={payload:this.teaqlMutationPayload(),ledgerId:this._ledgerId,action:this._action,loadedFields:new Set(this._loadedFields),fullyLoaded:this._fullyLoaded,loadedSnapshot:c.forEntity(this)},l=this.teaqlEntityKey();Object.assign(this,u.persistedRecord),c.captureFor(this,this.teaqlMutationPayload()),this._ledgerId=this.id??this._ledgerId;const p=this.teaqlEntityKey();this._root.rekey(l,p),e.afterGraphRollback(()=>{Object.assign(this,h.payload),this._ledgerId=h.ledgerId,this._action=h.action,this._loadedFields=h.loadedFields,this._fullyLoaded=h.fullyLoaded,c.restoreFor(this,h.loadedSnapshot),this._root.rekey(p,l)}),this._loadedFields=new Set(Object.keys(u.persistedRecord)),this._fullyLoaded=!1,n.action!=="Delete"&&(this._action="Update");const S=d.scopeFor(p);for(const[f,q]of this._workItemList.entries()){q.teaqlAttachRoot(this._root);const w=q.platform;(this.id===void 0||!q.isLoaded("platform")||(typeof w=="object"&&w!==null?w.id:w)!==this.id)&&q.updatePlatform(this);try{await q.teaqlSaveWithinGraph(t,e,i,S)}catch(_){if(!(_ instanceof v))throw _;const N=g.property("work_item_list").index(f);throw new v(_.violations.map(P=>({...P,location:P.location.prefixedBy(N)})))}}return e.afterGraphCommit(()=>{this._root.clearEntity(p),this.version!==void 0&&this._root.acceptCommittedVersion(p,Number(this.version))}),this}teaqlMutationPayload(){return{id:this.id,name:this.name,version:this.version}}updateId(t){return this.id=t,this.markLoaded("id"),this._root.set(this.teaqlEntityKey(),"id",t),this}updateName(t){return this.name=t,this.markLoaded("name"),this._root.set(this.teaqlEntityKey(),"name",t),this}updateVersion(t){return this.version=t,this.markLoaded("version"),this._root.set(this.teaqlEntityKey(),"version",t),this}workItemList(){return this._workItemList}}const D=Object.freeze({Platform:Object.freeze({fields:Object.freeze({id:"integer",name:"string",version:"integer"}),queryFields:Object.freeze({id:"id",name:"name",version:"version"}),relations:Object.freeze({workItemList:"WorkItem"})}),WorkItem:Object.freeze({fields:Object.freeze({id:"integer",title:"string",description:"string",platform:"integer",version:"integer"}),queryFields:Object.freeze({id:"id",title:"title",description:"description",platform:"platform",version:"version"}),relations:Object.freeze({platform:"Platform"})})});class A{query;filters=[];_purpose;_comment;_pageCountAlias;_pageCountMethod;_dynamicSearchWarnings=[];constructor(t=!1){this.query=new L("Platform"),this.filters.push({version:{$gte:1}}),t?(this.selectId(),this.selectVersion()):this.selectSelfFields()}comment(t){return this.query.comment(t),this._comment=t,this}filterByJson(t,e){const i=this.query.clone();this.filters.length>0&&i.filter({$and:this.filters});const r=O(i,t,D,e);return this.query=r.query,this.filters=this.query.filterCondition?[this.query.filterCondition]:[],this._dynamicSearchWarnings.push(...r.warnings),this}get dynamicSearchWarnings(){return this._dynamicSearchWarnings.map(t=>({...t}))}purpose(t){return this.query.purpose(t),this._purpose=t,new X(e=>e.withQueryRequest(this.query,()=>this.executeForListInternal(e)),e=>e.withQueryRequest(this.query,()=>this.executeForRowsInternal(e)),(e,i)=>this.executeForStreamInternal(e,i),()=>this.limit(1),e=>this.comment(e),()=>this.ensureIntent())}optimizeForContinuousPageFetch(){return this.query.optimizeForContinuousPageFetch(),this}optimizeForContinuousPageFetchWith(t,e){return this.query.optimizeForContinuousPageFetchWith(t,e),this}optimizePaginationWithIdSet(){return this.query.optimizePaginationWithIdSet(),this}optimizePaginationWithIdSetConfig(t,e,i){return this.query.optimizePaginationWithIdSetConfig(t,e,i),this}topNProbeParentThreshold(t){return this.query.topNProbeParentThreshold(t),this}limit(t){return this.query.limit(t),this}offset(t){return this.query.offset(t),this}toQuery(){return this.filters.length>0&&this.query.filter({$and:this.filters}),this.query}withDeletedRows(){return this.filters=this.filters.filter(t=>!("version"in t)),this}deletedRowsOnly(){return this.withDeletedRows(),this.filters.push({version:{$lte:-1}}),this}selectSelfFields(){return this.query.select(["id","name","version"]),this}selectId(){return this.query.select(["id"]),this}selectName(){return this.query.select(["name"]),this}selectVersion(){return this.query.select(["version"]),this}selectWorkItemListWith(t){return this.query.relationQuery("workItemList",t.toQuery(),"id","platform",!0,{kind:"relation-select",method:"selectWorkItemListWith",relation:"workItemList"}),this}haveWorkItems(){return this.withWorkItemListMatching({toQuery:()=>new L("WorkItem")})}haveNoWorkItems(){return this.withoutWorkItemListMatching({toQuery:()=>new L("WorkItem")})}withWorkItemListMatching(t){return this.filters.push({id:{$inSubquery:{query:t.toQuery(),field:"platform"}}}),this}withoutWorkItemListMatching(t){return this.filters.push({id:{$notInSubquery:{query:t.toQuery(),field:"platform"}}}),this}countWorkItems(){return this.countWorkItemsAs("countWorkItems")}countWorkItemsAs(t){const e=new L("WorkItem").filter({version:{$gte:1}});return this.countWorkItemsWith(t,{toQuery:()=>e}),this.query.relationAggregates[this.query.relationAggregates.length-1].operation={kind:"relation-count",method:"countWorkItemsAs",relation:"workItemList",alias:t},this}countWorkItemsWith(t,e){const i=e.toQuery().clone();return i.aggregateItems=[],i.aggregate("Count","id",t),this.query.relationAggregate("workItemList",t,i,!0,{kind:"relation-count",method:"countWorkItemsWith",relation:"workItemList",alias:t}),this}withIdIs(t){return this.filters.push({id:{$eq:t}}),this}withIdIsNot(t){return this.filters.push({id:{$ne:t}}),this}withIdIn(...t){return this.filters.push({id:{$in:t}}),this}withIdNotIn(...t){return this.filters.push({id:{$notIn:t}}),this}withIdGreaterThan(t){return this.filters.push({id:{$gt:t}}),this}withIdGreaterThanOrEqualTo(t){return this.filters.push({id:{$gte:t}}),this}withIdLessThan(t){return this.filters.push({id:{$lt:t}}),this}withIdLessThanOrEqualTo(t){return this.filters.push({id:{$lte:t}}),this}withIdBetween(t,e){return this.filters.push({id:{$between:[t,e]}}),this}withIdIsKnown(){return this.filters.push({id:{$isNull:!1}}),this}withIdIsUnknown(){return this.filters.push({id:{$isNull:!0}}),this}withNameContaining(t){return this.filters.push({name:{$contains:t}}),this}withNameIs(t){return this.filters.push({name:{$eq:t}}),this}withNameIsNot(t){return this.filters.push({name:{$ne:t}}),this}withNameIn(...t){return this.filters.push({name:{$in:t}}),this}withNameNotIn(...t){return this.filters.push({name:{$notIn:t}}),this}withNameGreaterThan(t){return this.filters.push({name:{$gt:t}}),this}withNameGreaterThanOrEqualTo(t){return this.filters.push({name:{$gte:t}}),this}withNameLessThan(t){return this.filters.push({name:{$lt:t}}),this}withNameLessThanOrEqualTo(t){return this.filters.push({name:{$lte:t}}),this}withNameBetween(t,e){return this.filters.push({name:{$between:[t,e]}}),this}withNameIsKnown(){return this.filters.push({name:{$isNull:!1}}),this}withNameIsUnknown(){return this.filters.push({name:{$isNull:!0}}),this}withNameNotContaining(t){return this.filters.push({name:{$notContains:t}}),this}withNameStartingWith(t){return this.filters.push({name:{$startsWith:t}}),this}withNameNotStartingWith(t){return this.filters.push({name:{$notStartsWith:t}}),this}withNameEndingWith(t){return this.filters.push({name:{$endsWith:t}}),this}withNameNotEndingWith(t){return this.filters.push({name:{$notEndsWith:t}}),this}withNameSoundingLike(t){return this.filters.push({name:{$soundLike:t}}),this}withVersionIs(t){return this.filters.push({version:{$eq:t}}),this}withVersionIsNot(t){return this.filters.push({version:{$ne:t}}),this}withVersionIn(...t){return this.filters.push({version:{$in:t}}),this}withVersionNotIn(...t){return this.filters.push({version:{$notIn:t}}),this}withVersionGreaterThan(t){return this.filters.push({version:{$gt:t}}),this}withVersionGreaterThanOrEqualTo(t){return this.filters.push({version:{$gte:t}}),this}withVersionLessThan(t){return this.filters.push({version:{$lt:t}}),this}withVersionLessThanOrEqualTo(t){return this.filters.push({version:{$lte:t}}),this}withVersionBetween(t,e){return this.filters.push({version:{$between:[t,e]}}),this}withVersionIsKnown(){return this.filters.push({version:{$isNull:!1}}),this}withVersionIsUnknown(){return this.filters.push({version:{$isNull:!0}}),this}orderByIdAscending(){return this.query.orderBy("id","asc"),this}orderByIdDescending(){return this.query.orderBy("id","desc"),this}orderByNameAscending(){return this.query.orderBy("name","asc"),this}orderByNameDescending(){return this.query.orderBy("name","desc"),this}orderByVersionAscending(){return this.query.orderBy("version","asc"),this}orderByVersionDescending(){return this.query.orderBy("version","desc"),this}count(){return this.query.aggregate("Count","id","count"),this._pageCountAlias="count",this._pageCountMethod="count",this}countAs(t){return this.query.aggregate("Count","id",t),this._pageCountAlias=t,this._pageCountMethod="countAs",this}groupById(){return this.query.groupBy("id"),this}groupByIdAs(t){return this.query.groupBy("id"),this}groupByName(){return this.query.groupBy("name"),this}groupByNameAs(t){return this.query.groupBy("name"),this}groupByVersion(){return this.query.groupBy("version"),this}groupByVersionAs(t){return this.query.groupBy("version"),this}async executeForListInternal(t){if(this.ensureIntent(),this._pageCountAlias!==void 0)return this.executeCountedListInternal(t);this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService"),i=await e.executeQuery(t.prepareQuery(this.query)),r=this.query.aggregateItems.length>0&&this.query.groupByItems.length===0,s=r?[]:i.map(n=>n instanceof y?n:y.fromRecord(n,new $)),a=new I(s);return r&&i[0]&&Object.assign(a.aggregations,i[0]),this.query.facets.length>0&&(a.facets=await C(e,n=>t.prepareQuery(n),this.query,this.query.facets)),a}async executeForRowsInternal(t){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService");return new I(await e.executeQuery(t.prepareQuery(this.query)))}async executeCountedListInternal(t){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService"),i=t.prepareQuery(this.query),r=i.localIdSetPaginationOptions()!==void 0,s={kind:"named-count",method:this._pageCountMethod??"count",...this._pageCountMethod==="countAs"?{alias:this._pageCountAlias}:{}},a=r?void 0:await e.executeCount(i,this._pageCountAlias,s),n=i.clone();n.aggregateItems=n.aggregateItems.filter(l=>!(String(l.function).toLowerCase()==="count"&&l.alias===this._pageCountAlias));const d=await e.executeQuery(n),u=r&&t.idSetPaginationCountAccuracy==="EXACT"?t.idSetPaginationCount:a??await e.executeCount(i,this._pageCountAlias,s),h=new I(d.map(l=>l instanceof y?l:y.fromRecord(l,new $)));return h.totalCount=u,this._pageCountAlias!==void 0&&(h.aggregations[this._pageCountAlias]=u),this.query.facets.length>0&&(h.facets=await C(e,l=>t.prepareQuery(l),i,i.facets)),h}executeForStreamInternal(t,e){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const i=t.requireResource("dataService"),r=t.prepareQuery(this.query),s=i.executeForStream(r,e);return(async function*(){for await(const a of s)for(const n of a)yield n instanceof y?n:y.fromRecord(n,new $)})()}ensureIntent(){new K(this._comment,this._purpose)}}class X{constructor(t,e,i,r,s,a){this.execute=t,this.executeRows=e,this.stream=i,this.limitOne=r,this.addComment=s,this.ensureIntent=a}execute;executeRows;stream;limitOne;addComment;ensureIntent;comment(t){return this.addComment(t),this}newEntity(t){return this.ensureIntent(),new y}executeForList(t){return this.ensureIntent(),this.execute(t)}executeForRows(t){return this.ensureIntent(),this.executeRows(t)}executeForStream(t,e=1e3){return this.ensureIntent(),this.stream(t,e)}async executeForOne(t){return this.limitOne(),(await this.executeForList(t))[0]}}class x{query;filters=[];_purpose;_comment;_pageCountAlias;_pageCountMethod;_dynamicSearchWarnings=[];constructor(t=!1){this.query=new L("WorkItem"),this.filters.push({version:{$gte:1}}),t?(this.selectId(),this.selectVersion()):this.selectSelfFields()}comment(t){return this.query.comment(t),this._comment=t,this}filterByJson(t,e){const i=this.query.clone();this.filters.length>0&&i.filter({$and:this.filters});const r=O(i,t,D,e);return this.query=r.query,this.filters=this.query.filterCondition?[this.query.filterCondition]:[],this._dynamicSearchWarnings.push(...r.warnings),this}get dynamicSearchWarnings(){return this._dynamicSearchWarnings.map(t=>({...t}))}purpose(t){return this.query.purpose(t),this._purpose=t,new Z(e=>e.withQueryRequest(this.query,()=>this.executeForListInternal(e)),e=>e.withQueryRequest(this.query,()=>this.executeForRowsInternal(e)),(e,i)=>this.executeForStreamInternal(e,i),()=>this.limit(1),e=>this.comment(e),()=>this.ensureIntent())}optimizeForContinuousPageFetch(){return this.query.optimizeForContinuousPageFetch(),this}optimizeForContinuousPageFetchWith(t,e){return this.query.optimizeForContinuousPageFetchWith(t,e),this}optimizePaginationWithIdSet(){return this.query.optimizePaginationWithIdSet(),this}optimizePaginationWithIdSetConfig(t,e,i){return this.query.optimizePaginationWithIdSetConfig(t,e,i),this}topNProbeParentThreshold(t){return this.query.topNProbeParentThreshold(t),this}limit(t){return this.query.limit(t),this}offset(t){return this.query.offset(t),this}toQuery(){return this.filters.length>0&&this.query.filter({$and:this.filters}),this.query}withDeletedRows(){return this.filters=this.filters.filter(t=>!("version"in t)),this}deletedRowsOnly(){return this.withDeletedRows(),this.filters.push({version:{$lte:-1}}),this}selectSelfFields(){return this.query.select(["id","title","description","platform","version"]),this}selectId(){return this.query.select(["id"]),this}selectTitle(){return this.query.select(["title"]),this}selectDescription(){return this.query.select(["description"]),this}selectVersion(){return this.query.select(["version"]),this}selectPlatformWith(t){return this.query.select(["platform"]),this.query.relationQuery("platform",t.toQuery(),"platform","id",!1,{kind:"relation-select",method:"selectPlatformWith",relation:"platform"}),this}withPlatformMatching(t){return this.filters.push({platform:{$inSubquery:{query:t.toQuery(),field:"id"}}}),this}withoutPlatformMatching(t){return this.filters.push({platform:{$notInSubquery:{query:t.toQuery(),field:"id"}}}),this}withIdIs(t){return this.filters.push({id:{$eq:t}}),this}withIdIsNot(t){return this.filters.push({id:{$ne:t}}),this}withIdIn(...t){return this.filters.push({id:{$in:t}}),this}withIdNotIn(...t){return this.filters.push({id:{$notIn:t}}),this}withIdGreaterThan(t){return this.filters.push({id:{$gt:t}}),this}withIdGreaterThanOrEqualTo(t){return this.filters.push({id:{$gte:t}}),this}withIdLessThan(t){return this.filters.push({id:{$lt:t}}),this}withIdLessThanOrEqualTo(t){return this.filters.push({id:{$lte:t}}),this}withIdBetween(t,e){return this.filters.push({id:{$between:[t,e]}}),this}withIdIsKnown(){return this.filters.push({id:{$isNull:!1}}),this}withIdIsUnknown(){return this.filters.push({id:{$isNull:!0}}),this}withTitleContaining(t){return this.filters.push({title:{$contains:t}}),this}withTitleIs(t){return this.filters.push({title:{$eq:t}}),this}withTitleIsNot(t){return this.filters.push({title:{$ne:t}}),this}withTitleIn(...t){return this.filters.push({title:{$in:t}}),this}withTitleNotIn(...t){return this.filters.push({title:{$notIn:t}}),this}withTitleGreaterThan(t){return this.filters.push({title:{$gt:t}}),this}withTitleGreaterThanOrEqualTo(t){return this.filters.push({title:{$gte:t}}),this}withTitleLessThan(t){return this.filters.push({title:{$lt:t}}),this}withTitleLessThanOrEqualTo(t){return this.filters.push({title:{$lte:t}}),this}withTitleBetween(t,e){return this.filters.push({title:{$between:[t,e]}}),this}withTitleIsKnown(){return this.filters.push({title:{$isNull:!1}}),this}withTitleIsUnknown(){return this.filters.push({title:{$isNull:!0}}),this}withTitleNotContaining(t){return this.filters.push({title:{$notContains:t}}),this}withTitleStartingWith(t){return this.filters.push({title:{$startsWith:t}}),this}withTitleNotStartingWith(t){return this.filters.push({title:{$notStartsWith:t}}),this}withTitleEndingWith(t){return this.filters.push({title:{$endsWith:t}}),this}withTitleNotEndingWith(t){return this.filters.push({title:{$notEndsWith:t}}),this}withTitleSoundingLike(t){return this.filters.push({title:{$soundLike:t}}),this}withDescriptionContaining(t){return this.filters.push({description:{$contains:t}}),this}withDescriptionIs(t){return this.filters.push({description:{$eq:t}}),this}withDescriptionIsNot(t){return this.filters.push({description:{$ne:t}}),this}withDescriptionIn(...t){return this.filters.push({description:{$in:t}}),this}withDescriptionNotIn(...t){return this.filters.push({description:{$notIn:t}}),this}withDescriptionGreaterThan(t){return this.filters.push({description:{$gt:t}}),this}withDescriptionGreaterThanOrEqualTo(t){return this.filters.push({description:{$gte:t}}),this}withDescriptionLessThan(t){return this.filters.push({description:{$lt:t}}),this}withDescriptionLessThanOrEqualTo(t){return this.filters.push({description:{$lte:t}}),this}withDescriptionBetween(t,e){return this.filters.push({description:{$between:[t,e]}}),this}withDescriptionIsKnown(){return this.filters.push({description:{$isNull:!1}}),this}withDescriptionIsUnknown(){return this.filters.push({description:{$isNull:!0}}),this}withDescriptionNotContaining(t){return this.filters.push({description:{$notContains:t}}),this}withDescriptionStartingWith(t){return this.filters.push({description:{$startsWith:t}}),this}withDescriptionNotStartingWith(t){return this.filters.push({description:{$notStartsWith:t}}),this}withDescriptionEndingWith(t){return this.filters.push({description:{$endsWith:t}}),this}withDescriptionNotEndingWith(t){return this.filters.push({description:{$notEndsWith:t}}),this}withDescriptionSoundingLike(t){return this.filters.push({description:{$soundLike:t}}),this}filterByPlatform(t){return this.filters.push({platform:{$eq:t}}),this}filterByPlatformIn(...t){return this.filters.push({platform:{$in:t}}),this}withPlatformIsKnown(){return this.filters.push({platform:{$isNull:!1}}),this}withPlatformIsUnknown(){return this.filters.push({platform:{$isNull:!0}}),this}withVersionIs(t){return this.filters.push({version:{$eq:t}}),this}withVersionIsNot(t){return this.filters.push({version:{$ne:t}}),this}withVersionIn(...t){return this.filters.push({version:{$in:t}}),this}withVersionNotIn(...t){return this.filters.push({version:{$notIn:t}}),this}withVersionGreaterThan(t){return this.filters.push({version:{$gt:t}}),this}withVersionGreaterThanOrEqualTo(t){return this.filters.push({version:{$gte:t}}),this}withVersionLessThan(t){return this.filters.push({version:{$lt:t}}),this}withVersionLessThanOrEqualTo(t){return this.filters.push({version:{$lte:t}}),this}withVersionBetween(t,e){return this.filters.push({version:{$between:[t,e]}}),this}withVersionIsKnown(){return this.filters.push({version:{$isNull:!1}}),this}withVersionIsUnknown(){return this.filters.push({version:{$isNull:!0}}),this}orderByIdAscending(){return this.query.orderBy("id","asc"),this}orderByIdDescending(){return this.query.orderBy("id","desc"),this}orderByTitleAscending(){return this.query.orderBy("title","asc"),this}orderByTitleDescending(){return this.query.orderBy("title","desc"),this}orderByDescriptionAscending(){return this.query.orderBy("description","asc"),this}orderByDescriptionDescending(){return this.query.orderBy("description","desc"),this}orderByVersionAscending(){return this.query.orderBy("version","asc"),this}orderByVersionDescending(){return this.query.orderBy("version","desc"),this}count(){return this.query.aggregate("Count","id","count"),this._pageCountAlias="count",this._pageCountMethod="count",this}countAs(t){return this.query.aggregate("Count","id",t),this._pageCountAlias=t,this._pageCountMethod="countAs",this}groupById(){return this.query.groupBy("id"),this}groupByIdAs(t){return this.query.groupBy("id"),this}groupByTitle(){return this.query.groupBy("title"),this}groupByTitleAs(t){return this.query.groupBy("title"),this}groupByDescription(){return this.query.groupBy("description"),this}groupByDescriptionAs(t){return this.query.groupBy("description"),this}groupByPlatform(){return this.query.groupBy("platform"),this}groupByPlatformAs(t){return this.query.groupBy("platform"),this}groupByVersion(){return this.query.groupBy("version"),this}groupByVersionAs(t){return this.query.groupBy("version"),this}facetByPlatformAs(t,e,i=!0){return this.query.facetBy(t,"platform",e,i,{kind:"facet",method:"facetByPlatformAs",relation:"platform",alias:t}),this}async executeForListInternal(t){if(this.ensureIntent(),this._pageCountAlias!==void 0)return this.executeCountedListInternal(t);this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService"),i=await e.executeQuery(t.prepareQuery(this.query)),r=this.query.aggregateItems.length>0&&this.query.groupByItems.length===0,s=r?[]:i.map(n=>n instanceof m?n:m.fromRecord(n,new $)),a=new I(s);return r&&i[0]&&Object.assign(a.aggregations,i[0]),this.query.facets.length>0&&(a.facets=await C(e,n=>t.prepareQuery(n),this.query,this.query.facets)),a}async executeForRowsInternal(t){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService");return new I(await e.executeQuery(t.prepareQuery(this.query)))}async executeCountedListInternal(t){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService"),i=t.prepareQuery(this.query),r=i.localIdSetPaginationOptions()!==void 0,s={kind:"named-count",method:this._pageCountMethod??"count",...this._pageCountMethod==="countAs"?{alias:this._pageCountAlias}:{}},a=r?void 0:await e.executeCount(i,this._pageCountAlias,s),n=i.clone();n.aggregateItems=n.aggregateItems.filter(l=>!(String(l.function).toLowerCase()==="count"&&l.alias===this._pageCountAlias));const d=await e.executeQuery(n),u=r&&t.idSetPaginationCountAccuracy==="EXACT"?t.idSetPaginationCount:a??await e.executeCount(i,this._pageCountAlias,s),h=new I(d.map(l=>l instanceof m?l:m.fromRecord(l,new $)));return h.totalCount=u,this._pageCountAlias!==void 0&&(h.aggregations[this._pageCountAlias]=u),this.query.facets.length>0&&(h.facets=await C(e,l=>t.prepareQuery(l),i,i.facets)),h}executeForStreamInternal(t,e){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const i=t.requireResource("dataService"),r=t.prepareQuery(this.query),s=i.executeForStream(r,e);return(async function*(){for await(const a of s)for(const n of a)yield n instanceof m?n:m.fromRecord(n,new $)})()}ensureIntent(){new K(this._comment,this._purpose)}}class Z{constructor(t,e,i,r,s,a){this.execute=t,this.executeRows=e,this.stream=i,this.limitOne=r,this.addComment=s,this.ensureIntent=a}execute;executeRows;stream;limitOne;addComment;ensureIntent;comment(t){return this.addComment(t),this}newEntity(t){return this.ensureIntent(),new m}executeForList(t){return this.ensureIntent(),this.execute(t)}executeForRows(t){return this.ensureIntent(),this.executeRows(t)}executeForStream(t,e=1e3){return this.ensureIntent(),this.stream(t,e)}async executeForOne(t){return this.limitOne(),(await this.executeForList(t))[0]}}class R{static platforms(){return new A(!1)}static platformsWithMinimalFields(){return new A(!0)}static workItems(){return new x(!1)}static workItemsWithMinimalFields(){return new x(!0)}}const tt={Platform:{table:"platform_data",auditMaskFields:[],columns:{id:{columnName:"id",modelName:"id",logPolicy:"plain",logicalType:"integer",decode:"string",nullable:!1},name:{columnName:"name",modelName:"name",logPolicy:"plain",logicalType:"text",decode:"native",nullable:!1},version:{columnName:"version",modelName:"version",logPolicy:"plain",logicalType:"integer",decode:"number",nullable:!1}},relations:{workItemList:{targetEntity:"WorkItem",localKey:"id",foreignKey:"platform",many:!0}}},WorkItem:{table:"work_item_data",auditMaskFields:[],columns:{id:{columnName:"id",modelName:"id",logPolicy:"plain",logicalType:"integer",decode:"string",nullable:!1},title:{columnName:"title",modelName:"title",logPolicy:"plain",logicalType:"text",decode:"native",nullable:!1},description:{columnName:"description",modelName:"description",logPolicy:"plain",logicalType:"text",decode:"native",nullable:!0},platform:{columnName:"platform",modelName:"platform",logPolicy:"plain",logicalType:"integer",decode:"string",nullable:!1},version:{columnName:"version",modelName:"version",logPolicy:"plain",logicalType:"integer",decode:"number",nullable:!1}},relations:{platform:{targetEntity:"Platform",localKey:"platform",foreignKey:"id",many:!1}}}};async function et(o){let t=(await R.platforms().withIdIs("1").comment("what: locate generated Domain Root").purpose("why: idempotent runtime bootstrap").executeForList(o))[0];t||(t=y.teaqlBootstrapNew("1"),t.updateName("Runtime Example"),await t.auditAs("create generated Domain Root Platform").save(o)),o.withActiveRoot({entity:"Platform",id:t.id})}const it=new U(tt,{Platform:{checkAndFix(o,t,e){o.getResource("fixTime"),(t.action==="Create"&&t.payload.name===void 0||t.payload.name===null)&&e.push({ruleId:"required",location:g.property("name")}),t.payload.name!=null&&[...String(t.payload.name)].length>100&&e.push({ruleId:"max_length",location:g.property("name"),inputValue:t.payload.name,systemValue:100})}},WorkItem:{checkAndFix(o,t,e){o.getResource("fixTime"),(t.action==="Create"&&t.payload.title===void 0||t.payload.title===null)&&e.push({ruleId:"required",location:g.property("title")}),t.payload.title!=null&&!([...String(t.payload.title)].length>=1)&&e.push({ruleId:"min_length",location:g.property("title"),inputValue:t.payload.title,systemValue:1}),t.payload.title!=null&&[...String(t.payload.title)].length>80&&e.push({ruleId:"max_length",location:g.property("title"),inputValue:t.payload.title,systemValue:80}),t.payload.description!=null&&[...String(t.payload.description)].length>100&&e.push({ruleId:"max_length",location:g.property("description"),inputValue:t.payload.description,systemValue:100}),(t.action==="Create"&&t.payload.platform===void 0||t.payload.platform===null)&&e.push({ruleId:"required",location:g.property("platform")})}}},{defaultDomainRoot:{entity:"Platform",id:"1",values:{name:"Runtime Example"}},constants:[],ensure:et}),rt={Platform:{table:"platform_data",columns:{id:{columnName:"id",modelName:"id",logicalType:"integer",decode:"string",nullable:!1},name:{columnName:"name",modelName:"name",logicalType:"text",decode:"native",nullable:!1},version:{columnName:"version",modelName:"version",logicalType:"integer",decode:"number",nullable:!1}},relations:{workItemList:{targetEntity:"WorkItem",localKey:"id",foreignKey:"platform",many:!0}}},WorkItem:{table:"work_item_data",columns:{id:{columnName:"id",modelName:"id",logicalType:"integer",decode:"string",nullable:!1},title:{columnName:"title",modelName:"title",logicalType:"text",decode:"native",nullable:!1},description:{columnName:"description",modelName:"description",logicalType:"text",decode:"native",nullable:!0},platform:{columnName:"platform",modelName:"platform",logicalType:"integer",decode:"string",nullable:!1},version:{columnName:"version",modelName:"version",logicalType:"integer",decode:"number",nullable:!1}},relations:{platform:{targetEntity:"Platform",localKey:"platform",foreignKey:"id",many:!1}}}},F=document.querySelector("#status"),st=document.querySelector("#result"),T=document.querySelector("#persist"),E=document.querySelector("#reset");let b;const M=localStorage.getItem("teaql-browser-storage")==="opfs"?"opfs":"memory";T.checked=M==="opfs";async function nt(o){const t=new Worker(new URL("/assets/sqlite.worker-DS5P4U1E.js",import.meta.url),{type:"module"}),e=await z.open(t,{...rt},{storage:o,databaseName:"teaql-browser-example.sqlite3"});e.install(it);const i=Object.freeze({policyId:"browser-demo-seed",version:"1",fingerprint:"sha256:browser-demo-seed-v1"}),r=new H().insertResource("dataService",e).withMutationPolicyRegistry(new J(()=>({identity:i,review:(s,a)=>a.operations.length>0?{verdict:"allow"}:{verdict:"deny",code:"EMPTY_GRAPH",message:"empty mutation graph"}}))).withMutationPolicyApprovalProvider(new Y(s=>({policy:s,approvedBy:"browser-demo-owner",approvedAt:new Date})));return e.setUserContext(r),await r.ensureSchema(),{client:e,context:r}}async function Q({context:o}){if(!(await R.workItemsWithMinimalFields().comment("what: detect existing browser demo records").purpose("why: keep generated mutation bootstrap idempotent").executeForList(o)).length)for(const e of["Evaluate semantic model","Generate typed library","Verify browser runtime"])await new m().updateTitle(e).updatePlatform("1").auditAs("seed deterministic browser demo data").save(o)}async function V(o){const t=await R.workItems().selectTitle().orderByIdAscending().limit(20).comment("what: load browser-local work items").purpose("why: prove the generated Q API runs without a backend").executeForList(o.context);st.textContent=JSON.stringify(t,null,2),F.textContent=`${o.client.storage.toUpperCase()} · ${t.length} rows · policy installed · ready`}async function j(o){F.textContent=`Opening ${o.toUpperCase()} SQLite/WASM…`;const t=b;b=void 0,await t?.client.close();const e=await nt(o);b=e,await Q(e),await V(e)}T.addEventListener("change",()=>{const o=T.checked?"opfs":"memory";localStorage.setItem("teaql-browser-storage",o),j(o).catch(W)});E.addEventListener("click",async()=>{if(b){E.disabled=!0;try{await b.client.reset(b.context),await Q(b),await V(b)}catch(o){W(o)}finally{E.disabled=!1}}});function W(o){const t=o instanceof Error?o:new Error(String(o));F.textContent=`${t.name}: ${t.message}`}j(M).catch(W);
|
|
|
|
| 1 |
+
import{S as G,L as c,M as k,C as v,a as I,d as O,e as C,Q as K,R as U,B as z,U as H,D as J,c as Y}from"./dynamic-search-Ch_QcWVU.js";import{E as $,O as g}from"./object-location-CJfVWqJC.js";class L extends G{orderBy(t,e){return this.order({field:t,expr:null,direction:e==="desc"?"Desc":"Asc"})}relationQuery(t,e,i="id",r="id",s=!0,a){return super.relationQuery(t,e,i,r,s,a)}}class m{static teaqlTemporaryId=0;id;title;description;platform;version;constructor(t){if(Object.defineProperty(this,"_action",{value:t&&t.id?"Update":"Create",writable:!0,enumerable:!1}),Object.defineProperty(this,"_comment",{value:void 0,writable:!0,enumerable:!1}),Object.defineProperty(this,"_fullyLoaded",{value:!t||!t.id,writable:!0,enumerable:!1}),Object.defineProperty(this,"_loadedFields",{value:new Set(Object.keys(t||{})),writable:!0,enumerable:!1}),Object.defineProperty(this,"_root",{value:new $,writable:!0,enumerable:!1}),Object.defineProperty(this,"_ledgerId",{value:t?.id??--m.teaqlTemporaryId,writable:!0,enumerable:!1}),t){const i={...t};Object.assign(this,i),t.platform&&typeof t.platform=="object"&&(this.platform=t.platform instanceof y?t.platform:y.fromRecord(t.platform),this.markLoaded("platform"))}const e=this.teaqlEntityKey();this._action==="Create"?this._root.markAsNew(e):this.version!==void 0&&this._root.setOriginalVersion(e,Number(this.version)),c.captureFor(this,this.teaqlMutationPayload())}teaqlEntityKey(){return{entity:"WorkItem",id:this._ledgerId}}teaqlAttachRoot(t){return this._root!==t&&(t.mergeEntityFrom(this._root,this.teaqlEntityKey()),this._root=t),this}static fromRecord(t,e){const i=new m(t);return e?i.teaqlAttachRoot(e):i}isLoaded(t){return this._fullyLoaded||this._loadedFields.has(t)}markLoaded(...t){for(const e of t)this._loadedFields.add(e);return this}markLoadedOnly(...t){return this._fullyLoaded=!1,this._loadedFields=new Set(t),this}static refer(t){return new m({id:String(t)})}static teaqlBootstrapNew(t){return new m().updateId(String(t))}markForDeletion(){return this._action="Delete",this._root.markAsDeleted(this.teaqlEntityKey()),this}auditAs(t){return new k(t),this._comment=t,this}async save(t){const e=t.requireResource("dataService");return e.executeGraphSave(new k(this._comment),async i=>(this.teaqlPreflightGraph(t,e,i),this.teaqlSaveWithinGraph(t,e,i)))}teaqlPreflightGraph(t,e,i,r){r||new k(this._comment);const s=this._action,a=s!=="Update"||this._root.hasPending(this.teaqlEntityKey());if(s==="Update"&&a){const d=[{member:"id",canonical:"id"},{member:"title",canonical:"title"},{member:"description",canonical:"description"},{member:"platform",canonical:"platform"},{member:"version",canonical:"version"}].find(u=>!this.isLoaded(u.member));if(d)throw new v([{ruleId:"invalid_type",location:g.property(d.canonical),message:"Mutation requires a fully loaded entity"}])}const n=i.request({entity:"WorkItem",action:s,payload:s==="Update"?this._root.change(this.teaqlEntityKey()):this.teaqlMutationPayload(),id:this.id,version:this.version,comment:this._comment,ledgerKey:this.teaqlEntityKey(),ledgerRoot:this._root},r,this._comment).withLoadedSnapshot(c.forEntity(this)??new c);a&&e.preflightMutation(n),n.scopeFor(this.teaqlEntityKey())}async teaqlSaveWithinGraph(t,e,i,r){r||new k(this._comment);const s=this._action,a=this._root.change(this.teaqlEntityKey()),n={entity:"WorkItem",action:this._action,payload:s==="Update"?a:this.teaqlMutationPayload(),id:this.id,version:this.version,comment:this._comment,ledgerKey:this.teaqlEntityKey(),ledgerRoot:this._root},d=i.request(n,r,this._comment).withLoadedSnapshot(c.forEntity(this)??new c);if(s==="Update"&&!this._root.hasPending(this.teaqlEntityKey()))return d.scopeFor(this.teaqlEntityKey()),this;const u=await e.executeMutation(d);for(const[S,f]of Object.entries(n.payload))S!=="id"&&S!=="version"&&this._root.set(this.teaqlEntityKey(),S,f);if(!u.persistedRecord)throw new Error("Mutation did not return the authoritative persisted record");const h={payload:this.teaqlMutationPayload(),ledgerId:this._ledgerId,action:this._action,loadedFields:new Set(this._loadedFields),fullyLoaded:this._fullyLoaded,loadedSnapshot:c.forEntity(this)},l=this.teaqlEntityKey();Object.assign(this,u.persistedRecord),c.captureFor(this,this.teaqlMutationPayload()),this._ledgerId=this.id??this._ledgerId;const p=this.teaqlEntityKey();return this._root.rekey(l,p),e.afterGraphRollback(()=>{Object.assign(this,h.payload),this._ledgerId=h.ledgerId,this._action=h.action,this._loadedFields=h.loadedFields,this._fullyLoaded=h.fullyLoaded,c.restoreFor(this,h.loadedSnapshot),this._root.rekey(p,l)}),this._loadedFields=new Set(Object.keys(u.persistedRecord)),this._fullyLoaded=!1,n.action!=="Delete"&&(this._action="Update"),d.scopeFor(p),e.afterGraphCommit(()=>{this._root.clearEntity(p),this.version!==void 0&&this._root.acceptCommittedVersion(p,Number(this.version))}),this}teaqlMutationPayload(){return{id:this.id,title:this.title,description:this.description,platform:this.platform,version:this.version}}updateId(t){return this.id=t,this.markLoaded("id"),this._root.set(this.teaqlEntityKey(),"id",t),this}updateTitle(t){return this.title=t,this.markLoaded("title"),this._root.set(this.teaqlEntityKey(),"title",t),this}updateDescription(t){return this.description=t,this.markLoaded("description"),this._root.set(this.teaqlEntityKey(),"description",t),this}updateVersion(t){return this.version=t,this.markLoaded("version"),this._root.set(this.teaqlEntityKey(),"version",t),this}updatePlatform(t){return this.platform=t?.id??t,this.markLoaded("platform"),this._root.set(this.teaqlEntityKey(),"platform",this.platform),this}}class y{static teaqlTemporaryId=0;id;name;version;constructor(t){if(Object.defineProperty(this,"_action",{value:t&&t.id?"Update":"Create",writable:!0,enumerable:!1}),Object.defineProperty(this,"_comment",{value:void 0,writable:!0,enumerable:!1}),Object.defineProperty(this,"_fullyLoaded",{value:!t||!t.id,writable:!0,enumerable:!1}),Object.defineProperty(this,"_loadedFields",{value:new Set(Object.keys(t||{})),writable:!0,enumerable:!1}),Object.defineProperty(this,"_root",{value:new $,writable:!0,enumerable:!1}),Object.defineProperty(this,"_ledgerId",{value:t?.id??--y.teaqlTemporaryId,writable:!0,enumerable:!1}),Object.defineProperty(this,"_workItemList",{value:t?.id?I.empty():new I,writable:!0,enumerable:!1}),t){const i={...t};if(delete i.workItemList,Object.assign(this,i),Array.isArray(t.workItemList)){const r=t.workItemList;this._workItemList=new I(r.map(s=>s instanceof m?s:m.fromRecord(s)),{totalCount:r.totalCount,aggregations:r.aggregations,summary:r.summary,facets:r.facets,isLoaded:r.isLoaded??!0}),this.markLoaded("workItemList")}}const e=this.teaqlEntityKey();this._action==="Create"?this._root.markAsNew(e):this.version!==void 0&&this._root.setOriginalVersion(e,Number(this.version)),c.captureFor(this,this.teaqlMutationPayload())}teaqlEntityKey(){return{entity:"Platform",id:this._ledgerId}}teaqlAttachRoot(t){this._root!==t&&(t.mergeEntityFrom(this._root,this.teaqlEntityKey()),this._root=t);for(const e of this._workItemList)e.teaqlAttachRoot(t);return this}static fromRecord(t,e){const i=new y(t);return e?i.teaqlAttachRoot(e):i}isLoaded(t){return this._fullyLoaded||this._loadedFields.has(t)}markLoaded(...t){for(const e of t)this._loadedFields.add(e);return this}markLoadedOnly(...t){return this._fullyLoaded=!1,this._loadedFields=new Set(t),this}static refer(t){return new y({id:String(t)})}static teaqlBootstrapNew(t){return new y().updateId(String(t))}markForDeletion(){return this._action="Delete",this._root.markAsDeleted(this.teaqlEntityKey()),this}auditAs(t){return new k(t),this._comment=t,this}async save(t){const e=t.requireResource("dataService");return e.executeGraphSave(new k(this._comment),async i=>(this.teaqlPreflightGraph(t,e,i),this.teaqlSaveWithinGraph(t,e,i)))}teaqlPreflightGraph(t,e,i,r){r||new k(this._comment);const s=this._action,a=s!=="Update"||this._root.hasPending(this.teaqlEntityKey());if(s==="Update"&&a){const u=[{member:"id",canonical:"id"},{member:"name",canonical:"name"},{member:"version",canonical:"version"}].find(h=>!this.isLoaded(h.member));if(u)throw new v([{ruleId:"invalid_type",location:g.property(u.canonical),message:"Mutation requires a fully loaded entity"}])}const n=i.request({entity:"Platform",action:s,payload:s==="Update"?this._root.change(this.teaqlEntityKey()):this.teaqlMutationPayload(),id:this.id,version:this.version,comment:this._comment,ledgerKey:this.teaqlEntityKey(),ledgerRoot:this._root},r,this._comment).withLoadedSnapshot(c.forEntity(this)??new c);a&&e.preflightMutation(n);const d=n.scopeFor(this.teaqlEntityKey());for(const[u,h]of this._workItemList.entries()){h.teaqlAttachRoot(this._root);const l=h.platform;(this.id===void 0||!h.isLoaded("platform")||(typeof l=="object"&&l!==null?l.id:l)!==this.id)&&h.updatePlatform(this);try{h.teaqlPreflightGraph(t,e,i,d)}catch(p){if(!(p instanceof v))throw p;const S=g.property("work_item_list").index(u);throw new v(p.violations.map(f=>({...f,location:f.location.prefixedBy(S)})))}}}async teaqlSaveWithinGraph(t,e,i,r){r||new k(this._comment);const s=this._action,a=this._root.change(this.teaqlEntityKey()),n={entity:"Platform",action:this._action,payload:s==="Update"?a:this.teaqlMutationPayload(),id:this.id,version:this.version,comment:this._comment,ledgerKey:this.teaqlEntityKey(),ledgerRoot:this._root},d=i.request(n,r,this._comment).withLoadedSnapshot(c.forEntity(this)??new c);if(s==="Update"&&!this._root.hasPending(this.teaqlEntityKey())){const f=d.scopeFor(this.teaqlEntityKey());for(const[q,w]of this._workItemList.entries()){w.teaqlAttachRoot(this._root);const _=w.platform;(this.id===void 0||!w.isLoaded("platform")||(typeof _=="object"&&_!==null?_.id:_)!==this.id)&&w.updatePlatform(this);try{await w.teaqlSaveWithinGraph(t,e,i,f)}catch(N){if(!(N instanceof v))throw N;const P=g.property("work_item_list").index(q);throw new v(N.violations.map(B=>({...B,location:B.location.prefixedBy(P)})))}}return this}const u=await e.executeMutation(d);for(const[f,q]of Object.entries(n.payload))f!=="id"&&f!=="version"&&this._root.set(this.teaqlEntityKey(),f,q);if(!u.persistedRecord)throw new Error("Mutation did not return the authoritative persisted record");const h={payload:this.teaqlMutationPayload(),ledgerId:this._ledgerId,action:this._action,loadedFields:new Set(this._loadedFields),fullyLoaded:this._fullyLoaded,loadedSnapshot:c.forEntity(this)},l=this.teaqlEntityKey();Object.assign(this,u.persistedRecord),c.captureFor(this,this.teaqlMutationPayload()),this._ledgerId=this.id??this._ledgerId;const p=this.teaqlEntityKey();this._root.rekey(l,p),e.afterGraphRollback(()=>{Object.assign(this,h.payload),this._ledgerId=h.ledgerId,this._action=h.action,this._loadedFields=h.loadedFields,this._fullyLoaded=h.fullyLoaded,c.restoreFor(this,h.loadedSnapshot),this._root.rekey(p,l)}),this._loadedFields=new Set(Object.keys(u.persistedRecord)),this._fullyLoaded=!1,n.action!=="Delete"&&(this._action="Update");const S=d.scopeFor(p);for(const[f,q]of this._workItemList.entries()){q.teaqlAttachRoot(this._root);const w=q.platform;(this.id===void 0||!q.isLoaded("platform")||(typeof w=="object"&&w!==null?w.id:w)!==this.id)&&q.updatePlatform(this);try{await q.teaqlSaveWithinGraph(t,e,i,S)}catch(_){if(!(_ instanceof v))throw _;const N=g.property("work_item_list").index(f);throw new v(_.violations.map(P=>({...P,location:P.location.prefixedBy(N)})))}}return e.afterGraphCommit(()=>{this._root.clearEntity(p),this.version!==void 0&&this._root.acceptCommittedVersion(p,Number(this.version))}),this}teaqlMutationPayload(){return{id:this.id,name:this.name,version:this.version}}updateId(t){return this.id=t,this.markLoaded("id"),this._root.set(this.teaqlEntityKey(),"id",t),this}updateName(t){return this.name=t,this.markLoaded("name"),this._root.set(this.teaqlEntityKey(),"name",t),this}updateVersion(t){return this.version=t,this.markLoaded("version"),this._root.set(this.teaqlEntityKey(),"version",t),this}workItemList(){return this._workItemList}}const D=Object.freeze({Platform:Object.freeze({fields:Object.freeze({id:"integer",name:"string",version:"integer"}),queryFields:Object.freeze({id:"id",name:"name",version:"version"}),relations:Object.freeze({workItemList:"WorkItem"})}),WorkItem:Object.freeze({fields:Object.freeze({id:"integer",title:"string",description:"string",platform:"integer",version:"integer"}),queryFields:Object.freeze({id:"id",title:"title",description:"description",platform:"platform",version:"version"}),relations:Object.freeze({platform:"Platform"})})});class A{query;filters=[];_purpose;_comment;_pageCountAlias;_pageCountMethod;_dynamicSearchWarnings=[];constructor(t=!1){this.query=new L("Platform"),this.filters.push({version:{$gte:1}}),t?(this.selectId(),this.selectVersion()):this.selectSelfFields()}comment(t){return this.query.comment(t),this._comment=t,this}filterByJson(t,e){const i=this.query.clone();this.filters.length>0&&i.filter({$and:this.filters});const r=O(i,t,D,e);return this.query=r.query,this.filters=this.query.filterCondition?[this.query.filterCondition]:[],this._dynamicSearchWarnings.push(...r.warnings),this}get dynamicSearchWarnings(){return this._dynamicSearchWarnings.map(t=>({...t}))}purpose(t){return this.query.purpose(t),this._purpose=t,new X(e=>e.withQueryRequest(this.query,()=>this.executeForListInternal(e)),e=>e.withQueryRequest(this.query,()=>this.executeForRowsInternal(e)),(e,i)=>this.executeForStreamInternal(e,i),()=>this.limit(1),e=>this.comment(e),()=>this.ensureIntent())}optimizeForContinuousPageFetch(){return this.query.optimizeForContinuousPageFetch(),this}optimizeForContinuousPageFetchWith(t,e){return this.query.optimizeForContinuousPageFetchWith(t,e),this}optimizePaginationWithIdSet(){return this.query.optimizePaginationWithIdSet(),this}optimizePaginationWithIdSetConfig(t,e,i){return this.query.optimizePaginationWithIdSetConfig(t,e,i),this}topNProbeParentThreshold(t){return this.query.topNProbeParentThreshold(t),this}limit(t){return this.query.limit(t),this}offset(t){return this.query.offset(t),this}toQuery(){return this.filters.length>0&&this.query.filter({$and:this.filters}),this.query}withDeletedRows(){return this.filters=this.filters.filter(t=>!("version"in t)),this}deletedRowsOnly(){return this.withDeletedRows(),this.filters.push({version:{$lte:-1}}),this}selectSelfFields(){return this.query.select(["id","name","version"]),this}selectId(){return this.query.select(["id"]),this}selectName(){return this.query.select(["name"]),this}selectVersion(){return this.query.select(["version"]),this}selectWorkItemListWith(t){return this.query.relationQuery("workItemList",t.toQuery(),"id","platform",!0,{kind:"relation-select",method:"selectWorkItemListWith",relation:"workItemList"}),this}haveWorkItems(){return this.withWorkItemListMatching({toQuery:()=>new L("WorkItem")})}haveNoWorkItems(){return this.withoutWorkItemListMatching({toQuery:()=>new L("WorkItem")})}withWorkItemListMatching(t){return this.filters.push({id:{$inSubquery:{query:t.toQuery(),field:"platform"}}}),this}withoutWorkItemListMatching(t){return this.filters.push({id:{$notInSubquery:{query:t.toQuery(),field:"platform"}}}),this}countWorkItems(){return this.countWorkItemsAs("countWorkItems")}countWorkItemsAs(t){const e=new L("WorkItem").filter({version:{$gte:1}});return this.countWorkItemsWith(t,{toQuery:()=>e}),this.query.relationAggregates[this.query.relationAggregates.length-1].operation={kind:"relation-count",method:"countWorkItemsAs",relation:"workItemList",alias:t},this}countWorkItemsWith(t,e){const i=e.toQuery().clone();return i.aggregateItems=[],i.aggregate("Count","id",t),this.query.relationAggregate("workItemList",t,i,!0,{kind:"relation-count",method:"countWorkItemsWith",relation:"workItemList",alias:t}),this}withIdIs(t){return this.filters.push({id:{$eq:t}}),this}withIdIsNot(t){return this.filters.push({id:{$ne:t}}),this}withIdIn(...t){return this.filters.push({id:{$in:t}}),this}withIdNotIn(...t){return this.filters.push({id:{$notIn:t}}),this}withIdGreaterThan(t){return this.filters.push({id:{$gt:t}}),this}withIdGreaterThanOrEqualTo(t){return this.filters.push({id:{$gte:t}}),this}withIdLessThan(t){return this.filters.push({id:{$lt:t}}),this}withIdLessThanOrEqualTo(t){return this.filters.push({id:{$lte:t}}),this}withIdBetween(t,e){return this.filters.push({id:{$between:[t,e]}}),this}withIdIsKnown(){return this.filters.push({id:{$isNull:!1}}),this}withIdIsUnknown(){return this.filters.push({id:{$isNull:!0}}),this}withNameContaining(t){return this.filters.push({name:{$contains:t}}),this}withNameIs(t){return this.filters.push({name:{$eq:t}}),this}withNameIsNot(t){return this.filters.push({name:{$ne:t}}),this}withNameIn(...t){return this.filters.push({name:{$in:t}}),this}withNameNotIn(...t){return this.filters.push({name:{$notIn:t}}),this}withNameGreaterThan(t){return this.filters.push({name:{$gt:t}}),this}withNameGreaterThanOrEqualTo(t){return this.filters.push({name:{$gte:t}}),this}withNameLessThan(t){return this.filters.push({name:{$lt:t}}),this}withNameLessThanOrEqualTo(t){return this.filters.push({name:{$lte:t}}),this}withNameBetween(t,e){return this.filters.push({name:{$between:[t,e]}}),this}withNameIsKnown(){return this.filters.push({name:{$isNull:!1}}),this}withNameIsUnknown(){return this.filters.push({name:{$isNull:!0}}),this}withNameNotContaining(t){return this.filters.push({name:{$notContains:t}}),this}withNameStartingWith(t){return this.filters.push({name:{$startsWith:t}}),this}withNameNotStartingWith(t){return this.filters.push({name:{$notStartsWith:t}}),this}withNameEndingWith(t){return this.filters.push({name:{$endsWith:t}}),this}withNameNotEndingWith(t){return this.filters.push({name:{$notEndsWith:t}}),this}withNameSoundingLike(t){return this.filters.push({name:{$soundLike:t}}),this}withVersionIs(t){return this.filters.push({version:{$eq:t}}),this}withVersionIsNot(t){return this.filters.push({version:{$ne:t}}),this}withVersionIn(...t){return this.filters.push({version:{$in:t}}),this}withVersionNotIn(...t){return this.filters.push({version:{$notIn:t}}),this}withVersionGreaterThan(t){return this.filters.push({version:{$gt:t}}),this}withVersionGreaterThanOrEqualTo(t){return this.filters.push({version:{$gte:t}}),this}withVersionLessThan(t){return this.filters.push({version:{$lt:t}}),this}withVersionLessThanOrEqualTo(t){return this.filters.push({version:{$lte:t}}),this}withVersionBetween(t,e){return this.filters.push({version:{$between:[t,e]}}),this}withVersionIsKnown(){return this.filters.push({version:{$isNull:!1}}),this}withVersionIsUnknown(){return this.filters.push({version:{$isNull:!0}}),this}orderByIdAscending(){return this.query.orderBy("id","asc"),this}orderByIdDescending(){return this.query.orderBy("id","desc"),this}orderByNameAscending(){return this.query.orderBy("name","asc"),this}orderByNameDescending(){return this.query.orderBy("name","desc"),this}orderByVersionAscending(){return this.query.orderBy("version","asc"),this}orderByVersionDescending(){return this.query.orderBy("version","desc"),this}count(){return this.query.aggregate("Count","id","count"),this._pageCountAlias="count",this._pageCountMethod="count",this}countAs(t){return this.query.aggregate("Count","id",t),this._pageCountAlias=t,this._pageCountMethod="countAs",this}groupById(){return this.query.groupBy("id"),this}groupByIdAs(t){return this.query.groupBy("id"),this}groupByName(){return this.query.groupBy("name"),this}groupByNameAs(t){return this.query.groupBy("name"),this}groupByVersion(){return this.query.groupBy("version"),this}groupByVersionAs(t){return this.query.groupBy("version"),this}async executeForListInternal(t){if(this.ensureIntent(),this._pageCountAlias!==void 0)return this.executeCountedListInternal(t);this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService"),i=await e.executeQuery(t.prepareQuery(this.query)),r=this.query.aggregateItems.length>0&&this.query.groupByItems.length===0,s=r?[]:i.map(n=>n instanceof y?n:y.fromRecord(n,new $)),a=new I(s);return r&&i[0]&&Object.assign(a.aggregations,i[0]),this.query.facets.length>0&&(a.facets=await C(e,n=>t.prepareQuery(n),this.query,this.query.facets)),a}async executeForRowsInternal(t){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService");return new I(await e.executeQuery(t.prepareQuery(this.query)))}async executeCountedListInternal(t){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService"),i=t.prepareQuery(this.query),r=i.localIdSetPaginationOptions()!==void 0,s={kind:"named-count",method:this._pageCountMethod??"count",...this._pageCountMethod==="countAs"?{alias:this._pageCountAlias}:{}},a=r?void 0:await e.executeCount(i,this._pageCountAlias,s),n=i.clone();n.aggregateItems=n.aggregateItems.filter(l=>!(String(l.function).toLowerCase()==="count"&&l.alias===this._pageCountAlias));const d=await e.executeQuery(n),u=r&&t.idSetPaginationCountAccuracy==="EXACT"?t.idSetPaginationCount:a??await e.executeCount(i,this._pageCountAlias,s),h=new I(d.map(l=>l instanceof y?l:y.fromRecord(l,new $)));return h.totalCount=u,this._pageCountAlias!==void 0&&(h.aggregations[this._pageCountAlias]=u),this.query.facets.length>0&&(h.facets=await C(e,l=>t.prepareQuery(l),i,i.facets)),h}executeForStreamInternal(t,e){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const i=t.requireResource("dataService"),r=t.prepareQuery(this.query),s=i.executeForStream(r,e);return(async function*(){for await(const a of s)for(const n of a)yield n instanceof y?n:y.fromRecord(n,new $)})()}ensureIntent(){new K(this._comment,this._purpose)}}class X{constructor(t,e,i,r,s,a){this.execute=t,this.executeRows=e,this.stream=i,this.limitOne=r,this.addComment=s,this.ensureIntent=a}execute;executeRows;stream;limitOne;addComment;ensureIntent;comment(t){return this.addComment(t),this}newEntity(t){return this.ensureIntent(),new y}executeForList(t){return this.ensureIntent(),this.execute(t)}executeForRows(t){return this.ensureIntent(),this.executeRows(t)}executeForStream(t,e=1e3){return this.ensureIntent(),this.stream(t,e)}async executeForOne(t){return this.limitOne(),(await this.executeForList(t))[0]}}class x{query;filters=[];_purpose;_comment;_pageCountAlias;_pageCountMethod;_dynamicSearchWarnings=[];constructor(t=!1){this.query=new L("WorkItem"),this.filters.push({version:{$gte:1}}),t?(this.selectId(),this.selectVersion()):this.selectSelfFields()}comment(t){return this.query.comment(t),this._comment=t,this}filterByJson(t,e){const i=this.query.clone();this.filters.length>0&&i.filter({$and:this.filters});const r=O(i,t,D,e);return this.query=r.query,this.filters=this.query.filterCondition?[this.query.filterCondition]:[],this._dynamicSearchWarnings.push(...r.warnings),this}get dynamicSearchWarnings(){return this._dynamicSearchWarnings.map(t=>({...t}))}purpose(t){return this.query.purpose(t),this._purpose=t,new Z(e=>e.withQueryRequest(this.query,()=>this.executeForListInternal(e)),e=>e.withQueryRequest(this.query,()=>this.executeForRowsInternal(e)),(e,i)=>this.executeForStreamInternal(e,i),()=>this.limit(1),e=>this.comment(e),()=>this.ensureIntent())}optimizeForContinuousPageFetch(){return this.query.optimizeForContinuousPageFetch(),this}optimizeForContinuousPageFetchWith(t,e){return this.query.optimizeForContinuousPageFetchWith(t,e),this}optimizePaginationWithIdSet(){return this.query.optimizePaginationWithIdSet(),this}optimizePaginationWithIdSetConfig(t,e,i){return this.query.optimizePaginationWithIdSetConfig(t,e,i),this}topNProbeParentThreshold(t){return this.query.topNProbeParentThreshold(t),this}limit(t){return this.query.limit(t),this}offset(t){return this.query.offset(t),this}toQuery(){return this.filters.length>0&&this.query.filter({$and:this.filters}),this.query}withDeletedRows(){return this.filters=this.filters.filter(t=>!("version"in t)),this}deletedRowsOnly(){return this.withDeletedRows(),this.filters.push({version:{$lte:-1}}),this}selectSelfFields(){return this.query.select(["id","title","description","platform","version"]),this}selectId(){return this.query.select(["id"]),this}selectTitle(){return this.query.select(["title"]),this}selectDescription(){return this.query.select(["description"]),this}selectVersion(){return this.query.select(["version"]),this}selectPlatformWith(t){return this.query.select(["platform"]),this.query.relationQuery("platform",t.toQuery(),"platform","id",!1,{kind:"relation-select",method:"selectPlatformWith",relation:"platform"}),this}withPlatformMatching(t){return this.filters.push({platform:{$inSubquery:{query:t.toQuery(),field:"id"}}}),this}withoutPlatformMatching(t){return this.filters.push({platform:{$notInSubquery:{query:t.toQuery(),field:"id"}}}),this}withIdIs(t){return this.filters.push({id:{$eq:t}}),this}withIdIsNot(t){return this.filters.push({id:{$ne:t}}),this}withIdIn(...t){return this.filters.push({id:{$in:t}}),this}withIdNotIn(...t){return this.filters.push({id:{$notIn:t}}),this}withIdGreaterThan(t){return this.filters.push({id:{$gt:t}}),this}withIdGreaterThanOrEqualTo(t){return this.filters.push({id:{$gte:t}}),this}withIdLessThan(t){return this.filters.push({id:{$lt:t}}),this}withIdLessThanOrEqualTo(t){return this.filters.push({id:{$lte:t}}),this}withIdBetween(t,e){return this.filters.push({id:{$between:[t,e]}}),this}withIdIsKnown(){return this.filters.push({id:{$isNull:!1}}),this}withIdIsUnknown(){return this.filters.push({id:{$isNull:!0}}),this}withTitleContaining(t){return this.filters.push({title:{$contains:t}}),this}withTitleIs(t){return this.filters.push({title:{$eq:t}}),this}withTitleIsNot(t){return this.filters.push({title:{$ne:t}}),this}withTitleIn(...t){return this.filters.push({title:{$in:t}}),this}withTitleNotIn(...t){return this.filters.push({title:{$notIn:t}}),this}withTitleGreaterThan(t){return this.filters.push({title:{$gt:t}}),this}withTitleGreaterThanOrEqualTo(t){return this.filters.push({title:{$gte:t}}),this}withTitleLessThan(t){return this.filters.push({title:{$lt:t}}),this}withTitleLessThanOrEqualTo(t){return this.filters.push({title:{$lte:t}}),this}withTitleBetween(t,e){return this.filters.push({title:{$between:[t,e]}}),this}withTitleIsKnown(){return this.filters.push({title:{$isNull:!1}}),this}withTitleIsUnknown(){return this.filters.push({title:{$isNull:!0}}),this}withTitleNotContaining(t){return this.filters.push({title:{$notContains:t}}),this}withTitleStartingWith(t){return this.filters.push({title:{$startsWith:t}}),this}withTitleNotStartingWith(t){return this.filters.push({title:{$notStartsWith:t}}),this}withTitleEndingWith(t){return this.filters.push({title:{$endsWith:t}}),this}withTitleNotEndingWith(t){return this.filters.push({title:{$notEndsWith:t}}),this}withTitleSoundingLike(t){return this.filters.push({title:{$soundLike:t}}),this}withDescriptionContaining(t){return this.filters.push({description:{$contains:t}}),this}withDescriptionIs(t){return this.filters.push({description:{$eq:t}}),this}withDescriptionIsNot(t){return this.filters.push({description:{$ne:t}}),this}withDescriptionIn(...t){return this.filters.push({description:{$in:t}}),this}withDescriptionNotIn(...t){return this.filters.push({description:{$notIn:t}}),this}withDescriptionGreaterThan(t){return this.filters.push({description:{$gt:t}}),this}withDescriptionGreaterThanOrEqualTo(t){return this.filters.push({description:{$gte:t}}),this}withDescriptionLessThan(t){return this.filters.push({description:{$lt:t}}),this}withDescriptionLessThanOrEqualTo(t){return this.filters.push({description:{$lte:t}}),this}withDescriptionBetween(t,e){return this.filters.push({description:{$between:[t,e]}}),this}withDescriptionIsKnown(){return this.filters.push({description:{$isNull:!1}}),this}withDescriptionIsUnknown(){return this.filters.push({description:{$isNull:!0}}),this}withDescriptionNotContaining(t){return this.filters.push({description:{$notContains:t}}),this}withDescriptionStartingWith(t){return this.filters.push({description:{$startsWith:t}}),this}withDescriptionNotStartingWith(t){return this.filters.push({description:{$notStartsWith:t}}),this}withDescriptionEndingWith(t){return this.filters.push({description:{$endsWith:t}}),this}withDescriptionNotEndingWith(t){return this.filters.push({description:{$notEndsWith:t}}),this}withDescriptionSoundingLike(t){return this.filters.push({description:{$soundLike:t}}),this}filterByPlatform(t){return this.filters.push({platform:{$eq:t}}),this}filterByPlatformIn(...t){return this.filters.push({platform:{$in:t}}),this}withPlatformIsKnown(){return this.filters.push({platform:{$isNull:!1}}),this}withPlatformIsUnknown(){return this.filters.push({platform:{$isNull:!0}}),this}withVersionIs(t){return this.filters.push({version:{$eq:t}}),this}withVersionIsNot(t){return this.filters.push({version:{$ne:t}}),this}withVersionIn(...t){return this.filters.push({version:{$in:t}}),this}withVersionNotIn(...t){return this.filters.push({version:{$notIn:t}}),this}withVersionGreaterThan(t){return this.filters.push({version:{$gt:t}}),this}withVersionGreaterThanOrEqualTo(t){return this.filters.push({version:{$gte:t}}),this}withVersionLessThan(t){return this.filters.push({version:{$lt:t}}),this}withVersionLessThanOrEqualTo(t){return this.filters.push({version:{$lte:t}}),this}withVersionBetween(t,e){return this.filters.push({version:{$between:[t,e]}}),this}withVersionIsKnown(){return this.filters.push({version:{$isNull:!1}}),this}withVersionIsUnknown(){return this.filters.push({version:{$isNull:!0}}),this}orderByIdAscending(){return this.query.orderBy("id","asc"),this}orderByIdDescending(){return this.query.orderBy("id","desc"),this}orderByTitleAscending(){return this.query.orderBy("title","asc"),this}orderByTitleDescending(){return this.query.orderBy("title","desc"),this}orderByDescriptionAscending(){return this.query.orderBy("description","asc"),this}orderByDescriptionDescending(){return this.query.orderBy("description","desc"),this}orderByVersionAscending(){return this.query.orderBy("version","asc"),this}orderByVersionDescending(){return this.query.orderBy("version","desc"),this}count(){return this.query.aggregate("Count","id","count"),this._pageCountAlias="count",this._pageCountMethod="count",this}countAs(t){return this.query.aggregate("Count","id",t),this._pageCountAlias=t,this._pageCountMethod="countAs",this}groupById(){return this.query.groupBy("id"),this}groupByIdAs(t){return this.query.groupBy("id"),this}groupByTitle(){return this.query.groupBy("title"),this}groupByTitleAs(t){return this.query.groupBy("title"),this}groupByDescription(){return this.query.groupBy("description"),this}groupByDescriptionAs(t){return this.query.groupBy("description"),this}groupByPlatform(){return this.query.groupBy("platform"),this}groupByPlatformAs(t){return this.query.groupBy("platform"),this}groupByVersion(){return this.query.groupBy("version"),this}groupByVersionAs(t){return this.query.groupBy("version"),this}facetByPlatformAs(t,e,i=!0){return this.query.facetBy(t,"platform",e,i,{kind:"facet",method:"facetByPlatformAs",relation:"platform",alias:t}),this}async executeForListInternal(t){if(this.ensureIntent(),this._pageCountAlias!==void 0)return this.executeCountedListInternal(t);this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService"),i=await e.executeQuery(t.prepareQuery(this.query)),r=this.query.aggregateItems.length>0&&this.query.groupByItems.length===0,s=r?[]:i.map(n=>n instanceof m?n:m.fromRecord(n,new $)),a=new I(s);return r&&i[0]&&Object.assign(a.aggregations,i[0]),this.query.facets.length>0&&(a.facets=await C(e,n=>t.prepareQuery(n),this.query,this.query.facets)),a}async executeForRowsInternal(t){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService");return new I(await e.executeQuery(t.prepareQuery(this.query)))}async executeCountedListInternal(t){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const e=t.requireResource("dataService"),i=t.prepareQuery(this.query),r=i.localIdSetPaginationOptions()!==void 0,s={kind:"named-count",method:this._pageCountMethod??"count",...this._pageCountMethod==="countAs"?{alias:this._pageCountAlias}:{}},a=r?void 0:await e.executeCount(i,this._pageCountAlias,s),n=i.clone();n.aggregateItems=n.aggregateItems.filter(l=>!(String(l.function).toLowerCase()==="count"&&l.alias===this._pageCountAlias));const d=await e.executeQuery(n),u=r&&t.idSetPaginationCountAccuracy==="EXACT"?t.idSetPaginationCount:a??await e.executeCount(i,this._pageCountAlias,s),h=new I(d.map(l=>l instanceof m?l:m.fromRecord(l,new $)));return h.totalCount=u,this._pageCountAlias!==void 0&&(h.aggregations[this._pageCountAlias]=u),this.query.facets.length>0&&(h.facets=await C(e,l=>t.prepareQuery(l),i,i.facets)),h}executeForStreamInternal(t,e){this.ensureIntent(),this.filters.length>0&&this.query.filter({$and:this.filters});const i=t.requireResource("dataService"),r=t.prepareQuery(this.query),s=i.executeForStream(r,e);return(async function*(){for await(const a of s)for(const n of a)yield n instanceof m?n:m.fromRecord(n,new $)})()}ensureIntent(){new K(this._comment,this._purpose)}}class Z{constructor(t,e,i,r,s,a){this.execute=t,this.executeRows=e,this.stream=i,this.limitOne=r,this.addComment=s,this.ensureIntent=a}execute;executeRows;stream;limitOne;addComment;ensureIntent;comment(t){return this.addComment(t),this}newEntity(t){return this.ensureIntent(),new m}executeForList(t){return this.ensureIntent(),this.execute(t)}executeForRows(t){return this.ensureIntent(),this.executeRows(t)}executeForStream(t,e=1e3){return this.ensureIntent(),this.stream(t,e)}async executeForOne(t){return this.limitOne(),(await this.executeForList(t))[0]}}class R{static platforms(){return new A(!1)}static platformsWithMinimalFields(){return new A(!0)}static workItems(){return new x(!1)}static workItemsWithMinimalFields(){return new x(!0)}}const tt={Platform:{table:"platform_data",auditMaskFields:[],columns:{id:{columnName:"id",modelName:"id",logPolicy:"plain",logicalType:"integer",decode:"string",nullable:!1},name:{columnName:"name",modelName:"name",logPolicy:"plain",logicalType:"text",decode:"native",nullable:!1},version:{columnName:"version",modelName:"version",logPolicy:"plain",logicalType:"integer",decode:"number",nullable:!1}},relations:{workItemList:{targetEntity:"WorkItem",localKey:"id",foreignKey:"platform",many:!0}}},WorkItem:{table:"work_item_data",auditMaskFields:[],columns:{id:{columnName:"id",modelName:"id",logPolicy:"plain",logicalType:"integer",decode:"string",nullable:!1},title:{columnName:"title",modelName:"title",logPolicy:"plain",logicalType:"text",decode:"native",nullable:!1},description:{columnName:"description",modelName:"description",logPolicy:"plain",logicalType:"text",decode:"native",nullable:!0},platform:{columnName:"platform",modelName:"platform",logPolicy:"plain",logicalType:"integer",decode:"string",nullable:!1},version:{columnName:"version",modelName:"version",logPolicy:"plain",logicalType:"integer",decode:"number",nullable:!1}},relations:{platform:{targetEntity:"Platform",localKey:"platform",foreignKey:"id",many:!1}}}};async function et(o){let t=(await R.platforms().withIdIs("1").comment("what: locate generated Domain Root").purpose("why: idempotent runtime bootstrap").executeForList(o))[0];t||(t=y.teaqlBootstrapNew("1"),t.updateName("Runtime Example"),await t.auditAs("create generated Domain Root Platform").save(o)),o.withActiveRoot({entity:"Platform",id:t.id})}const it=new U(tt,{Platform:{checkAndFix(o,t,e){o.getResource("fixTime"),(t.action==="Create"&&t.payload.name===void 0||t.payload.name===null)&&e.push({ruleId:"required",location:g.property("name")}),t.payload.name!=null&&[...String(t.payload.name)].length>100&&e.push({ruleId:"max_length",location:g.property("name"),inputValue:t.payload.name,systemValue:100})}},WorkItem:{checkAndFix(o,t,e){o.getResource("fixTime"),(t.action==="Create"&&t.payload.title===void 0||t.payload.title===null)&&e.push({ruleId:"required",location:g.property("title")}),t.payload.title!=null&&!([...String(t.payload.title)].length>=1)&&e.push({ruleId:"min_length",location:g.property("title"),inputValue:t.payload.title,systemValue:1}),t.payload.title!=null&&[...String(t.payload.title)].length>80&&e.push({ruleId:"max_length",location:g.property("title"),inputValue:t.payload.title,systemValue:80}),t.payload.description!=null&&[...String(t.payload.description)].length>100&&e.push({ruleId:"max_length",location:g.property("description"),inputValue:t.payload.description,systemValue:100}),(t.action==="Create"&&t.payload.platform===void 0||t.payload.platform===null)&&e.push({ruleId:"required",location:g.property("platform")})}}},{defaultDomainRoot:{entity:"Platform",id:"1",values:{name:"Runtime Example"}},constants:[],ensure:et}),rt={Platform:{table:"platform_data",columns:{id:{columnName:"id",modelName:"id",logicalType:"integer",decode:"string",nullable:!1},name:{columnName:"name",modelName:"name",logicalType:"text",decode:"native",nullable:!1},version:{columnName:"version",modelName:"version",logicalType:"integer",decode:"number",nullable:!1}},relations:{workItemList:{targetEntity:"WorkItem",localKey:"id",foreignKey:"platform",many:!0}}},WorkItem:{table:"work_item_data",columns:{id:{columnName:"id",modelName:"id",logicalType:"integer",decode:"string",nullable:!1},title:{columnName:"title",modelName:"title",logicalType:"text",decode:"native",nullable:!1},description:{columnName:"description",modelName:"description",logicalType:"text",decode:"native",nullable:!0},platform:{columnName:"platform",modelName:"platform",logicalType:"integer",decode:"string",nullable:!1},version:{columnName:"version",modelName:"version",logicalType:"integer",decode:"number",nullable:!1}},relations:{platform:{targetEntity:"Platform",localKey:"platform",foreignKey:"id",many:!1}}}},F=document.querySelector("#status"),st=document.querySelector("#result"),T=document.querySelector("#persist"),E=document.querySelector("#reset");let b;const M=localStorage.getItem("teaql-browser-storage")==="opfs"?"opfs":"memory";T.checked=M==="opfs";async function nt(o){const t=new Worker(new URL("/assets/sqlite.worker-DS5P4U1E.js",import.meta.url),{type:"module"}),e=await z.open(t,{...rt},{storage:o,databaseName:"teaql-browser-example.sqlite3"});e.install(it);const i=Object.freeze({policyId:"browser-demo-seed",version:"1",fingerprint:"sha256:browser-demo-seed-v1"}),r=new H().insertResource("dataService",e).withMutationPolicyRegistry(new J(()=>({identity:i,review:(s,a)=>a.operations.length>0?{verdict:"allow"}:{verdict:"deny",code:"EMPTY_GRAPH",message:"empty mutation graph"}}))).withMutationPolicyApprovalProvider(new Y(s=>({policy:s,approvedBy:"browser-demo-owner",approvedAt:new Date})));return e.setUserContext(r),await r.ensureSchema(),{client:e,context:r}}async function Q({context:o}){if(!(await R.workItemsWithMinimalFields().comment("what: detect existing browser demo records").purpose("why: keep generated mutation bootstrap idempotent").executeForList(o)).length)for(const e of["Evaluate semantic model","Generate typed library","Verify browser runtime"])await new m().updateTitle(e).updatePlatform("1").auditAs("seed deterministic browser demo data").save(o)}async function V(o){const t=await R.workItems().selectTitle().orderByIdAscending().limit(20).comment("what: load browser-local work items").purpose("why: prove the generated Q API runs without a backend").executeForList(o.context);st.textContent=JSON.stringify(t,null,2),F.textContent=`${o.client.storage.toUpperCase()} · ${t.length} rows · policy installed · ready`}async function j(o){F.textContent=`Opening ${o.toUpperCase()} SQLite/WASM…`;const t=b;b=void 0,await t?.client.close();const e=await nt(o);b=e,await Q(e),await V(e)}T.addEventListener("change",()=>{const o=T.checked?"opfs":"memory";localStorage.setItem("teaql-browser-storage",o),j(o).catch(W)});E.addEventListener("click",async()=>{if(b){E.disabled=!0;try{await b.client.reset(b.context),await Q(b),await V(b)}catch(o){W(o)}finally{E.disabled=!1}}});function W(o){const t=o instanceof Error?o:new Error(String(o));F.textContent=`${t.name}: ${t.message}`}j(M).catch(W);
|
dist/index.html
CHANGED
|
@@ -6,9 +6,9 @@
|
|
| 6 |
<link rel="icon" href="data:," />
|
| 7 |
<meta name="description" content="A TeaQL order-query playground running entirely in the browser" />
|
| 8 |
<title>TeaQL Order Query Playground</title>
|
| 9 |
-
<script type="module" crossorigin src="/assets/main-
|
| 10 |
-
<link rel="modulepreload" crossorigin href="/assets/dynamic-search-
|
| 11 |
-
<link rel="stylesheet" crossorigin href="/assets/style-
|
| 12 |
</head>
|
| 13 |
<body>
|
| 14 |
<div class="page-shell">
|
|
@@ -51,6 +51,51 @@
|
|
| 51 |
</div>
|
| 52 |
</section>
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
<section class="runtime-bar" aria-label="Runtime settings">
|
| 55 |
<p id="status" role="status">Starting SQLite/WASM…</p>
|
| 56 |
<div class="controls">
|
|
|
|
| 6 |
<link rel="icon" href="data:," />
|
| 7 |
<meta name="description" content="A TeaQL order-query playground running entirely in the browser" />
|
| 8 |
<title>TeaQL Order Query Playground</title>
|
| 9 |
+
<script type="module" crossorigin src="/assets/main-Cg0XY2hs.js"></script>
|
| 10 |
+
<link rel="modulepreload" crossorigin href="/assets/dynamic-search-Ch_QcWVU.js">
|
| 11 |
+
<link rel="stylesheet" crossorigin href="/assets/style-DVG2mb5q.css">
|
| 12 |
</head>
|
| 13 |
<body>
|
| 14 |
<div class="page-shell">
|
|
|
|
| 51 |
</div>
|
| 52 |
</section>
|
| 53 |
|
| 54 |
+
<section class="runtime-language-panel" aria-labelledby="runtime-language-title">
|
| 55 |
+
<div class="runtime-language-copy">
|
| 56 |
+
<p class="section-index" data-i18n="runtimeCoverage">RUNTIME COVERAGE</p>
|
| 57 |
+
<h2 id="runtime-language-title" data-i18n="runtimeTitle">This demo runs TypeScript in your browser.</h2>
|
| 58 |
+
<p data-i18n="runtimeIntro">The same model-driven Q and TraceChain contract is supported by seven TeaQL runtimes. Select a language to inspect its runtime source.</p>
|
| 59 |
+
</div>
|
| 60 |
+
<nav class="runtime-language-selector" aria-label="TeaQL runtimes">
|
| 61 |
+
<a class="runtime-language active" href="https://github.com/teaql/teaql-ts" target="_blank" rel="noreferrer" aria-current="true">
|
| 62 |
+
<span class="runtime-language-icon" aria-hidden="true">📘</span>
|
| 63 |
+
<strong>TypeScript</strong>
|
| 64 |
+
<small data-i18n="currentBrowserRuntime">Current browser runtime</small>
|
| 65 |
+
</a>
|
| 66 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-java" target="_blank" rel="noreferrer">
|
| 67 |
+
<span class="runtime-language-icon" aria-hidden="true">☕</span>
|
| 68 |
+
<strong>Java</strong>
|
| 69 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 70 |
+
</a>
|
| 71 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-rs" target="_blank" rel="noreferrer">
|
| 72 |
+
<span class="runtime-language-icon" aria-hidden="true">🦀</span>
|
| 73 |
+
<strong>Rust</strong>
|
| 74 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 75 |
+
</a>
|
| 76 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-golang" target="_blank" rel="noreferrer">
|
| 77 |
+
<span class="runtime-language-icon" aria-hidden="true">🐹</span>
|
| 78 |
+
<strong>Go</strong>
|
| 79 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 80 |
+
</a>
|
| 81 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-python" target="_blank" rel="noreferrer">
|
| 82 |
+
<span class="runtime-language-icon" aria-hidden="true">🐍</span>
|
| 83 |
+
<strong>Python</strong>
|
| 84 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 85 |
+
</a>
|
| 86 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-dotnet" target="_blank" rel="noreferrer">
|
| 87 |
+
<span class="runtime-language-icon" aria-hidden="true">🎯</span>
|
| 88 |
+
<strong>.NET / C#</strong>
|
| 89 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 90 |
+
</a>
|
| 91 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-swift" target="_blank" rel="noreferrer">
|
| 92 |
+
<span class="runtime-language-icon" aria-hidden="true">🐦</span>
|
| 93 |
+
<strong>Swift</strong>
|
| 94 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 95 |
+
</a>
|
| 96 |
+
</nav>
|
| 97 |
+
</section>
|
| 98 |
+
|
| 99 |
<section class="runtime-bar" aria-label="Runtime settings">
|
| 100 |
<p id="status" role="status">Starting SQLite/WASM…</p>
|
| 101 |
<div class="controls">
|
dist/orders.html
CHANGED
|
@@ -5,10 +5,10 @@
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
<link rel="icon" href="data:," />
|
| 7 |
<title>TeaQL browser order TraceChain</title>
|
| 8 |
-
<script type="module" crossorigin src="/assets/orders-
|
| 9 |
-
<link rel="modulepreload" crossorigin href="/assets/dynamic-search-
|
| 10 |
-
<link rel="modulepreload" crossorigin href="/assets/object-location-
|
| 11 |
-
<link rel="stylesheet" crossorigin href="/assets/style-
|
| 12 |
</head>
|
| 13 |
<body>
|
| 14 |
<main>
|
|
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
<link rel="icon" href="data:," />
|
| 7 |
<title>TeaQL browser order TraceChain</title>
|
| 8 |
+
<script type="module" crossorigin src="/assets/orders-BIvSfQqM.js"></script>
|
| 9 |
+
<link rel="modulepreload" crossorigin href="/assets/dynamic-search-Ch_QcWVU.js">
|
| 10 |
+
<link rel="modulepreload" crossorigin href="/assets/object-location-CJfVWqJC.js">
|
| 11 |
+
<link rel="stylesheet" crossorigin href="/assets/style-DVG2mb5q.css">
|
| 12 |
</head>
|
| 13 |
<body>
|
| 14 |
<main>
|
dist/work-items.html
CHANGED
|
@@ -5,9 +5,9 @@
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
<link rel="icon" href="data:," />
|
| 7 |
<title>TeaQL Browser SQLite WorkItems</title>
|
| 8 |
-
<script type="module" crossorigin src="/assets/workItems-
|
| 9 |
-
<link rel="modulepreload" crossorigin href="/assets/dynamic-search-
|
| 10 |
-
<link rel="modulepreload" crossorigin href="/assets/object-location-
|
| 11 |
<link rel="stylesheet" crossorigin href="/assets/workItems-5mJKEgxC.css">
|
| 12 |
</head>
|
| 13 |
<body>
|
|
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
<link rel="icon" href="data:," />
|
| 7 |
<title>TeaQL Browser SQLite WorkItems</title>
|
| 8 |
+
<script type="module" crossorigin src="/assets/workItems-B6je_A1X.js"></script>
|
| 9 |
+
<link rel="modulepreload" crossorigin href="/assets/dynamic-search-Ch_QcWVU.js">
|
| 10 |
+
<link rel="modulepreload" crossorigin href="/assets/object-location-CJfVWqJC.js">
|
| 11 |
<link rel="stylesheet" crossorigin href="/assets/workItems-5mJKEgxC.css">
|
| 12 |
</head>
|
| 13 |
<body>
|
index.html
CHANGED
|
@@ -6,9 +6,9 @@
|
|
| 6 |
<link rel="icon" href="data:," />
|
| 7 |
<meta name="description" content="A TeaQL order-query playground running entirely in the browser" />
|
| 8 |
<title>TeaQL Order Query Playground</title>
|
| 9 |
-
<script type="module" crossorigin src="/assets/main-
|
| 10 |
-
<link rel="modulepreload" crossorigin href="/assets/dynamic-search-
|
| 11 |
-
<link rel="stylesheet" crossorigin href="/assets/style-
|
| 12 |
</head>
|
| 13 |
<body>
|
| 14 |
<div class="page-shell">
|
|
@@ -51,6 +51,51 @@
|
|
| 51 |
</div>
|
| 52 |
</section>
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
<section class="runtime-bar" aria-label="Runtime settings">
|
| 55 |
<p id="status" role="status">Starting SQLite/WASM…</p>
|
| 56 |
<div class="controls">
|
|
|
|
| 6 |
<link rel="icon" href="data:," />
|
| 7 |
<meta name="description" content="A TeaQL order-query playground running entirely in the browser" />
|
| 8 |
<title>TeaQL Order Query Playground</title>
|
| 9 |
+
<script type="module" crossorigin src="/assets/main-Cg0XY2hs.js"></script>
|
| 10 |
+
<link rel="modulepreload" crossorigin href="/assets/dynamic-search-Ch_QcWVU.js">
|
| 11 |
+
<link rel="stylesheet" crossorigin href="/assets/style-DVG2mb5q.css">
|
| 12 |
</head>
|
| 13 |
<body>
|
| 14 |
<div class="page-shell">
|
|
|
|
| 51 |
</div>
|
| 52 |
</section>
|
| 53 |
|
| 54 |
+
<section class="runtime-language-panel" aria-labelledby="runtime-language-title">
|
| 55 |
+
<div class="runtime-language-copy">
|
| 56 |
+
<p class="section-index" data-i18n="runtimeCoverage">RUNTIME COVERAGE</p>
|
| 57 |
+
<h2 id="runtime-language-title" data-i18n="runtimeTitle">This demo runs TypeScript in your browser.</h2>
|
| 58 |
+
<p data-i18n="runtimeIntro">The same model-driven Q and TraceChain contract is supported by seven TeaQL runtimes. Select a language to inspect its runtime source.</p>
|
| 59 |
+
</div>
|
| 60 |
+
<nav class="runtime-language-selector" aria-label="TeaQL runtimes">
|
| 61 |
+
<a class="runtime-language active" href="https://github.com/teaql/teaql-ts" target="_blank" rel="noreferrer" aria-current="true">
|
| 62 |
+
<span class="runtime-language-icon" aria-hidden="true">📘</span>
|
| 63 |
+
<strong>TypeScript</strong>
|
| 64 |
+
<small data-i18n="currentBrowserRuntime">Current browser runtime</small>
|
| 65 |
+
</a>
|
| 66 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-java" target="_blank" rel="noreferrer">
|
| 67 |
+
<span class="runtime-language-icon" aria-hidden="true">☕</span>
|
| 68 |
+
<strong>Java</strong>
|
| 69 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 70 |
+
</a>
|
| 71 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-rs" target="_blank" rel="noreferrer">
|
| 72 |
+
<span class="runtime-language-icon" aria-hidden="true">🦀</span>
|
| 73 |
+
<strong>Rust</strong>
|
| 74 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 75 |
+
</a>
|
| 76 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-golang" target="_blank" rel="noreferrer">
|
| 77 |
+
<span class="runtime-language-icon" aria-hidden="true">🐹</span>
|
| 78 |
+
<strong>Go</strong>
|
| 79 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 80 |
+
</a>
|
| 81 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-python" target="_blank" rel="noreferrer">
|
| 82 |
+
<span class="runtime-language-icon" aria-hidden="true">🐍</span>
|
| 83 |
+
<strong>Python</strong>
|
| 84 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 85 |
+
</a>
|
| 86 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-dotnet" target="_blank" rel="noreferrer">
|
| 87 |
+
<span class="runtime-language-icon" aria-hidden="true">🎯</span>
|
| 88 |
+
<strong>.NET / C#</strong>
|
| 89 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 90 |
+
</a>
|
| 91 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-swift" target="_blank" rel="noreferrer">
|
| 92 |
+
<span class="runtime-language-icon" aria-hidden="true">🐦</span>
|
| 93 |
+
<strong>Swift</strong>
|
| 94 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 95 |
+
</a>
|
| 96 |
+
</nav>
|
| 97 |
+
</section>
|
| 98 |
+
|
| 99 |
<section class="runtime-bar" aria-label="Runtime settings">
|
| 100 |
<p id="status" role="status">Starting SQLite/WASM…</p>
|
| 101 |
<div class="controls">
|
orders.html
CHANGED
|
@@ -5,10 +5,10 @@
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
<link rel="icon" href="data:," />
|
| 7 |
<title>TeaQL browser order TraceChain</title>
|
| 8 |
-
<script type="module" crossorigin src="/assets/orders-
|
| 9 |
-
<link rel="modulepreload" crossorigin href="/assets/dynamic-search-
|
| 10 |
-
<link rel="modulepreload" crossorigin href="/assets/object-location-
|
| 11 |
-
<link rel="stylesheet" crossorigin href="/assets/style-
|
| 12 |
</head>
|
| 13 |
<body>
|
| 14 |
<main>
|
|
|
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
<link rel="icon" href="data:," />
|
| 7 |
<title>TeaQL browser order TraceChain</title>
|
| 8 |
+
<script type="module" crossorigin src="/assets/orders-BIvSfQqM.js"></script>
|
| 9 |
+
<link rel="modulepreload" crossorigin href="/assets/dynamic-search-Ch_QcWVU.js">
|
| 10 |
+
<link rel="modulepreload" crossorigin href="/assets/object-location-CJfVWqJC.js">
|
| 11 |
+
<link rel="stylesheet" crossorigin href="/assets/style-DVG2mb5q.css">
|
| 12 |
</head>
|
| 13 |
<body>
|
| 14 |
<main>
|
source/provenance.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
{
|
| 2 |
"repository": "https://github.com/teaql/teaql-ts",
|
| 3 |
-
"commit": "
|
| 4 |
"branch": "main",
|
| 5 |
"runtimeVersion": "0.3.1",
|
| 6 |
"sourceDirectory": "source/teaql-ts",
|
| 7 |
"applicationDirectory": "source/teaql-ts/examples/browser-sqlite",
|
| 8 |
"buildDirectory": "dist",
|
| 9 |
"validation": {
|
| 10 |
-
"runtimeSuitesPassed":
|
| 11 |
-
"runtimeTestsPassed":
|
| 12 |
"runtimeTestsSkipped": 6,
|
| 13 |
"browserSmoke": "passed",
|
| 14 |
"generatedOrderSmoke": "passed"
|
|
|
|
| 1 |
{
|
| 2 |
"repository": "https://github.com/teaql/teaql-ts",
|
| 3 |
+
"commit": "9341b0a1fe5f2c090a39a46f9c03c50e55e27341",
|
| 4 |
"branch": "main",
|
| 5 |
"runtimeVersion": "0.3.1",
|
| 6 |
"sourceDirectory": "source/teaql-ts",
|
| 7 |
"applicationDirectory": "source/teaql-ts/examples/browser-sqlite",
|
| 8 |
"buildDirectory": "dist",
|
| 9 |
"validation": {
|
| 10 |
+
"runtimeSuitesPassed": 57,
|
| 11 |
+
"runtimeTestsPassed": 608,
|
| 12 |
"runtimeTestsSkipped": 6,
|
| 13 |
"browserSmoke": "passed",
|
| 14 |
"generatedOrderSmoke": "passed"
|
source/teaql-ts/.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
test-vectors/*.tsv whitespace=-blank-at-eol
|
source/teaql-ts/.github/workflows/example-gate.yml
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Example Gate
|
| 2 |
+
on:
|
| 3 |
+
pull_request:
|
| 4 |
+
push:
|
| 5 |
+
branches: [main]
|
| 6 |
+
workflow_dispatch:
|
| 7 |
+
jobs:
|
| 8 |
+
examples:
|
| 9 |
+
runs-on: ubuntu-latest
|
| 10 |
+
env:
|
| 11 |
+
TEAQL_S3_ENDPOINT: http://127.0.0.1:19010
|
| 12 |
+
TEAQL_S3_BUCKET: teaql-ts-example-ci
|
| 13 |
+
TEAQL_S3_ACCESS_KEY: teaql-ts-example-ci
|
| 14 |
+
TEAQL_S3_SECRET_KEY: teaql-ts-example-ci-fixture-only
|
| 15 |
+
steps:
|
| 16 |
+
- uses: actions/checkout@v4
|
| 17 |
+
- name: Install example verification tools
|
| 18 |
+
run: sudo apt-get update && sudo apt-get install -y ripgrep
|
| 19 |
+
- uses: actions/setup-node@v4
|
| 20 |
+
with:
|
| 21 |
+
node-version: '22'
|
| 22 |
+
cache: npm
|
| 23 |
+
- run: npm install
|
| 24 |
+
- run: npm run build
|
| 25 |
+
- name: Start dedicated S3 example fixture
|
| 26 |
+
run: |
|
| 27 |
+
docker run -d --name teaql-ts-example-s3 \
|
| 28 |
+
-p 127.0.0.1:19010:9000 \
|
| 29 |
+
-e RUSTFS_ACCESS_KEY="$TEAQL_S3_ACCESS_KEY" \
|
| 30 |
+
-e RUSTFS_SECRET_KEY="$TEAQL_S3_SECRET_KEY" \
|
| 31 |
+
-e RUSTFS_CONSOLE_ENABLE=false \
|
| 32 |
+
rustfs/rustfs@sha256:41fe89380f4120a337790c02af192c3fe7bb55c3edc2e6e9357b487b47c6ab21 /data
|
| 33 |
+
for attempt in {1..30}; do
|
| 34 |
+
if curl -sS -o /dev/null --max-time 2 "$TEAQL_S3_ENDPOINT/"; then
|
| 35 |
+
exit 0
|
| 36 |
+
fi
|
| 37 |
+
if [[ "$(docker inspect --format '{{.State.Running}}' teaql-ts-example-s3)" != true ]]; then
|
| 38 |
+
docker logs teaql-ts-example-s3
|
| 39 |
+
exit 1
|
| 40 |
+
fi
|
| 41 |
+
sleep 1
|
| 42 |
+
done
|
| 43 |
+
docker logs teaql-ts-example-s3
|
| 44 |
+
exit 1
|
| 45 |
+
- run: ./scripts/verify-examples.sh
|
| 46 |
+
- name: Stop dedicated S3 example fixture
|
| 47 |
+
if: always()
|
| 48 |
+
run: docker rm -f teaql-ts-example-s3 || true
|
source/teaql-ts/.github/workflows/release.yml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Publish TypeScript package
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
workflow_dispatch:
|
| 5 |
+
push:
|
| 6 |
+
tags:
|
| 7 |
+
- "typescript-v*"
|
| 8 |
+
|
| 9 |
+
jobs:
|
| 10 |
+
publish:
|
| 11 |
+
runs-on: ubuntu-latest
|
| 12 |
+
environment: npm
|
| 13 |
+
permissions:
|
| 14 |
+
contents: read
|
| 15 |
+
id-token: write
|
| 16 |
+
steps:
|
| 17 |
+
- uses: actions/checkout@v4
|
| 18 |
+
- uses: actions/setup-node@v4
|
| 19 |
+
with:
|
| 20 |
+
node-version: "24"
|
| 21 |
+
registry-url: https://registry.npmjs.org
|
| 22 |
+
cache: npm
|
| 23 |
+
- run: npm ci
|
| 24 |
+
- name: Verify tag matches package version
|
| 25 |
+
run: test "${GITHUB_REF_NAME#typescript-v}" = "$(node -p 'require("./package.json").version')"
|
| 26 |
+
# Keep native SQLite lifecycle coverage deterministic and verify the
|
| 27 |
+
# current Node LTS used by generated TeaQL projects.
|
| 28 |
+
- run: npm test -- --runInBand
|
| 29 |
+
- run: npm run build
|
| 30 |
+
- name: Upgrade npm for trusted publishing
|
| 31 |
+
run: npm install --global npm@latest
|
| 32 |
+
- run: npm publish --access public
|
source/teaql-ts/.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
node_modules
|
| 2 |
+
/examples/browser-sqlite/dist/
|
source/teaql-ts/README.md
CHANGED
|
@@ -352,6 +352,7 @@ Request JSON is not allowed to replace those trusted capabilities.
|
|
| 352 |
- [Browser SQLite example](examples/browser-sqlite/README.md)
|
| 353 |
- [Facet example](examples/facet-trace/README.md)
|
| 354 |
- [Trace Chain example](examples/trace-chain/README.md)
|
|
|
|
| 355 |
|
| 356 |
## Safe troubleshooting
|
| 357 |
|
|
|
|
| 352 |
- [Browser SQLite example](examples/browser-sqlite/README.md)
|
| 353 |
- [Facet example](examples/facet-trace/README.md)
|
| 354 |
- [Trace Chain example](examples/trace-chain/README.md)
|
| 355 |
+
- [Binary object storage and temporary S3 URLs](examples/object-storage/README.md)
|
| 356 |
|
| 357 |
## Safe troubleshooting
|
| 358 |
|
source/teaql-ts/RUNTIME_GUIDE.md
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TeaQL TypeScript Runtime Guide
|
| 2 |
+
|
| 3 |
+
Reference details for the runtime and its extension points. Start with the
|
| 4 |
+
[README](README.md) for the application-facing APIs and runnable examples.
|
| 5 |
+
|
| 6 |
+
Current published versions and acceptance status are tracked in
|
| 7 |
+
[TeaQL Conformance](https://github.com/teaql/teaql-conformance). Individual
|
| 8 |
+
verification notes below describe their own scope, not all-provider parity.
|
| 9 |
+
|
| 10 |
+
## Request intent and version compatibility
|
| 11 |
+
|
| 12 |
+
The 0.3.0 runtime provides validated, request-owned `QueryIntent` and
|
| 13 |
+
`MutationIntent`. Query Request requires non-blank `comment` and `purpose`; Mutation
|
| 14 |
+
Request requires non-blank `comment`, also exposed to policy/audit as its root
|
| 15 |
+
reason. Existing generated `.comment(...).purpose(...)` and `.auditAs(...)`
|
| 16 |
+
spelling stays unchanged after regeneration.
|
| 17 |
+
|
| 18 |
+
Missing intent fails with `REQUEST_COMMENT_REQUIRED` at `comment`, or
|
| 19 |
+
`QUERY_PURPOSE_REQUIRED` at `purpose`, before policies and provider access.
|
| 20 |
+
The errors identify the request kind without echoing payload values. Context
|
| 21 |
+
resources, fabricated trace frames, child comments, and logging switches do
|
| 22 |
+
not supply a missing request property. Unicode whitespace validation follows
|
| 23 |
+
Rust; valid text is preserved without trimming.
|
| 24 |
+
|
| 25 |
+
Low-level adapters can construct `QueryRequest(query)` or
|
| 26 |
+
`MutationRequest(mutation)`. Envelopes capture intent independently of mutable
|
| 27 |
+
builders. SQL relations, aggregates, Facets and TFP Facet serialization inherit
|
| 28 |
+
the root intent. Generated library guards delegate to the runtime validators;
|
| 29 |
+
pair the changed generator with this local runtime before testing.
|
| 30 |
+
|
| 31 |
+
The SQL execution path now uses the Rust-baseline canonical algorithm. Typed
|
| 32 |
+
nodes separate entity/relation names from operation/qualified-property detail.
|
| 33 |
+
The physical path contains no intent nodes; validated comment, purpose and root
|
| 34 |
+
audit reason are separate fields. Mutation lineage is a separate typed carrier,
|
| 35 |
+
not another name for the physical SQL path. Readback failure records a distinct
|
| 36 |
+
`Sql(select)` path instead of adding a second SQL node to a mutation path.
|
| 37 |
+
|
| 38 |
+
Query provenance belongs to immutable request snapshots. Derived relation,
|
| 39 |
+
aggregate and Facet requests carry the original root and append the local
|
| 40 |
+
relation name with its qualified property. Provenance never comes from a
|
| 41 |
+
caller-supplied `__teaqlTracePath` or a mutable Context stack. This also preserves
|
| 42 |
+
the root through overlapping queries and stream execution. Privacy projection
|
| 43 |
+
scrubs reason text without removing structural typed identity or path shape.
|
| 44 |
+
|
| 45 |
+
Graph saves now receive an explicit validated `MutationIntent` and an
|
| 46 |
+
operation-owned `GraphMutationSession`. Persistent immutable parent scopes carry
|
| 47 |
+
branch-local reasons; an unrelated request cannot join the active transaction
|
| 48 |
+
or borrow another graph's scope. Type plus ID distinguishes ledger entries;
|
| 49 |
+
an entity's complete ledger chain replaces its graph fallback. Database-assigned
|
| 50 |
+
IDs are captured before saving descendants. Context owns no lineage stack.
|
| 51 |
+
|
| 52 |
+
Audits are queued until the whole graph commits and discarded on rollback.
|
| 53 |
+
After commit, a failing sink does not stop remaining cleanup/audits or pretend
|
| 54 |
+
the database rolled back. `GraphCommittedError.committed` tells callers not to
|
| 55 |
+
retry the operation as an uncommitted write. SQL metadata still distinguishes
|
| 56 |
+
the physical path, root intent and each entity's mutation lineage. Failed
|
| 57 |
+
readback remains a separate SELECT outcome.
|
| 58 |
+
|
| 59 |
+
Successful SQL mutations also retain the actual persisted-row SELECT, not just
|
| 60 |
+
failed readbacks. `MutationResult.metadata` is a trusted internal logical write
|
| 61 |
+
summary; its frozen `statements` array contains ordered write/SELECT facts.
|
| 62 |
+
There is no additional query for tracing. Safe sinks receive each physical fact
|
| 63 |
+
once with inherited intent and per-item lineage, without double-counting audits.
|
| 64 |
+
Query/mutation log switches control diagnostic output independently; an installed
|
| 65 |
+
evidence sink and returned raw result metadata remain available when logs are
|
| 66 |
+
off. Use the evidence store's own modes to disable evidence collection. Do not
|
| 67 |
+
serialize raw result metadata across a trust boundary or log it directly.
|
| 68 |
+
|
| 69 |
+
The runtime adapter SPI is intentionally changed to
|
| 70 |
+
`executeGraphSave(intent, async graph => ...)`; adapter code must create each
|
| 71 |
+
request with `graph.request(...)`. Regenerate domain libraries rather than
|
| 72 |
+
patching their source. The generated public `.auditAs(...).save(context)` API
|
| 73 |
+
is unchanged. A child can supply its own local reason or inherit its parent;
|
| 74 |
+
save no longer overwrites child reasons with the root reason.
|
| 75 |
+
|
| 76 |
+
The [generated SQLite example](examples/trace-chain/README.md) verifies the
|
| 77 |
+
six-entity graph through real Q/E/Mutation APIs, independent overlapping saves,
|
| 78 |
+
provider/readback failures and two runs on the same database without cleanup.
|
| 79 |
+
Its generated library is hash-checked and unmodified. Shared graph vectors,
|
| 80 |
+
native transaction/audit tests and the prior canonical SQL cases are separate
|
| 81 |
+
evidence, not substitutes for generated acceptance.
|
| 82 |
+
|
| 83 |
+
The [generated School Facet example](examples/facet-trace/) verifies 48
|
| 84 |
+
root/nested/loaded-relation combinations twice on a retained SQLite database.
|
| 85 |
+
It covers exact/prefix operands, empty metadata, full counts despite a limit-one
|
| 86 |
+
list, exact ordered ancestry and future-binding masking. Diagnostic logging
|
| 87 |
+
on/off is distinct from its explicitly installed safe evidence collector.
|
| 88 |
+
`bash examples/facet-trace/verify.sh` rebuilds and resolves the local runtime;
|
| 89 |
+
the all-examples gate includes it and checks generated library fingerprints.
|
| 90 |
+
|
| 91 |
+
Relation assembly preserves scalar keys before hydrated references or aggregate
|
| 92 |
+
aliases replace their source fields. A reference filtered to null does not
|
| 93 |
+
remove its child from an enclosing list or break a sibling using the same FK.
|
| 94 |
+
Private per-load key capture and per-chunk snapshots cover lists and streams;
|
| 95 |
+
no key cache is added to records, mutation ledgers or UserContext. The example
|
| 96 |
+
gate runs a small real-SQLite fixture with text keys, empty parents, nested
|
| 97 |
+
graphs, filtered references and diagnostic logging on/off. These are native
|
| 98 |
+
regression cases, separate from the generated Q/E/save acceptance above.
|
| 99 |
+
|
| 100 |
+
Prepared same-type batches, complete entry-point/deep privacy coverage,
|
| 101 |
+
file-backed/Expo graph acceptance and immutable internal Registry replay remain
|
| 102 |
+
open. Verify local source with `npm test -- --runInBand` and
|
| 103 |
+
`bash scripts/verify-examples.sh` before any internal artifact or public release.
|
| 104 |
+
The 0.3.0 release is verified separately from these individual source cases;
|
| 105 |
+
no complete Trace Chain or all-provider claim is implied.
|
| 106 |
+
|
| 107 |
+
## Sensitive log data
|
| 108 |
+
|
| 109 |
+
Runtime diagnostic logs redact payload values by default, before delivery to
|
| 110 |
+
file, console, buffers, or custom logging sinks. Selecting a diagnostic sink
|
| 111 |
+
alone does not authorize plaintext. For controlled troubleshooting only:
|
| 112 |
+
|
| 113 |
+
```bash
|
| 114 |
+
export TEAQL_ALLOW_SENSITIVE_PLAINTEXT_LOGS=I_UNDERSTAND_SENSITIVE_DATA_MAY_BE_WRITTEN_TO_DISK
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
Only this exact value enables plaintext permission; empty values, `true`, and
|
| 118 |
+
whitespace variants do not. Enabling it emits a warning. Credential-classified
|
| 119 |
+
fields remain redacted. The flag does not force every sink to expose values.
|
| 120 |
+
SQL without reliable field/literal provenance may be suppressed and marked
|
| 121 |
+
`NOT REPLAYABLE`. Execution parameters and persisted business data are unchanged.
|
| 122 |
+
|
| 123 |
+
Do not put sensitive data in free-text comments or purpose declarations.
|
| 124 |
+
TeaQL cannot govern arbitrary application prints or independent driver loggers;
|
| 125 |
+
configure those separately. This setting does not erase older plaintext files.
|
| 126 |
+
Restrict access and retention when using plaintext diagnostics, then unset the
|
| 127 |
+
variable and restart processes when troubleshooting is complete.
|
| 128 |
+
|
| 129 |
+
`@teaql/teaql` is the core TypeScript runtime framework for the **TEAQL Federation Protocol (TFP)**. It provides an ultra-lightweight engine responsible for securely translating elegant chained DSLs into cross-language ASTs, allowing you to enjoy a strongly-typed, highly expressive data fetching experience on the frontend (or Node.js).
|
| 130 |
+
|
| 131 |
+
## Recommended Agent Harness
|
| 132 |
+
|
| 133 |
+
When building database-backed or federated applications with the TeaQL
|
| 134 |
+
TypeScript runtime, we recommend using it together with the [TeaQL Agent Kit](https://github.com/teaql/teaql-agent-kit).
|
| 135 |
+
The Agent Kit is TeaQL's continuously evolving **Harness Engineering** method.
|
| 136 |
+
It gives coding agents a model-mediated, executable workflow for domain
|
| 137 |
+
modeling, deterministic evaluation and repair, code generation, implementation,
|
| 138 |
+
and evidence-based verification as the generator and runtimes evolve.
|
| 139 |
+
|
| 140 |
+
## Runtime Profiles
|
| 141 |
+
|
| 142 |
+
`@teaql/teaql` uses explicit package entry points as runtime profiles. Import only the
|
| 143 |
+
profile needed by the application:
|
| 144 |
+
|
| 145 |
+
| Profile | Import | Runtime | Database driver |
|
| 146 |
+
| --- | --- | --- | --- |
|
| 147 |
+
| Browser / TFP | `@teaql/teaql` | Browser or Node HTTP client | None |
|
| 148 |
+
| PostgreSQL | `@teaql/teaql/sql/postgres` | Node.js | `pg` |
|
| 149 |
+
| MySQL | `@teaql/teaql/sql/mysql` | Node.js | `mysql2` |
|
| 150 |
+
| SQLite | `@teaql/teaql/sql/sqlite` | Node.js | `better-sqlite3` |
|
| 151 |
+
| Expo SQLite | `@teaql/teaql/sql/expo-sqlite` | React Native / Expo | `expo-sqlite` |
|
| 152 |
+
| Browser SQLite | `@teaql/teaql/sql/browser-sqlite` | Browser Web Worker | `@sqlite.org/sqlite-wasm` |
|
| 153 |
+
|
| 154 |
+
## Security Boundary
|
| 155 |
+
|
| 156 |
+
The browser/TFP profile is a client, not a key-custody service. It produces a
|
| 157 |
+
controlled AST and sends declared comment/purpose to a trusted TeaQL backend;
|
| 158 |
+
it cannot override server tenant, role, field, hard-limit, or optimistic-lock
|
| 159 |
+
policy. Browser SQLite is local application storage and does not turn the
|
| 160 |
+
browser into a public TFP server.
|
| 161 |
+
|
| 162 |
+
When a Java, Rust, Go, or .NET backend returns a TeaQL opaque entity reference,
|
| 163 |
+
TypeScript treats it as an indivisible string and returns it only for the
|
| 164 |
+
operation and purpose for which it was issued. Client code must not parse,
|
| 165 |
+
rewrite, log, or manufacture the token, and must not fall back to exposing a raw
|
| 166 |
+
internal ID/version pair. The current TypeScript profile deliberately does not
|
| 167 |
+
hold backend AES keys or provide local encode/decode APIs; this is a supported
|
| 168 |
+
frontend boundary rather than a conformance defect.
|
| 169 |
+
|
| 170 |
+
Local SQL diagnostics show expanded SQL with parameters masked by default.
|
| 171 |
+
Plaintext submitted values require the explicit, access-controlled diagnostic
|
| 172 |
+
opt-in above. The server-side envelope, golden vector, stable errors, and
|
| 173 |
+
development-only raw-reference acknowledgement are defined in the canonical
|
| 174 |
+
[opaque entity reference contract](https://github.com/teaql/teaql-conformance/blob/main/design/opaque-entity-references.md).
|
| 175 |
+
|
| 176 |
+
## Mutation Policy installation
|
| 177 |
+
|
| 178 |
+
All profiles support the same application-owned Mutation Policy identity,
|
| 179 |
+
approval, warning, and evidence contract. Node SQL and browser SQLite review a
|
| 180 |
+
complete generated graph after Checker/Fix and before the first provider
|
| 181 |
+
mutation. The TFP browser/Node client applies the policy before `fetch` as
|
| 182 |
+
defense in depth; the receiving server still performs the authoritative review.
|
| 183 |
+
|
| 184 |
+
```typescript
|
| 185 |
+
const context = new UserContext()
|
| 186 |
+
.withMutationPolicyRegistry(policyRegistry)
|
| 187 |
+
.withMutationPolicyApprovalProvider(approvalProvider)
|
| 188 |
+
.withMutationGovernanceSink(warningSink);
|
| 189 |
+
|
| 190 |
+
client.setUserContext(context);
|
| 191 |
+
```
|
| 192 |
+
|
| 193 |
+
A customer policy denial reaches neither SQL, the browser SQLite worker, nor a
|
| 194 |
+
TFP mutation request. Missing customer policy or exact approval uses stable
|
| 195 |
+
warning codes and remains fail-open, while explicit denial and incomplete graph
|
| 196 |
+
plans fail closed. Policy implementations are installed only through trusted
|
| 197 |
+
context assembly and are never accepted from JSON or TFP payloads.
|
| 198 |
+
|
| 199 |
+
### Browser / TFP profile
|
| 200 |
+
|
| 201 |
+
The default entry point contains the AST, Peggy-generated controlled query
|
| 202 |
+
parser, and TFP HTTP client. It does not import or bundle PostgreSQL, MySQL, or
|
| 203 |
+
SQLite drivers.
|
| 204 |
+
|
| 205 |
+
```bash
|
| 206 |
+
npm install @teaql/teaql
|
| 207 |
+
```
|
| 208 |
+
|
| 209 |
+
```typescript
|
| 210 |
+
import { SelectQuery, TeaQLClient } from "@teaql/teaql";
|
| 211 |
+
|
| 212 |
+
const client = new TeaQLClient({ baseUrl: "/api/teaql" });
|
| 213 |
+
const tasks = await client.executeQuery(
|
| 214 |
+
new SelectQuery("Task")
|
| 215 |
+
.comment("task board initial load")
|
| 216 |
+
.limit(20)
|
| 217 |
+
.purpose("show current tasks"),
|
| 218 |
+
);
|
| 219 |
+
```
|
| 220 |
+
|
| 221 |
+
Database drivers are optional peer dependencies. A browser application should
|
| 222 |
+
import only from `@teaql/teaql` and should not install a SQL driver package.
|
| 223 |
+
|
| 224 |
+
### Node SQL profiles
|
| 225 |
+
|
| 226 |
+
Install only the driver selected by the service:
|
| 227 |
+
|
| 228 |
+
```bash
|
| 229 |
+
# PostgreSQL
|
| 230 |
+
npm install @teaql/teaql pg
|
| 231 |
+
|
| 232 |
+
# MySQL
|
| 233 |
+
npm install @teaql/teaql mysql2
|
| 234 |
+
|
| 235 |
+
# SQLite
|
| 236 |
+
npm install @teaql/teaql better-sqlite3
|
| 237 |
+
```
|
| 238 |
+
|
| 239 |
+
Use the matching subpath when building a runtime manually. `ENTITY_SCHEMAS` is
|
| 240 |
+
normally generated by `teaql-code-gen`:
|
| 241 |
+
|
| 242 |
+
```typescript
|
| 243 |
+
import { PostgreSQLTeaQLClient } from "@teaql/teaql/sql/postgres";
|
| 244 |
+
import { ENTITY_SCHEMAS } from "./teaql-node-sql";
|
| 245 |
+
|
| 246 |
+
const client = new PostgreSQLTeaQLClient(
|
| 247 |
+
process.env.DATABASE_URL!,
|
| 248 |
+
ENTITY_SCHEMAS,
|
| 249 |
+
);
|
| 250 |
+
const ctx = { client };
|
| 251 |
+
```
|
| 252 |
+
|
| 253 |
+
The MySQL and SQLite forms are identical apart from the selected profile:
|
| 254 |
+
|
| 255 |
+
```typescript
|
| 256 |
+
import { MySQLTeaQLClient } from "@teaql/teaql/sql/mysql";
|
| 257 |
+
import { SQLiteTeaQLClient } from "@teaql/teaql/sql/sqlite";
|
| 258 |
+
```
|
| 259 |
+
|
| 260 |
+
Generated Node projects wrap these classes in `teaql-node-postgres.ts`,
|
| 261 |
+
`teaql-node-mysql.ts`, or `teaql-node-sqlite.ts`, so application code normally
|
| 262 |
+
imports the generated wrapper and does not pass `ENTITY_SCHEMAS` itself.
|
| 263 |
+
|
| 264 |
+
In a TeaQL model, `data_service="postgres"`, `data_service="mysql"`, or
|
| 265 |
+
`data_service="sqlite"` selects the corresponding generated SQL profile. The
|
| 266 |
+
regular TypeScript/browser generation profile continues to use TFP and has no
|
| 267 |
+
database-driver import.
|
| 268 |
+
|
| 269 |
+
### React Native / Expo SQLite profile
|
| 270 |
+
|
| 271 |
+
Generated `typescript-app-expo` workspaces open and ensure their local schema
|
| 272 |
+
on first launch, so a new user does not need to download or prepare a database
|
| 273 |
+
file. The generated schema remains the source of truth:
|
| 274 |
+
|
| 275 |
+
```typescript
|
| 276 |
+
import * as SQLite from "expo-sqlite";
|
| 277 |
+
import { ExpoSQLiteTeaQLClient } from "@teaql/teaql/sql/expo-sqlite";
|
| 278 |
+
import { ENTITY_SCHEMAS } from "./teaql-expo-sql";
|
| 279 |
+
|
| 280 |
+
const database = await SQLite.openDatabaseAsync("order-management.db");
|
| 281 |
+
const client = new ExpoSQLiteTeaQLClient(database, ENTITY_SCHEMAS);
|
| 282 |
+
```
|
| 283 |
+
|
| 284 |
+
Local queries still require `comment(...)` and `purpose(...)`, and saves still
|
| 285 |
+
require an audit reason. The same generated model can instead use the default
|
| 286 |
+
TFP client for authenticated server queries. Tenant, user, permission, purpose
|
| 287 |
+
policy, hard-limit policy, and continuous-page cursor policy must be supplied
|
| 288 |
+
by trusted runtime context; they are not accepted from federation JSON.
|
| 289 |
+
|
| 290 |
+
### Browser SQLite/WASM profile
|
| 291 |
+
|
| 292 |
+
Browser-local applications can execute the same generated Q API, E API,
|
| 293 |
+
Checker/Fix rules, audited mutations, and Runtime Module bootstrap without a
|
| 294 |
+
backend. Install the official SQLite/WASM package and create an
|
| 295 |
+
application-owned worker entry point so bundlers can package the worker and
|
| 296 |
+
WASM assets correctly:
|
| 297 |
+
|
| 298 |
+
```bash
|
| 299 |
+
npm install @teaql/teaql @sqlite.org/sqlite-wasm
|
| 300 |
+
```
|
| 301 |
+
|
| 302 |
+
```typescript title="sqlite.worker.ts"
|
| 303 |
+
import sqliteWasmUrl from "@sqlite.org/sqlite-wasm/sqlite3.wasm?url";
|
| 304 |
+
import { startBrowserSQLiteWorker } from "@teaql/teaql/sql/browser-sqlite-worker";
|
| 305 |
+
|
| 306 |
+
startBrowserSQLiteWorker({ wasmUrl: sqliteWasmUrl });
|
| 307 |
+
```
|
| 308 |
+
|
| 309 |
+
```typescript
|
| 310 |
+
import { BrowserSQLiteTeaQLClient } from "@teaql/teaql/sql/browser-sqlite";
|
| 311 |
+
|
| 312 |
+
const worker = new Worker(new URL("./sqlite.worker.ts", import.meta.url), {
|
| 313 |
+
type: "module",
|
| 314 |
+
});
|
| 315 |
+
const client = await BrowserSQLiteTeaQLClient.open(worker, ENTITY_SCHEMAS, {
|
| 316 |
+
storage: "memory", // deterministic default; use "opfs" only by explicit choice
|
| 317 |
+
});
|
| 318 |
+
client.install(GENERATED_RUNTIME_MODULE);
|
| 319 |
+
const context = new UserContext().insertResource("dataService", client);
|
| 320 |
+
client.setUserContext(context);
|
| 321 |
+
await context.ensureSchema();
|
| 322 |
+
```
|
| 323 |
+
|
| 324 |
+
`client.reset(context)` drops browser-local tables, explicitly reconciles the
|
| 325 |
+
schema again, and runs the generated mutation bootstrap. OPFS requires the
|
| 326 |
+
COOP/COEP headers documented by SQLite. The first browser profile deliberately
|
| 327 |
+
buffers stream results and does not promise multi-tab database coordination.
|
| 328 |
+
It is intended for Playground, offline, and local-data scenarios—not as a
|
| 329 |
+
trusted authorization boundary for tenant or permission enforcement.
|
| 330 |
+
|
| 331 |
+
See [`examples/browser-sqlite`](./examples/browser-sqlite) for the executable
|
| 332 |
+
memory, OPFS, Mutation Policy, generated-mutation seed, Q API, and reset
|
| 333 |
+
verification.
|
| 334 |
+
|
| 335 |
+
## Generated query and mutation APIs
|
| 336 |
+
|
| 337 |
+
See the [README examples](README.md#query-and-read-the-result) for generated
|
| 338 |
+
Q/E and audited Save usage. Always supply non-empty comment and purpose;
|
| 339 |
+
load complete fields before modifying a persisted object. `QueryParser` returns
|
| 340 |
+
a controlled request, not arbitrary executable JavaScript. Supply the generated
|
| 341 |
+
Q entry point and an intentional, bounded query before executing it.
|
| 342 |
+
|
| 343 |
+
## 📂 Project Architecture and Domain Examples
|
| 344 |
+
|
| 345 |
+
Architecturally, `@teaql/teaql` adheres to the philosophy of absolute isolation between the **Framework Layer** and the **Business Layer**. The `src` directory in this repository is the pure, uncontaminated core engine, while all practical business demonstrations are divided by domain in the `examples` directory.
|
| 346 |
+
|
| 347 |
+
```text
|
| 348 |
+
teaql-ts/
|
| 349 |
+
├── src/ # [Framework Layer] Pure core engine, no business code
|
| 350 |
+
│ ├── core/ # AST definitions
|
| 351 |
+
│ ├── parser/ # DSL reflection and secure interpreter
|
| 352 |
+
│ ├── tfp/ # Federation network transport protocol layer
|
| 353 |
+
│ └── sql/ # Explicit Node, Expo and browser SQLite profiles
|
| 354 |
+
│
|
| 355 |
+
└── examples/ # [Business Example Layer] Integrated demos for various use cases
|
| 356 |
+
│
|
| 357 |
+
├── task-board/ # Example 1: Task Board System Domain
|
| 358 |
+
│ ├── ts-lib-core/ # Strongly-typed domain models generated by the code generator (e.g. Task, Q.ts)
|
| 359 |
+
│ ├── app-dynamic/ # Runtime Demo based on dynamic string parsing
|
| 360 |
+
│ └── app-native/ # Demo based on fluent hardcoded API
|
| 361 |
+
│
|
| 362 |
+
└── ecommerce-system/ # Example 2: [Planned] E-commerce System Example
|
| 363 |
+
```
|
source/teaql-ts/docs/releases/0.3.1.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TypeScript 0.3.1
|
| 2 |
+
|
| 3 |
+
Tracking: [TypeScript #51](https://github.com/teaql/teaql-ts/issues/51) and
|
| 4 |
+
[conformance #109](https://github.com/teaql/teaql-conformance/issues/109).
|
| 5 |
+
|
| 6 |
+
The optional Node standard telemetry module uses trusted environment activation
|
| 7 |
+
and reports enabled/disabled startup settings. Supported runtime operations
|
| 8 |
+
produce full safe traces, metrics and logs without per-method instrumentation.
|
| 9 |
+
Expanded SQL stays masked, and each completion carries its own physical identity.
|
| 10 |
+
Owned SDK queues, acknowledgement handling and finite shutdown preserve customer
|
| 11 |
+
globals, business outcomes and independent audit.
|
| 12 |
+
|
| 13 |
+
Node telemetry is not enabled in browser SQLite or Expo. Regenerate libraries to
|
| 14 |
+
retire the separate page terminal and adopt the current request-tree/search metadata;
|
| 15 |
+
use ordinary list execution with offset/limit and explicit count when needed.
|
| 16 |
+
|
| 17 |
+
The conformance `2026-10-13-standard-telemetry-onboarding` report retains source and
|
| 18 |
+
internal-candidate tests. Signed-tag, final-package and public-consumer verification
|
| 19 |
+
are separate gates, not inferred from those candidate results.
|
source/teaql-ts/examples/browser-sqlite/README.md
CHANGED
|
@@ -6,6 +6,12 @@ dedicated browser worker. It includes deterministic, internally consistent demo
|
|
| 6 |
data and thirteen runnable examples organized as basic, aggregate, filtered,
|
| 7 |
and dynamic queries.
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
`OrderStatus` is a seventh, constant model object rather than a string field.
|
| 10 |
Its five fixed values are reconciled through `RuntimeModule` bootstrap, orders
|
| 11 |
store the status object ID, and generated Q expressions select, filter, and
|
|
@@ -41,8 +47,8 @@ page query.
|
|
| 41 |
The order-center projection intentionally contains only the four visible table
|
| 42 |
columns: order number, order date, the `OrderStatus` object, and item preview.
|
| 43 |
It does not load Platform or Customer. The Q chain follows the page vertically:
|
| 44 |
-
dynamic filter, `countAs('totalOrders')`, status facet, four table projections,
|
| 45 |
-
execution.
|
| 46 |
|
| 47 |
```bash
|
| 48 |
npm install
|
|
|
|
| 6 |
data and thirteen runnable examples organized as basic, aggregate, filtered,
|
| 7 |
and dynamic queries.
|
| 8 |
|
| 9 |
+
This page executes the TeaQL TypeScript runtime and SQLite/WASM directly in the
|
| 10 |
+
browser. The model-driven Q and TraceChain contract is also implemented by the
|
| 11 |
+
Java, Rust, Go, Python, .NET and Swift runtimes. The seven-language strip links
|
| 12 |
+
to each runtime source and marks TypeScript as the current browser runtime; it
|
| 13 |
+
does not imply that selecting another link swaps the page's execution engine.
|
| 14 |
+
|
| 15 |
`OrderStatus` is a seventh, constant model object rather than a string field.
|
| 16 |
Its five fixed values are reconciled through `RuntimeModule` bootstrap, orders
|
| 17 |
store the status object ID, and generated Q expressions select, filter, and
|
|
|
|
| 47 |
The order-center projection intentionally contains only the four visible table
|
| 48 |
columns: order number, order date, the `OrderStatus` object, and item preview.
|
| 49 |
It does not load Platform or Customer. The Q chain follows the page vertically:
|
| 50 |
+
dynamic filter, `countAs('totalOrders')`, status facet, four table projections,
|
| 51 |
+
then bounded `offset` / `limit` list execution.
|
| 52 |
|
| 53 |
```bash
|
| 54 |
npm install
|
source/teaql-ts/examples/browser-sqlite/index.html
CHANGED
|
@@ -48,6 +48,51 @@
|
|
| 48 |
</div>
|
| 49 |
</section>
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
<section class="runtime-bar" aria-label="Runtime settings">
|
| 52 |
<p id="status" role="status">Starting SQLite/WASM…</p>
|
| 53 |
<div class="controls">
|
|
|
|
| 48 |
</div>
|
| 49 |
</section>
|
| 50 |
|
| 51 |
+
<section class="runtime-language-panel" aria-labelledby="runtime-language-title">
|
| 52 |
+
<div class="runtime-language-copy">
|
| 53 |
+
<p class="section-index" data-i18n="runtimeCoverage">RUNTIME COVERAGE</p>
|
| 54 |
+
<h2 id="runtime-language-title" data-i18n="runtimeTitle">This demo runs TypeScript in your browser.</h2>
|
| 55 |
+
<p data-i18n="runtimeIntro">The same model-driven Q and TraceChain contract is supported by seven TeaQL runtimes. Select a language to inspect its runtime source.</p>
|
| 56 |
+
</div>
|
| 57 |
+
<nav class="runtime-language-selector" aria-label="TeaQL runtimes">
|
| 58 |
+
<a class="runtime-language active" href="https://github.com/teaql/teaql-ts" target="_blank" rel="noreferrer" aria-current="true">
|
| 59 |
+
<span class="runtime-language-icon" aria-hidden="true">📘</span>
|
| 60 |
+
<strong>TypeScript</strong>
|
| 61 |
+
<small data-i18n="currentBrowserRuntime">Current browser runtime</small>
|
| 62 |
+
</a>
|
| 63 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-java" target="_blank" rel="noreferrer">
|
| 64 |
+
<span class="runtime-language-icon" aria-hidden="true">☕</span>
|
| 65 |
+
<strong>Java</strong>
|
| 66 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 67 |
+
</a>
|
| 68 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-rs" target="_blank" rel="noreferrer">
|
| 69 |
+
<span class="runtime-language-icon" aria-hidden="true">🦀</span>
|
| 70 |
+
<strong>Rust</strong>
|
| 71 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 72 |
+
</a>
|
| 73 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-golang" target="_blank" rel="noreferrer">
|
| 74 |
+
<span class="runtime-language-icon" aria-hidden="true">🐹</span>
|
| 75 |
+
<strong>Go</strong>
|
| 76 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 77 |
+
</a>
|
| 78 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-python" target="_blank" rel="noreferrer">
|
| 79 |
+
<span class="runtime-language-icon" aria-hidden="true">🐍</span>
|
| 80 |
+
<strong>Python</strong>
|
| 81 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 82 |
+
</a>
|
| 83 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-dotnet" target="_blank" rel="noreferrer">
|
| 84 |
+
<span class="runtime-language-icon" aria-hidden="true">🎯</span>
|
| 85 |
+
<strong>.NET / C#</strong>
|
| 86 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 87 |
+
</a>
|
| 88 |
+
<a class="runtime-language" href="https://github.com/teaql/teaql-swift" target="_blank" rel="noreferrer">
|
| 89 |
+
<span class="runtime-language-icon" aria-hidden="true">🐦</span>
|
| 90 |
+
<strong>Swift</strong>
|
| 91 |
+
<small data-i18n="supportedRuntime">Supported runtime</small>
|
| 92 |
+
</a>
|
| 93 |
+
</nav>
|
| 94 |
+
</section>
|
| 95 |
+
|
| 96 |
<section class="runtime-bar" aria-label="Runtime settings">
|
| 97 |
<p id="status" role="status">Starting SQLite/WASM…</p>
|
| 98 |
<div class="controls">
|
source/teaql-ts/examples/browser-sqlite/package-lock.json
CHANGED
|
@@ -19,18 +19,21 @@
|
|
| 19 |
},
|
| 20 |
"../..": {
|
| 21 |
"name": "@teaql/teaql",
|
| 22 |
-
"version": "0.3.
|
| 23 |
"license": "Apache-2.0",
|
| 24 |
"dependencies": {
|
| 25 |
"node-fetch": "^2.7.0"
|
| 26 |
},
|
| 27 |
"devDependencies": {
|
|
|
|
|
|
|
| 28 |
"@opentelemetry/api-logs": "^0.221.0",
|
| 29 |
"@opentelemetry/context-async-hooks": "^2.10.0",
|
| 30 |
"@opentelemetry/core": "^2.10.0",
|
| 31 |
"@opentelemetry/exporter-logs-otlp-http": "^0.221.0",
|
| 32 |
"@opentelemetry/exporter-metrics-otlp-http": "^0.221.0",
|
| 33 |
"@opentelemetry/exporter-trace-otlp-http": "^0.221.0",
|
|
|
|
| 34 |
"@opentelemetry/resources": "^2.10.0",
|
| 35 |
"@opentelemetry/sdk-logs": "^0.221.0",
|
| 36 |
"@opentelemetry/sdk-metrics": "^2.10.0",
|
|
@@ -52,8 +55,20 @@
|
|
| 52 |
"typescript": "5.4.5"
|
| 53 |
},
|
| 54 |
"peerDependencies": {
|
|
|
|
|
|
|
| 55 |
"@opentelemetry/api": "^1.9.1",
|
| 56 |
"@opentelemetry/api-logs": "^0.221.0",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
"@sqlite.org/sqlite-wasm": "3.53.0-build1",
|
| 58 |
"better-sqlite3": "^12.10.0",
|
| 59 |
"expo-sqlite": "*",
|
|
@@ -62,12 +77,48 @@
|
|
| 62 |
"pg-query-stream": "^4.7.0"
|
| 63 |
},
|
| 64 |
"peerDependenciesMeta": {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
"@opentelemetry/api": {
|
| 66 |
"optional": true
|
| 67 |
},
|
| 68 |
"@opentelemetry/api-logs": {
|
| 69 |
"optional": true
|
| 70 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
"@sqlite.org/sqlite-wasm": {
|
| 72 |
"optional": true
|
| 73 |
},
|
|
|
|
| 19 |
},
|
| 20 |
"../..": {
|
| 21 |
"name": "@teaql/teaql",
|
| 22 |
+
"version": "0.3.1",
|
| 23 |
"license": "Apache-2.0",
|
| 24 |
"dependencies": {
|
| 25 |
"node-fetch": "^2.7.0"
|
| 26 |
},
|
| 27 |
"devDependencies": {
|
| 28 |
+
"@aws-sdk/client-s3": "3.1151.0",
|
| 29 |
+
"@aws-sdk/s3-request-presigner": "3.1151.0",
|
| 30 |
"@opentelemetry/api-logs": "^0.221.0",
|
| 31 |
"@opentelemetry/context-async-hooks": "^2.10.0",
|
| 32 |
"@opentelemetry/core": "^2.10.0",
|
| 33 |
"@opentelemetry/exporter-logs-otlp-http": "^0.221.0",
|
| 34 |
"@opentelemetry/exporter-metrics-otlp-http": "^0.221.0",
|
| 35 |
"@opentelemetry/exporter-trace-otlp-http": "^0.221.0",
|
| 36 |
+
"@opentelemetry/otlp-transformer": "0.221.0",
|
| 37 |
"@opentelemetry/resources": "^2.10.0",
|
| 38 |
"@opentelemetry/sdk-logs": "^0.221.0",
|
| 39 |
"@opentelemetry/sdk-metrics": "^2.10.0",
|
|
|
|
| 55 |
"typescript": "5.4.5"
|
| 56 |
},
|
| 57 |
"peerDependencies": {
|
| 58 |
+
"@aws-sdk/client-s3": "3.1151.0",
|
| 59 |
+
"@aws-sdk/s3-request-presigner": "3.1151.0",
|
| 60 |
"@opentelemetry/api": "^1.9.1",
|
| 61 |
"@opentelemetry/api-logs": "^0.221.0",
|
| 62 |
+
"@opentelemetry/context-async-hooks": "^2.10.0",
|
| 63 |
+
"@opentelemetry/core": "^2.10.0",
|
| 64 |
+
"@opentelemetry/exporter-logs-otlp-http": "^0.221.0",
|
| 65 |
+
"@opentelemetry/exporter-metrics-otlp-http": "^0.221.0",
|
| 66 |
+
"@opentelemetry/exporter-trace-otlp-http": "^0.221.0",
|
| 67 |
+
"@opentelemetry/otlp-transformer": "0.221.0",
|
| 68 |
+
"@opentelemetry/resources": "^2.10.0",
|
| 69 |
+
"@opentelemetry/sdk-logs": "^0.221.0",
|
| 70 |
+
"@opentelemetry/sdk-metrics": "^2.10.0",
|
| 71 |
+
"@opentelemetry/sdk-trace-base": "^2.10.0",
|
| 72 |
"@sqlite.org/sqlite-wasm": "3.53.0-build1",
|
| 73 |
"better-sqlite3": "^12.10.0",
|
| 74 |
"expo-sqlite": "*",
|
|
|
|
| 77 |
"pg-query-stream": "^4.7.0"
|
| 78 |
},
|
| 79 |
"peerDependenciesMeta": {
|
| 80 |
+
"@aws-sdk/client-s3": {
|
| 81 |
+
"optional": true
|
| 82 |
+
},
|
| 83 |
+
"@aws-sdk/s3-request-presigner": {
|
| 84 |
+
"optional": true
|
| 85 |
+
},
|
| 86 |
"@opentelemetry/api": {
|
| 87 |
"optional": true
|
| 88 |
},
|
| 89 |
"@opentelemetry/api-logs": {
|
| 90 |
"optional": true
|
| 91 |
},
|
| 92 |
+
"@opentelemetry/context-async-hooks": {
|
| 93 |
+
"optional": true
|
| 94 |
+
},
|
| 95 |
+
"@opentelemetry/core": {
|
| 96 |
+
"optional": true
|
| 97 |
+
},
|
| 98 |
+
"@opentelemetry/exporter-logs-otlp-http": {
|
| 99 |
+
"optional": true
|
| 100 |
+
},
|
| 101 |
+
"@opentelemetry/exporter-metrics-otlp-http": {
|
| 102 |
+
"optional": true
|
| 103 |
+
},
|
| 104 |
+
"@opentelemetry/exporter-trace-otlp-http": {
|
| 105 |
+
"optional": true
|
| 106 |
+
},
|
| 107 |
+
"@opentelemetry/otlp-transformer": {
|
| 108 |
+
"optional": true
|
| 109 |
+
},
|
| 110 |
+
"@opentelemetry/resources": {
|
| 111 |
+
"optional": true
|
| 112 |
+
},
|
| 113 |
+
"@opentelemetry/sdk-logs": {
|
| 114 |
+
"optional": true
|
| 115 |
+
},
|
| 116 |
+
"@opentelemetry/sdk-metrics": {
|
| 117 |
+
"optional": true
|
| 118 |
+
},
|
| 119 |
+
"@opentelemetry/sdk-trace-base": {
|
| 120 |
+
"optional": true
|
| 121 |
+
},
|
| 122 |
"@sqlite.org/sqlite-wasm": {
|
| 123 |
"optional": true
|
| 124 |
},
|
source/teaql-ts/examples/browser-sqlite/scripts/smoke.mjs
CHANGED
|
@@ -65,6 +65,20 @@ try {
|
|
| 65 |
if (defaultLocale.lang !== 'en' || defaultLocale.title !== 'Choose a query' || !defaultLocale.englishActive) {
|
| 66 |
throw new Error(`English was not the default locale: ${JSON.stringify(defaultLocale)}`);
|
| 67 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
if (!firstStatus.includes('policy installed')) {
|
| 69 |
throw new Error(`Browser runtime did not install Mutation Policy: ${firstStatus}`);
|
| 70 |
}
|
|
@@ -184,7 +198,9 @@ try {
|
|
| 184 |
|| !dashboardQuery.includes(".sumOrderTotalAmountAs('orderTotalAmount')")
|
| 185 |
|| !dashboardQuery.includes(".facetByStatusAs('statusCounts'")
|
| 186 |
|| !dashboardQuery.includes('.filterByJson(searchParams)')
|
| 187 |
-
|| !dashboardQuery.includes('.
|
|
|
|
|
|
|
| 188 |
|| dashboardQuery.includes('new SelectQuery')
|
| 189 |
|| dashboardQuery.includes('.selectCode()')
|
| 190 |
|| dashboardQuery.includes('Q.orderStatuses()\n')
|
|
@@ -208,7 +224,9 @@ try {
|
|
| 208 |
'.selectOrderDate()',
|
| 209 |
'.selectStatusWith(',
|
| 210 |
'.selectItemListWith(',
|
| 211 |
-
'.
|
|
|
|
|
|
|
| 212 |
].map(fragment => dashboardQuery.indexOf(fragment));
|
| 213 |
if (visualQueryOrder.some(index => index < 0)
|
| 214 |
|| visualQueryOrder.some((index, position) => position > 0 && index <= visualQueryOrder[position - 1])) {
|
|
@@ -323,12 +341,16 @@ try {
|
|
| 323 |
&& document.querySelector('#result-title')?.textContent === '动态:字段白名单');
|
| 324 |
const chineseLocale = await page.evaluate(() => ({
|
| 325 |
title: document.querySelector('#query-browser-title')?.textContent || '',
|
|
|
|
|
|
|
| 326 |
evidenceTitle: document.querySelector('.sql-card-heading .query-card-label')?.textContent || '',
|
| 327 |
evidenceColumns: [...document.querySelectorAll('.execution-evidence th')].map(element => element.textContent || ''),
|
| 328 |
executionId: document.querySelector('.evidence-time')?.dataset.executedAt || '',
|
| 329 |
rows: [...document.querySelectorAll('#sql-output .evidence-row')].map(element => element.textContent || ''),
|
| 330 |
}));
|
| 331 |
if (chineseLocale.title !== '选择一个查询'
|
|
|
|
|
|
|
| 332 |
|| chineseLocale.evidenceTitle !== '执行证据'
|
| 333 |
|| chineseLocale.evidenceColumns.join('|') !== '时间|身份|追踪链|SQL'
|
| 334 |
|| chineseLocale.executionId !== beforeLocaleSwitch.executionId
|
|
|
|
| 65 |
if (defaultLocale.lang !== 'en' || defaultLocale.title !== 'Choose a query' || !defaultLocale.englishActive) {
|
| 66 |
throw new Error(`English was not the default locale: ${JSON.stringify(defaultLocale)}`);
|
| 67 |
}
|
| 68 |
+
const runtimeLanguages = await page.evaluate(() => ({
|
| 69 |
+
title: document.querySelector('#runtime-language-title')?.textContent || '',
|
| 70 |
+
links: [...document.querySelectorAll('.runtime-language')].map(element => ({
|
| 71 |
+
name: element.querySelector('strong')?.textContent || '',
|
| 72 |
+
href: element.getAttribute('href') || '',
|
| 73 |
+
active: element.classList.contains('active'),
|
| 74 |
+
})),
|
| 75 |
+
}));
|
| 76 |
+
if (runtimeLanguages.title !== 'This demo runs TypeScript in your browser.'
|
| 77 |
+
|| runtimeLanguages.links.length !== 7
|
| 78 |
+
|| runtimeLanguages.links.filter(language => language.active).map(language => language.name).join() !== 'TypeScript'
|
| 79 |
+
|| runtimeLanguages.links.some(language => !language.href.startsWith('https://github.com/teaql/'))) {
|
| 80 |
+
throw new Error(`Seven-runtime selector is incomplete: ${JSON.stringify(runtimeLanguages)}`);
|
| 81 |
+
}
|
| 82 |
if (!firstStatus.includes('policy installed')) {
|
| 83 |
throw new Error(`Browser runtime did not install Mutation Policy: ${firstStatus}`);
|
| 84 |
}
|
|
|
|
| 198 |
|| !dashboardQuery.includes(".sumOrderTotalAmountAs('orderTotalAmount')")
|
| 199 |
|| !dashboardQuery.includes(".facetByStatusAs('statusCounts'")
|
| 200 |
|| !dashboardQuery.includes('.filterByJson(searchParams)')
|
| 201 |
+
|| !dashboardQuery.includes('.offset(pageOffset)')
|
| 202 |
+
|| !dashboardQuery.includes('.limit(pageSize)')
|
| 203 |
+
|| !dashboardQuery.includes('.executeForList(ctx)')
|
| 204 |
|| dashboardQuery.includes('new SelectQuery')
|
| 205 |
|| dashboardQuery.includes('.selectCode()')
|
| 206 |
|| dashboardQuery.includes('Q.orderStatuses()\n')
|
|
|
|
| 224 |
'.selectOrderDate()',
|
| 225 |
'.selectStatusWith(',
|
| 226 |
'.selectItemListWith(',
|
| 227 |
+
'.offset(pageOffset)',
|
| 228 |
+
'.limit(pageSize)',
|
| 229 |
+
'.executeForList(ctx)',
|
| 230 |
].map(fragment => dashboardQuery.indexOf(fragment));
|
| 231 |
if (visualQueryOrder.some(index => index < 0)
|
| 232 |
|| visualQueryOrder.some((index, position) => position > 0 && index <= visualQueryOrder[position - 1])) {
|
|
|
|
| 341 |
&& document.querySelector('#result-title')?.textContent === '动态:字段白名单');
|
| 342 |
const chineseLocale = await page.evaluate(() => ({
|
| 343 |
title: document.querySelector('#query-browser-title')?.textContent || '',
|
| 344 |
+
runtimeTitle: document.querySelector('#runtime-language-title')?.textContent || '',
|
| 345 |
+
currentRuntime: document.querySelector('.runtime-language.active small')?.textContent || '',
|
| 346 |
evidenceTitle: document.querySelector('.sql-card-heading .query-card-label')?.textContent || '',
|
| 347 |
evidenceColumns: [...document.querySelectorAll('.execution-evidence th')].map(element => element.textContent || ''),
|
| 348 |
executionId: document.querySelector('.evidence-time')?.dataset.executedAt || '',
|
| 349 |
rows: [...document.querySelectorAll('#sql-output .evidence-row')].map(element => element.textContent || ''),
|
| 350 |
}));
|
| 351 |
if (chineseLocale.title !== '选择一个查询'
|
| 352 |
+
|| chineseLocale.runtimeTitle !== '这个演示在浏览器中运行 TypeScript。'
|
| 353 |
+
|| chineseLocale.currentRuntime !== '当前浏览器 runtime'
|
| 354 |
|| chineseLocale.evidenceTitle !== '执行证据'
|
| 355 |
|| chineseLocale.evidenceColumns.join('|') !== '时间|身份|追踪链|SQL'
|
| 356 |
|| chineseLocale.executionId !== beforeLocaleSwitch.executionId
|
source/teaql-ts/examples/browser-sqlite/src/generated/Q.ts
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
| 6 |
UserContext,
|
| 7 |
executeRelationFacets,
|
| 8 |
type QueryOperation,
|
| 9 |
-
type TeaQLPage,
|
| 10 |
} from 'teaql-ts';
|
| 11 |
import { ORDER_STATUS } from '../order-model';
|
| 12 |
|
|
@@ -103,48 +102,38 @@ abstract class GeneratedRequest {
|
|
| 103 |
}
|
| 104 |
|
| 105 |
async executeForList(context: UserContext): Promise<SmartList<Row>> {
|
| 106 |
-
this.
|
| 107 |
-
const service = this.service(context);
|
| 108 |
-
const query = this.toQuery();
|
| 109 |
-
const rows = await service.executeQuery<Row>(context.prepareQuery(query));
|
| 110 |
-
const data = new SmartList(rows);
|
| 111 |
-
if (query.facets.length) {
|
| 112 |
-
data.facets = await executeRelationFacets(
|
| 113 |
-
service, nested => context.prepareQuery(nested), query, query.facets,
|
| 114 |
-
);
|
| 115 |
-
}
|
| 116 |
-
return data;
|
| 117 |
}
|
| 118 |
|
| 119 |
async executeForRows(context: UserContext): Promise<SmartList<Row>> {
|
| 120 |
-
return this.
|
| 121 |
}
|
| 122 |
|
| 123 |
-
async
|
| 124 |
this.ensureIntent();
|
| 125 |
const service = this.service(context);
|
| 126 |
-
const
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
const totalCount = await service.executeCount(
|
| 130 |
-
countQuery,
|
| 131 |
this.pageTotalAlias,
|
| 132 |
-
this.pageTotalAlias
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
)
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
);
|
| 141 |
-
if (
|
| 142 |
-
|
|
|
|
|
|
|
| 143 |
data.facets = await executeRelationFacets(
|
| 144 |
-
service, nested => context.prepareQuery(nested),
|
| 145 |
);
|
| 146 |
}
|
| 147 |
-
return
|
| 148 |
}
|
| 149 |
protected addFilter(filter: unknown): this { this.filters.push(filter); return this; }
|
| 150 |
protected select(...fields: string[]): this { this.query.select(fields); return this; }
|
|
@@ -390,22 +379,13 @@ export class CustomerOrderRequest extends GeneratedRequest {
|
|
| 390 |
averageTotalAmountAs(alias: string): this { return this.aggregate('Avg', 'totalAmount', alias); }
|
| 391 |
|
| 392 |
override executeForList(context: UserContext): Promise<SmartList<Row>> {
|
| 393 |
-
this.
|
| 394 |
return super.executeForList(context);
|
| 395 |
}
|
| 396 |
|
| 397 |
override executeForRows(context: UserContext): Promise<SmartList<Row>> {
|
| 398 |
this.applyRowCount();
|
| 399 |
-
return super.
|
| 400 |
-
}
|
| 401 |
-
|
| 402 |
-
override executeForPage(
|
| 403 |
-
context: UserContext,
|
| 404 |
-
offset: number,
|
| 405 |
-
limit: number,
|
| 406 |
-
): Promise<TeaQLPage<Row>> {
|
| 407 |
-
if (this.countAlias) this.includePageTotalAs(this.countAlias);
|
| 408 |
-
return super.executeForPage(context, offset, limit);
|
| 409 |
}
|
| 410 |
|
| 411 |
private applyRowCount(): void {
|
|
|
|
| 6 |
UserContext,
|
| 7 |
executeRelationFacets,
|
| 8 |
type QueryOperation,
|
|
|
|
| 9 |
} from 'teaql-ts';
|
| 10 |
import { ORDER_STATUS } from '../order-model';
|
| 11 |
|
|
|
|
| 102 |
}
|
| 103 |
|
| 104 |
async executeForList(context: UserContext): Promise<SmartList<Row>> {
|
| 105 |
+
return this.executeList(context, this.pageTotalAlias !== undefined);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
}
|
| 107 |
|
| 108 |
async executeForRows(context: UserContext): Promise<SmartList<Row>> {
|
| 109 |
+
return this.executeList(context, false);
|
| 110 |
}
|
| 111 |
|
| 112 |
+
private async executeList(context: UserContext, counted: boolean): Promise<SmartList<Row>> {
|
| 113 |
this.ensureIntent();
|
| 114 |
const service = this.service(context);
|
| 115 |
+
const query = this.toQuery();
|
| 116 |
+
const totalCount = counted ? await service.executeCount(
|
| 117 |
+
query,
|
|
|
|
|
|
|
| 118 |
this.pageTotalAlias,
|
| 119 |
+
{ kind: 'named-count', method: 'countAs', alias: this.pageTotalAlias },
|
| 120 |
+
) : undefined;
|
| 121 |
+
const rowsQuery = query.clone();
|
| 122 |
+
if (counted) {
|
| 123 |
+
rowsQuery.aggregateItems = rowsQuery.aggregateItems.filter(item =>
|
| 124 |
+
!(String(item.function).toLowerCase() === 'count' && item.alias === this.pageTotalAlias));
|
| 125 |
+
}
|
| 126 |
+
const rows = await service.executeQuery<Row>(context.prepareQuery(rowsQuery));
|
| 127 |
+
const data = new SmartList(rows, { totalCount });
|
| 128 |
+
if (counted && this.pageTotalAlias !== undefined) {
|
| 129 |
+
data.aggregations[this.pageTotalAlias] = totalCount;
|
| 130 |
+
}
|
| 131 |
+
if (query.facets.length) {
|
| 132 |
data.facets = await executeRelationFacets(
|
| 133 |
+
service, nested => context.prepareQuery(nested), query, query.facets,
|
| 134 |
);
|
| 135 |
}
|
| 136 |
+
return data;
|
| 137 |
}
|
| 138 |
protected addFilter(filter: unknown): this { this.filters.push(filter); return this; }
|
| 139 |
protected select(...fields: string[]): this { this.query.select(fields); return this; }
|
|
|
|
| 379 |
averageTotalAmountAs(alias: string): this { return this.aggregate('Avg', 'totalAmount', alias); }
|
| 380 |
|
| 381 |
override executeForList(context: UserContext): Promise<SmartList<Row>> {
|
| 382 |
+
if (this.countAlias) this.includePageTotalAs(this.countAlias);
|
| 383 |
return super.executeForList(context);
|
| 384 |
}
|
| 385 |
|
| 386 |
override executeForRows(context: UserContext): Promise<SmartList<Row>> {
|
| 387 |
this.applyRowCount();
|
| 388 |
+
return super.executeForRows(context);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 389 |
}
|
| 390 |
|
| 391 |
private applyRowCount(): void {
|
source/teaql-ts/examples/browser-sqlite/src/main.ts
CHANGED
|
@@ -65,6 +65,11 @@ type LocalizedCopy = Readonly<{ en: string; zh: string }>;
|
|
| 65 |
const UI_COPY: Readonly<Record<string, LocalizedCopy>> = {
|
| 66 |
heroTitle: { en: 'Understand TeaQL queries through a familiar order model.', zh: '用一个熟悉的订单模型,看懂 TeaQL 查询。' },
|
| 67 |
heroIntro: { en: 'Platform, customer, order, item, payment, and shipment data all run in the browser. Order status is backed by a constant model. Choose a query below to inspect real SQLite/WASM results.', zh: '平台、用户、订单、明细、支付和物流数据都在浏览器中运行;订单状态由常数模型提供。选择下面的查询,查看真实的 SQLite/WASM 结果。' },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
platform: { en: 'Platform', zh: '平台' }, customer: { en: 'Customer', zh: '用户' },
|
| 69 |
order: { en: 'Order', zh: '订单' }, item: { en: 'Item', zh: '明细' },
|
| 70 |
payment: { en: 'Payment', zh: '支付' }, shipment: { en: 'Shipment', zh: '物流' },
|
|
@@ -209,16 +214,16 @@ async function runOrderCenter(active: Runtime): Promise<DashboardData> {
|
|
| 209 |
.orderByIdDescending()
|
| 210 |
.comment('load order list')
|
| 211 |
.purpose('render order list page');
|
| 212 |
-
const
|
| 213 |
-
|
| 214 |
-
dashboardState.page * dashboardState.pageSize
|
| 215 |
-
dashboardState.pageSize
|
| 216 |
-
|
| 217 |
-
const statusRows =
|
| 218 |
return {
|
| 219 |
-
orders
|
| 220 |
-
totalOrders: Number(
|
| 221 |
-
filteredOrders:
|
| 222 |
statusFacets: statusRows.map(row => ({
|
| 223 |
code: statusCodeFor(row),
|
| 224 |
name: String(row.name ?? ''),
|
|
@@ -229,7 +234,7 @@ async function runOrderCenter(active: Runtime): Promise<DashboardData> {
|
|
| 229 |
search: dashboardState.search,
|
| 230 |
page: dashboardState.page,
|
| 231 |
pageSize: dashboardState.pageSize,
|
| 232 |
-
queryExpression
|
| 233 |
};
|
| 234 |
}
|
| 235 |
|
|
@@ -1127,6 +1132,7 @@ function applyLocale(): void {
|
|
| 1127 |
document.querySelector<HTMLElement>('.language-switch')?.setAttribute('aria-label', locale === 'en' ? 'Language' : '语言');
|
| 1128 |
document.querySelector<HTMLElement>('.brand')?.setAttribute('aria-label', locale === 'en' ? 'TeaQL Playground home' : 'TeaQL 演练场首页');
|
| 1129 |
document.querySelector<HTMLElement>('.model-map')?.setAttribute('aria-label', locale === 'en' ? 'Order domain model' : '订单领域模型');
|
|
|
|
| 1130 |
document.querySelector<HTMLElement>('.runtime-bar')?.setAttribute('aria-label', locale === 'en' ? 'Runtime settings' : '运行时设置');
|
| 1131 |
queryCatalog.setAttribute('aria-label', locale === 'en' ? 'Example queries' : '示例查询');
|
| 1132 |
document.querySelector<HTMLElement>('.result-view-switch')?.setAttribute('aria-label', locale === 'en' ? 'Result views' : '结果视图');
|
|
|
|
| 65 |
const UI_COPY: Readonly<Record<string, LocalizedCopy>> = {
|
| 66 |
heroTitle: { en: 'Understand TeaQL queries through a familiar order model.', zh: '用一个熟悉的订单模型,看懂 TeaQL 查询。' },
|
| 67 |
heroIntro: { en: 'Platform, customer, order, item, payment, and shipment data all run in the browser. Order status is backed by a constant model. Choose a query below to inspect real SQLite/WASM results.', zh: '平台、用户、订单、明细、支付和物流数据都在浏览器中运行;订单状态由常数模型提供。选择下面的查询,查看真实的 SQLite/WASM 结果。' },
|
| 68 |
+
runtimeCoverage: { en: 'RUNTIME COVERAGE', zh: 'RUNTIME 覆盖' },
|
| 69 |
+
runtimeTitle: { en: 'This demo runs TypeScript in your browser.', zh: '这个演示在浏览器中运行 TypeScript。' },
|
| 70 |
+
runtimeIntro: { en: 'The same model-driven Q and TraceChain contract is supported by seven TeaQL runtimes. Select a language to inspect its runtime source.', zh: '同一套模型驱动的 Q 与 TraceChain 契约支持七种 TeaQL runtime。选择一种语言,可以查看对应的 runtime 源码。' },
|
| 71 |
+
currentBrowserRuntime: { en: 'Current browser runtime', zh: '当前浏览器 runtime' },
|
| 72 |
+
supportedRuntime: { en: 'Supported runtime', zh: '已支持 runtime' },
|
| 73 |
platform: { en: 'Platform', zh: '平台' }, customer: { en: 'Customer', zh: '用户' },
|
| 74 |
order: { en: 'Order', zh: '订单' }, item: { en: 'Item', zh: '明细' },
|
| 75 |
payment: { en: 'Payment', zh: '支付' }, shipment: { en: 'Shipment', zh: '物流' },
|
|
|
|
| 214 |
.orderByIdDescending()
|
| 215 |
.comment('load order list')
|
| 216 |
.purpose('render order list page');
|
| 217 |
+
const queryExpression = request.toQExpression('offset(pageOffset)\n .limit(pageSize)\n .executeForList(ctx);');
|
| 218 |
+
const orders = await request
|
| 219 |
+
.offset(dashboardState.page * dashboardState.pageSize)
|
| 220 |
+
.limit(dashboardState.pageSize)
|
| 221 |
+
.executeForList(active.context);
|
| 222 |
+
const statusRows = orders.facet('statusCounts') ?? [];
|
| 223 |
return {
|
| 224 |
+
orders,
|
| 225 |
+
totalOrders: Number(orders.aggregations.totalOrders ?? orders.totalCount),
|
| 226 |
+
filteredOrders: orders.totalCount ?? 0,
|
| 227 |
statusFacets: statusRows.map(row => ({
|
| 228 |
code: statusCodeFor(row),
|
| 229 |
name: String(row.name ?? ''),
|
|
|
|
| 234 |
search: dashboardState.search,
|
| 235 |
page: dashboardState.page,
|
| 236 |
pageSize: dashboardState.pageSize,
|
| 237 |
+
queryExpression,
|
| 238 |
};
|
| 239 |
}
|
| 240 |
|
|
|
|
| 1132 |
document.querySelector<HTMLElement>('.language-switch')?.setAttribute('aria-label', locale === 'en' ? 'Language' : '语言');
|
| 1133 |
document.querySelector<HTMLElement>('.brand')?.setAttribute('aria-label', locale === 'en' ? 'TeaQL Playground home' : 'TeaQL 演练场首页');
|
| 1134 |
document.querySelector<HTMLElement>('.model-map')?.setAttribute('aria-label', locale === 'en' ? 'Order domain model' : '订单领域模型');
|
| 1135 |
+
document.querySelector<HTMLElement>('.runtime-language-selector')?.setAttribute('aria-label', locale === 'en' ? 'TeaQL runtimes' : 'TeaQL 运行时');
|
| 1136 |
document.querySelector<HTMLElement>('.runtime-bar')?.setAttribute('aria-label', locale === 'en' ? 'Runtime settings' : '运行时设置');
|
| 1137 |
queryCatalog.setAttribute('aria-label', locale === 'en' ? 'Example queries' : '示例查询');
|
| 1138 |
document.querySelector<HTMLElement>('.result-view-switch')?.setAttribute('aria-label', locale === 'en' ? 'Result views' : '结果视图');
|
source/teaql-ts/examples/browser-sqlite/src/style.css
CHANGED
|
@@ -115,6 +115,50 @@ h1 {
|
|
| 115 |
.model-arrow-split { height: 22px; line-height: 18px; }
|
| 116 |
.model-leaves { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
.runtime-bar {
|
| 119 |
min-height: 72px;
|
| 120 |
padding: 14px 18px 14px 22px;
|
|
@@ -409,6 +453,8 @@ footer {
|
|
| 409 |
.page-shell { padding: 0 24px; }
|
| 410 |
.hero { grid-template-columns: 1fr; gap: 46px; padding-top: 58px; }
|
| 411 |
.model-map { min-height: 260px; }
|
|
|
|
|
|
|
| 412 |
.result-panel { margin: 0 -24px; padding-left: 24px; padding-right: 24px; }
|
| 413 |
.result-grid { grid-template-columns: 1fr; }
|
| 414 |
}
|
|
@@ -426,6 +472,9 @@ footer {
|
|
| 426 |
.model-flow > span:not(.model-arrow), .model-leaves span { width: 100%; }
|
| 427 |
.model-flow .model-arrow { transform: rotate(90deg); }
|
| 428 |
.model-leaves { grid-template-columns: 1fr; }
|
|
|
|
|
|
|
|
|
|
| 429 |
.runtime-bar, .section-heading, .result-heading { align-items: flex-start; flex-direction: column; }
|
| 430 |
.runtime-bar { padding: 18px; }
|
| 431 |
.controls { width: 100%; justify-content: space-between; }
|
|
|
|
| 115 |
.model-arrow-split { height: 22px; line-height: 18px; }
|
| 116 |
.model-leaves { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
|
| 117 |
|
| 118 |
+
.runtime-language-panel {
|
| 119 |
+
margin-bottom: 28px;
|
| 120 |
+
padding: 24px;
|
| 121 |
+
display: grid;
|
| 122 |
+
grid-template-columns: minmax(240px, .72fr) minmax(0, 1.8fr);
|
| 123 |
+
align-items: center;
|
| 124 |
+
gap: 30px;
|
| 125 |
+
border: 1px solid var(--line);
|
| 126 |
+
border-radius: 18px;
|
| 127 |
+
background: var(--paper);
|
| 128 |
+
}
|
| 129 |
+
.runtime-language-copy .section-index { margin-bottom: 8px; }
|
| 130 |
+
.runtime-language-copy h2 {
|
| 131 |
+
margin: 0;
|
| 132 |
+
font-family: Georgia, "Noto Serif SC", serif;
|
| 133 |
+
font-size: clamp(22px, 2.4vw, 31px);
|
| 134 |
+
font-weight: 500;
|
| 135 |
+
line-height: 1.15;
|
| 136 |
+
letter-spacing: -.035em;
|
| 137 |
+
}
|
| 138 |
+
.runtime-language-copy p:last-child { margin: 11px 0 0; color: var(--muted); font-size: 13px; }
|
| 139 |
+
.runtime-language-selector { display: grid; grid-template-columns: repeat(7, minmax(82px, 1fr)); gap: 8px; }
|
| 140 |
+
.runtime-language {
|
| 141 |
+
min-width: 0;
|
| 142 |
+
padding: 13px 8px 11px;
|
| 143 |
+
display: flex;
|
| 144 |
+
align-items: center;
|
| 145 |
+
flex-direction: column;
|
| 146 |
+
gap: 4px;
|
| 147 |
+
border: 1px solid #d7ddd5;
|
| 148 |
+
border-radius: 12px;
|
| 149 |
+
color: var(--ink);
|
| 150 |
+
background: #fafbf7;
|
| 151 |
+
text-align: center;
|
| 152 |
+
text-decoration: none;
|
| 153 |
+
transition: border-color .16s ease, background .16s ease, transform .16s ease;
|
| 154 |
+
}
|
| 155 |
+
.runtime-language:hover { border-color: #98aa9d; background: white; transform: translateY(-2px); }
|
| 156 |
+
.runtime-language.active { color: white; border-color: var(--green); background: var(--green); box-shadow: 0 8px 20px rgba(20, 91, 55, .14); }
|
| 157 |
+
.runtime-language-icon { font-size: 25px; line-height: 1.1; }
|
| 158 |
+
.runtime-language strong { overflow: hidden; max-width: 100%; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
|
| 159 |
+
.runtime-language small { color: #78837a; font-size: 8px; line-height: 1.25; }
|
| 160 |
+
.runtime-language.active small { color: #d5e7da; }
|
| 161 |
+
|
| 162 |
.runtime-bar {
|
| 163 |
min-height: 72px;
|
| 164 |
padding: 14px 18px 14px 22px;
|
|
|
|
| 453 |
.page-shell { padding: 0 24px; }
|
| 454 |
.hero { grid-template-columns: 1fr; gap: 46px; padding-top: 58px; }
|
| 455 |
.model-map { min-height: 260px; }
|
| 456 |
+
.runtime-language-panel { grid-template-columns: 1fr; }
|
| 457 |
+
.runtime-language-selector { grid-template-columns: repeat(4, minmax(100px, 1fr)); }
|
| 458 |
.result-panel { margin: 0 -24px; padding-left: 24px; padding-right: 24px; }
|
| 459 |
.result-grid { grid-template-columns: 1fr; }
|
| 460 |
}
|
|
|
|
| 472 |
.model-flow > span:not(.model-arrow), .model-leaves span { width: 100%; }
|
| 473 |
.model-flow .model-arrow { transform: rotate(90deg); }
|
| 474 |
.model-leaves { grid-template-columns: 1fr; }
|
| 475 |
+
.runtime-language-panel { padding: 20px 16px; gap: 20px; }
|
| 476 |
+
.runtime-language-selector { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
| 477 |
+
.runtime-language:last-child { grid-column: 1 / -1; }
|
| 478 |
.runtime-bar, .section-heading, .result-heading { align-items: flex-start; flex-direction: column; }
|
| 479 |
.runtime-bar { padding: 18px; }
|
| 480 |
.controls { width: 100%; justify-content: space-between; }
|
source/teaql-ts/examples/conformance/.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
node_modules/
|
| 2 |
+
.local/
|
source/teaql-ts/examples/conformance/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TypeScript runtime conformance example
|
| 2 |
+
|
| 3 |
+
This retained SQLite example is generated from `model.xml` and verifies the minimum runtime-owned contract: explicit `ensureSchema`, Create, Update, Delete, typed Q, E loaded/null/not-loaded semantics, Checker rejection before SQL, and optimistic-version isolation for different entity types that share a numeric ID.
|
| 4 |
+
|
| 5 |
+
```bash
|
| 6 |
+
npm install
|
| 7 |
+
npm run build
|
| 8 |
+
npm start
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
The generated workspace targets `@teaql/teaql` 0.1.17. Regenerate it with the local code generator's `typescript-app-console` target before checking a new generator/runtime combination.
|
source/teaql-ts/examples/conformance/evidence/2026-08-26.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TypeScript minimum runtime conformance — 2026-08-26
|
| 2 |
+
|
| 3 |
+
- Generator: `bb904a621e982bb86aaf057e36ee9c1cbb9c1c6b`
|
| 4 |
+
- Runtime baseline: `a3eeee8f9b24c7016ca4ab2ef88ae4fd7f128d78` plus the projection correction tracked by issue #9
|
| 5 |
+
- Database: SQLite (`better-sqlite3`), fresh local database
|
| 6 |
+
- KSML evaluation: 0 errors, 0 warnings, 0 suggestions, 8 solids
|
| 7 |
+
|
| 8 |
+
Executed commands:
|
| 9 |
+
|
| 10 |
+
```text
|
| 11 |
+
npm run build
|
| 12 |
+
npm start
|
| 13 |
+
```
|
| 14 |
+
|
| 15 |
+
Retained result:
|
| 16 |
+
|
| 17 |
+
```text
|
| 18 |
+
PASS ensureSchema (explicit SQLite DDL and Platform(1) bootstrap)
|
| 19 |
+
PASS Checker (canonical title key, rejected before SQL)
|
| 20 |
+
PASS Create (id=1, version=1)
|
| 21 |
+
PASS Q API (typed WorkItem)
|
| 22 |
+
PASS E API (loaded, null fallback, and not-loaded are distinct)
|
| 23 |
+
PASS Update (version 1 -> 2)
|
| 24 |
+
PASS Delete (default Q excludes deleted rows)
|
| 25 |
+
PASS TypeScript minimum runtime conformance: 7/7
|
| 26 |
+
```
|
| 27 |
+
|
| 28 |
+
The full runtime suite also passed: 21 suites passed, 1 skipped; 73 tests passed, 2 skipped.
|
source/teaql-ts/examples/conformance/model.xml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<root name="runtime-example-conformance-service" org="teaql" version="1.0.0" data_service="sqlite">
|
| 2 |
+
<platform
|
| 3 |
+
name="Runtime Example"
|
| 4 |
+
_name="Platform"
|
| 5 |
+
_module="Example"
|
| 6 |
+
_module_key="example"
|
| 7 |
+
/>
|
| 8 |
+
<work_item
|
| 9 |
+
title="Work item|[1,80]"
|
| 10 |
+
description="Verify the runtime-owned conformance example?"
|
| 11 |
+
platform="platform()"
|
| 12 |
+
_name="Work Item"
|
| 13 |
+
_module="Example"
|
| 14 |
+
_module_key="example"
|
| 15 |
+
/>
|
| 16 |
+
</root>
|
source/teaql-ts/examples/conformance/package-lock.json
ADDED
|
@@ -0,0 +1,828 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "runtime-example-conformance-service-lib",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"lockfileVersion": 3,
|
| 5 |
+
"requires": true,
|
| 6 |
+
"packages": {
|
| 7 |
+
"": {
|
| 8 |
+
"name": "runtime-example-conformance-service-lib",
|
| 9 |
+
"version": "1.0.0",
|
| 10 |
+
"dependencies": {
|
| 11 |
+
"better-sqlite3": "^12.10.0",
|
| 12 |
+
"teaql-ts": "file:../.."
|
| 13 |
+
},
|
| 14 |
+
"devDependencies": {
|
| 15 |
+
"@types/better-sqlite3": "^7.6.12",
|
| 16 |
+
"@types/node": "^22.0.0",
|
| 17 |
+
"ts-node": "^10.9.2",
|
| 18 |
+
"typescript": "^5.0.0"
|
| 19 |
+
}
|
| 20 |
+
},
|
| 21 |
+
"../..": {
|
| 22 |
+
"name": "@teaql/teaql",
|
| 23 |
+
"version": "0.3.1",
|
| 24 |
+
"license": "Apache-2.0",
|
| 25 |
+
"dependencies": {
|
| 26 |
+
"node-fetch": "^2.7.0"
|
| 27 |
+
},
|
| 28 |
+
"devDependencies": {
|
| 29 |
+
"@aws-sdk/client-s3": "3.1151.0",
|
| 30 |
+
"@aws-sdk/s3-request-presigner": "3.1151.0",
|
| 31 |
+
"@opentelemetry/api-logs": "^0.221.0",
|
| 32 |
+
"@opentelemetry/context-async-hooks": "^2.10.0",
|
| 33 |
+
"@opentelemetry/core": "^2.10.0",
|
| 34 |
+
"@opentelemetry/exporter-logs-otlp-http": "^0.221.0",
|
| 35 |
+
"@opentelemetry/exporter-metrics-otlp-http": "^0.221.0",
|
| 36 |
+
"@opentelemetry/exporter-trace-otlp-http": "^0.221.0",
|
| 37 |
+
"@opentelemetry/otlp-transformer": "0.221.0",
|
| 38 |
+
"@opentelemetry/resources": "^2.10.0",
|
| 39 |
+
"@opentelemetry/sdk-logs": "^0.221.0",
|
| 40 |
+
"@opentelemetry/sdk-metrics": "^2.10.0",
|
| 41 |
+
"@opentelemetry/sdk-trace-base": "^2.10.0",
|
| 42 |
+
"@sqlite.org/sqlite-wasm": "3.53.0-build1",
|
| 43 |
+
"@types/better-sqlite3": "^7.6.12",
|
| 44 |
+
"@types/jest": "^29.5.0",
|
| 45 |
+
"@types/node-fetch": "^2.6.13",
|
| 46 |
+
"@types/pg": "^8.11.0",
|
| 47 |
+
"better-sqlite3": "^12.10.0",
|
| 48 |
+
"esbuild": "^0.28.2",
|
| 49 |
+
"jest": "^29.5.0",
|
| 50 |
+
"jest-util": "^29.7.0",
|
| 51 |
+
"mysql2": "^3.11.0",
|
| 52 |
+
"peggy": "^5.1.0",
|
| 53 |
+
"pg": "^8.12.0",
|
| 54 |
+
"pg-query-stream": "^4.7.0",
|
| 55 |
+
"ts-jest": "^29.1.0",
|
| 56 |
+
"typescript": "5.4.5"
|
| 57 |
+
},
|
| 58 |
+
"peerDependencies": {
|
| 59 |
+
"@aws-sdk/client-s3": "3.1151.0",
|
| 60 |
+
"@aws-sdk/s3-request-presigner": "3.1151.0",
|
| 61 |
+
"@opentelemetry/api": "^1.9.1",
|
| 62 |
+
"@opentelemetry/api-logs": "^0.221.0",
|
| 63 |
+
"@opentelemetry/context-async-hooks": "^2.10.0",
|
| 64 |
+
"@opentelemetry/core": "^2.10.0",
|
| 65 |
+
"@opentelemetry/exporter-logs-otlp-http": "^0.221.0",
|
| 66 |
+
"@opentelemetry/exporter-metrics-otlp-http": "^0.221.0",
|
| 67 |
+
"@opentelemetry/exporter-trace-otlp-http": "^0.221.0",
|
| 68 |
+
"@opentelemetry/otlp-transformer": "0.221.0",
|
| 69 |
+
"@opentelemetry/resources": "^2.10.0",
|
| 70 |
+
"@opentelemetry/sdk-logs": "^0.221.0",
|
| 71 |
+
"@opentelemetry/sdk-metrics": "^2.10.0",
|
| 72 |
+
"@opentelemetry/sdk-trace-base": "^2.10.0",
|
| 73 |
+
"@sqlite.org/sqlite-wasm": "3.53.0-build1",
|
| 74 |
+
"better-sqlite3": "^12.10.0",
|
| 75 |
+
"expo-sqlite": "*",
|
| 76 |
+
"mysql2": "^3.11.0",
|
| 77 |
+
"pg": "^8.12.0",
|
| 78 |
+
"pg-query-stream": "^4.7.0"
|
| 79 |
+
},
|
| 80 |
+
"peerDependenciesMeta": {
|
| 81 |
+
"@aws-sdk/client-s3": {
|
| 82 |
+
"optional": true
|
| 83 |
+
},
|
| 84 |
+
"@aws-sdk/s3-request-presigner": {
|
| 85 |
+
"optional": true
|
| 86 |
+
},
|
| 87 |
+
"@opentelemetry/api": {
|
| 88 |
+
"optional": true
|
| 89 |
+
},
|
| 90 |
+
"@opentelemetry/api-logs": {
|
| 91 |
+
"optional": true
|
| 92 |
+
},
|
| 93 |
+
"@opentelemetry/context-async-hooks": {
|
| 94 |
+
"optional": true
|
| 95 |
+
},
|
| 96 |
+
"@opentelemetry/core": {
|
| 97 |
+
"optional": true
|
| 98 |
+
},
|
| 99 |
+
"@opentelemetry/exporter-logs-otlp-http": {
|
| 100 |
+
"optional": true
|
| 101 |
+
},
|
| 102 |
+
"@opentelemetry/exporter-metrics-otlp-http": {
|
| 103 |
+
"optional": true
|
| 104 |
+
},
|
| 105 |
+
"@opentelemetry/exporter-trace-otlp-http": {
|
| 106 |
+
"optional": true
|
| 107 |
+
},
|
| 108 |
+
"@opentelemetry/otlp-transformer": {
|
| 109 |
+
"optional": true
|
| 110 |
+
},
|
| 111 |
+
"@opentelemetry/resources": {
|
| 112 |
+
"optional": true
|
| 113 |
+
},
|
| 114 |
+
"@opentelemetry/sdk-logs": {
|
| 115 |
+
"optional": true
|
| 116 |
+
},
|
| 117 |
+
"@opentelemetry/sdk-metrics": {
|
| 118 |
+
"optional": true
|
| 119 |
+
},
|
| 120 |
+
"@opentelemetry/sdk-trace-base": {
|
| 121 |
+
"optional": true
|
| 122 |
+
},
|
| 123 |
+
"@sqlite.org/sqlite-wasm": {
|
| 124 |
+
"optional": true
|
| 125 |
+
},
|
| 126 |
+
"better-sqlite3": {
|
| 127 |
+
"optional": true
|
| 128 |
+
},
|
| 129 |
+
"expo-sqlite": {
|
| 130 |
+
"optional": true
|
| 131 |
+
},
|
| 132 |
+
"mysql2": {
|
| 133 |
+
"optional": true
|
| 134 |
+
},
|
| 135 |
+
"pg": {
|
| 136 |
+
"optional": true
|
| 137 |
+
},
|
| 138 |
+
"pg-query-stream": {
|
| 139 |
+
"optional": true
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
},
|
| 143 |
+
"node_modules/@cspotcode/source-map-support": {
|
| 144 |
+
"version": "0.8.1",
|
| 145 |
+
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
|
| 146 |
+
"integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
|
| 147 |
+
"dev": true,
|
| 148 |
+
"license": "MIT",
|
| 149 |
+
"dependencies": {
|
| 150 |
+
"@jridgewell/trace-mapping": "0.3.9"
|
| 151 |
+
},
|
| 152 |
+
"engines": {
|
| 153 |
+
"node": ">=12"
|
| 154 |
+
}
|
| 155 |
+
},
|
| 156 |
+
"node_modules/@jridgewell/resolve-uri": {
|
| 157 |
+
"version": "3.1.2",
|
| 158 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
|
| 159 |
+
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
|
| 160 |
+
"dev": true,
|
| 161 |
+
"license": "MIT",
|
| 162 |
+
"engines": {
|
| 163 |
+
"node": ">=6.0.0"
|
| 164 |
+
}
|
| 165 |
+
},
|
| 166 |
+
"node_modules/@jridgewell/sourcemap-codec": {
|
| 167 |
+
"version": "1.5.5",
|
| 168 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
|
| 169 |
+
"integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
|
| 170 |
+
"dev": true,
|
| 171 |
+
"license": "MIT"
|
| 172 |
+
},
|
| 173 |
+
"node_modules/@jridgewell/trace-mapping": {
|
| 174 |
+
"version": "0.3.9",
|
| 175 |
+
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
|
| 176 |
+
"integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
|
| 177 |
+
"dev": true,
|
| 178 |
+
"license": "MIT",
|
| 179 |
+
"dependencies": {
|
| 180 |
+
"@jridgewell/resolve-uri": "^3.0.3",
|
| 181 |
+
"@jridgewell/sourcemap-codec": "^1.4.10"
|
| 182 |
+
}
|
| 183 |
+
},
|
| 184 |
+
"node_modules/@tsconfig/node10": {
|
| 185 |
+
"version": "1.0.13",
|
| 186 |
+
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.13.tgz",
|
| 187 |
+
"integrity": "sha512-gcLdvR9HO1ZJBypsOGqaP6TFEzb6vIta0KSTLt9NAQ6pXQO3cRgSVyCN6pzYqI9DlJgY71XKO0dpDhCf08b3pg==",
|
| 188 |
+
"dev": true,
|
| 189 |
+
"license": "MIT"
|
| 190 |
+
},
|
| 191 |
+
"node_modules/@tsconfig/node12": {
|
| 192 |
+
"version": "1.0.11",
|
| 193 |
+
"resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz",
|
| 194 |
+
"integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==",
|
| 195 |
+
"dev": true,
|
| 196 |
+
"license": "MIT"
|
| 197 |
+
},
|
| 198 |
+
"node_modules/@tsconfig/node14": {
|
| 199 |
+
"version": "1.0.3",
|
| 200 |
+
"resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz",
|
| 201 |
+
"integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==",
|
| 202 |
+
"dev": true,
|
| 203 |
+
"license": "MIT"
|
| 204 |
+
},
|
| 205 |
+
"node_modules/@tsconfig/node16": {
|
| 206 |
+
"version": "1.0.4",
|
| 207 |
+
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz",
|
| 208 |
+
"integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==",
|
| 209 |
+
"dev": true,
|
| 210 |
+
"license": "MIT"
|
| 211 |
+
},
|
| 212 |
+
"node_modules/@types/better-sqlite3": {
|
| 213 |
+
"version": "7.6.13",
|
| 214 |
+
"resolved": "https://registry.npmjs.org/@types/better-sqlite3/-/better-sqlite3-7.6.13.tgz",
|
| 215 |
+
"integrity": "sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==",
|
| 216 |
+
"dev": true,
|
| 217 |
+
"license": "MIT",
|
| 218 |
+
"dependencies": {
|
| 219 |
+
"@types/node": "*"
|
| 220 |
+
}
|
| 221 |
+
},
|
| 222 |
+
"node_modules/@types/node": {
|
| 223 |
+
"version": "22.20.1",
|
| 224 |
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.1.tgz",
|
| 225 |
+
"integrity": "sha512-EANqOCF9QFyra+4pfxUcX9STKJpCLjMbObVzljIJomAWSnuSIEAvyzEU53GaajbXJEgdh0iEcPL+DGvpUd4k1Q==",
|
| 226 |
+
"dev": true,
|
| 227 |
+
"license": "MIT",
|
| 228 |
+
"dependencies": {
|
| 229 |
+
"undici-types": "~6.21.0"
|
| 230 |
+
}
|
| 231 |
+
},
|
| 232 |
+
"node_modules/acorn": {
|
| 233 |
+
"version": "8.18.0",
|
| 234 |
+
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz",
|
| 235 |
+
"integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==",
|
| 236 |
+
"dev": true,
|
| 237 |
+
"license": "MIT",
|
| 238 |
+
"bin": {
|
| 239 |
+
"acorn": "bin/acorn"
|
| 240 |
+
},
|
| 241 |
+
"engines": {
|
| 242 |
+
"node": ">=0.4.0"
|
| 243 |
+
}
|
| 244 |
+
},
|
| 245 |
+
"node_modules/acorn-walk": {
|
| 246 |
+
"version": "8.3.5",
|
| 247 |
+
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.5.tgz",
|
| 248 |
+
"integrity": "sha512-HEHNfbars9v4pgpW6SO1KSPkfoS0xVOM/9UzkJltjlsHZmJasxg8aXkuZa7SMf8vKGIBhpUsPluQSqhJFCqebw==",
|
| 249 |
+
"dev": true,
|
| 250 |
+
"license": "MIT",
|
| 251 |
+
"dependencies": {
|
| 252 |
+
"acorn": "^8.11.0"
|
| 253 |
+
},
|
| 254 |
+
"engines": {
|
| 255 |
+
"node": ">=0.4.0"
|
| 256 |
+
}
|
| 257 |
+
},
|
| 258 |
+
"node_modules/arg": {
|
| 259 |
+
"version": "4.1.3",
|
| 260 |
+
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
|
| 261 |
+
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
|
| 262 |
+
"dev": true,
|
| 263 |
+
"license": "MIT"
|
| 264 |
+
},
|
| 265 |
+
"node_modules/base64-js": {
|
| 266 |
+
"version": "1.5.1",
|
| 267 |
+
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
| 268 |
+
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
| 269 |
+
"funding": [
|
| 270 |
+
{
|
| 271 |
+
"type": "github",
|
| 272 |
+
"url": "https://github.com/sponsors/feross"
|
| 273 |
+
},
|
| 274 |
+
{
|
| 275 |
+
"type": "patreon",
|
| 276 |
+
"url": "https://www.patreon.com/feross"
|
| 277 |
+
},
|
| 278 |
+
{
|
| 279 |
+
"type": "consulting",
|
| 280 |
+
"url": "https://feross.org/support"
|
| 281 |
+
}
|
| 282 |
+
],
|
| 283 |
+
"license": "MIT"
|
| 284 |
+
},
|
| 285 |
+
"node_modules/better-sqlite3": {
|
| 286 |
+
"version": "12.11.1",
|
| 287 |
+
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-12.11.1.tgz",
|
| 288 |
+
"integrity": "sha512-dq9AtApgg5PGFtBzPFSBl3HZQjHok5gaQCM6zh2Yk0aSmDCs1CbnVI8/HgASQkNKsWFpseIO9beg5xxpYhbIfA==",
|
| 289 |
+
"hasInstallScript": true,
|
| 290 |
+
"license": "MIT",
|
| 291 |
+
"dependencies": {
|
| 292 |
+
"bindings": "^1.5.0",
|
| 293 |
+
"prebuild-install": "^7.1.1"
|
| 294 |
+
},
|
| 295 |
+
"engines": {
|
| 296 |
+
"node": "20.x || 22.x || 23.x || 24.x || 25.x || 26.x"
|
| 297 |
+
}
|
| 298 |
+
},
|
| 299 |
+
"node_modules/bindings": {
|
| 300 |
+
"version": "1.5.0",
|
| 301 |
+
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
|
| 302 |
+
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
| 303 |
+
"license": "MIT",
|
| 304 |
+
"dependencies": {
|
| 305 |
+
"file-uri-to-path": "1.0.0"
|
| 306 |
+
}
|
| 307 |
+
},
|
| 308 |
+
"node_modules/bl": {
|
| 309 |
+
"version": "4.1.0",
|
| 310 |
+
"resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz",
|
| 311 |
+
"integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==",
|
| 312 |
+
"license": "MIT",
|
| 313 |
+
"dependencies": {
|
| 314 |
+
"buffer": "^5.5.0",
|
| 315 |
+
"inherits": "^2.0.4",
|
| 316 |
+
"readable-stream": "^3.4.0"
|
| 317 |
+
}
|
| 318 |
+
},
|
| 319 |
+
"node_modules/buffer": {
|
| 320 |
+
"version": "5.7.1",
|
| 321 |
+
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz",
|
| 322 |
+
"integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==",
|
| 323 |
+
"funding": [
|
| 324 |
+
{
|
| 325 |
+
"type": "github",
|
| 326 |
+
"url": "https://github.com/sponsors/feross"
|
| 327 |
+
},
|
| 328 |
+
{
|
| 329 |
+
"type": "patreon",
|
| 330 |
+
"url": "https://www.patreon.com/feross"
|
| 331 |
+
},
|
| 332 |
+
{
|
| 333 |
+
"type": "consulting",
|
| 334 |
+
"url": "https://feross.org/support"
|
| 335 |
+
}
|
| 336 |
+
],
|
| 337 |
+
"license": "MIT",
|
| 338 |
+
"dependencies": {
|
| 339 |
+
"base64-js": "^1.3.1",
|
| 340 |
+
"ieee754": "^1.1.13"
|
| 341 |
+
}
|
| 342 |
+
},
|
| 343 |
+
"node_modules/chownr": {
|
| 344 |
+
"version": "1.1.4",
|
| 345 |
+
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz",
|
| 346 |
+
"integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==",
|
| 347 |
+
"license": "ISC"
|
| 348 |
+
},
|
| 349 |
+
"node_modules/create-require": {
|
| 350 |
+
"version": "1.1.1",
|
| 351 |
+
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
|
| 352 |
+
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
|
| 353 |
+
"dev": true,
|
| 354 |
+
"license": "MIT"
|
| 355 |
+
},
|
| 356 |
+
"node_modules/decompress-response": {
|
| 357 |
+
"version": "6.0.0",
|
| 358 |
+
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
|
| 359 |
+
"integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==",
|
| 360 |
+
"license": "MIT",
|
| 361 |
+
"dependencies": {
|
| 362 |
+
"mimic-response": "^3.1.0"
|
| 363 |
+
},
|
| 364 |
+
"engines": {
|
| 365 |
+
"node": ">=10"
|
| 366 |
+
},
|
| 367 |
+
"funding": {
|
| 368 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
| 369 |
+
}
|
| 370 |
+
},
|
| 371 |
+
"node_modules/deep-extend": {
|
| 372 |
+
"version": "0.6.0",
|
| 373 |
+
"resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz",
|
| 374 |
+
"integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==",
|
| 375 |
+
"license": "MIT",
|
| 376 |
+
"engines": {
|
| 377 |
+
"node": ">=4.0.0"
|
| 378 |
+
}
|
| 379 |
+
},
|
| 380 |
+
"node_modules/detect-libc": {
|
| 381 |
+
"version": "2.1.2",
|
| 382 |
+
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
|
| 383 |
+
"integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
|
| 384 |
+
"license": "Apache-2.0",
|
| 385 |
+
"engines": {
|
| 386 |
+
"node": ">=8"
|
| 387 |
+
}
|
| 388 |
+
},
|
| 389 |
+
"node_modules/diff": {
|
| 390 |
+
"version": "4.0.4",
|
| 391 |
+
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.4.tgz",
|
| 392 |
+
"integrity": "sha512-X07nttJQkwkfKfvTPG/KSnE2OMdcUCao6+eXF3wmnIQRn2aPAHH3VxDbDOdegkd6JbPsXqShpvEOHfAT+nCNwQ==",
|
| 393 |
+
"dev": true,
|
| 394 |
+
"license": "BSD-3-Clause",
|
| 395 |
+
"engines": {
|
| 396 |
+
"node": ">=0.3.1"
|
| 397 |
+
}
|
| 398 |
+
},
|
| 399 |
+
"node_modules/end-of-stream": {
|
| 400 |
+
"version": "1.4.5",
|
| 401 |
+
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz",
|
| 402 |
+
"integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==",
|
| 403 |
+
"license": "MIT",
|
| 404 |
+
"dependencies": {
|
| 405 |
+
"once": "^1.4.0"
|
| 406 |
+
}
|
| 407 |
+
},
|
| 408 |
+
"node_modules/expand-template": {
|
| 409 |
+
"version": "2.0.3",
|
| 410 |
+
"resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz",
|
| 411 |
+
"integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==",
|
| 412 |
+
"license": "(MIT OR WTFPL)",
|
| 413 |
+
"engines": {
|
| 414 |
+
"node": ">=6"
|
| 415 |
+
}
|
| 416 |
+
},
|
| 417 |
+
"node_modules/file-uri-to-path": {
|
| 418 |
+
"version": "1.0.0",
|
| 419 |
+
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
| 420 |
+
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
|
| 421 |
+
"license": "MIT"
|
| 422 |
+
},
|
| 423 |
+
"node_modules/fs-constants": {
|
| 424 |
+
"version": "1.0.0",
|
| 425 |
+
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
|
| 426 |
+
"integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==",
|
| 427 |
+
"license": "MIT"
|
| 428 |
+
},
|
| 429 |
+
"node_modules/github-from-package": {
|
| 430 |
+
"version": "0.0.0",
|
| 431 |
+
"resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz",
|
| 432 |
+
"integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==",
|
| 433 |
+
"license": "MIT"
|
| 434 |
+
},
|
| 435 |
+
"node_modules/ieee754": {
|
| 436 |
+
"version": "1.2.1",
|
| 437 |
+
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
|
| 438 |
+
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
|
| 439 |
+
"funding": [
|
| 440 |
+
{
|
| 441 |
+
"type": "github",
|
| 442 |
+
"url": "https://github.com/sponsors/feross"
|
| 443 |
+
},
|
| 444 |
+
{
|
| 445 |
+
"type": "patreon",
|
| 446 |
+
"url": "https://www.patreon.com/feross"
|
| 447 |
+
},
|
| 448 |
+
{
|
| 449 |
+
"type": "consulting",
|
| 450 |
+
"url": "https://feross.org/support"
|
| 451 |
+
}
|
| 452 |
+
],
|
| 453 |
+
"license": "BSD-3-Clause"
|
| 454 |
+
},
|
| 455 |
+
"node_modules/inherits": {
|
| 456 |
+
"version": "2.0.4",
|
| 457 |
+
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
| 458 |
+
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
| 459 |
+
"license": "ISC"
|
| 460 |
+
},
|
| 461 |
+
"node_modules/ini": {
|
| 462 |
+
"version": "1.3.8",
|
| 463 |
+
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
|
| 464 |
+
"integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==",
|
| 465 |
+
"license": "ISC"
|
| 466 |
+
},
|
| 467 |
+
"node_modules/make-error": {
|
| 468 |
+
"version": "1.3.6",
|
| 469 |
+
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
|
| 470 |
+
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
|
| 471 |
+
"dev": true,
|
| 472 |
+
"license": "ISC"
|
| 473 |
+
},
|
| 474 |
+
"node_modules/mimic-response": {
|
| 475 |
+
"version": "3.1.0",
|
| 476 |
+
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz",
|
| 477 |
+
"integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==",
|
| 478 |
+
"license": "MIT",
|
| 479 |
+
"engines": {
|
| 480 |
+
"node": ">=10"
|
| 481 |
+
},
|
| 482 |
+
"funding": {
|
| 483 |
+
"url": "https://github.com/sponsors/sindresorhus"
|
| 484 |
+
}
|
| 485 |
+
},
|
| 486 |
+
"node_modules/minimist": {
|
| 487 |
+
"version": "1.2.8",
|
| 488 |
+
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
| 489 |
+
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
|
| 490 |
+
"license": "MIT",
|
| 491 |
+
"funding": {
|
| 492 |
+
"url": "https://github.com/sponsors/ljharb"
|
| 493 |
+
}
|
| 494 |
+
},
|
| 495 |
+
"node_modules/mkdirp-classic": {
|
| 496 |
+
"version": "0.5.3",
|
| 497 |
+
"resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz",
|
| 498 |
+
"integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==",
|
| 499 |
+
"license": "MIT"
|
| 500 |
+
},
|
| 501 |
+
"node_modules/napi-build-utils": {
|
| 502 |
+
"version": "2.0.0",
|
| 503 |
+
"resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-2.0.0.tgz",
|
| 504 |
+
"integrity": "sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==",
|
| 505 |
+
"license": "MIT"
|
| 506 |
+
},
|
| 507 |
+
"node_modules/node-abi": {
|
| 508 |
+
"version": "3.95.0",
|
| 509 |
+
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.95.0.tgz",
|
| 510 |
+
"integrity": "sha512-T9iGctuocf0qIWFFOTxPzjT5q0SILqaBYXt272tlBHvTKC5+3JnkMirLxNJNkXHtFyBjU2Jx+NL4Zipr0B/c6Q==",
|
| 511 |
+
"license": "MIT",
|
| 512 |
+
"dependencies": {
|
| 513 |
+
"semver": "^7.3.5"
|
| 514 |
+
},
|
| 515 |
+
"engines": {
|
| 516 |
+
"node": ">=10"
|
| 517 |
+
}
|
| 518 |
+
},
|
| 519 |
+
"node_modules/once": {
|
| 520 |
+
"version": "1.4.0",
|
| 521 |
+
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
| 522 |
+
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
|
| 523 |
+
"license": "ISC",
|
| 524 |
+
"dependencies": {
|
| 525 |
+
"wrappy": "1"
|
| 526 |
+
}
|
| 527 |
+
},
|
| 528 |
+
"node_modules/prebuild-install": {
|
| 529 |
+
"version": "7.1.3",
|
| 530 |
+
"resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.3.tgz",
|
| 531 |
+
"integrity": "sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==",
|
| 532 |
+
"deprecated": "No longer maintained. Please contact the author of the relevant native addon; alternatives are available.",
|
| 533 |
+
"license": "MIT",
|
| 534 |
+
"dependencies": {
|
| 535 |
+
"detect-libc": "^2.0.0",
|
| 536 |
+
"expand-template": "^2.0.3",
|
| 537 |
+
"github-from-package": "0.0.0",
|
| 538 |
+
"minimist": "^1.2.3",
|
| 539 |
+
"mkdirp-classic": "^0.5.3",
|
| 540 |
+
"napi-build-utils": "^2.0.0",
|
| 541 |
+
"node-abi": "^3.3.0",
|
| 542 |
+
"pump": "^3.0.0",
|
| 543 |
+
"rc": "^1.2.7",
|
| 544 |
+
"simple-get": "^4.0.0",
|
| 545 |
+
"tar-fs": "^2.0.0",
|
| 546 |
+
"tunnel-agent": "^0.6.0"
|
| 547 |
+
},
|
| 548 |
+
"bin": {
|
| 549 |
+
"prebuild-install": "bin.js"
|
| 550 |
+
},
|
| 551 |
+
"engines": {
|
| 552 |
+
"node": ">=10"
|
| 553 |
+
}
|
| 554 |
+
},
|
| 555 |
+
"node_modules/pump": {
|
| 556 |
+
"version": "3.0.4",
|
| 557 |
+
"resolved": "https://registry.npmjs.org/pump/-/pump-3.0.4.tgz",
|
| 558 |
+
"integrity": "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==",
|
| 559 |
+
"license": "MIT",
|
| 560 |
+
"dependencies": {
|
| 561 |
+
"end-of-stream": "^1.1.0",
|
| 562 |
+
"once": "^1.3.1"
|
| 563 |
+
}
|
| 564 |
+
},
|
| 565 |
+
"node_modules/rc": {
|
| 566 |
+
"version": "1.2.8",
|
| 567 |
+
"resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz",
|
| 568 |
+
"integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==",
|
| 569 |
+
"license": "(BSD-2-Clause OR MIT OR Apache-2.0)",
|
| 570 |
+
"dependencies": {
|
| 571 |
+
"deep-extend": "^0.6.0",
|
| 572 |
+
"ini": "~1.3.0",
|
| 573 |
+
"minimist": "^1.2.0",
|
| 574 |
+
"strip-json-comments": "~2.0.1"
|
| 575 |
+
},
|
| 576 |
+
"bin": {
|
| 577 |
+
"rc": "cli.js"
|
| 578 |
+
}
|
| 579 |
+
},
|
| 580 |
+
"node_modules/readable-stream": {
|
| 581 |
+
"version": "3.6.2",
|
| 582 |
+
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
|
| 583 |
+
"integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
|
| 584 |
+
"license": "MIT",
|
| 585 |
+
"dependencies": {
|
| 586 |
+
"inherits": "^2.0.3",
|
| 587 |
+
"string_decoder": "^1.1.1",
|
| 588 |
+
"util-deprecate": "^1.0.1"
|
| 589 |
+
},
|
| 590 |
+
"engines": {
|
| 591 |
+
"node": ">= 6"
|
| 592 |
+
}
|
| 593 |
+
},
|
| 594 |
+
"node_modules/safe-buffer": {
|
| 595 |
+
"version": "5.2.1",
|
| 596 |
+
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
| 597 |
+
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
|
| 598 |
+
"funding": [
|
| 599 |
+
{
|
| 600 |
+
"type": "github",
|
| 601 |
+
"url": "https://github.com/sponsors/feross"
|
| 602 |
+
},
|
| 603 |
+
{
|
| 604 |
+
"type": "patreon",
|
| 605 |
+
"url": "https://www.patreon.com/feross"
|
| 606 |
+
},
|
| 607 |
+
{
|
| 608 |
+
"type": "consulting",
|
| 609 |
+
"url": "https://feross.org/support"
|
| 610 |
+
}
|
| 611 |
+
],
|
| 612 |
+
"license": "MIT"
|
| 613 |
+
},
|
| 614 |
+
"node_modules/semver": {
|
| 615 |
+
"version": "7.8.5",
|
| 616 |
+
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz",
|
| 617 |
+
"integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==",
|
| 618 |
+
"license": "ISC",
|
| 619 |
+
"bin": {
|
| 620 |
+
"semver": "bin/semver.js"
|
| 621 |
+
},
|
| 622 |
+
"engines": {
|
| 623 |
+
"node": ">=10"
|
| 624 |
+
}
|
| 625 |
+
},
|
| 626 |
+
"node_modules/simple-concat": {
|
| 627 |
+
"version": "1.0.1",
|
| 628 |
+
"resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz",
|
| 629 |
+
"integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==",
|
| 630 |
+
"funding": [
|
| 631 |
+
{
|
| 632 |
+
"type": "github",
|
| 633 |
+
"url": "https://github.com/sponsors/feross"
|
| 634 |
+
},
|
| 635 |
+
{
|
| 636 |
+
"type": "patreon",
|
| 637 |
+
"url": "https://www.patreon.com/feross"
|
| 638 |
+
},
|
| 639 |
+
{
|
| 640 |
+
"type": "consulting",
|
| 641 |
+
"url": "https://feross.org/support"
|
| 642 |
+
}
|
| 643 |
+
],
|
| 644 |
+
"license": "MIT"
|
| 645 |
+
},
|
| 646 |
+
"node_modules/simple-get": {
|
| 647 |
+
"version": "4.0.1",
|
| 648 |
+
"resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz",
|
| 649 |
+
"integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==",
|
| 650 |
+
"funding": [
|
| 651 |
+
{
|
| 652 |
+
"type": "github",
|
| 653 |
+
"url": "https://github.com/sponsors/feross"
|
| 654 |
+
},
|
| 655 |
+
{
|
| 656 |
+
"type": "patreon",
|
| 657 |
+
"url": "https://www.patreon.com/feross"
|
| 658 |
+
},
|
| 659 |
+
{
|
| 660 |
+
"type": "consulting",
|
| 661 |
+
"url": "https://feross.org/support"
|
| 662 |
+
}
|
| 663 |
+
],
|
| 664 |
+
"license": "MIT",
|
| 665 |
+
"dependencies": {
|
| 666 |
+
"decompress-response": "^6.0.0",
|
| 667 |
+
"once": "^1.3.1",
|
| 668 |
+
"simple-concat": "^1.0.0"
|
| 669 |
+
}
|
| 670 |
+
},
|
| 671 |
+
"node_modules/string_decoder": {
|
| 672 |
+
"version": "1.3.0",
|
| 673 |
+
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
|
| 674 |
+
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
|
| 675 |
+
"license": "MIT",
|
| 676 |
+
"dependencies": {
|
| 677 |
+
"safe-buffer": "~5.2.0"
|
| 678 |
+
}
|
| 679 |
+
},
|
| 680 |
+
"node_modules/strip-json-comments": {
|
| 681 |
+
"version": "2.0.1",
|
| 682 |
+
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
|
| 683 |
+
"integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==",
|
| 684 |
+
"license": "MIT",
|
| 685 |
+
"engines": {
|
| 686 |
+
"node": ">=0.10.0"
|
| 687 |
+
}
|
| 688 |
+
},
|
| 689 |
+
"node_modules/tar-fs": {
|
| 690 |
+
"version": "2.1.5",
|
| 691 |
+
"resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.5.tgz",
|
| 692 |
+
"integrity": "sha512-OboTd8mmMhZDNPV+UjQcK9yKAatXu2aJ+r1w4im1Otd4M4fl2hwvdoXUxIYHFTHWK/3y3FarBP70v3vwmGlOxw==",
|
| 693 |
+
"license": "MIT",
|
| 694 |
+
"dependencies": {
|
| 695 |
+
"chownr": "^1.1.1",
|
| 696 |
+
"mkdirp-classic": "^0.5.2",
|
| 697 |
+
"pump": "^3.0.0",
|
| 698 |
+
"tar-stream": "^2.1.4"
|
| 699 |
+
}
|
| 700 |
+
},
|
| 701 |
+
"node_modules/tar-stream": {
|
| 702 |
+
"version": "2.2.0",
|
| 703 |
+
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz",
|
| 704 |
+
"integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==",
|
| 705 |
+
"license": "MIT",
|
| 706 |
+
"dependencies": {
|
| 707 |
+
"bl": "^4.0.3",
|
| 708 |
+
"end-of-stream": "^1.4.1",
|
| 709 |
+
"fs-constants": "^1.0.0",
|
| 710 |
+
"inherits": "^2.0.3",
|
| 711 |
+
"readable-stream": "^3.1.1"
|
| 712 |
+
},
|
| 713 |
+
"engines": {
|
| 714 |
+
"node": ">=6"
|
| 715 |
+
}
|
| 716 |
+
},
|
| 717 |
+
"node_modules/teaql-ts": {
|
| 718 |
+
"resolved": "../..",
|
| 719 |
+
"link": true
|
| 720 |
+
},
|
| 721 |
+
"node_modules/ts-node": {
|
| 722 |
+
"version": "10.9.2",
|
| 723 |
+
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz",
|
| 724 |
+
"integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==",
|
| 725 |
+
"dev": true,
|
| 726 |
+
"license": "MIT",
|
| 727 |
+
"dependencies": {
|
| 728 |
+
"@cspotcode/source-map-support": "^0.8.0",
|
| 729 |
+
"@tsconfig/node10": "^1.0.7",
|
| 730 |
+
"@tsconfig/node12": "^1.0.7",
|
| 731 |
+
"@tsconfig/node14": "^1.0.0",
|
| 732 |
+
"@tsconfig/node16": "^1.0.2",
|
| 733 |
+
"acorn": "^8.4.1",
|
| 734 |
+
"acorn-walk": "^8.1.1",
|
| 735 |
+
"arg": "^4.1.0",
|
| 736 |
+
"create-require": "^1.1.0",
|
| 737 |
+
"diff": "^4.0.1",
|
| 738 |
+
"make-error": "^1.1.1",
|
| 739 |
+
"v8-compile-cache-lib": "^3.0.1",
|
| 740 |
+
"yn": "3.1.1"
|
| 741 |
+
},
|
| 742 |
+
"bin": {
|
| 743 |
+
"ts-node": "dist/bin.js",
|
| 744 |
+
"ts-node-cwd": "dist/bin-cwd.js",
|
| 745 |
+
"ts-node-esm": "dist/bin-esm.js",
|
| 746 |
+
"ts-node-script": "dist/bin-script.js",
|
| 747 |
+
"ts-node-transpile-only": "dist/bin-transpile.js",
|
| 748 |
+
"ts-script": "dist/bin-script-deprecated.js"
|
| 749 |
+
},
|
| 750 |
+
"peerDependencies": {
|
| 751 |
+
"@swc/core": ">=1.2.50",
|
| 752 |
+
"@swc/wasm": ">=1.2.50",
|
| 753 |
+
"@types/node": "*",
|
| 754 |
+
"typescript": ">=2.7"
|
| 755 |
+
},
|
| 756 |
+
"peerDependenciesMeta": {
|
| 757 |
+
"@swc/core": {
|
| 758 |
+
"optional": true
|
| 759 |
+
},
|
| 760 |
+
"@swc/wasm": {
|
| 761 |
+
"optional": true
|
| 762 |
+
}
|
| 763 |
+
}
|
| 764 |
+
},
|
| 765 |
+
"node_modules/tunnel-agent": {
|
| 766 |
+
"version": "0.6.0",
|
| 767 |
+
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
|
| 768 |
+
"integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==",
|
| 769 |
+
"license": "Apache-2.0",
|
| 770 |
+
"dependencies": {
|
| 771 |
+
"safe-buffer": "^5.0.1"
|
| 772 |
+
},
|
| 773 |
+
"engines": {
|
| 774 |
+
"node": "*"
|
| 775 |
+
}
|
| 776 |
+
},
|
| 777 |
+
"node_modules/typescript": {
|
| 778 |
+
"version": "5.9.3",
|
| 779 |
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
| 780 |
+
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
| 781 |
+
"dev": true,
|
| 782 |
+
"license": "Apache-2.0",
|
| 783 |
+
"bin": {
|
| 784 |
+
"tsc": "bin/tsc",
|
| 785 |
+
"tsserver": "bin/tsserver"
|
| 786 |
+
},
|
| 787 |
+
"engines": {
|
| 788 |
+
"node": ">=14.17"
|
| 789 |
+
}
|
| 790 |
+
},
|
| 791 |
+
"node_modules/undici-types": {
|
| 792 |
+
"version": "6.21.0",
|
| 793 |
+
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
| 794 |
+
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
| 795 |
+
"dev": true,
|
| 796 |
+
"license": "MIT"
|
| 797 |
+
},
|
| 798 |
+
"node_modules/util-deprecate": {
|
| 799 |
+
"version": "1.0.2",
|
| 800 |
+
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
| 801 |
+
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
|
| 802 |
+
"license": "MIT"
|
| 803 |
+
},
|
| 804 |
+
"node_modules/v8-compile-cache-lib": {
|
| 805 |
+
"version": "3.0.1",
|
| 806 |
+
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
|
| 807 |
+
"integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==",
|
| 808 |
+
"dev": true,
|
| 809 |
+
"license": "MIT"
|
| 810 |
+
},
|
| 811 |
+
"node_modules/wrappy": {
|
| 812 |
+
"version": "1.0.2",
|
| 813 |
+
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
| 814 |
+
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
|
| 815 |
+
"license": "ISC"
|
| 816 |
+
},
|
| 817 |
+
"node_modules/yn": {
|
| 818 |
+
"version": "3.1.1",
|
| 819 |
+
"resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
|
| 820 |
+
"integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
|
| 821 |
+
"dev": true,
|
| 822 |
+
"license": "MIT",
|
| 823 |
+
"engines": {
|
| 824 |
+
"node": ">=6"
|
| 825 |
+
}
|
| 826 |
+
}
|
| 827 |
+
}
|
| 828 |
+
}
|
source/teaql-ts/examples/conformance/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "runtime-example-conformance-service-lib",
|
| 3 |
+
"version": "1.0.0",
|
| 4 |
+
"description": "Generated typescript library",
|
| 5 |
+
"main": "src/generated/Q.ts",
|
| 6 |
+
"scripts": {
|
| 7 |
+
"build": "tsc --noEmit",
|
| 8 |
+
"start": "ts-node src/main.ts"
|
| 9 |
+
},
|
| 10 |
+
"dependencies": {
|
| 11 |
+
"teaql-ts": "file:../..",
|
| 12 |
+
"better-sqlite3": "^12.10.0"},
|
| 13 |
+
"devDependencies": {
|
| 14 |
+
"typescript": "^5.0.0",
|
| 15 |
+
"ts-node": "^10.9.2",
|
| 16 |
+
"@types/node": "^22.0.0",
|
| 17 |
+
"@types/better-sqlite3": "^7.6.12"}
|
| 18 |
+
}
|
source/teaql-ts/examples/conformance/src/generated-bootstrap.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { UserContext } from './teaql-ts';
|
| 2 |
+
import { Q } from './generated/Q';
|
| 3 |
+
import { Platform } from './generated/models/Platform';
|
| 4 |
+
|
| 5 |
+
/** @internal Generated typed Mutation bootstrap; never call from application code. */
|
| 6 |
+
export async function ensureGeneratedBootstrap(context: UserContext): Promise<void> {
|
| 7 |
+
let domainRoot = (await Q.platforms().withIdIs('1').comment('what: locate generated Domain Root').purpose('why: idempotent runtime bootstrap').executeForList(context))[0];
|
| 8 |
+
if (!domainRoot) {
|
| 9 |
+
domainRoot = Platform.teaqlBootstrapNew('1');
|
| 10 |
+
domainRoot.updateName("Runtime Example");
|
| 11 |
+
await domainRoot.auditAs('create generated Domain Root Platform').save(context);
|
| 12 |
+
}
|
| 13 |
+
context.withActiveRoot({ entity: 'Platform', id: domainRoot.id! });
|
| 14 |
+
}
|
source/teaql-ts/examples/conformance/src/generated-search-models.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { GeneratedSearchModel } from "teaql-ts";
|
| 2 |
+
|
| 3 |
+
/** Generated trusted naming/type metadata. No query execution or authorization lives here. */
|
| 4 |
+
export const GENERATED_SEARCH_MODELS: Readonly<Record<string, GeneratedSearchModel>> = Object.freeze({
|
| 5 |
+
"Platform": Object.freeze({
|
| 6 |
+
fields: Object.freeze({
|
| 7 |
+
"id": "integer" as const,
|
| 8 |
+
"name": "string" as const,
|
| 9 |
+
"version": "integer" as const,
|
| 10 |
+
}),
|
| 11 |
+
queryFields: Object.freeze({
|
| 12 |
+
"id": "id",
|
| 13 |
+
"name": "name",
|
| 14 |
+
"version": "version",
|
| 15 |
+
}),
|
| 16 |
+
relations: Object.freeze({
|
| 17 |
+
"workItemList": "WorkItem",
|
| 18 |
+
}),
|
| 19 |
+
}),
|
| 20 |
+
"WorkItem": Object.freeze({
|
| 21 |
+
fields: Object.freeze({
|
| 22 |
+
"id": "integer" as const,
|
| 23 |
+
"title": "string" as const,
|
| 24 |
+
"description": "string" as const,
|
| 25 |
+
"platform": "integer" as const,
|
| 26 |
+
"version": "integer" as const,
|
| 27 |
+
}),
|
| 28 |
+
queryFields: Object.freeze({
|
| 29 |
+
"id": "id",
|
| 30 |
+
"title": "title",
|
| 31 |
+
"description": "description",
|
| 32 |
+
"platform": "platform",
|
| 33 |
+
"version": "version",
|
| 34 |
+
}),
|
| 35 |
+
relations: Object.freeze({
|
| 36 |
+
"platform": "Platform",
|
| 37 |
+
}),
|
| 38 |
+
}),
|
| 39 |
+
});
|
source/teaql-ts/examples/conformance/src/generated/E.ts
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Platform } from './models/Platform';
|
| 2 |
+
import { WorkItem } from './models/WorkItem';
|
| 3 |
+
|
| 4 |
+
export class TeaQLNotLoadedError extends Error {
|
| 5 |
+
readonly details: Record<string, unknown>;
|
| 6 |
+
|
| 7 |
+
constructor(
|
| 8 |
+
readonly root: string,
|
| 9 |
+
readonly accessPath: string,
|
| 10 |
+
readonly breakPoint: string,
|
| 11 |
+
) {
|
| 12 |
+
const suggestedFix = `select${breakPoint.charAt(0).toUpperCase()}${breakPoint.slice(1)}(...)`;
|
| 13 |
+
const details = {
|
| 14 |
+
error: 'TeaQLNotLoadedError',
|
| 15 |
+
root,
|
| 16 |
+
accessPath: accessPath.split('.'),
|
| 17 |
+
breakPoint,
|
| 18 |
+
missingPreload: [breakPoint],
|
| 19 |
+
suggestedFix,
|
| 20 |
+
severity: 'error',
|
| 21 |
+
humanMessage: `访问 ${root}.${accessPath} 时缺少预加载。请在查询中加入 ${suggestedFix}`,
|
| 22 |
+
};
|
| 23 |
+
super(JSON.stringify(details));
|
| 24 |
+
this.name = 'TeaQLNotLoadedError';
|
| 25 |
+
this.details = details;
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
function expressionPath(prefix: string, field: string): string {
|
| 30 |
+
return prefix ? `${prefix}.${field}` : field;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
export class ValueExpression<T> {
|
| 34 |
+
constructor(
|
| 35 |
+
private readonly value: T | null | undefined,
|
| 36 |
+
private readonly present = true,
|
| 37 |
+
private readonly notLoaded?: TeaQLNotLoadedError,
|
| 38 |
+
) {}
|
| 39 |
+
|
| 40 |
+
static missing<T>(): ValueExpression<T> {
|
| 41 |
+
return new ValueExpression<T>(undefined, false);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
static notLoaded<T>(error: TeaQLNotLoadedError): ValueExpression<T> {
|
| 45 |
+
return new ValueExpression<T>(undefined, false, error);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
eval(): T | null | undefined {
|
| 49 |
+
if (this.notLoaded) throw this.notLoaded;
|
| 50 |
+
return this.present ? this.value : undefined;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
isPresent(): boolean {
|
| 54 |
+
if (this.notLoaded) throw this.notLoaded;
|
| 55 |
+
return this.present;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
orElse(fallback: T): T {
|
| 59 |
+
const value = this.eval();
|
| 60 |
+
return this.present && value != null ? value : fallback;
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
export class PlatformExpression {
|
| 65 |
+
constructor(
|
| 66 |
+
private readonly value: Platform | null | undefined,
|
| 67 |
+
private readonly root = 'Platform(null)',
|
| 68 |
+
private readonly path = '',
|
| 69 |
+
private readonly notLoaded?: TeaQLNotLoadedError,
|
| 70 |
+
) {}
|
| 71 |
+
|
| 72 |
+
eval(): Platform | null | undefined {
|
| 73 |
+
if (this.notLoaded) throw this.notLoaded;
|
| 74 |
+
return this.value;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
id(): ValueExpression<string> {
|
| 78 |
+
if (this.notLoaded) return ValueExpression.notLoaded<string>(this.notLoaded);
|
| 79 |
+
if (!this.value) return ValueExpression.missing<string>();
|
| 80 |
+
const path = expressionPath(this.path, 'id');
|
| 81 |
+
if (!this.value.isLoaded('id')) {
|
| 82 |
+
return ValueExpression.notLoaded<string>(
|
| 83 |
+
new TeaQLNotLoadedError(this.root, path, 'id'),
|
| 84 |
+
);
|
| 85 |
+
}
|
| 86 |
+
return new ValueExpression<string>(this.value.id);
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
name(): ValueExpression<string> {
|
| 90 |
+
if (this.notLoaded) return ValueExpression.notLoaded<string>(this.notLoaded);
|
| 91 |
+
if (!this.value) return ValueExpression.missing<string>();
|
| 92 |
+
const path = expressionPath(this.path, 'name');
|
| 93 |
+
if (!this.value.isLoaded('name')) {
|
| 94 |
+
return ValueExpression.notLoaded<string>(
|
| 95 |
+
new TeaQLNotLoadedError(this.root, path, 'name'),
|
| 96 |
+
);
|
| 97 |
+
}
|
| 98 |
+
return new ValueExpression<string>(this.value.name);
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
version(): ValueExpression<number> {
|
| 102 |
+
if (this.notLoaded) return ValueExpression.notLoaded<number>(this.notLoaded);
|
| 103 |
+
if (!this.value) return ValueExpression.missing<number>();
|
| 104 |
+
const path = expressionPath(this.path, 'version');
|
| 105 |
+
if (!this.value.isLoaded('version')) {
|
| 106 |
+
return ValueExpression.notLoaded<number>(
|
| 107 |
+
new TeaQLNotLoadedError(this.root, path, 'version'),
|
| 108 |
+
);
|
| 109 |
+
}
|
| 110 |
+
return new ValueExpression<number>(this.value.version);
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
workItemList(): WorkItemListExpression {
|
| 116 |
+
const path = expressionPath(this.path, 'workItemList');
|
| 117 |
+
if (this.notLoaded) {
|
| 118 |
+
return new WorkItemListExpression([], this.root, path, false, this.notLoaded);
|
| 119 |
+
}
|
| 120 |
+
if (!this.value) return WorkItemListExpression.missing(this.root, path);
|
| 121 |
+
if (!this.value.isLoaded('workItemList')) {
|
| 122 |
+
return new WorkItemListExpression([], this.root, path, false,
|
| 123 |
+
new TeaQLNotLoadedError(this.root, path, 'workItemList'));
|
| 124 |
+
}
|
| 125 |
+
return new WorkItemListExpression(
|
| 126 |
+
this.value.workItemList(), this.root, path,
|
| 127 |
+
);
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
export class WorkItemExpression {
|
| 132 |
+
constructor(
|
| 133 |
+
private readonly value: WorkItem | null | undefined,
|
| 134 |
+
private readonly root = 'WorkItem(null)',
|
| 135 |
+
private readonly path = '',
|
| 136 |
+
private readonly notLoaded?: TeaQLNotLoadedError,
|
| 137 |
+
) {}
|
| 138 |
+
|
| 139 |
+
eval(): WorkItem | null | undefined {
|
| 140 |
+
if (this.notLoaded) throw this.notLoaded;
|
| 141 |
+
return this.value;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
id(): ValueExpression<string> {
|
| 145 |
+
if (this.notLoaded) return ValueExpression.notLoaded<string>(this.notLoaded);
|
| 146 |
+
if (!this.value) return ValueExpression.missing<string>();
|
| 147 |
+
const path = expressionPath(this.path, 'id');
|
| 148 |
+
if (!this.value.isLoaded('id')) {
|
| 149 |
+
return ValueExpression.notLoaded<string>(
|
| 150 |
+
new TeaQLNotLoadedError(this.root, path, 'id'),
|
| 151 |
+
);
|
| 152 |
+
}
|
| 153 |
+
return new ValueExpression<string>(this.value.id);
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
title(): ValueExpression<string> {
|
| 157 |
+
if (this.notLoaded) return ValueExpression.notLoaded<string>(this.notLoaded);
|
| 158 |
+
if (!this.value) return ValueExpression.missing<string>();
|
| 159 |
+
const path = expressionPath(this.path, 'title');
|
| 160 |
+
if (!this.value.isLoaded('title')) {
|
| 161 |
+
return ValueExpression.notLoaded<string>(
|
| 162 |
+
new TeaQLNotLoadedError(this.root, path, 'title'),
|
| 163 |
+
);
|
| 164 |
+
}
|
| 165 |
+
return new ValueExpression<string>(this.value.title);
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
description(): ValueExpression<string> {
|
| 169 |
+
if (this.notLoaded) return ValueExpression.notLoaded<string>(this.notLoaded);
|
| 170 |
+
if (!this.value) return ValueExpression.missing<string>();
|
| 171 |
+
const path = expressionPath(this.path, 'description');
|
| 172 |
+
if (!this.value.isLoaded('description')) {
|
| 173 |
+
return ValueExpression.notLoaded<string>(
|
| 174 |
+
new TeaQLNotLoadedError(this.root, path, 'description'),
|
| 175 |
+
);
|
| 176 |
+
}
|
| 177 |
+
return new ValueExpression<string>(this.value.description);
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
version(): ValueExpression<number> {
|
| 181 |
+
if (this.notLoaded) return ValueExpression.notLoaded<number>(this.notLoaded);
|
| 182 |
+
if (!this.value) return ValueExpression.missing<number>();
|
| 183 |
+
const path = expressionPath(this.path, 'version');
|
| 184 |
+
if (!this.value.isLoaded('version')) {
|
| 185 |
+
return ValueExpression.notLoaded<number>(
|
| 186 |
+
new TeaQLNotLoadedError(this.root, path, 'version'),
|
| 187 |
+
);
|
| 188 |
+
}
|
| 189 |
+
return new ValueExpression<number>(this.value.version);
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
platformId(): ValueExpression<string | number> {
|
| 193 |
+
if (this.notLoaded) return ValueExpression.notLoaded<string | number>(this.notLoaded);
|
| 194 |
+
if (!this.value) return ValueExpression.missing<string | number>();
|
| 195 |
+
const path = expressionPath(this.path, 'platform');
|
| 196 |
+
if (!this.value.isLoaded('platform')) {
|
| 197 |
+
return ValueExpression.notLoaded<string | number>(
|
| 198 |
+
new TeaQLNotLoadedError(this.root, path, 'platform'),
|
| 199 |
+
);
|
| 200 |
+
}
|
| 201 |
+
const reference = this.value.platform;
|
| 202 |
+
return new ValueExpression<string | number>(
|
| 203 |
+
reference instanceof Platform
|
| 204 |
+
? reference.id : reference as string | number | undefined,
|
| 205 |
+
);
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
platform(): PlatformExpression {
|
| 209 |
+
const path = expressionPath(this.path, 'platform');
|
| 210 |
+
if (this.notLoaded) {
|
| 211 |
+
return new PlatformExpression(undefined, this.root, path, this.notLoaded);
|
| 212 |
+
}
|
| 213 |
+
if (!this.value) return new PlatformExpression(undefined, this.root, path);
|
| 214 |
+
if (!this.value.isLoaded('platform')) {
|
| 215 |
+
return new PlatformExpression(undefined, this.root, path,
|
| 216 |
+
new TeaQLNotLoadedError(this.root, path, 'platform'));
|
| 217 |
+
}
|
| 218 |
+
const relation = this.value.platform;
|
| 219 |
+
const target = relation == null
|
| 220 |
+
? undefined
|
| 221 |
+
: relation instanceof Platform
|
| 222 |
+
? relation
|
| 223 |
+
: Platform.fromRecord({ id: relation });
|
| 224 |
+
return new PlatformExpression(target, this.root, path);
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
export class PlatformListExpression {
|
| 230 |
+
constructor(
|
| 231 |
+
private readonly items: readonly Platform[],
|
| 232 |
+
private readonly root = 'Platform(null)',
|
| 233 |
+
private readonly path = '',
|
| 234 |
+
private readonly present = true,
|
| 235 |
+
private readonly notLoaded?: TeaQLNotLoadedError,
|
| 236 |
+
) {}
|
| 237 |
+
|
| 238 |
+
static missing(root?: string, path = ''): PlatformListExpression {
|
| 239 |
+
return new PlatformListExpression([], root, path, false);
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
size(): ValueExpression<number> {
|
| 243 |
+
if (this.notLoaded) return ValueExpression.notLoaded<number>(this.notLoaded);
|
| 244 |
+
return this.present
|
| 245 |
+
? new ValueExpression<number>(this.items.length)
|
| 246 |
+
: ValueExpression.missing<number>();
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
first(): PlatformExpression {
|
| 250 |
+
return this.get(0);
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
get(index: number): PlatformExpression {
|
| 254 |
+
const itemPath = expressionPath(this.path, `get(${index})`);
|
| 255 |
+
if (this.notLoaded) {
|
| 256 |
+
return new PlatformExpression(undefined, this.root, itemPath, this.notLoaded);
|
| 257 |
+
}
|
| 258 |
+
return !this.present || index < 0 || index >= this.items.length
|
| 259 |
+
? new PlatformExpression(undefined, this.root, itemPath)
|
| 260 |
+
: new PlatformExpression(this.items[index], this.root, itemPath);
|
| 261 |
+
}
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
export class WorkItemListExpression {
|
| 265 |
+
constructor(
|
| 266 |
+
private readonly items: readonly WorkItem[],
|
| 267 |
+
private readonly root = 'WorkItem(null)',
|
| 268 |
+
private readonly path = '',
|
| 269 |
+
private readonly present = true,
|
| 270 |
+
private readonly notLoaded?: TeaQLNotLoadedError,
|
| 271 |
+
) {}
|
| 272 |
+
|
| 273 |
+
static missing(root?: string, path = ''): WorkItemListExpression {
|
| 274 |
+
return new WorkItemListExpression([], root, path, false);
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
size(): ValueExpression<number> {
|
| 278 |
+
if (this.notLoaded) return ValueExpression.notLoaded<number>(this.notLoaded);
|
| 279 |
+
return this.present
|
| 280 |
+
? new ValueExpression<number>(this.items.length)
|
| 281 |
+
: ValueExpression.missing<number>();
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
first(): WorkItemExpression {
|
| 285 |
+
return this.get(0);
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
get(index: number): WorkItemExpression {
|
| 289 |
+
const itemPath = expressionPath(this.path, `get(${index})`);
|
| 290 |
+
if (this.notLoaded) {
|
| 291 |
+
return new WorkItemExpression(undefined, this.root, itemPath, this.notLoaded);
|
| 292 |
+
}
|
| 293 |
+
return !this.present || index < 0 || index >= this.items.length
|
| 294 |
+
? new WorkItemExpression(undefined, this.root, itemPath)
|
| 295 |
+
: new WorkItemExpression(this.items[index], this.root, itemPath);
|
| 296 |
+
}
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
export class E {
|
| 300 |
+
static platform(
|
| 301 |
+
value: Platform | null | undefined,
|
| 302 |
+
): PlatformExpression {
|
| 303 |
+
return new PlatformExpression(
|
| 304 |
+
value, `Platform(id=${value?.id ?? 'null'})`,
|
| 305 |
+
);
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
static workItem(
|
| 309 |
+
value: WorkItem | null | undefined,
|
| 310 |
+
): WorkItemExpression {
|
| 311 |
+
return new WorkItemExpression(
|
| 312 |
+
value, `WorkItem(id=${value?.id ?? 'null'})`,
|
| 313 |
+
);
|
| 314 |
+
}
|
| 315 |
+
}
|
source/teaql-ts/examples/conformance/src/generated/Q.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { TeaQLClient } from '../teaql-ts';
|
| 2 |
+
import { PlatformRequest } from './requests/PlatformRequest';
|
| 3 |
+
import { WorkItemRequest } from './requests/WorkItemRequest';
|
| 4 |
+
|
| 5 |
+
export class Q {
|
| 6 |
+
static platforms(): PlatformRequest {
|
| 7 |
+
return new PlatformRequest(false);
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
static platformsWithMinimalFields(): PlatformRequest {
|
| 11 |
+
return new PlatformRequest(true);
|
| 12 |
+
}
|
| 13 |
+
static workItems(): WorkItemRequest {
|
| 14 |
+
return new WorkItemRequest(false);
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
static workItemsWithMinimalFields(): WorkItemRequest {
|
| 18 |
+
return new WorkItemRequest(true);
|
| 19 |
+
}
|
| 20 |
+
}
|
source/teaql-ts/examples/conformance/src/generated/models/Platform.ts
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { CheckException, EntityKey, EntityRoot, GraphMutationSession, LoadedScalarSnapshot, MutationIntent, MutationTraceScope, ObjectLocation, SmartList, TeaQLDataService, UserContext } from '../../teaql-ts';
|
| 2 |
+
import { WorkItem } from './WorkItem';
|
| 3 |
+
|
| 4 |
+
export class Platform {
|
| 5 |
+
private static teaqlTemporaryId = 0;
|
| 6 |
+
id?: string;
|
| 7 |
+
name?: string;
|
| 8 |
+
version?: number;
|
| 9 |
+
|
| 10 |
+
constructor(init?: Partial<Platform>) {
|
| 11 |
+
Object.defineProperty(this, "_action", { value: init && init.id ? "Update" : "Create", writable: true, enumerable: false });
|
| 12 |
+
Object.defineProperty(this, "_comment", { value: undefined, writable: true, enumerable: false });
|
| 13 |
+
Object.defineProperty(this, "_fullyLoaded", { value: !init || !init.id, writable: true, enumerable: false });
|
| 14 |
+
Object.defineProperty(this, "_loadedFields", { value: new Set(Object.keys(init || {})), writable: true, enumerable: false });
|
| 15 |
+
Object.defineProperty(this, "_root", { value: new EntityRoot(), writable: true, enumerable: false });
|
| 16 |
+
Object.defineProperty(this, "_ledgerId", { value: init?.id ?? --Platform.teaqlTemporaryId, writable: true, enumerable: false });
|
| 17 |
+
Object.defineProperty(this, "_workItemList", { value: init?.id ? SmartList.empty() : new SmartList(), writable: true, enumerable: false });
|
| 18 |
+
if (init) {
|
| 19 |
+
const fields: Record<string, unknown> = { ...(init as Record<string, unknown>) };
|
| 20 |
+
delete fields["workItemList"];
|
| 21 |
+
Object.assign(this, fields);
|
| 22 |
+
if (Array.isArray((init as any).workItemList)) {
|
| 23 |
+
const selected = (init as any).workItemList;
|
| 24 |
+
(this as any)._workItemList = new SmartList(selected.map(
|
| 25 |
+
(child: unknown) => child instanceof WorkItem
|
| 26 |
+
? child
|
| 27 |
+
: WorkItem.fromRecord(child as Record<string, unknown>),
|
| 28 |
+
), { totalCount: selected.totalCount, aggregations: selected.aggregations,
|
| 29 |
+
summary: selected.summary, facets: selected.facets, isLoaded: selected.isLoaded ?? true });
|
| 30 |
+
this.markLoaded("workItemList");
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
const key = this.teaqlEntityKey();
|
| 34 |
+
if ((this as any)._action === "Create") (this as any)._root.markAsNew(key);
|
| 35 |
+
else if ((this as any).version !== undefined) (this as any)._root.setOriginalVersion(key, Number((this as any).version));
|
| 36 |
+
LoadedScalarSnapshot.captureFor(this, this.teaqlMutationPayload());
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
private teaqlEntityKey(): EntityKey { return { entity: "Platform", id: (this as any)._ledgerId }; }
|
| 40 |
+
private teaqlAttachRoot(root: EntityRoot): this {
|
| 41 |
+
if ((this as any)._root !== root) {
|
| 42 |
+
root.mergeEntityFrom((this as any)._root, this.teaqlEntityKey());
|
| 43 |
+
(this as any)._root = root;
|
| 44 |
+
}
|
| 45 |
+
for (const child of (this as any)._workItemList) child.teaqlAttachRoot(root);
|
| 46 |
+
return this;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
static fromRecord(record: Record<string, unknown>, root?: EntityRoot): Platform {
|
| 50 |
+
const entity = new Platform(record as Partial<Platform>);
|
| 51 |
+
return root ? entity.teaqlAttachRoot(root) : entity;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
isLoaded(field: string): boolean {
|
| 55 |
+
return (this as any)._fullyLoaded || (this as any)._loadedFields.has(field);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
markLoaded(...fields: string[]): this {
|
| 59 |
+
for (const field of fields) (this as any)._loadedFields.add(field);
|
| 60 |
+
return this;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
markLoadedOnly(...fields: string[]): this {
|
| 64 |
+
(this as any)._fullyLoaded = false;
|
| 65 |
+
(this as any)._loadedFields = new Set(fields);
|
| 66 |
+
return this;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
static refer(id: string | number): Platform {
|
| 70 |
+
return new Platform({ id: String(id) } as Partial<Platform>);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
/** @internal Generated Runtime Module fixed-ID construction capability. */
|
| 74 |
+
static teaqlBootstrapNew(id: string | number): Platform {
|
| 75 |
+
return new Platform().updateId(String(id));
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
markForDeletion(): this {
|
| 79 |
+
(this as any)._action = "Delete";
|
| 80 |
+
(this as any)._root.markAsDeleted(this.teaqlEntityKey());
|
| 81 |
+
return this;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
auditAs(comment: string): this {
|
| 85 |
+
new MutationIntent(comment);
|
| 86 |
+
(this as any)._comment = comment;
|
| 87 |
+
return this;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
async save(context: UserContext): Promise<Platform> {
|
| 91 |
+
const service = context.requireResource<TeaQLDataService>("dataService");
|
| 92 |
+
return service.executeGraphSave(new MutationIntent((this as any)._comment), async (graph) => {
|
| 93 |
+
this.teaqlPreflightGraph(context, service, graph);
|
| 94 |
+
return this.teaqlSaveWithinGraph(context, service, graph);
|
| 95 |
+
});
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
/** @internal Validates and fixes the complete graph before its first mutation. */
|
| 99 |
+
teaqlPreflightGraph(context: UserContext, service: TeaQLDataService, graph: GraphMutationSession, parent?: MutationTraceScope): void {
|
| 100 |
+
if (!parent) new MutationIntent((this as any)._comment);
|
| 101 |
+
const action = (this as any)._action;
|
| 102 |
+
const pending = action !== "Update" || (this as any)._root.hasPending(this.teaqlEntityKey());
|
| 103 |
+
if (action === "Update" && pending) {
|
| 104 |
+
const notLoaded = [{ member: "id", canonical: "id" }, { member: "name", canonical: "name" }, { member: "version", canonical: "version" }]
|
| 105 |
+
.find(field => !this.isLoaded(field.member));
|
| 106 |
+
if (notLoaded) {
|
| 107 |
+
throw new CheckException([{
|
| 108 |
+
ruleId: "invalid_type",
|
| 109 |
+
location: ObjectLocation.property(notLoaded.canonical),
|
| 110 |
+
message: "Mutation requires a fully loaded entity",
|
| 111 |
+
}]);
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
const request = graph.request({
|
| 115 |
+
entity: "Platform", action,
|
| 116 |
+
payload: action === "Update"
|
| 117 |
+
? (this as any)._root.change(this.teaqlEntityKey())
|
| 118 |
+
: this.teaqlMutationPayload(),
|
| 119 |
+
id: (this as any).id, version: (this as any).version,
|
| 120 |
+
comment: (this as any)._comment,
|
| 121 |
+
ledgerKey: this.teaqlEntityKey(), ledgerRoot: (this as any)._root,
|
| 122 |
+
}, parent, (this as any)._comment).withLoadedSnapshot(LoadedScalarSnapshot.forEntity(this) ?? new LoadedScalarSnapshot());
|
| 123 |
+
if (pending) service.preflightMutation(request);
|
| 124 |
+
const scope = request.scopeFor(this.teaqlEntityKey());
|
| 125 |
+
for (const [index, child] of (this as any)._workItemList.entries()) {
|
| 126 |
+
child.teaqlAttachRoot((this as any)._root);
|
| 127 |
+
const currentParent = child.platform;
|
| 128 |
+
if (this.id === undefined || !child.isLoaded("platform") || (typeof currentParent === "object" && currentParent !== null
|
| 129 |
+
? currentParent.id : currentParent) !== this.id) child.updatePlatform(this);
|
| 130 |
+
try { child.teaqlPreflightGraph(context, service, graph, scope); }
|
| 131 |
+
catch (error) {
|
| 132 |
+
if (!(error instanceof CheckException)) throw error;
|
| 133 |
+
const prefix = ObjectLocation.property("work_item_list").index(index);
|
| 134 |
+
throw new CheckException(error.violations.map(violation => ({
|
| 135 |
+
...violation, location: violation.location.prefixedBy(prefix),
|
| 136 |
+
})));
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
/** @internal Used by generated relation cascades inside the root graph transaction. */
|
| 142 |
+
async teaqlSaveWithinGraph(context: UserContext, service: TeaQLDataService, graph: GraphMutationSession, parent?: MutationTraceScope): Promise<Platform> {
|
| 143 |
+
if (!parent) new MutationIntent((this as any)._comment);
|
| 144 |
+
const action = (this as any)._action;
|
| 145 |
+
const ledgerPayload = (this as any)._root.change(this.teaqlEntityKey());
|
| 146 |
+
const mutation = {
|
| 147 |
+
entity: "Platform",
|
| 148 |
+
action: (this as any)._action,
|
| 149 |
+
payload: action === "Update" ? ledgerPayload : this.teaqlMutationPayload(),
|
| 150 |
+
id: (this as any).id,
|
| 151 |
+
version: (this as any).version,
|
| 152 |
+
comment: (this as any)._comment
|
| 153 |
+
,ledgerKey: this.teaqlEntityKey()
|
| 154 |
+
,ledgerRoot: (this as any)._root
|
| 155 |
+
};
|
| 156 |
+
const request = graph.request(mutation, parent, (this as any)._comment)
|
| 157 |
+
.withLoadedSnapshot(LoadedScalarSnapshot.forEntity(this) ?? new LoadedScalarSnapshot());
|
| 158 |
+
if (action === "Update" && !(this as any)._root.hasPending(this.teaqlEntityKey())) {
|
| 159 |
+
const scope = request.scopeFor(this.teaqlEntityKey());
|
| 160 |
+
for (const [index, child] of (this as any)._workItemList.entries()) {
|
| 161 |
+
child.teaqlAttachRoot((this as any)._root);
|
| 162 |
+
const currentParent = child.platform;
|
| 163 |
+
if (this.id === undefined || !child.isLoaded("platform") || (typeof currentParent === "object" && currentParent !== null
|
| 164 |
+
? currentParent.id : currentParent) !== this.id) child.updatePlatform(this);
|
| 165 |
+
try { await child.teaqlSaveWithinGraph(context, service, graph, scope); }
|
| 166 |
+
catch (error) {
|
| 167 |
+
if (!(error instanceof CheckException)) throw error;
|
| 168 |
+
const prefix = ObjectLocation.property("work_item_list").index(index);
|
| 169 |
+
throw new CheckException(error.violations.map(violation => ({
|
| 170 |
+
...violation, location: violation.location.prefixedBy(prefix),
|
| 171 |
+
})));
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
return this;
|
| 175 |
+
}
|
| 176 |
+
const result = await service.executeMutation(request);
|
| 177 |
+
for (const [field, value] of Object.entries(mutation.payload as Record<string, unknown>)) {
|
| 178 |
+
if (field !== "id" && field !== "version") (this as any)._root.set(this.teaqlEntityKey(), field, value);
|
| 179 |
+
}
|
| 180 |
+
if (!result.persistedRecord) {
|
| 181 |
+
throw new Error("Mutation did not return the authoritative persisted record");
|
| 182 |
+
}
|
| 183 |
+
const rollbackState = {
|
| 184 |
+
payload: this.teaqlMutationPayload(),
|
| 185 |
+
ledgerId: (this as any)._ledgerId,
|
| 186 |
+
action: (this as any)._action,
|
| 187 |
+
loadedFields: new Set((this as any)._loadedFields),
|
| 188 |
+
fullyLoaded: (this as any)._fullyLoaded,
|
| 189 |
+
loadedSnapshot: LoadedScalarSnapshot.forEntity(this),
|
| 190 |
+
};
|
| 191 |
+
const oldKey = this.teaqlEntityKey();
|
| 192 |
+
Object.assign(this, result.persistedRecord);
|
| 193 |
+
LoadedScalarSnapshot.captureFor(this, this.teaqlMutationPayload());
|
| 194 |
+
(this as any)._ledgerId = (this as any).id ?? (this as any)._ledgerId;
|
| 195 |
+
const newKey = this.teaqlEntityKey();
|
| 196 |
+
(this as any)._root.rekey(oldKey, newKey);
|
| 197 |
+
service.afterGraphRollback(() => {
|
| 198 |
+
Object.assign(this, rollbackState.payload);
|
| 199 |
+
(this as any)._ledgerId = rollbackState.ledgerId;
|
| 200 |
+
(this as any)._action = rollbackState.action;
|
| 201 |
+
(this as any)._loadedFields = rollbackState.loadedFields;
|
| 202 |
+
(this as any)._fullyLoaded = rollbackState.fullyLoaded;
|
| 203 |
+
LoadedScalarSnapshot.restoreFor(this, rollbackState.loadedSnapshot);
|
| 204 |
+
(this as any)._root.rekey(newKey, oldKey);
|
| 205 |
+
});
|
| 206 |
+
(this as any)._loadedFields = new Set(Object.keys(result.persistedRecord));
|
| 207 |
+
(this as any)._fullyLoaded = false;
|
| 208 |
+
if (mutation.action !== "Delete") (this as any)._action = "Update";
|
| 209 |
+
const scope = request.scopeFor(newKey);
|
| 210 |
+
for (const [index, child] of (this as any)._workItemList.entries()) {
|
| 211 |
+
child.teaqlAttachRoot((this as any)._root);
|
| 212 |
+
const currentParent = child.platform;
|
| 213 |
+
if (this.id === undefined || !child.isLoaded("platform") || (typeof currentParent === "object" && currentParent !== null
|
| 214 |
+
? currentParent.id : currentParent) !== this.id) child.updatePlatform(this);
|
| 215 |
+
try { await child.teaqlSaveWithinGraph(context, service, graph, scope); }
|
| 216 |
+
catch (error) {
|
| 217 |
+
if (!(error instanceof CheckException)) throw error;
|
| 218 |
+
const prefix = ObjectLocation.property("work_item_list").index(index);
|
| 219 |
+
throw new CheckException(error.violations.map(violation => ({
|
| 220 |
+
...violation, location: violation.location.prefixedBy(prefix),
|
| 221 |
+
})));
|
| 222 |
+
}
|
| 223 |
+
}
|
| 224 |
+
service.afterGraphCommit(() => {
|
| 225 |
+
(this as any)._root.clearEntity(newKey);
|
| 226 |
+
if ((this as any).version !== undefined) (this as any)._root.acceptCommittedVersion(newKey, Number((this as any).version));
|
| 227 |
+
});
|
| 228 |
+
return this;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
private teaqlMutationPayload(): Record<string, unknown> {
|
| 232 |
+
return {
|
| 233 |
+
"id": this.id,
|
| 234 |
+
"name": this.name,
|
| 235 |
+
"version": this.version
|
| 236 |
+
};
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
updateId(value: string): this {
|
| 240 |
+
this.id = value;
|
| 241 |
+
this.markLoaded("id");
|
| 242 |
+
(this as any)._root.set(this.teaqlEntityKey(), "id", value);
|
| 243 |
+
return this;
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
updateName(value: string): this {
|
| 247 |
+
this.name = value;
|
| 248 |
+
this.markLoaded("name");
|
| 249 |
+
(this as any)._root.set(this.teaqlEntityKey(), "name", value);
|
| 250 |
+
return this;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
updateVersion(value: number): this {
|
| 254 |
+
this.version = value;
|
| 255 |
+
this.markLoaded("version");
|
| 256 |
+
(this as any)._root.set(this.teaqlEntityKey(), "version", value);
|
| 257 |
+
return this;
|
| 258 |
+
}
|
| 259 |
+
workItemList(): SmartList<WorkItem> {
|
| 260 |
+
return (this as any)._workItemList;
|
| 261 |
+
}
|
| 262 |
+
}
|
source/teaql-ts/examples/conformance/src/generated/models/WorkItem.ts
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { CheckException, EntityKey, EntityRoot, GraphMutationSession, LoadedScalarSnapshot, MutationIntent, MutationTraceScope, ObjectLocation, SmartList, TeaQLDataService, UserContext } from '../../teaql-ts';
|
| 2 |
+
import { Platform } from './Platform';
|
| 3 |
+
|
| 4 |
+
export class WorkItem {
|
| 5 |
+
private static teaqlTemporaryId = 0;
|
| 6 |
+
id?: string;
|
| 7 |
+
title?: string;
|
| 8 |
+
description?: string;
|
| 9 |
+
platform?: Platform | string;
|
| 10 |
+
version?: number;
|
| 11 |
+
|
| 12 |
+
constructor(init?: Partial<WorkItem>) {
|
| 13 |
+
Object.defineProperty(this, "_action", { value: init && init.id ? "Update" : "Create", writable: true, enumerable: false });
|
| 14 |
+
Object.defineProperty(this, "_comment", { value: undefined, writable: true, enumerable: false });
|
| 15 |
+
Object.defineProperty(this, "_fullyLoaded", { value: !init || !init.id, writable: true, enumerable: false });
|
| 16 |
+
Object.defineProperty(this, "_loadedFields", { value: new Set(Object.keys(init || {})), writable: true, enumerable: false });
|
| 17 |
+
Object.defineProperty(this, "_root", { value: new EntityRoot(), writable: true, enumerable: false });
|
| 18 |
+
Object.defineProperty(this, "_ledgerId", { value: init?.id ?? --WorkItem.teaqlTemporaryId, writable: true, enumerable: false });
|
| 19 |
+
if (init) {
|
| 20 |
+
const fields: Record<string, unknown> = { ...(init as Record<string, unknown>) };
|
| 21 |
+
Object.assign(this, fields);
|
| 22 |
+
if ((init as any).platform && typeof (init as any).platform === "object") {
|
| 23 |
+
this.platform = (init as any).platform instanceof Platform
|
| 24 |
+
? (init as any).platform
|
| 25 |
+
: Platform.fromRecord((init as any).platform);
|
| 26 |
+
this.markLoaded("platform");
|
| 27 |
+
}
|
| 28 |
+
}
|
| 29 |
+
const key = this.teaqlEntityKey();
|
| 30 |
+
if ((this as any)._action === "Create") (this as any)._root.markAsNew(key);
|
| 31 |
+
else if ((this as any).version !== undefined) (this as any)._root.setOriginalVersion(key, Number((this as any).version));
|
| 32 |
+
LoadedScalarSnapshot.captureFor(this, this.teaqlMutationPayload());
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
private teaqlEntityKey(): EntityKey { return { entity: "WorkItem", id: (this as any)._ledgerId }; }
|
| 36 |
+
private teaqlAttachRoot(root: EntityRoot): this {
|
| 37 |
+
if ((this as any)._root !== root) {
|
| 38 |
+
root.mergeEntityFrom((this as any)._root, this.teaqlEntityKey());
|
| 39 |
+
(this as any)._root = root;
|
| 40 |
+
}
|
| 41 |
+
return this;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
static fromRecord(record: Record<string, unknown>, root?: EntityRoot): WorkItem {
|
| 45 |
+
const entity = new WorkItem(record as Partial<WorkItem>);
|
| 46 |
+
return root ? entity.teaqlAttachRoot(root) : entity;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
isLoaded(field: string): boolean {
|
| 50 |
+
return (this as any)._fullyLoaded || (this as any)._loadedFields.has(field);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
markLoaded(...fields: string[]): this {
|
| 54 |
+
for (const field of fields) (this as any)._loadedFields.add(field);
|
| 55 |
+
return this;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
markLoadedOnly(...fields: string[]): this {
|
| 59 |
+
(this as any)._fullyLoaded = false;
|
| 60 |
+
(this as any)._loadedFields = new Set(fields);
|
| 61 |
+
return this;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
static refer(id: string | number): WorkItem {
|
| 65 |
+
return new WorkItem({ id: String(id) } as Partial<WorkItem>);
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/** @internal Generated Runtime Module fixed-ID construction capability. */
|
| 69 |
+
static teaqlBootstrapNew(id: string | number): WorkItem {
|
| 70 |
+
return new WorkItem().updateId(String(id));
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
markForDeletion(): this {
|
| 74 |
+
(this as any)._action = "Delete";
|
| 75 |
+
(this as any)._root.markAsDeleted(this.teaqlEntityKey());
|
| 76 |
+
return this;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
auditAs(comment: string): this {
|
| 80 |
+
new MutationIntent(comment);
|
| 81 |
+
(this as any)._comment = comment;
|
| 82 |
+
return this;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
async save(context: UserContext): Promise<WorkItem> {
|
| 86 |
+
const service = context.requireResource<TeaQLDataService>("dataService");
|
| 87 |
+
return service.executeGraphSave(new MutationIntent((this as any)._comment), async (graph) => {
|
| 88 |
+
this.teaqlPreflightGraph(context, service, graph);
|
| 89 |
+
return this.teaqlSaveWithinGraph(context, service, graph);
|
| 90 |
+
});
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
/** @internal Validates and fixes the complete graph before its first mutation. */
|
| 94 |
+
teaqlPreflightGraph(context: UserContext, service: TeaQLDataService, graph: GraphMutationSession, parent?: MutationTraceScope): void {
|
| 95 |
+
if (!parent) new MutationIntent((this as any)._comment);
|
| 96 |
+
const action = (this as any)._action;
|
| 97 |
+
const pending = action !== "Update" || (this as any)._root.hasPending(this.teaqlEntityKey());
|
| 98 |
+
if (action === "Update" && pending) {
|
| 99 |
+
const notLoaded = [{ member: "id", canonical: "id" }, { member: "title", canonical: "title" }, { member: "description", canonical: "description" }, { member: "platform", canonical: "platform" }, { member: "version", canonical: "version" }]
|
| 100 |
+
.find(field => !this.isLoaded(field.member));
|
| 101 |
+
if (notLoaded) {
|
| 102 |
+
throw new CheckException([{
|
| 103 |
+
ruleId: "invalid_type",
|
| 104 |
+
location: ObjectLocation.property(notLoaded.canonical),
|
| 105 |
+
message: "Mutation requires a fully loaded entity",
|
| 106 |
+
}]);
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
const request = graph.request({
|
| 110 |
+
entity: "WorkItem", action,
|
| 111 |
+
payload: action === "Update"
|
| 112 |
+
? (this as any)._root.change(this.teaqlEntityKey())
|
| 113 |
+
: this.teaqlMutationPayload(),
|
| 114 |
+
id: (this as any).id, version: (this as any).version,
|
| 115 |
+
comment: (this as any)._comment,
|
| 116 |
+
ledgerKey: this.teaqlEntityKey(), ledgerRoot: (this as any)._root,
|
| 117 |
+
}, parent, (this as any)._comment).withLoadedSnapshot(LoadedScalarSnapshot.forEntity(this) ?? new LoadedScalarSnapshot());
|
| 118 |
+
if (pending) service.preflightMutation(request);
|
| 119 |
+
const scope = request.scopeFor(this.teaqlEntityKey());
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
/** @internal Used by generated relation cascades inside the root graph transaction. */
|
| 123 |
+
async teaqlSaveWithinGraph(context: UserContext, service: TeaQLDataService, graph: GraphMutationSession, parent?: MutationTraceScope): Promise<WorkItem> {
|
| 124 |
+
if (!parent) new MutationIntent((this as any)._comment);
|
| 125 |
+
const action = (this as any)._action;
|
| 126 |
+
const ledgerPayload = (this as any)._root.change(this.teaqlEntityKey());
|
| 127 |
+
const mutation = {
|
| 128 |
+
entity: "WorkItem",
|
| 129 |
+
action: (this as any)._action,
|
| 130 |
+
payload: action === "Update" ? ledgerPayload : this.teaqlMutationPayload(),
|
| 131 |
+
id: (this as any).id,
|
| 132 |
+
version: (this as any).version,
|
| 133 |
+
comment: (this as any)._comment
|
| 134 |
+
,ledgerKey: this.teaqlEntityKey()
|
| 135 |
+
,ledgerRoot: (this as any)._root
|
| 136 |
+
};
|
| 137 |
+
const request = graph.request(mutation, parent, (this as any)._comment)
|
| 138 |
+
.withLoadedSnapshot(LoadedScalarSnapshot.forEntity(this) ?? new LoadedScalarSnapshot());
|
| 139 |
+
if (action === "Update" && !(this as any)._root.hasPending(this.teaqlEntityKey())) {
|
| 140 |
+
const scope = request.scopeFor(this.teaqlEntityKey());
|
| 141 |
+
return this;
|
| 142 |
+
}
|
| 143 |
+
const result = await service.executeMutation(request);
|
| 144 |
+
for (const [field, value] of Object.entries(mutation.payload as Record<string, unknown>)) {
|
| 145 |
+
if (field !== "id" && field !== "version") (this as any)._root.set(this.teaqlEntityKey(), field, value);
|
| 146 |
+
}
|
| 147 |
+
if (!result.persistedRecord) {
|
| 148 |
+
throw new Error("Mutation did not return the authoritative persisted record");
|
| 149 |
+
}
|
| 150 |
+
const rollbackState = {
|
| 151 |
+
payload: this.teaqlMutationPayload(),
|
| 152 |
+
ledgerId: (this as any)._ledgerId,
|
| 153 |
+
action: (this as any)._action,
|
| 154 |
+
loadedFields: new Set((this as any)._loadedFields),
|
| 155 |
+
fullyLoaded: (this as any)._fullyLoaded,
|
| 156 |
+
loadedSnapshot: LoadedScalarSnapshot.forEntity(this),
|
| 157 |
+
};
|
| 158 |
+
const oldKey = this.teaqlEntityKey();
|
| 159 |
+
Object.assign(this, result.persistedRecord);
|
| 160 |
+
LoadedScalarSnapshot.captureFor(this, this.teaqlMutationPayload());
|
| 161 |
+
(this as any)._ledgerId = (this as any).id ?? (this as any)._ledgerId;
|
| 162 |
+
const newKey = this.teaqlEntityKey();
|
| 163 |
+
(this as any)._root.rekey(oldKey, newKey);
|
| 164 |
+
service.afterGraphRollback(() => {
|
| 165 |
+
Object.assign(this, rollbackState.payload);
|
| 166 |
+
(this as any)._ledgerId = rollbackState.ledgerId;
|
| 167 |
+
(this as any)._action = rollbackState.action;
|
| 168 |
+
(this as any)._loadedFields = rollbackState.loadedFields;
|
| 169 |
+
(this as any)._fullyLoaded = rollbackState.fullyLoaded;
|
| 170 |
+
LoadedScalarSnapshot.restoreFor(this, rollbackState.loadedSnapshot);
|
| 171 |
+
(this as any)._root.rekey(newKey, oldKey);
|
| 172 |
+
});
|
| 173 |
+
(this as any)._loadedFields = new Set(Object.keys(result.persistedRecord));
|
| 174 |
+
(this as any)._fullyLoaded = false;
|
| 175 |
+
if (mutation.action !== "Delete") (this as any)._action = "Update";
|
| 176 |
+
const scope = request.scopeFor(newKey);
|
| 177 |
+
service.afterGraphCommit(() => {
|
| 178 |
+
(this as any)._root.clearEntity(newKey);
|
| 179 |
+
if ((this as any).version !== undefined) (this as any)._root.acceptCommittedVersion(newKey, Number((this as any).version));
|
| 180 |
+
});
|
| 181 |
+
return this;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
private teaqlMutationPayload(): Record<string, unknown> {
|
| 185 |
+
return {
|
| 186 |
+
"id": this.id,
|
| 187 |
+
"title": this.title,
|
| 188 |
+
"description": this.description,
|
| 189 |
+
"platform": this.platform,
|
| 190 |
+
"version": this.version
|
| 191 |
+
};
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
updateId(value: string): this {
|
| 195 |
+
this.id = value;
|
| 196 |
+
this.markLoaded("id");
|
| 197 |
+
(this as any)._root.set(this.teaqlEntityKey(), "id", value);
|
| 198 |
+
return this;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
updateTitle(value: string): this {
|
| 202 |
+
this.title = value;
|
| 203 |
+
this.markLoaded("title");
|
| 204 |
+
(this as any)._root.set(this.teaqlEntityKey(), "title", value);
|
| 205 |
+
return this;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
updateDescription(value: string): this {
|
| 209 |
+
this.description = value;
|
| 210 |
+
this.markLoaded("description");
|
| 211 |
+
(this as any)._root.set(this.teaqlEntityKey(), "description", value);
|
| 212 |
+
return this;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
updateVersion(value: number): this {
|
| 216 |
+
this.version = value;
|
| 217 |
+
this.markLoaded("version");
|
| 218 |
+
(this as any)._root.set(this.teaqlEntityKey(), "version", value);
|
| 219 |
+
return this;
|
| 220 |
+
}
|
| 221 |
+
updatePlatform(value: any): this {
|
| 222 |
+
this.platform = value?.id ?? value;
|
| 223 |
+
this.markLoaded("platform");
|
| 224 |
+
(this as any)._root.set(this.teaqlEntityKey(), "platform", this.platform);
|
| 225 |
+
return this;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
}
|
source/teaql-ts/examples/conformance/src/generated/requests/PlatformRequest.ts
ADDED
|
@@ -0,0 +1,607 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { EntityRoot, SelectQuery, SmartList, TeaQLDataService, UserContext, executeRelationFacets } from '../../teaql-ts';
|
| 2 |
+
import { Platform } from '../models/Platform';
|
| 3 |
+
import { mergeGeneratedScalarSearch, DynamicSearchWarning, QueryIntent } from 'teaql-ts';
|
| 4 |
+
import { GENERATED_SEARCH_MODELS } from '../../generated-search-models';
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
export class PlatformRequest {
|
| 9 |
+
private query: SelectQuery;
|
| 10 |
+
private filters: any[] = [];
|
| 11 |
+
private _purpose: string | undefined;
|
| 12 |
+
private _comment: string | undefined;
|
| 13 |
+
private _pageCountAlias: string | undefined;
|
| 14 |
+
private _pageCountMethod: "count" | "countAs" | undefined;
|
| 15 |
+
private _dynamicSearchWarnings: DynamicSearchWarning[] = [];
|
| 16 |
+
|
| 17 |
+
constructor(minimal = false) {
|
| 18 |
+
this.query = new SelectQuery("Platform");
|
| 19 |
+
this.filters.push({ version: { "$gte": 1 } });
|
| 20 |
+
if (minimal) {
|
| 21 |
+
this.selectId();
|
| 22 |
+
this.selectVersion();
|
| 23 |
+
}
|
| 24 |
+
else this.selectSelfFields();
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
comment(c: string): this {
|
| 28 |
+
this.query.comment(c);
|
| 29 |
+
this._comment = c;
|
| 30 |
+
return this;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
filterByJson(source: unknown, warn?: (warning: DynamicSearchWarning) => void): this {
|
| 34 |
+
const base = this.query.clone();
|
| 35 |
+
if (this.filters.length > 0) base.filter({ "$and": this.filters });
|
| 36 |
+
const merged = mergeGeneratedScalarSearch(base, source, GENERATED_SEARCH_MODELS, warn);
|
| 37 |
+
this.query = merged.query as SelectQuery;
|
| 38 |
+
this.filters = this.query.filterCondition ? [this.query.filterCondition] : [];
|
| 39 |
+
this._dynamicSearchWarnings.push(...merged.warnings);
|
| 40 |
+
return this;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
get dynamicSearchWarnings(): readonly DynamicSearchWarning[] {
|
| 44 |
+
return this._dynamicSearchWarnings.map(warning => ({ ...warning }));
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
purpose(p: string): ExecutablePlatformRequest {
|
| 48 |
+
this.query.purpose(p);
|
| 49 |
+
this._purpose = p;
|
| 50 |
+
return new ExecutablePlatformRequest(
|
| 51 |
+
(context) => context.withQueryRequest(this.query, () => this.executeForListInternal(context)),
|
| 52 |
+
(context) => context.withQueryRequest(this.query, () => this.executeForRowsInternal(context)),
|
| 53 |
+
(context, chunkSize) => this.executeForStreamInternal(context, chunkSize),
|
| 54 |
+
() => this.limit(1),
|
| 55 |
+
(c) => this.comment(c),
|
| 56 |
+
() => this.ensureIntent());
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
optimizeForContinuousPageFetch(): this {
|
| 60 |
+
this.query.optimizeForContinuousPageFetch();
|
| 61 |
+
return this;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
optimizeForContinuousPageFetchWith(namespace: string, ttlSeconds: number): this {
|
| 65 |
+
this.query.optimizeForContinuousPageFetchWith(namespace, ttlSeconds);
|
| 66 |
+
return this;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
optimizePaginationWithIdSet(): this {
|
| 70 |
+
this.query.optimizePaginationWithIdSet();
|
| 71 |
+
return this;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
optimizePaginationWithIdSetConfig(namespace: string, ttlSeconds: number, maxIds: number): this {
|
| 75 |
+
this.query.optimizePaginationWithIdSetConfig(namespace, ttlSeconds, maxIds);
|
| 76 |
+
return this;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
topNProbeParentThreshold(threshold: number): this {
|
| 80 |
+
this.query.topNProbeParentThreshold(threshold);
|
| 81 |
+
return this;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
limit(n: number): this {
|
| 85 |
+
this.query.limit(n);
|
| 86 |
+
return this;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
offset(n: number): this {
|
| 90 |
+
this.query.offset(n);
|
| 91 |
+
return this;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
toQuery(): SelectQuery {
|
| 95 |
+
if (this.filters.length > 0) {
|
| 96 |
+
this.query.filter({ "$and": this.filters });
|
| 97 |
+
}
|
| 98 |
+
return this.query;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
withDeletedRows(): this {
|
| 102 |
+
this.filters = this.filters.filter(filter => !("version" in filter));
|
| 103 |
+
return this;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
deletedRowsOnly(): this {
|
| 107 |
+
this.withDeletedRows();
|
| 108 |
+
this.filters.push({ version: { "$lte": -1 } });
|
| 109 |
+
return this;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
selectSelfFields(): this {
|
| 113 |
+
this.query.select(["id", "name", "version"]);
|
| 114 |
+
return this;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
selectId(): this {
|
| 118 |
+
this.query.select(["id"]);
|
| 119 |
+
return this;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
selectName(): this {
|
| 123 |
+
this.query.select(["name"]);
|
| 124 |
+
return this;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
selectVersion(): this {
|
| 128 |
+
this.query.select(["version"]);
|
| 129 |
+
return this;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
selectWorkItemListWith(request: { toQuery(): SelectQuery }): this {
|
| 136 |
+
this.query.relationQuery(
|
| 137 |
+
"workItemList", request.toQuery(), "id", "platform", true,
|
| 138 |
+
{ kind: "relation-select", method: "selectWorkItemListWith", relation: "workItemList" });
|
| 139 |
+
return this;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
haveWorkItems(): this {
|
| 143 |
+
return this.withWorkItemListMatching({
|
| 144 |
+
toQuery: () => new SelectQuery("WorkItem"),
|
| 145 |
+
});
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
haveNoWorkItems(): this {
|
| 149 |
+
return this.withoutWorkItemListMatching({
|
| 150 |
+
toQuery: () => new SelectQuery("WorkItem"),
|
| 151 |
+
});
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
withWorkItemListMatching(request: { toQuery(): SelectQuery }): this {
|
| 155 |
+
this.filters.push({
|
| 156 |
+
"id": {
|
| 157 |
+
"$inSubquery": {
|
| 158 |
+
query: request.toQuery(), field: "platform",
|
| 159 |
+
},
|
| 160 |
+
},
|
| 161 |
+
});
|
| 162 |
+
return this;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
withoutWorkItemListMatching(request: { toQuery(): SelectQuery }): this {
|
| 166 |
+
this.filters.push({
|
| 167 |
+
"id": {
|
| 168 |
+
"$notInSubquery": {
|
| 169 |
+
query: request.toQuery(), field: "platform",
|
| 170 |
+
},
|
| 171 |
+
},
|
| 172 |
+
});
|
| 173 |
+
return this;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
countWorkItems(): this {
|
| 177 |
+
return this.countWorkItemsAs("countWorkItems");
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
countWorkItemsAs(alias: string): this {
|
| 181 |
+
const query = new SelectQuery("WorkItem").filter({ version: { "$gte": 1 } });
|
| 182 |
+
this.countWorkItemsWith(alias, { toQuery: () => query });
|
| 183 |
+
this.query.relationAggregates[this.query.relationAggregates.length - 1].operation = {
|
| 184 |
+
kind: "relation-count", method: "countWorkItemsAs", relation: "workItemList", alias };
|
| 185 |
+
return this;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
countWorkItemsWith(alias: string, child: { toQuery(): SelectQuery }): this {
|
| 189 |
+
const query = child.toQuery().clone();
|
| 190 |
+
query.aggregateItems = [];
|
| 191 |
+
query.aggregate("Count", "id", alias);
|
| 192 |
+
this.query.relationAggregate("workItemList", alias, query, true,
|
| 193 |
+
{ kind: "relation-count", method: "countWorkItemsWith", relation: "workItemList", alias });
|
| 194 |
+
return this;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
withIdIs(val: any): this {
|
| 200 |
+
this.filters.push({ "id": { "$eq": val } });
|
| 201 |
+
return this;
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
withIdIsNot(val: any): this {
|
| 205 |
+
this.filters.push({ "id": { "$ne": val } });
|
| 206 |
+
return this;
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
withIdIn(...vals: any[]): this {
|
| 210 |
+
this.filters.push({ "id": { "$in": vals } });
|
| 211 |
+
return this;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
withIdNotIn(...vals: any[]): this {
|
| 215 |
+
this.filters.push({ "id": { "$notIn": vals } });
|
| 216 |
+
return this;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
withIdGreaterThan(val: any): this {
|
| 220 |
+
this.filters.push({ "id": { "$gt": val } });
|
| 221 |
+
return this;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
withIdGreaterThanOrEqualTo(val: any): this {
|
| 225 |
+
this.filters.push({ "id": { "$gte": val } });
|
| 226 |
+
return this;
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
withIdLessThan(val: any): this {
|
| 230 |
+
this.filters.push({ "id": { "$lt": val } });
|
| 231 |
+
return this;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
withIdLessThanOrEqualTo(val: any): this {
|
| 235 |
+
this.filters.push({ "id": { "$lte": val } });
|
| 236 |
+
return this;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
withIdBetween(lower: any, upper: any): this {
|
| 240 |
+
this.filters.push({ "id": { "$between": [lower, upper] } });
|
| 241 |
+
return this;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
withIdIsKnown(): this {
|
| 245 |
+
this.filters.push({ "id": { "$isNull": false } });
|
| 246 |
+
return this;
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
withIdIsUnknown(): this {
|
| 250 |
+
this.filters.push({ "id": { "$isNull": true } });
|
| 251 |
+
return this;
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
withNameContaining(val: string): this {
|
| 255 |
+
this.filters.push({ "name": { "$contains": val } });
|
| 256 |
+
return this;
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
withNameIs(val: string): this {
|
| 260 |
+
this.filters.push({ "name": { "$eq": val } });
|
| 261 |
+
return this;
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
withNameIsNot(val: any): this {
|
| 265 |
+
this.filters.push({ "name": { "$ne": val } });
|
| 266 |
+
return this;
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
withNameIn(...vals: any[]): this {
|
| 270 |
+
this.filters.push({ "name": { "$in": vals } });
|
| 271 |
+
return this;
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
withNameNotIn(...vals: any[]): this {
|
| 275 |
+
this.filters.push({ "name": { "$notIn": vals } });
|
| 276 |
+
return this;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
withNameGreaterThan(val: any): this {
|
| 280 |
+
this.filters.push({ "name": { "$gt": val } });
|
| 281 |
+
return this;
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
withNameGreaterThanOrEqualTo(val: any): this {
|
| 285 |
+
this.filters.push({ "name": { "$gte": val } });
|
| 286 |
+
return this;
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
withNameLessThan(val: any): this {
|
| 290 |
+
this.filters.push({ "name": { "$lt": val } });
|
| 291 |
+
return this;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
withNameLessThanOrEqualTo(val: any): this {
|
| 295 |
+
this.filters.push({ "name": { "$lte": val } });
|
| 296 |
+
return this;
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
withNameBetween(lower: any, upper: any): this {
|
| 300 |
+
this.filters.push({ "name": { "$between": [lower, upper] } });
|
| 301 |
+
return this;
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
withNameIsKnown(): this {
|
| 305 |
+
this.filters.push({ "name": { "$isNull": false } });
|
| 306 |
+
return this;
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
withNameIsUnknown(): this {
|
| 310 |
+
this.filters.push({ "name": { "$isNull": true } });
|
| 311 |
+
return this;
|
| 312 |
+
}
|
| 313 |
+
withNameNotContaining(val: string): this {
|
| 314 |
+
this.filters.push({ "name": { "$notContains": val } });
|
| 315 |
+
return this;
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
withNameStartingWith(val: string): this {
|
| 319 |
+
this.filters.push({ "name": { "$startsWith": val } });
|
| 320 |
+
return this;
|
| 321 |
+
}
|
| 322 |
+
|
| 323 |
+
withNameNotStartingWith(val: string): this {
|
| 324 |
+
this.filters.push({ "name": { "$notStartsWith": val } });
|
| 325 |
+
return this;
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
withNameEndingWith(val: string): this {
|
| 329 |
+
this.filters.push({ "name": { "$endsWith": val } });
|
| 330 |
+
return this;
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
withNameNotEndingWith(val: string): this {
|
| 334 |
+
this.filters.push({ "name": { "$notEndsWith": val } });
|
| 335 |
+
return this;
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
withNameSoundingLike(val: string): this {
|
| 339 |
+
this.filters.push({ "name": { "$soundLike": val } });
|
| 340 |
+
return this;
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
withVersionIs(val: any): this {
|
| 344 |
+
this.filters.push({ "version": { "$eq": val } });
|
| 345 |
+
return this;
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
withVersionIsNot(val: any): this {
|
| 349 |
+
this.filters.push({ "version": { "$ne": val } });
|
| 350 |
+
return this;
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
withVersionIn(...vals: any[]): this {
|
| 354 |
+
this.filters.push({ "version": { "$in": vals } });
|
| 355 |
+
return this;
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
withVersionNotIn(...vals: any[]): this {
|
| 359 |
+
this.filters.push({ "version": { "$notIn": vals } });
|
| 360 |
+
return this;
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
withVersionGreaterThan(val: any): this {
|
| 364 |
+
this.filters.push({ "version": { "$gt": val } });
|
| 365 |
+
return this;
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
withVersionGreaterThanOrEqualTo(val: any): this {
|
| 369 |
+
this.filters.push({ "version": { "$gte": val } });
|
| 370 |
+
return this;
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
withVersionLessThan(val: any): this {
|
| 374 |
+
this.filters.push({ "version": { "$lt": val } });
|
| 375 |
+
return this;
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
withVersionLessThanOrEqualTo(val: any): this {
|
| 379 |
+
this.filters.push({ "version": { "$lte": val } });
|
| 380 |
+
return this;
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
withVersionBetween(lower: any, upper: any): this {
|
| 384 |
+
this.filters.push({ "version": { "$between": [lower, upper] } });
|
| 385 |
+
return this;
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
withVersionIsKnown(): this {
|
| 389 |
+
this.filters.push({ "version": { "$isNull": false } });
|
| 390 |
+
return this;
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
withVersionIsUnknown(): this {
|
| 394 |
+
this.filters.push({ "version": { "$isNull": true } });
|
| 395 |
+
return this;
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
+
orderByIdAscending(): this {
|
| 399 |
+
this.query.orderBy("id", "asc");
|
| 400 |
+
return this;
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
orderByIdDescending(): this {
|
| 404 |
+
this.query.orderBy("id", "desc");
|
| 405 |
+
return this;
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
orderByNameAscending(): this {
|
| 409 |
+
this.query.orderBy("name", "asc");
|
| 410 |
+
return this;
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
orderByNameDescending(): this {
|
| 414 |
+
this.query.orderBy("name", "desc");
|
| 415 |
+
return this;
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
orderByVersionAscending(): this {
|
| 419 |
+
this.query.orderBy("version", "asc");
|
| 420 |
+
return this;
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
orderByVersionDescending(): this {
|
| 424 |
+
this.query.orderBy("version", "desc");
|
| 425 |
+
return this;
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
|
| 429 |
+
// --- Aggregations ---
|
| 430 |
+
count(): this {
|
| 431 |
+
this.query.aggregate("Count", "id", "count");
|
| 432 |
+
this._pageCountAlias = "count";
|
| 433 |
+
this._pageCountMethod = "count";
|
| 434 |
+
return this;
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
countAs(retName: string): this {
|
| 438 |
+
this.query.aggregate("Count", "id", retName);
|
| 439 |
+
this._pageCountAlias = retName;
|
| 440 |
+
this._pageCountMethod = "countAs";
|
| 441 |
+
return this;
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
|
| 445 |
+
// --- Group By ---
|
| 446 |
+
groupById(): this {
|
| 447 |
+
this.query.groupBy("id");
|
| 448 |
+
return this;
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
+
groupByIdAs(retName: string): this {
|
| 452 |
+
this.query.groupBy("id"); // In TS we don't alias group by yet natively
|
| 453 |
+
return this;
|
| 454 |
+
}
|
| 455 |
+
groupByName(): this {
|
| 456 |
+
this.query.groupBy("name");
|
| 457 |
+
return this;
|
| 458 |
+
}
|
| 459 |
+
|
| 460 |
+
groupByNameAs(retName: string): this {
|
| 461 |
+
this.query.groupBy("name"); // In TS we don't alias group by yet natively
|
| 462 |
+
return this;
|
| 463 |
+
}
|
| 464 |
+
groupByVersion(): this {
|
| 465 |
+
this.query.groupBy("version");
|
| 466 |
+
return this;
|
| 467 |
+
}
|
| 468 |
+
|
| 469 |
+
groupByVersionAs(retName: string): this {
|
| 470 |
+
this.query.groupBy("version"); // In TS we don't alias group by yet natively
|
| 471 |
+
return this;
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
// --- Facets ---
|
| 475 |
+
|
| 476 |
+
private async executeForListInternal(context: UserContext): Promise<SmartList<Platform>> {
|
| 477 |
+
this.ensureIntent();
|
| 478 |
+
if (this._pageCountAlias !== undefined) return this.executeCountedListInternal(context);
|
| 479 |
+
if (this.filters.length > 0) {
|
| 480 |
+
this.query.filter({ "$and": this.filters });
|
| 481 |
+
}
|
| 482 |
+
|
| 483 |
+
const service = context.requireResource<TeaQLDataService>("dataService");
|
| 484 |
+
const rows = await service.executeQuery(context.prepareQuery(this.query));
|
| 485 |
+
const aggregateOnly = this.query.aggregateItems.length > 0 && this.query.groupByItems.length === 0;
|
| 486 |
+
const data = aggregateOnly ? [] : rows.map((row: unknown) =>
|
| 487 |
+
row instanceof Platform
|
| 488 |
+
? row
|
| 489 |
+
: Platform.fromRecord(row as Record<string, unknown>, new EntityRoot()));
|
| 490 |
+
const result = new SmartList<Platform>(data);
|
| 491 |
+
if (aggregateOnly && rows[0]) Object.assign(result.aggregations, rows[0]);
|
| 492 |
+
|
| 493 |
+
if (this.query.facets.length > 0) {
|
| 494 |
+
result.facets = await executeRelationFacets(
|
| 495 |
+
service, (query: any) => context.prepareQuery(query), this.query, this.query.facets);
|
| 496 |
+
}
|
| 497 |
+
|
| 498 |
+
return result;
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
private async executeForRowsInternal(context: UserContext): Promise<SmartList<Record<string, unknown>>> {
|
| 502 |
+
this.ensureIntent();
|
| 503 |
+
if (this.filters.length > 0) this.query.filter({ "$and": this.filters });
|
| 504 |
+
const service = context.requireResource<TeaQLDataService>("dataService");
|
| 505 |
+
return new SmartList<Record<string, unknown>>(
|
| 506 |
+
await service.executeQuery(context.prepareQuery(this.query)) as Record<string, unknown>[]);
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
private async executeCountedListInternal(
|
| 510 |
+
context: UserContext,
|
| 511 |
+
): Promise<SmartList<Platform>> {
|
| 512 |
+
this.ensureIntent();
|
| 513 |
+
if (this.filters.length > 0) this.query.filter({ "$and": this.filters });
|
| 514 |
+
const service = context.requireResource<TeaQLDataService>("dataService");
|
| 515 |
+
const preparedQuery = context.prepareQuery(this.query);
|
| 516 |
+
const useIdSet = preparedQuery.localIdSetPaginationOptions() !== undefined;
|
| 517 |
+
const countOperation = { kind: "named-count" as const,
|
| 518 |
+
method: this._pageCountMethod ?? "count",
|
| 519 |
+
...(this._pageCountMethod === "countAs" ? { alias: this._pageCountAlias } : {}) };
|
| 520 |
+
const totalCountBeforeRows = useIdSet ? undefined : await service.executeCount(
|
| 521 |
+
preparedQuery, this._pageCountAlias, countOperation);
|
| 522 |
+
const pageQuery = preparedQuery.clone();
|
| 523 |
+
// A page count describes the full filtered set, not an aggregate-only page row.
|
| 524 |
+
pageQuery.aggregateItems = pageQuery.aggregateItems.filter(item =>
|
| 525 |
+
!(String(item.function).toLowerCase() === "count" && item.alias === this._pageCountAlias));
|
| 526 |
+
const rows = await service.executeQuery(pageQuery);
|
| 527 |
+
const totalCount = useIdSet && context.idSetPaginationCountAccuracy === "EXACT"
|
| 528 |
+
? context.idSetPaginationCount!
|
| 529 |
+
: (totalCountBeforeRows ?? await service.executeCount(preparedQuery, this._pageCountAlias, countOperation));
|
| 530 |
+
const data = new SmartList(rows.map((row: unknown) =>
|
| 531 |
+
row instanceof Platform
|
| 532 |
+
? row
|
| 533 |
+
: Platform.fromRecord(row as Record<string, unknown>, new EntityRoot())));
|
| 534 |
+
data.totalCount = totalCount;
|
| 535 |
+
if (this._pageCountAlias !== undefined) data.aggregations[this._pageCountAlias] = totalCount;
|
| 536 |
+
if (this.query.facets.length > 0) {
|
| 537 |
+
data.facets = await executeRelationFacets(
|
| 538 |
+
service, (query: any) => context.prepareQuery(query), preparedQuery, preparedQuery.facets);
|
| 539 |
+
}
|
| 540 |
+
return data;
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
private executeForStreamInternal(context: UserContext, chunkSize: number): AsyncIterable<Platform> {
|
| 544 |
+
this.ensureIntent();
|
| 545 |
+
if (this.filters.length > 0) this.query.filter({ "$and": this.filters });
|
| 546 |
+
const service = context.requireResource<TeaQLDataService>("dataService");
|
| 547 |
+
const preparedQuery = context.prepareQuery(this.query);
|
| 548 |
+
// Prepare Context and capture the runtime request before returning a lazy iterator.
|
| 549 |
+
const chunks = service.executeForStream(preparedQuery, chunkSize);
|
| 550 |
+
return (async function* () {
|
| 551 |
+
for await (const chunk of chunks) {
|
| 552 |
+
for (const entity of chunk) {
|
| 553 |
+
yield entity instanceof Platform
|
| 554 |
+
? entity
|
| 555 |
+
: Platform.fromRecord(entity as Record<string, unknown>, new EntityRoot());
|
| 556 |
+
}
|
| 557 |
+
}
|
| 558 |
+
})();
|
| 559 |
+
}
|
| 560 |
+
|
| 561 |
+
private ensureIntent(): void {
|
| 562 |
+
// Runtime owns validation, Unicode whitespace rules and typed diagnostics.
|
| 563 |
+
new QueryIntent(this._comment, this._purpose);
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
export class ExecutablePlatformRequest {
|
| 569 |
+
constructor(
|
| 570 |
+
private readonly execute: (context: UserContext) => Promise<SmartList<Platform>>,
|
| 571 |
+
private readonly executeRows: (context: UserContext) => Promise<SmartList<Record<string, unknown>>>,
|
| 572 |
+
private readonly stream: (context: UserContext, chunkSize: number) => AsyncIterable<Platform>,
|
| 573 |
+
private readonly limitOne: () => void,
|
| 574 |
+
private readonly addComment: (comment: string) => void,
|
| 575 |
+
private readonly ensureIntent: () => void,
|
| 576 |
+
) {}
|
| 577 |
+
|
| 578 |
+
comment(c: string): this {
|
| 579 |
+
this.addComment(c);
|
| 580 |
+
return this;
|
| 581 |
+
}
|
| 582 |
+
|
| 583 |
+
newEntity(context: UserContext): Platform {
|
| 584 |
+
this.ensureIntent();
|
| 585 |
+
return new Platform();
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
executeForList(context: UserContext): Promise<SmartList<Platform>> {
|
| 589 |
+
this.ensureIntent();
|
| 590 |
+
return this.execute(context);
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
executeForRows(context: UserContext): Promise<SmartList<Record<string, unknown>>> {
|
| 594 |
+
this.ensureIntent();
|
| 595 |
+
return this.executeRows(context);
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
executeForStream(context: UserContext, chunkSize = 1000): AsyncIterable<Platform> {
|
| 599 |
+
this.ensureIntent();
|
| 600 |
+
return this.stream(context, chunkSize);
|
| 601 |
+
}
|
| 602 |
+
|
| 603 |
+
async executeForOne(context: UserContext): Promise<Platform | undefined> {
|
| 604 |
+
this.limitOne();
|
| 605 |
+
return (await this.executeForList(context))[0];
|
| 606 |
+
}
|
| 607 |
+
}
|
source/teaql-ts/examples/conformance/src/generated/requests/WorkItemRequest.ts
ADDED
|
@@ -0,0 +1,724 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { EntityRoot, SelectQuery, SmartList, TeaQLDataService, UserContext, executeRelationFacets } from '../../teaql-ts';
|
| 2 |
+
import { WorkItem } from '../models/WorkItem';
|
| 3 |
+
import { mergeGeneratedScalarSearch, DynamicSearchWarning, QueryIntent } from 'teaql-ts';
|
| 4 |
+
import { GENERATED_SEARCH_MODELS } from '../../generated-search-models';
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
export class WorkItemRequest {
|
| 9 |
+
private query: SelectQuery;
|
| 10 |
+
private filters: any[] = [];
|
| 11 |
+
private _purpose: string | undefined;
|
| 12 |
+
private _comment: string | undefined;
|
| 13 |
+
private _pageCountAlias: string | undefined;
|
| 14 |
+
private _pageCountMethod: "count" | "countAs" | undefined;
|
| 15 |
+
private _dynamicSearchWarnings: DynamicSearchWarning[] = [];
|
| 16 |
+
|
| 17 |
+
constructor(minimal = false) {
|
| 18 |
+
this.query = new SelectQuery("WorkItem");
|
| 19 |
+
this.filters.push({ version: { "$gte": 1 } });
|
| 20 |
+
if (minimal) {
|
| 21 |
+
this.selectId();
|
| 22 |
+
this.selectVersion();
|
| 23 |
+
}
|
| 24 |
+
else this.selectSelfFields();
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
comment(c: string): this {
|
| 28 |
+
this.query.comment(c);
|
| 29 |
+
this._comment = c;
|
| 30 |
+
return this;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
filterByJson(source: unknown, warn?: (warning: DynamicSearchWarning) => void): this {
|
| 34 |
+
const base = this.query.clone();
|
| 35 |
+
if (this.filters.length > 0) base.filter({ "$and": this.filters });
|
| 36 |
+
const merged = mergeGeneratedScalarSearch(base, source, GENERATED_SEARCH_MODELS, warn);
|
| 37 |
+
this.query = merged.query as SelectQuery;
|
| 38 |
+
this.filters = this.query.filterCondition ? [this.query.filterCondition] : [];
|
| 39 |
+
this._dynamicSearchWarnings.push(...merged.warnings);
|
| 40 |
+
return this;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
get dynamicSearchWarnings(): readonly DynamicSearchWarning[] {
|
| 44 |
+
return this._dynamicSearchWarnings.map(warning => ({ ...warning }));
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
purpose(p: string): ExecutableWorkItemRequest {
|
| 48 |
+
this.query.purpose(p);
|
| 49 |
+
this._purpose = p;
|
| 50 |
+
return new ExecutableWorkItemRequest(
|
| 51 |
+
(context) => context.withQueryRequest(this.query, () => this.executeForListInternal(context)),
|
| 52 |
+
(context) => context.withQueryRequest(this.query, () => this.executeForRowsInternal(context)),
|
| 53 |
+
(context, chunkSize) => this.executeForStreamInternal(context, chunkSize),
|
| 54 |
+
() => this.limit(1),
|
| 55 |
+
(c) => this.comment(c),
|
| 56 |
+
() => this.ensureIntent());
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
optimizeForContinuousPageFetch(): this {
|
| 60 |
+
this.query.optimizeForContinuousPageFetch();
|
| 61 |
+
return this;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
optimizeForContinuousPageFetchWith(namespace: string, ttlSeconds: number): this {
|
| 65 |
+
this.query.optimizeForContinuousPageFetchWith(namespace, ttlSeconds);
|
| 66 |
+
return this;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
optimizePaginationWithIdSet(): this {
|
| 70 |
+
this.query.optimizePaginationWithIdSet();
|
| 71 |
+
return this;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
optimizePaginationWithIdSetConfig(namespace: string, ttlSeconds: number, maxIds: number): this {
|
| 75 |
+
this.query.optimizePaginationWithIdSetConfig(namespace, ttlSeconds, maxIds);
|
| 76 |
+
return this;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
topNProbeParentThreshold(threshold: number): this {
|
| 80 |
+
this.query.topNProbeParentThreshold(threshold);
|
| 81 |
+
return this;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
limit(n: number): this {
|
| 85 |
+
this.query.limit(n);
|
| 86 |
+
return this;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
offset(n: number): this {
|
| 90 |
+
this.query.offset(n);
|
| 91 |
+
return this;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
toQuery(): SelectQuery {
|
| 95 |
+
if (this.filters.length > 0) {
|
| 96 |
+
this.query.filter({ "$and": this.filters });
|
| 97 |
+
}
|
| 98 |
+
return this.query;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
withDeletedRows(): this {
|
| 102 |
+
this.filters = this.filters.filter(filter => !("version" in filter));
|
| 103 |
+
return this;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
deletedRowsOnly(): this {
|
| 107 |
+
this.withDeletedRows();
|
| 108 |
+
this.filters.push({ version: { "$lte": -1 } });
|
| 109 |
+
return this;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
selectSelfFields(): this {
|
| 113 |
+
this.query.select(["id", "title", "description", "platform", "version"]);
|
| 114 |
+
return this;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
selectId(): this {
|
| 118 |
+
this.query.select(["id"]);
|
| 119 |
+
return this;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
selectTitle(): this {
|
| 123 |
+
this.query.select(["title"]);
|
| 124 |
+
return this;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
selectDescription(): this {
|
| 128 |
+
this.query.select(["description"]);
|
| 129 |
+
return this;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
selectVersion(): this {
|
| 134 |
+
this.query.select(["version"]);
|
| 135 |
+
return this;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
selectPlatformWith(request: { toQuery(): SelectQuery }): this {
|
| 140 |
+
this.query.select(["platform"]);
|
| 141 |
+
this.query.relationQuery(
|
| 142 |
+
"platform", request.toQuery(), "platform", "id", false,
|
| 143 |
+
{ kind: "relation-select", method: "selectPlatformWith", relation: "platform" });
|
| 144 |
+
return this;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
withPlatformMatching(request: { toQuery(): SelectQuery }): this {
|
| 148 |
+
this.filters.push({
|
| 149 |
+
"platform": {
|
| 150 |
+
"$inSubquery": { query: request.toQuery(), field: "id" },
|
| 151 |
+
},
|
| 152 |
+
});
|
| 153 |
+
return this;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
withoutPlatformMatching(request: { toQuery(): SelectQuery }): this {
|
| 157 |
+
this.filters.push({
|
| 158 |
+
"platform": {
|
| 159 |
+
"$notInSubquery": { query: request.toQuery(), field: "id" },
|
| 160 |
+
},
|
| 161 |
+
});
|
| 162 |
+
return this;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
withIdIs(val: any): this {
|
| 169 |
+
this.filters.push({ "id": { "$eq": val } });
|
| 170 |
+
return this;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
withIdIsNot(val: any): this {
|
| 174 |
+
this.filters.push({ "id": { "$ne": val } });
|
| 175 |
+
return this;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
withIdIn(...vals: any[]): this {
|
| 179 |
+
this.filters.push({ "id": { "$in": vals } });
|
| 180 |
+
return this;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
withIdNotIn(...vals: any[]): this {
|
| 184 |
+
this.filters.push({ "id": { "$notIn": vals } });
|
| 185 |
+
return this;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
withIdGreaterThan(val: any): this {
|
| 189 |
+
this.filters.push({ "id": { "$gt": val } });
|
| 190 |
+
return this;
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
withIdGreaterThanOrEqualTo(val: any): this {
|
| 194 |
+
this.filters.push({ "id": { "$gte": val } });
|
| 195 |
+
return this;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
withIdLessThan(val: any): this {
|
| 199 |
+
this.filters.push({ "id": { "$lt": val } });
|
| 200 |
+
return this;
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
withIdLessThanOrEqualTo(val: any): this {
|
| 204 |
+
this.filters.push({ "id": { "$lte": val } });
|
| 205 |
+
return this;
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
withIdBetween(lower: any, upper: any): this {
|
| 209 |
+
this.filters.push({ "id": { "$between": [lower, upper] } });
|
| 210 |
+
return this;
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
withIdIsKnown(): this {
|
| 214 |
+
this.filters.push({ "id": { "$isNull": false } });
|
| 215 |
+
return this;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
withIdIsUnknown(): this {
|
| 219 |
+
this.filters.push({ "id": { "$isNull": true } });
|
| 220 |
+
return this;
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
withTitleContaining(val: string): this {
|
| 224 |
+
this.filters.push({ "title": { "$contains": val } });
|
| 225 |
+
return this;
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
withTitleIs(val: string): this {
|
| 229 |
+
this.filters.push({ "title": { "$eq": val } });
|
| 230 |
+
return this;
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
withTitleIsNot(val: any): this {
|
| 234 |
+
this.filters.push({ "title": { "$ne": val } });
|
| 235 |
+
return this;
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
withTitleIn(...vals: any[]): this {
|
| 239 |
+
this.filters.push({ "title": { "$in": vals } });
|
| 240 |
+
return this;
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
withTitleNotIn(...vals: any[]): this {
|
| 244 |
+
this.filters.push({ "title": { "$notIn": vals } });
|
| 245 |
+
return this;
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
withTitleGreaterThan(val: any): this {
|
| 249 |
+
this.filters.push({ "title": { "$gt": val } });
|
| 250 |
+
return this;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
withTitleGreaterThanOrEqualTo(val: any): this {
|
| 254 |
+
this.filters.push({ "title": { "$gte": val } });
|
| 255 |
+
return this;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
withTitleLessThan(val: any): this {
|
| 259 |
+
this.filters.push({ "title": { "$lt": val } });
|
| 260 |
+
return this;
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
withTitleLessThanOrEqualTo(val: any): this {
|
| 264 |
+
this.filters.push({ "title": { "$lte": val } });
|
| 265 |
+
return this;
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
withTitleBetween(lower: any, upper: any): this {
|
| 269 |
+
this.filters.push({ "title": { "$between": [lower, upper] } });
|
| 270 |
+
return this;
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
withTitleIsKnown(): this {
|
| 274 |
+
this.filters.push({ "title": { "$isNull": false } });
|
| 275 |
+
return this;
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
withTitleIsUnknown(): this {
|
| 279 |
+
this.filters.push({ "title": { "$isNull": true } });
|
| 280 |
+
return this;
|
| 281 |
+
}
|
| 282 |
+
withTitleNotContaining(val: string): this {
|
| 283 |
+
this.filters.push({ "title": { "$notContains": val } });
|
| 284 |
+
return this;
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
withTitleStartingWith(val: string): this {
|
| 288 |
+
this.filters.push({ "title": { "$startsWith": val } });
|
| 289 |
+
return this;
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
withTitleNotStartingWith(val: string): this {
|
| 293 |
+
this.filters.push({ "title": { "$notStartsWith": val } });
|
| 294 |
+
return this;
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
withTitleEndingWith(val: string): this {
|
| 298 |
+
this.filters.push({ "title": { "$endsWith": val } });
|
| 299 |
+
return this;
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
withTitleNotEndingWith(val: string): this {
|
| 303 |
+
this.filters.push({ "title": { "$notEndsWith": val } });
|
| 304 |
+
return this;
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
withTitleSoundingLike(val: string): this {
|
| 308 |
+
this.filters.push({ "title": { "$soundLike": val } });
|
| 309 |
+
return this;
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
withDescriptionContaining(val: string): this {
|
| 313 |
+
this.filters.push({ "description": { "$contains": val } });
|
| 314 |
+
return this;
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
withDescriptionIs(val: string): this {
|
| 318 |
+
this.filters.push({ "description": { "$eq": val } });
|
| 319 |
+
return this;
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
withDescriptionIsNot(val: any): this {
|
| 323 |
+
this.filters.push({ "description": { "$ne": val } });
|
| 324 |
+
return this;
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
withDescriptionIn(...vals: any[]): this {
|
| 328 |
+
this.filters.push({ "description": { "$in": vals } });
|
| 329 |
+
return this;
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
withDescriptionNotIn(...vals: any[]): this {
|
| 333 |
+
this.filters.push({ "description": { "$notIn": vals } });
|
| 334 |
+
return this;
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
withDescriptionGreaterThan(val: any): this {
|
| 338 |
+
this.filters.push({ "description": { "$gt": val } });
|
| 339 |
+
return this;
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
withDescriptionGreaterThanOrEqualTo(val: any): this {
|
| 343 |
+
this.filters.push({ "description": { "$gte": val } });
|
| 344 |
+
return this;
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
withDescriptionLessThan(val: any): this {
|
| 348 |
+
this.filters.push({ "description": { "$lt": val } });
|
| 349 |
+
return this;
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
withDescriptionLessThanOrEqualTo(val: any): this {
|
| 353 |
+
this.filters.push({ "description": { "$lte": val } });
|
| 354 |
+
return this;
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
withDescriptionBetween(lower: any, upper: any): this {
|
| 358 |
+
this.filters.push({ "description": { "$between": [lower, upper] } });
|
| 359 |
+
return this;
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
withDescriptionIsKnown(): this {
|
| 363 |
+
this.filters.push({ "description": { "$isNull": false } });
|
| 364 |
+
return this;
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
withDescriptionIsUnknown(): this {
|
| 368 |
+
this.filters.push({ "description": { "$isNull": true } });
|
| 369 |
+
return this;
|
| 370 |
+
}
|
| 371 |
+
withDescriptionNotContaining(val: string): this {
|
| 372 |
+
this.filters.push({ "description": { "$notContains": val } });
|
| 373 |
+
return this;
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
withDescriptionStartingWith(val: string): this {
|
| 377 |
+
this.filters.push({ "description": { "$startsWith": val } });
|
| 378 |
+
return this;
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
withDescriptionNotStartingWith(val: string): this {
|
| 382 |
+
this.filters.push({ "description": { "$notStartsWith": val } });
|
| 383 |
+
return this;
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
withDescriptionEndingWith(val: string): this {
|
| 387 |
+
this.filters.push({ "description": { "$endsWith": val } });
|
| 388 |
+
return this;
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
withDescriptionNotEndingWith(val: string): this {
|
| 392 |
+
this.filters.push({ "description": { "$notEndsWith": val } });
|
| 393 |
+
return this;
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
withDescriptionSoundingLike(val: string): this {
|
| 397 |
+
this.filters.push({ "description": { "$soundLike": val } });
|
| 398 |
+
return this;
|
| 399 |
+
}
|
| 400 |
+
|
| 401 |
+
filterByPlatform(val: any): this {
|
| 402 |
+
this.filters.push({ "platform": { "$eq": val } });
|
| 403 |
+
return this;
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
filterByPlatformIn(...vals: any[]): this {
|
| 407 |
+
this.filters.push({ "platform": { "$in": vals } });
|
| 408 |
+
return this;
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
withPlatformIsKnown(): this {
|
| 412 |
+
this.filters.push({ "platform": { "$isNull": false } });
|
| 413 |
+
return this;
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
withPlatformIsUnknown(): this {
|
| 417 |
+
this.filters.push({ "platform": { "$isNull": true } });
|
| 418 |
+
return this;
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
withVersionIs(val: any): this {
|
| 422 |
+
this.filters.push({ "version": { "$eq": val } });
|
| 423 |
+
return this;
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
withVersionIsNot(val: any): this {
|
| 427 |
+
this.filters.push({ "version": { "$ne": val } });
|
| 428 |
+
return this;
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
+
withVersionIn(...vals: any[]): this {
|
| 432 |
+
this.filters.push({ "version": { "$in": vals } });
|
| 433 |
+
return this;
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
withVersionNotIn(...vals: any[]): this {
|
| 437 |
+
this.filters.push({ "version": { "$notIn": vals } });
|
| 438 |
+
return this;
|
| 439 |
+
}
|
| 440 |
+
|
| 441 |
+
withVersionGreaterThan(val: any): this {
|
| 442 |
+
this.filters.push({ "version": { "$gt": val } });
|
| 443 |
+
return this;
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
withVersionGreaterThanOrEqualTo(val: any): this {
|
| 447 |
+
this.filters.push({ "version": { "$gte": val } });
|
| 448 |
+
return this;
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
+
withVersionLessThan(val: any): this {
|
| 452 |
+
this.filters.push({ "version": { "$lt": val } });
|
| 453 |
+
return this;
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
withVersionLessThanOrEqualTo(val: any): this {
|
| 457 |
+
this.filters.push({ "version": { "$lte": val } });
|
| 458 |
+
return this;
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
withVersionBetween(lower: any, upper: any): this {
|
| 462 |
+
this.filters.push({ "version": { "$between": [lower, upper] } });
|
| 463 |
+
return this;
|
| 464 |
+
}
|
| 465 |
+
|
| 466 |
+
withVersionIsKnown(): this {
|
| 467 |
+
this.filters.push({ "version": { "$isNull": false } });
|
| 468 |
+
return this;
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
withVersionIsUnknown(): this {
|
| 472 |
+
this.filters.push({ "version": { "$isNull": true } });
|
| 473 |
+
return this;
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
orderByIdAscending(): this {
|
| 477 |
+
this.query.orderBy("id", "asc");
|
| 478 |
+
return this;
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
orderByIdDescending(): this {
|
| 482 |
+
this.query.orderBy("id", "desc");
|
| 483 |
+
return this;
|
| 484 |
+
}
|
| 485 |
+
|
| 486 |
+
orderByTitleAscending(): this {
|
| 487 |
+
this.query.orderBy("title", "asc");
|
| 488 |
+
return this;
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
orderByTitleDescending(): this {
|
| 492 |
+
this.query.orderBy("title", "desc");
|
| 493 |
+
return this;
|
| 494 |
+
}
|
| 495 |
+
|
| 496 |
+
orderByDescriptionAscending(): this {
|
| 497 |
+
this.query.orderBy("description", "asc");
|
| 498 |
+
return this;
|
| 499 |
+
}
|
| 500 |
+
|
| 501 |
+
orderByDescriptionDescending(): this {
|
| 502 |
+
this.query.orderBy("description", "desc");
|
| 503 |
+
return this;
|
| 504 |
+
}
|
| 505 |
+
|
| 506 |
+
|
| 507 |
+
orderByVersionAscending(): this {
|
| 508 |
+
this.query.orderBy("version", "asc");
|
| 509 |
+
return this;
|
| 510 |
+
}
|
| 511 |
+
|
| 512 |
+
orderByVersionDescending(): this {
|
| 513 |
+
this.query.orderBy("version", "desc");
|
| 514 |
+
return this;
|
| 515 |
+
}
|
| 516 |
+
|
| 517 |
+
|
| 518 |
+
// --- Aggregations ---
|
| 519 |
+
count(): this {
|
| 520 |
+
this.query.aggregate("Count", "id", "count");
|
| 521 |
+
this._pageCountAlias = "count";
|
| 522 |
+
this._pageCountMethod = "count";
|
| 523 |
+
return this;
|
| 524 |
+
}
|
| 525 |
+
|
| 526 |
+
countAs(retName: string): this {
|
| 527 |
+
this.query.aggregate("Count", "id", retName);
|
| 528 |
+
this._pageCountAlias = retName;
|
| 529 |
+
this._pageCountMethod = "countAs";
|
| 530 |
+
return this;
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
|
| 534 |
+
// --- Group By ---
|
| 535 |
+
groupById(): this {
|
| 536 |
+
this.query.groupBy("id");
|
| 537 |
+
return this;
|
| 538 |
+
}
|
| 539 |
+
|
| 540 |
+
groupByIdAs(retName: string): this {
|
| 541 |
+
this.query.groupBy("id"); // In TS we don't alias group by yet natively
|
| 542 |
+
return this;
|
| 543 |
+
}
|
| 544 |
+
groupByTitle(): this {
|
| 545 |
+
this.query.groupBy("title");
|
| 546 |
+
return this;
|
| 547 |
+
}
|
| 548 |
+
|
| 549 |
+
groupByTitleAs(retName: string): this {
|
| 550 |
+
this.query.groupBy("title"); // In TS we don't alias group by yet natively
|
| 551 |
+
return this;
|
| 552 |
+
}
|
| 553 |
+
groupByDescription(): this {
|
| 554 |
+
this.query.groupBy("description");
|
| 555 |
+
return this;
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
groupByDescriptionAs(retName: string): this {
|
| 559 |
+
this.query.groupBy("description"); // In TS we don't alias group by yet natively
|
| 560 |
+
return this;
|
| 561 |
+
}
|
| 562 |
+
groupByPlatform(): this {
|
| 563 |
+
this.query.groupBy("platform");
|
| 564 |
+
return this;
|
| 565 |
+
}
|
| 566 |
+
|
| 567 |
+
groupByPlatformAs(retName: string): this {
|
| 568 |
+
this.query.groupBy("platform"); // In TS we don't alias group by yet natively
|
| 569 |
+
return this;
|
| 570 |
+
}
|
| 571 |
+
groupByVersion(): this {
|
| 572 |
+
this.query.groupBy("version");
|
| 573 |
+
return this;
|
| 574 |
+
}
|
| 575 |
+
|
| 576 |
+
groupByVersionAs(retName: string): this {
|
| 577 |
+
this.query.groupBy("version"); // In TS we don't alias group by yet natively
|
| 578 |
+
return this;
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
// --- Facets ---
|
| 582 |
+
facetByPlatformAs(
|
| 583 |
+
facetName: string,
|
| 584 |
+
request: { toQuery(): SelectQuery },
|
| 585 |
+
includeAllFacets = true,
|
| 586 |
+
): this {
|
| 587 |
+
this.query.facetBy(facetName, "platform", request, includeAllFacets,
|
| 588 |
+
{ kind: "facet", method: "facetByPlatformAs", relation: "platform", alias: facetName });
|
| 589 |
+
return this;
|
| 590 |
+
}
|
| 591 |
+
|
| 592 |
+
|
| 593 |
+
private async executeForListInternal(context: UserContext): Promise<SmartList<WorkItem>> {
|
| 594 |
+
this.ensureIntent();
|
| 595 |
+
if (this._pageCountAlias !== undefined) return this.executeCountedListInternal(context);
|
| 596 |
+
if (this.filters.length > 0) {
|
| 597 |
+
this.query.filter({ "$and": this.filters });
|
| 598 |
+
}
|
| 599 |
+
|
| 600 |
+
const service = context.requireResource<TeaQLDataService>("dataService");
|
| 601 |
+
const rows = await service.executeQuery(context.prepareQuery(this.query));
|
| 602 |
+
const aggregateOnly = this.query.aggregateItems.length > 0 && this.query.groupByItems.length === 0;
|
| 603 |
+
const data = aggregateOnly ? [] : rows.map((row: unknown) =>
|
| 604 |
+
row instanceof WorkItem
|
| 605 |
+
? row
|
| 606 |
+
: WorkItem.fromRecord(row as Record<string, unknown>, new EntityRoot()));
|
| 607 |
+
const result = new SmartList<WorkItem>(data);
|
| 608 |
+
if (aggregateOnly && rows[0]) Object.assign(result.aggregations, rows[0]);
|
| 609 |
+
|
| 610 |
+
if (this.query.facets.length > 0) {
|
| 611 |
+
result.facets = await executeRelationFacets(
|
| 612 |
+
service, (query: any) => context.prepareQuery(query), this.query, this.query.facets);
|
| 613 |
+
}
|
| 614 |
+
|
| 615 |
+
return result;
|
| 616 |
+
}
|
| 617 |
+
|
| 618 |
+
private async executeForRowsInternal(context: UserContext): Promise<SmartList<Record<string, unknown>>> {
|
| 619 |
+
this.ensureIntent();
|
| 620 |
+
if (this.filters.length > 0) this.query.filter({ "$and": this.filters });
|
| 621 |
+
const service = context.requireResource<TeaQLDataService>("dataService");
|
| 622 |
+
return new SmartList<Record<string, unknown>>(
|
| 623 |
+
await service.executeQuery(context.prepareQuery(this.query)) as Record<string, unknown>[]);
|
| 624 |
+
}
|
| 625 |
+
|
| 626 |
+
private async executeCountedListInternal(
|
| 627 |
+
context: UserContext,
|
| 628 |
+
): Promise<SmartList<WorkItem>> {
|
| 629 |
+
this.ensureIntent();
|
| 630 |
+
if (this.filters.length > 0) this.query.filter({ "$and": this.filters });
|
| 631 |
+
const service = context.requireResource<TeaQLDataService>("dataService");
|
| 632 |
+
const preparedQuery = context.prepareQuery(this.query);
|
| 633 |
+
const useIdSet = preparedQuery.localIdSetPaginationOptions() !== undefined;
|
| 634 |
+
const countOperation = { kind: "named-count" as const,
|
| 635 |
+
method: this._pageCountMethod ?? "count",
|
| 636 |
+
...(this._pageCountMethod === "countAs" ? { alias: this._pageCountAlias } : {}) };
|
| 637 |
+
const totalCountBeforeRows = useIdSet ? undefined : await service.executeCount(
|
| 638 |
+
preparedQuery, this._pageCountAlias, countOperation);
|
| 639 |
+
const pageQuery = preparedQuery.clone();
|
| 640 |
+
// A page count describes the full filtered set, not an aggregate-only page row.
|
| 641 |
+
pageQuery.aggregateItems = pageQuery.aggregateItems.filter(item =>
|
| 642 |
+
!(String(item.function).toLowerCase() === "count" && item.alias === this._pageCountAlias));
|
| 643 |
+
const rows = await service.executeQuery(pageQuery);
|
| 644 |
+
const totalCount = useIdSet && context.idSetPaginationCountAccuracy === "EXACT"
|
| 645 |
+
? context.idSetPaginationCount!
|
| 646 |
+
: (totalCountBeforeRows ?? await service.executeCount(preparedQuery, this._pageCountAlias, countOperation));
|
| 647 |
+
const data = new SmartList(rows.map((row: unknown) =>
|
| 648 |
+
row instanceof WorkItem
|
| 649 |
+
? row
|
| 650 |
+
: WorkItem.fromRecord(row as Record<string, unknown>, new EntityRoot())));
|
| 651 |
+
data.totalCount = totalCount;
|
| 652 |
+
if (this._pageCountAlias !== undefined) data.aggregations[this._pageCountAlias] = totalCount;
|
| 653 |
+
if (this.query.facets.length > 0) {
|
| 654 |
+
data.facets = await executeRelationFacets(
|
| 655 |
+
service, (query: any) => context.prepareQuery(query), preparedQuery, preparedQuery.facets);
|
| 656 |
+
}
|
| 657 |
+
return data;
|
| 658 |
+
}
|
| 659 |
+
|
| 660 |
+
private executeForStreamInternal(context: UserContext, chunkSize: number): AsyncIterable<WorkItem> {
|
| 661 |
+
this.ensureIntent();
|
| 662 |
+
if (this.filters.length > 0) this.query.filter({ "$and": this.filters });
|
| 663 |
+
const service = context.requireResource<TeaQLDataService>("dataService");
|
| 664 |
+
const preparedQuery = context.prepareQuery(this.query);
|
| 665 |
+
// Prepare Context and capture the runtime request before returning a lazy iterator.
|
| 666 |
+
const chunks = service.executeForStream(preparedQuery, chunkSize);
|
| 667 |
+
return (async function* () {
|
| 668 |
+
for await (const chunk of chunks) {
|
| 669 |
+
for (const entity of chunk) {
|
| 670 |
+
yield entity instanceof WorkItem
|
| 671 |
+
? entity
|
| 672 |
+
: WorkItem.fromRecord(entity as Record<string, unknown>, new EntityRoot());
|
| 673 |
+
}
|
| 674 |
+
}
|
| 675 |
+
})();
|
| 676 |
+
}
|
| 677 |
+
|
| 678 |
+
private ensureIntent(): void {
|
| 679 |
+
// Runtime owns validation, Unicode whitespace rules and typed diagnostics.
|
| 680 |
+
new QueryIntent(this._comment, this._purpose);
|
| 681 |
+
}
|
| 682 |
+
|
| 683 |
+
}
|
| 684 |
+
|
| 685 |
+
export class ExecutableWorkItemRequest {
|
| 686 |
+
constructor(
|
| 687 |
+
private readonly execute: (context: UserContext) => Promise<SmartList<WorkItem>>,
|
| 688 |
+
private readonly executeRows: (context: UserContext) => Promise<SmartList<Record<string, unknown>>>,
|
| 689 |
+
private readonly stream: (context: UserContext, chunkSize: number) => AsyncIterable<WorkItem>,
|
| 690 |
+
private readonly limitOne: () => void,
|
| 691 |
+
private readonly addComment: (comment: string) => void,
|
| 692 |
+
private readonly ensureIntent: () => void,
|
| 693 |
+
) {}
|
| 694 |
+
|
| 695 |
+
comment(c: string): this {
|
| 696 |
+
this.addComment(c);
|
| 697 |
+
return this;
|
| 698 |
+
}
|
| 699 |
+
|
| 700 |
+
newEntity(context: UserContext): WorkItem {
|
| 701 |
+
this.ensureIntent();
|
| 702 |
+
return new WorkItem();
|
| 703 |
+
}
|
| 704 |
+
|
| 705 |
+
executeForList(context: UserContext): Promise<SmartList<WorkItem>> {
|
| 706 |
+
this.ensureIntent();
|
| 707 |
+
return this.execute(context);
|
| 708 |
+
}
|
| 709 |
+
|
| 710 |
+
executeForRows(context: UserContext): Promise<SmartList<Record<string, unknown>>> {
|
| 711 |
+
this.ensureIntent();
|
| 712 |
+
return this.executeRows(context);
|
| 713 |
+
}
|
| 714 |
+
|
| 715 |
+
executeForStream(context: UserContext, chunkSize = 1000): AsyncIterable<WorkItem> {
|
| 716 |
+
this.ensureIntent();
|
| 717 |
+
return this.stream(context, chunkSize);
|
| 718 |
+
}
|
| 719 |
+
|
| 720 |
+
async executeForOne(context: UserContext): Promise<WorkItem | undefined> {
|
| 721 |
+
this.limitOne();
|
| 722 |
+
return (await this.executeForList(context))[0];
|
| 723 |
+
}
|
| 724 |
+
}
|
source/teaql-ts/examples/conformance/src/main.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import assert from "node:assert/strict";
|
| 2 |
+
import fs from "node:fs";
|
| 3 |
+
import path from "node:path";
|
| 4 |
+
import { CheckException, EntityRoot, UserContext } from "./teaql-ts";
|
| 5 |
+
import { E, TeaQLNotLoadedError } from "./generated/E";
|
| 6 |
+
import { Q } from "./generated/Q";
|
| 7 |
+
import { WorkItem } from "./generated/models/WorkItem";
|
| 8 |
+
import { SQLiteTeaQLClient } from "./teaql-node-sqlite";
|
| 9 |
+
import { verifyMaskingLifecycle } from './masking-verification';
|
| 10 |
+
|
| 11 |
+
async function main(): Promise<void> {
|
| 12 |
+
const orderKey = { entity: "Order", id: 1 } as const;
|
| 13 |
+
const executionKey = { entity: "InferenceExecution", id: 1 } as const;
|
| 14 |
+
const target = new EntityRoot();
|
| 15 |
+
const source = new EntityRoot();
|
| 16 |
+
target.setOriginalVersion(orderKey, 3);
|
| 17 |
+
source.setOriginalVersion(executionKey, 9);
|
| 18 |
+
source.set(executionKey, "execution_status", "COMPLETED");
|
| 19 |
+
target.mergeFrom(source);
|
| 20 |
+
assert.equal(target.originalVersion(orderKey), 3);
|
| 21 |
+
assert.equal(target.originalVersion(executionKey), 9);
|
| 22 |
+
console.log("PASS Mutation ledger identity (same ID, different entity types keep versions 3/9)");
|
| 23 |
+
|
| 24 |
+
const database = path.resolve(__dirname, "../.local/conformance.sqlite");
|
| 25 |
+
fs.mkdirSync(path.dirname(database), { recursive: true });
|
| 26 |
+
fs.rmSync(database, { force: true });
|
| 27 |
+
const client = new SQLiteTeaQLClient(database);
|
| 28 |
+
const context = new UserContext().insertResource("dataService", client);
|
| 29 |
+
client.setUserContext(context);
|
| 30 |
+
|
| 31 |
+
await context.ensureSchema();
|
| 32 |
+
console.log("PASS ensureSchema (explicit SQLite DDL and Platform(1) bootstrap)");
|
| 33 |
+
|
| 34 |
+
const sqlBeforeInvalidSave = client.sqlTrace.length;
|
| 35 |
+
const invalid = new WorkItem().updatePlatform("1");
|
| 36 |
+
await assert.rejects(invalid.auditAs("Checker must reject a missing title").save(context), (error: unknown) => {
|
| 37 |
+
assert(error instanceof CheckException);
|
| 38 |
+
assert(error.violations.some(item => item.ruleId === "required" && String(item.location).includes("title")));
|
| 39 |
+
return true;
|
| 40 |
+
});
|
| 41 |
+
assert.equal(client.sqlTrace.length, sqlBeforeInvalidSave, "Checker must run before mutation SQL");
|
| 42 |
+
console.log("PASS Checker (canonical title key, rejected before SQL)");
|
| 43 |
+
|
| 44 |
+
const created = await new WorkItem()
|
| 45 |
+
.updateTitle("Verify TypeScript runtime")
|
| 46 |
+
.updatePlatform("1")
|
| 47 |
+
.auditAs("Create conformance work item").save(context);
|
| 48 |
+
assert(created.id);
|
| 49 |
+
assert.equal(created.version, 1);
|
| 50 |
+
console.log(`PASS Create (id=${created.id}, version=${created.version})`);
|
| 51 |
+
|
| 52 |
+
const queried = await Q.workItems().withIdIs(created.id)
|
| 53 |
+
.selectPlatformWith(Q.platforms().selectName())
|
| 54 |
+
.comment("Load the complete work item before mutation")
|
| 55 |
+
.purpose("Verify typed Q API and update semantics").executeForOne(context);
|
| 56 |
+
assert(queried);
|
| 57 |
+
assert.equal(queried.title, "Verify TypeScript runtime");
|
| 58 |
+
assert.equal(E.workItem(queried).platform().name().eval(), "Runtime Example");
|
| 59 |
+
console.log("PASS Q API (typed WorkItem)");
|
| 60 |
+
|
| 61 |
+
assert.equal(E.workItem(queried).title().eval(), "Verify TypeScript runtime");
|
| 62 |
+
assert.equal(E.workItem(queried).description().orElse("N/A"), "N/A");
|
| 63 |
+
const minimal = await Q.workItemsWithMinimalFields().withIdIs(created.id)
|
| 64 |
+
.comment("Load only mandatory identity fields")
|
| 65 |
+
.purpose("Verify E not-loaded semantics").executeForOne(context);
|
| 66 |
+
assert(minimal);
|
| 67 |
+
assert.throws(() => E.workItem(minimal).title().eval(), TeaQLNotLoadedError);
|
| 68 |
+
console.log("PASS E API (loaded, null fallback, and not-loaded are distinct)");
|
| 69 |
+
|
| 70 |
+
const previousVersion = queried.version!;
|
| 71 |
+
await queried.updateTitle("Verified TypeScript runtime")
|
| 72 |
+
.auditAs("Update conformance work item").save(context);
|
| 73 |
+
assert.equal(queried.version, previousVersion + 1);
|
| 74 |
+
console.log(`PASS Update (version ${previousVersion} -> ${queried.version})`);
|
| 75 |
+
|
| 76 |
+
await queried.markForDeletion().auditAs("Delete conformance work item").save(context);
|
| 77 |
+
const remaining = await Q.workItems().withIdIs(created.id)
|
| 78 |
+
.comment("Verify soft-deleted work item is excluded")
|
| 79 |
+
.purpose("Verify delete semantics").executeForList(context);
|
| 80 |
+
assert.equal(remaining.length, 0);
|
| 81 |
+
console.log("PASS Delete (default Q excludes deleted rows)");
|
| 82 |
+
|
| 83 |
+
await client.close();
|
| 84 |
+
console.log("PASS TypeScript minimum runtime conformance: 8/8");
|
| 85 |
+
await verifyMaskingLifecycle();
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
main().catch(error => { console.error(error); process.exitCode = 1; });
|