appflare 0.2.40 → 0.2.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- 'use strict';var l=class n{def;constructor(e,t){this.def={kind:"enum",name:e,values:t};}sql(e){return new n(e,this.def.values)}toDefinition(){return {...this.def}}getValues(){return this.def.values}};function d(n,e){return new l(n,e)}var u=class{_element;constructor(e){this._element=e;}get shape(){return {kind:"array",element:this._element}}toColumnBuilder(){return new o("json",{jsonShape:this.shape})}};var o=class n{definition;constructor(e,t={}){if(typeof e=="string"){this.definition={kind:"column",type:e,sqlName:t.sqlName,length:t.length,enumValues:t.enumValues,enumRef:t.enumRef,jsonShape:t.jsonShape};return}this.definition={...e};}with(e){return new n({...this.definition,...e})}sql(e){return this.with({sqlName:e})}notNull(){return this.with({notNull:true,nullable:false})}nullable(){return this.with({nullable:true,notNull:false})}primaryKey(e={}){return this.with({primaryKey:true,autoIncrement:e.autoIncrement??this.definition.autoIncrement})}unique(e){return this.with({unique:e?{name:e}:true})}index(e){return this.with({index:e?{name:e}:true})}default(e){return this.with({sqlDefault:e})}defaultFn(e){return this.with({runtimeDefaultFn:e})}defaultNow(){return this.with({nowDefault:true,runtimeDefaultFn:()=>new Date})}references(e,t="id",r={}){return this.with({references:{table:e,column:t,onDelete:r.onDelete,onUpdate:r.onUpdate}})}array(){return this.with({isArray:true})}toDefinition(){return {...this.definition}}};function p(n,e={}){let t={},r={};for(let[i,a]of Object.entries(n)){if(a instanceof o){t[i]=a.toDefinition();continue}if(a.kind==="relation"){r[i]=a;continue}throw new Error(`Invalid table field '${i}'. Use column builders or relation helpers.`)}return {kind:"table",sqlName:e.sqlName,columns:t,relations:r}}function m(n,e={}){return {kind:"schema",tables:n,enums:e.enums??{}}}function f(n){if(typeof n!="object"||n===null)return false;let e=n;return e.kind==="schema"&&typeof e.tables=="object"&&(typeof e.enums=="object"||e.enums===void 0)}function c(n,e,t={}){let r=typeof e=="string"?e:void 0,i=typeof e=="string"?t:e??t;return {kind:"relation",relation:"one",targetTable:n,field:i.field??r,referenceField:i.referenceField,fkType:i.fkType,sqlName:i.sqlName,notNull:i.notNull,nullable:i.nullable,onDelete:i.onDelete,onUpdate:i.onUpdate}}function y(n,e,t={}){let r=typeof e=="string"?e:void 0,i=typeof e=="string"?t:e??t;return {kind:"relation",relation:"many",targetTable:n,field:i.field??r,referenceField:i.referenceField,fkType:i.fkType,sqlName:i.sqlName,notNull:i.notNull,nullable:i.nullable,onDelete:i.onDelete,onUpdate:i.onUpdate}}function g(n,e={}){return {kind:"relation",relation:"manyToMany",targetTable:n,referenceField:e.referenceField,targetReferenceField:e.targetReferenceField,junctionTable:e.junctionTable,sourceField:e.sourceField,targetField:e.targetField,sourceSqlName:e.sourceSqlName,targetSqlName:e.targetSqlName,onDelete:e.onDelete,onUpdate:e.onUpdate}}function s(n){let e=n.toDefinition();return e.jsonShape?e.jsonShape:e.type==="int"?{kind:"number"}:e.type==="string"?{kind:"string"}:e.type==="boolean"?{kind:"boolean"}:e.type==="date"?{kind:"date"}:e.type==="enum"&&e.enumValues?{kind:"string"}:{kind:"unknown"}}var h={defineEnum:(n,e)=>d(n,e),int:(n={})=>new o("int",n),number:(n={})=>new o("int",n),string:(n={})=>new o("string",n),boolean:(n={})=>new o("boolean",n),date:(n={})=>new o("date",n),uuid:(n={})=>new o({kind:"column",type:"string",sqlName:n.sqlName,length:n.length??36,primaryKey:true,notNull:true,nullable:false,uuidPrimaryKey:true,runtimeDefaultFn:()=>crypto.randomUUID()}),enum:(n,e={})=>{if(n instanceof l){let t=n.toDefinition();return new o("enum",{...e,enumValues:t.values,enumRef:t.name})}return new o("enum",{...e,enumValues:n})},enumArray:(n,e={})=>{if(n instanceof l){let t=n.toDefinition();return new o("enum",{...e,enumValues:t.values,enumRef:t.name,isArray:true})}return new o("enum",{...e,enumValues:n,isArray:true})},array:n=>{if(n instanceof u)return n.toColumnBuilder();if(n instanceof o){let e=n.toDefinition();if(e.jsonShape)return new o("json",{jsonShape:e.jsonShape});let t={kind:"array",element:s(n)};return new o("json",{jsonShape:t})}return new o("json",{jsonShape:{kind:"unknown"}})},object:n=>{let e={};for(let[t,r]of Object.entries(n))r instanceof o?e[t]=s(r):e[t]=r;return new o("json",{jsonShape:{kind:"object",shape:e}})},one:(n,e,t={})=>c(n,e,t),many:(n,e,t={})=>y(n,e,t),manyToMany:(n,e={})=>g(n,e)};exports.isSchemaDefinition=f;exports.schema=m;exports.table=p;exports.v=h;
1
+ 'use strict';var l=class n{def;constructor(e,t){this.def={kind:"enum",name:e,values:t};}sql(e){return new n(e,this.def.values)}toDefinition(){return {...this.def}}getValues(){return this.def.values}};function d(n,e){return new l(n,e)}var u=class{_element;constructor(e){this._element=e;}get shape(){return {kind:"array",element:this._element}}toColumnBuilder(){return new o("json",{jsonShape:this.shape})}};var o=class n{definition;constructor(e,t={}){if(typeof e=="string"){this.definition={kind:"column",type:e,sqlName:t.sqlName,length:t.length,enumValues:t.enumValues,enumRef:t.enumRef,jsonShape:t.jsonShape};return}this.definition={...e};}with(e){return new n({...this.definition,...e})}sql(e){return this.with({sqlName:e})}notNull(){return this.with({notNull:true,nullable:false})}nullable(){return this.with({nullable:true,notNull:false})}primaryKey(e={}){return this.with({primaryKey:true,autoIncrement:e.autoIncrement??this.definition.autoIncrement})}unique(e){return this.with({unique:e?{name:e}:true})}index(e){return this.with({index:e?{name:e}:true})}default(e){return this.with({sqlDefault:e})}defaultFn(e){return this.with({runtimeDefaultFn:e})}defaultNow(){return this.with({nowDefault:true,runtimeDefaultFn:()=>new Date})}references(e,t="id",r={}){return this.with({references:{table:e,column:t,onDelete:r.onDelete,onUpdate:r.onUpdate}})}array(){return this.with({isArray:true})}toDefinition(){return {...this.definition}}};function p(n,e={}){let t={},r={};for(let[i,a]of Object.entries(n)){if(a instanceof o){t[i]=a.toDefinition();continue}if(a.kind==="relation"){r[i]=a;continue}throw new Error(`Invalid table field '${i}'. Use column builders or relation helpers.`)}return {kind:"table",sqlName:e.sqlName,columns:t,relations:r}}function m(n,e={}){return {kind:"schema",tables:n,enums:e.enums??{}}}function f(n){if(typeof n!="object"||n===null)return false;let e=n;return e.kind==="schema"&&typeof e.tables=="object"&&(typeof e.enums=="object"||e.enums===void 0)}function c(n,e,t={}){let r=typeof e=="string"?e:void 0,i=typeof e=="string"?t:e??t;return {kind:"relation",relation:"one",targetTable:n,field:i.field??r,referenceField:i.referenceField,fkType:i.fkType,sqlName:i.sqlName,notNull:i.notNull,nullable:i.nullable,onDelete:i.onDelete,onUpdate:i.onUpdate}}function y(n,e,t={}){let r=typeof e=="string"?e:void 0,i=typeof e=="string"?t:e??t;return {kind:"relation",relation:"many",targetTable:n,field:i.field??r,referenceField:i.referenceField,fkType:i.fkType,sqlName:i.sqlName,notNull:i.notNull,nullable:i.nullable,onDelete:i.onDelete,onUpdate:i.onUpdate}}function g(n,e={}){return {kind:"relation",relation:"manyToMany",targetTable:n,referenceField:e.referenceField,targetReferenceField:e.targetReferenceField,junctionTable:e.junctionTable,sourceField:e.sourceField,targetField:e.targetField,sourceSqlName:e.sourceSqlName,targetSqlName:e.targetSqlName,onDelete:e.onDelete,onUpdate:e.onUpdate}}function s(n){let e=n.toDefinition();return e.jsonShape?e.jsonShape:e.type==="int"?{kind:"number"}:e.type==="string"?{kind:"string"}:e.type==="boolean"?{kind:"boolean"}:e.type==="date"?{kind:"date"}:e.type==="enum"&&e.enumValues?{kind:"string"}:{kind:"unknown"}}var h={defineEnum:(n,e)=>d(n,e),int:(n={})=>new o("int",n),number:(n={})=>new o("int",n),string:(n={})=>new o("string",n),boolean:(n={})=>new o("boolean",n),date:(n={})=>new o("date",n),uuid:(n={})=>new o({kind:"column",type:"string",sqlName:n.sqlName,length:n.length??36,primaryKey:true,notNull:true,nullable:false,uuidPrimaryKey:true,runtimeDefaultFn:()=>crypto.randomUUID()}),enum:(n,e={})=>{if(n instanceof l){let t=n.toDefinition();return new o("enum",{...e,enumValues:t.values,enumRef:t.name})}return new o("enum",{...e,enumValues:n})},enumArray:(n,e={})=>{if(n instanceof l){let t=n.toDefinition();return new o("enum",{...e,enumValues:t.values,enumRef:t.name,isArray:true})}return new o("enum",{...e,enumValues:n,isArray:true})},array:n=>{if(n instanceof u)return n.toColumnBuilder();if(n instanceof o){let e=n.toDefinition();if(e.jsonShape)return new o("json",{jsonShape:{kind:"array",element:e.jsonShape}});let t={kind:"array",element:s(n)};return new o("json",{jsonShape:t})}return new o("json",{jsonShape:{kind:"unknown"}})},object:n=>{let e={};for(let[t,r]of Object.entries(n))r instanceof o?e[t]=s(r):e[t]=r;return new o("json",{jsonShape:{kind:"object",shape:e}})},one:(n,e,t={})=>c(n,e,t),many:(n,e,t={})=>y(n,e,t),manyToMany:(n,e={})=>g(n,e)};exports.isSchemaDefinition=f;exports.schema=m;exports.table=p;exports.v=h;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var l=class n{def;constructor(e,t){this.def={kind:"enum",name:e,values:t};}sql(e){return new n(e,this.def.values)}toDefinition(){return {...this.def}}getValues(){return this.def.values}};function d(n,e){return new l(n,e)}var u=class{_element;constructor(e){this._element=e;}get shape(){return {kind:"array",element:this._element}}toColumnBuilder(){return new o("json",{jsonShape:this.shape})}};var o=class n{definition;constructor(e,t={}){if(typeof e=="string"){this.definition={kind:"column",type:e,sqlName:t.sqlName,length:t.length,enumValues:t.enumValues,enumRef:t.enumRef,jsonShape:t.jsonShape};return}this.definition={...e};}with(e){return new n({...this.definition,...e})}sql(e){return this.with({sqlName:e})}notNull(){return this.with({notNull:true,nullable:false})}nullable(){return this.with({nullable:true,notNull:false})}primaryKey(e={}){return this.with({primaryKey:true,autoIncrement:e.autoIncrement??this.definition.autoIncrement})}unique(e){return this.with({unique:e?{name:e}:true})}index(e){return this.with({index:e?{name:e}:true})}default(e){return this.with({sqlDefault:e})}defaultFn(e){return this.with({runtimeDefaultFn:e})}defaultNow(){return this.with({nowDefault:true,runtimeDefaultFn:()=>new Date})}references(e,t="id",r={}){return this.with({references:{table:e,column:t,onDelete:r.onDelete,onUpdate:r.onUpdate}})}array(){return this.with({isArray:true})}toDefinition(){return {...this.definition}}};function p(n,e={}){let t={},r={};for(let[i,a]of Object.entries(n)){if(a instanceof o){t[i]=a.toDefinition();continue}if(a.kind==="relation"){r[i]=a;continue}throw new Error(`Invalid table field '${i}'. Use column builders or relation helpers.`)}return {kind:"table",sqlName:e.sqlName,columns:t,relations:r}}function m(n,e={}){return {kind:"schema",tables:n,enums:e.enums??{}}}function f(n){if(typeof n!="object"||n===null)return false;let e=n;return e.kind==="schema"&&typeof e.tables=="object"&&(typeof e.enums=="object"||e.enums===void 0)}function c(n,e,t={}){let r=typeof e=="string"?e:void 0,i=typeof e=="string"?t:e??t;return {kind:"relation",relation:"one",targetTable:n,field:i.field??r,referenceField:i.referenceField,fkType:i.fkType,sqlName:i.sqlName,notNull:i.notNull,nullable:i.nullable,onDelete:i.onDelete,onUpdate:i.onUpdate}}function y(n,e,t={}){let r=typeof e=="string"?e:void 0,i=typeof e=="string"?t:e??t;return {kind:"relation",relation:"many",targetTable:n,field:i.field??r,referenceField:i.referenceField,fkType:i.fkType,sqlName:i.sqlName,notNull:i.notNull,nullable:i.nullable,onDelete:i.onDelete,onUpdate:i.onUpdate}}function g(n,e={}){return {kind:"relation",relation:"manyToMany",targetTable:n,referenceField:e.referenceField,targetReferenceField:e.targetReferenceField,junctionTable:e.junctionTable,sourceField:e.sourceField,targetField:e.targetField,sourceSqlName:e.sourceSqlName,targetSqlName:e.targetSqlName,onDelete:e.onDelete,onUpdate:e.onUpdate}}function s(n){let e=n.toDefinition();return e.jsonShape?e.jsonShape:e.type==="int"?{kind:"number"}:e.type==="string"?{kind:"string"}:e.type==="boolean"?{kind:"boolean"}:e.type==="date"?{kind:"date"}:e.type==="enum"&&e.enumValues?{kind:"string"}:{kind:"unknown"}}var h={defineEnum:(n,e)=>d(n,e),int:(n={})=>new o("int",n),number:(n={})=>new o("int",n),string:(n={})=>new o("string",n),boolean:(n={})=>new o("boolean",n),date:(n={})=>new o("date",n),uuid:(n={})=>new o({kind:"column",type:"string",sqlName:n.sqlName,length:n.length??36,primaryKey:true,notNull:true,nullable:false,uuidPrimaryKey:true,runtimeDefaultFn:()=>crypto.randomUUID()}),enum:(n,e={})=>{if(n instanceof l){let t=n.toDefinition();return new o("enum",{...e,enumValues:t.values,enumRef:t.name})}return new o("enum",{...e,enumValues:n})},enumArray:(n,e={})=>{if(n instanceof l){let t=n.toDefinition();return new o("enum",{...e,enumValues:t.values,enumRef:t.name,isArray:true})}return new o("enum",{...e,enumValues:n,isArray:true})},array:n=>{if(n instanceof u)return n.toColumnBuilder();if(n instanceof o){let e=n.toDefinition();if(e.jsonShape)return new o("json",{jsonShape:e.jsonShape});let t={kind:"array",element:s(n)};return new o("json",{jsonShape:t})}return new o("json",{jsonShape:{kind:"unknown"}})},object:n=>{let e={};for(let[t,r]of Object.entries(n))r instanceof o?e[t]=s(r):e[t]=r;return new o("json",{jsonShape:{kind:"object",shape:e}})},one:(n,e,t={})=>c(n,e,t),many:(n,e,t={})=>y(n,e,t),manyToMany:(n,e={})=>g(n,e)};export{f as isSchemaDefinition,m as schema,p as table,h as v};
1
+ var l=class n{def;constructor(e,t){this.def={kind:"enum",name:e,values:t};}sql(e){return new n(e,this.def.values)}toDefinition(){return {...this.def}}getValues(){return this.def.values}};function d(n,e){return new l(n,e)}var u=class{_element;constructor(e){this._element=e;}get shape(){return {kind:"array",element:this._element}}toColumnBuilder(){return new o("json",{jsonShape:this.shape})}};var o=class n{definition;constructor(e,t={}){if(typeof e=="string"){this.definition={kind:"column",type:e,sqlName:t.sqlName,length:t.length,enumValues:t.enumValues,enumRef:t.enumRef,jsonShape:t.jsonShape};return}this.definition={...e};}with(e){return new n({...this.definition,...e})}sql(e){return this.with({sqlName:e})}notNull(){return this.with({notNull:true,nullable:false})}nullable(){return this.with({nullable:true,notNull:false})}primaryKey(e={}){return this.with({primaryKey:true,autoIncrement:e.autoIncrement??this.definition.autoIncrement})}unique(e){return this.with({unique:e?{name:e}:true})}index(e){return this.with({index:e?{name:e}:true})}default(e){return this.with({sqlDefault:e})}defaultFn(e){return this.with({runtimeDefaultFn:e})}defaultNow(){return this.with({nowDefault:true,runtimeDefaultFn:()=>new Date})}references(e,t="id",r={}){return this.with({references:{table:e,column:t,onDelete:r.onDelete,onUpdate:r.onUpdate}})}array(){return this.with({isArray:true})}toDefinition(){return {...this.definition}}};function p(n,e={}){let t={},r={};for(let[i,a]of Object.entries(n)){if(a instanceof o){t[i]=a.toDefinition();continue}if(a.kind==="relation"){r[i]=a;continue}throw new Error(`Invalid table field '${i}'. Use column builders or relation helpers.`)}return {kind:"table",sqlName:e.sqlName,columns:t,relations:r}}function m(n,e={}){return {kind:"schema",tables:n,enums:e.enums??{}}}function f(n){if(typeof n!="object"||n===null)return false;let e=n;return e.kind==="schema"&&typeof e.tables=="object"&&(typeof e.enums=="object"||e.enums===void 0)}function c(n,e,t={}){let r=typeof e=="string"?e:void 0,i=typeof e=="string"?t:e??t;return {kind:"relation",relation:"one",targetTable:n,field:i.field??r,referenceField:i.referenceField,fkType:i.fkType,sqlName:i.sqlName,notNull:i.notNull,nullable:i.nullable,onDelete:i.onDelete,onUpdate:i.onUpdate}}function y(n,e,t={}){let r=typeof e=="string"?e:void 0,i=typeof e=="string"?t:e??t;return {kind:"relation",relation:"many",targetTable:n,field:i.field??r,referenceField:i.referenceField,fkType:i.fkType,sqlName:i.sqlName,notNull:i.notNull,nullable:i.nullable,onDelete:i.onDelete,onUpdate:i.onUpdate}}function g(n,e={}){return {kind:"relation",relation:"manyToMany",targetTable:n,referenceField:e.referenceField,targetReferenceField:e.targetReferenceField,junctionTable:e.junctionTable,sourceField:e.sourceField,targetField:e.targetField,sourceSqlName:e.sourceSqlName,targetSqlName:e.targetSqlName,onDelete:e.onDelete,onUpdate:e.onUpdate}}function s(n){let e=n.toDefinition();return e.jsonShape?e.jsonShape:e.type==="int"?{kind:"number"}:e.type==="string"?{kind:"string"}:e.type==="boolean"?{kind:"boolean"}:e.type==="date"?{kind:"date"}:e.type==="enum"&&e.enumValues?{kind:"string"}:{kind:"unknown"}}var h={defineEnum:(n,e)=>d(n,e),int:(n={})=>new o("int",n),number:(n={})=>new o("int",n),string:(n={})=>new o("string",n),boolean:(n={})=>new o("boolean",n),date:(n={})=>new o("date",n),uuid:(n={})=>new o({kind:"column",type:"string",sqlName:n.sqlName,length:n.length??36,primaryKey:true,notNull:true,nullable:false,uuidPrimaryKey:true,runtimeDefaultFn:()=>crypto.randomUUID()}),enum:(n,e={})=>{if(n instanceof l){let t=n.toDefinition();return new o("enum",{...e,enumValues:t.values,enumRef:t.name})}return new o("enum",{...e,enumValues:n})},enumArray:(n,e={})=>{if(n instanceof l){let t=n.toDefinition();return new o("enum",{...e,enumValues:t.values,enumRef:t.name,isArray:true})}return new o("enum",{...e,enumValues:n,isArray:true})},array:n=>{if(n instanceof u)return n.toColumnBuilder();if(n instanceof o){let e=n.toDefinition();if(e.jsonShape)return new o("json",{jsonShape:{kind:"array",element:e.jsonShape}});let t={kind:"array",element:s(n)};return new o("json",{jsonShape:t})}return new o("json",{jsonShape:{kind:"unknown"}})},object:n=>{let e={};for(let[t,r]of Object.entries(n))r instanceof o?e[t]=s(r):e[t]=r;return new o("json",{jsonShape:{kind:"object",shape:e}})},one:(n,e,t={})=>c(n,e,t),many:(n,e,t={})=>y(n,e,t),manyToMany:(n,e={})=>g(n,e)};export{f as isSchemaDefinition,m as schema,p as table,h as v};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appflare",
3
- "version": "0.2.40",
3
+ "version": "0.2.42",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
package/schema.ts CHANGED
@@ -587,7 +587,7 @@ export const v = {
587
587
  if (element instanceof ColumnBuilder) {
588
588
  const def = element.toDefinition();
589
589
  if (def.jsonShape) {
590
- return new ColumnBuilder("json", { jsonShape: def.jsonShape });
590
+ return new ColumnBuilder("json", { jsonShape: { kind: "array", element: def.jsonShape } });
591
591
  }
592
592
  const shape: JsonShape = {
593
593
  kind: "array",