@open-commune/core 0.2.20 → 0.2.22

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.
@@ -8,6 +8,13 @@
8
8
  "when": 1785245884628,
9
9
  "tag": "0000_init",
10
10
  "breakpoints": true
11
+ },
12
+ {
13
+ "idx": 1,
14
+ "version": "6",
15
+ "when": 1785245885628,
16
+ "tag": "0001_entries-fts",
17
+ "breakpoints": true
11
18
  }
12
19
  ]
13
- }
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-commune/core",
3
- "version": "0.2.20",
3
+ "version": "0.2.22",
4
4
  "type": "module",
5
5
  "description": "Business domains, database schema and tRPC router. Holds the logic; knows nothing of transport.",
6
6
  "main": "./dist/index.mjs",
@@ -1 +0,0 @@
1
- import{createInsertSchema as y,createUpdateSchema as c,createSelectSchema as D}from"drizzle-zod";import{z as e}from"zod";import{fieldDefinitionSchema as g,fieldReadSchema as C}from"../domains/collections/utils.mjs";import{sqliteTable as i,text as t,integer as I,uniqueIndex as F}from"drizzle-orm/sqlite-core";import{PUBLICATION_STATUSES as b,FIELD_TYPES as z}from"../domains/collections/constants.mjs";const A={id:!0,createdAt:!0,updatedAt:!0,legacyExtra:!0},B={createdBy:!0,updatedBy:!0},_={...A,...B},r=()=>t("id").primaryKey().$defaultFn(()=>crypto.randomUUID()),a=()=>t("created_at").notNull().$defaultFn(()=>new Date().toISOString()),l=()=>t("updated_at").notNull().$defaultFn(()=>new Date().toISOString()).$onUpdateFn(()=>new Date().toISOString()),u=()=>t("legacy_extra",{mode:"json"}).$type(),M=()=>t("status",{enum:b}).notNull().default("draft"),q=()=>t("published_at"),S=e.object({street:e.string().optional(),postalCode:e.string().optional(),city:e.string().optional()}),m=i("organization",{id:I("id").primaryKey().default(1),name:t("name").notNull(),type:t("type",{enum:["commune","intercommunality","syndicate","other"]}).notNull().default("commune"),slug:t("slug").notNull(),description:t("description"),address:t("address",{mode:"json"}).$type(),deployment:t("deployment",{mode:"json"}).$type(),settings:t("settings",{mode:"json"}).$type(),updatedBy:t("updated_by"),legacyExtra:u(),createdAt:a(),updatedAt:l()}),N=i("users",{id:r(),email:t("email").notNull().unique(),name:t("name").notNull(),passwordHash:t("password_hash"),role:t("role",{enum:["admin","redacteur"]}).notNull().default("redacteur"),createdAt:a(),updatedAt:l()}),E=i("sessions",{id:r(),userId:t("user_id").notNull().references(()=>N.id,{onDelete:"cascade"}),expiresAt:t("expires_at").notNull(),revokedAt:t("revoked_at"),ua:t("ua"),ip:t("ip"),createdAt:a()}),O=i("invitations",{id:r(),email:t("email").notNull(),tokenHash:t("token_hash").notNull().unique(),role:t("role",{enum:["admin","redacteur"]}).notNull().default("redacteur"),expiresAt:t("expires_at").notNull(),usedAt:t("used_at"),createdAt:a()}),T=i("api_tokens",{id:r(),name:t("name").notNull(),tokenHash:t("token_hash").notNull().unique(),lastUsedAt:t("last_used_at"),revokedAt:t("revoked_at"),createdAt:a()}),f=i("media",{id:r(),filename:t("filename").notNull(),mime:t("mime").notNull(),size:I("size").notNull(),alt:t("alt"),caption:t("caption"),objects:t("objects",{mode:"json"}).$type().notNull(),metaData:t("meta_data",{mode:"json"}).$type(),createdBy:t("created_by"),updatedBy:t("updated_by"),legacyExtra:u(),createdAt:a(),updatedAt:l()}),s=i("collection_definitions",{id:r(),name:t("name").notNull(),slug:t("slug").notNull().unique(),description:t("description"),fields:t("fields",{mode:"json"}).$type().notNull(),editor:t("editor",{mode:"json"}).$type(),display:t("display",{mode:"json"}).$type(),headings:t("headings",{mode:"json"}).$type(),createdBy:t("created_by"),updatedBy:t("updated_by"),legacyExtra:u(),createdAt:a(),updatedAt:l()}),d=i("entries",{id:r(),collectionId:t("collection_id").notNull().references(()=>s.id,{onDelete:"cascade"}),title:t("title").notNull(),slug:t("slug").notNull(),data:t("data",{mode:"json"}).$type().notNull(),related:t("related",{mode:"json"}).$type(),createdBy:t("created_by"),updatedBy:t("updated_by"),status:M(),publishedAt:q(),legacyExtra:u(),createdAt:a(),updatedAt:l()},n=>[F("entries_slug_unique").on(n.collectionId,n.slug)]),Y={__proto__:null,FIELD_TYPES:z,PUBLICATION_STATUSES:b,addressSchema:S,apiTokens:T,collectionDefinitions:s,entries:d,fieldDefinitionSchema:g,invitations:O,media:f,organization:m,sessions:E,users:N},V=y(s).omit(_).extend({fields:e.array(g).min(1),slug:e.string().optional()}),H=c(s).omit(_).extend({fields:e.array(g).min(1).optional()}),G=D(s,{fields:e.array(C).describe("The fields every entry of the collection is made of")}),j={..._,related:!0,collectionId:!0},K=y(d).omit(j).extend({slug:e.string().optional()}),Z=c(d).omit(j).extend({related:e.array(e.string()).optional()}),U=D(d,{collectionId:n=>n.describe("Id of the collection the entry belongs to"),slug:n=>n.describe("Route segment of the entry on the published site"),data:e.record(e.string(),e.unknown()).describe("Values of the collection\u2019s fields, keyed by field name"),related:e.array(e.string()).nullable().describe("Ids of the entries that reference this one"),status:n=>n.describe("Publication status; only `published` entries are on the public site")}),J=U.extend({collectionSlug:e.string().describe("Slug of the collection the entry belongs to")}),Q=e.object({filename:e.string().min(1),mime:e.string().min(1),metaData:e.record(e.string(),e.string()).optional()}),W=e.object({key:e.string().min(1),filename:e.string().min(1),mime:e.string().min(1),alt:e.string().optional(),metaData:e.record(e.string(),e.unknown()).optional()}),X=c(f).pick({alt:!0,caption:!0,filename:!0}),v={...A,updatedBy:!0},L={name:n=>n.trim().min(1)},ee=y(m,L).omit(v),te=c(m,L).omit(v),ne=e.object({email:e.email(),password:e.string().min(1)}),oe=e.object({token:e.string().min(1),name:e.string().min(1).optional(),password:e.string().min(10)}),ie=e.object({email:e.email()}),ae=e.object({email:e.email(),role:e.enum(["admin","redacteur"])}),re=e.object({id:e.string(),data:e.object({name:e.string().min(1).optional(),role:e.enum(["admin","redacteur"]).optional(),email:e.email().optional()})}),se=e.strictObject({name:e.string().trim().min(1).max(120)}),k=({id:n,email:p,name:w,role:R})=>({id:n,email:p,name:w,role:R}),le=(n,p)=>({...k(n),audience:p.audience}),de=e.object({name:e.string().min(1)}),$=[7,30,90],x=e.object({period:e.coerce.number().pipe(e.union($.map(n=>e.literal(n)))),collection:e.string().min(1).optional(),entry:e.string().min(1).optional()}),h=e.object({name:e.string(),share:e.number()}),o=e.number().nonnegative(),ce=e.object({period:e.object({from:e.string(),to:e.string(),days:e.number()}),visits:o,visitsPrevious:o.nullish(),visitors:o.nullish(),readingMs:o.nullish(),viewsPerVisit:o.nullish(),rightNow:o.nullish(),daily:e.array(e.object({day:e.string(),visits:o})),top:e.array(e.object({path:e.string(),collection:e.string().nullish(),views:o})).optional(),sources:e.array(h).optional(),devices:e.array(h).optional(),places:e.array(h).optional(),campaigns:e.array(e.object({name:e.string(),visits:o})).optional(),depth:e.object({reached25:o,reached50:o,reachedEnd:o}).nullish()}),ue=e.object({period:x.shape.period,collection:e.string().min(1).optional(),entry:e.string().min(1).optional()}).refine(n=>!n.entry||n.collection,{message:"an entry is asked within its collection",path:["collection"]}),P={AUDIENCE_UNAVAILABLE:"audience-unavailable-error",COLLECTION_NOT_FOUND:"collection-not-found-error",ENTRY_NOT_FOUND:"entry-not-found-error",INVALID_ENTRY_DATA:"invalid-entry-data-error",DUPLICATE_SLUG:"duplicate-slug-error",MEDIA_NOT_FOUND:"media-not-found-error",UNSUPPORTED_MIME:"unsupported-mime-error",UPLOAD_INCOMPLETE:"upload-incomplete-error",ORGANIZATION_NOT_INITIALIZED:"organization-not-initialized-error",ORGANIZATION_ALREADY_INITIALIZED:"organization-already-initialized-error",DEPLOY_HOOK_MISSING:"deploy-hook-missing-error",DEPLOY_FAILED:"deploy-failed-error",USER_NOT_FOUND:"user-not-found-error",SESSION_NOT_FOUND:"session-not-found-error",INVITATION_INVALID:"invitation-invalid-error",CANNOT_REMOVE_SELF:"cannot-remove-self-error",TOO_MANY_ATTEMPTS:"too-many-attempts-error"},me=new Set(Object.values(P)),pe=n=>typeof n=="string"&&me.has(n);export{$ as A,N as B,E as C,O as D,P as E,T as F,m as G,f as H,s as I,d as J,S as K,oe as a,de as b,ue as c,x as d,ce as e,V as f,G as g,H as h,K as i,U as j,J as k,Z as l,ae as m,pe as n,ne as o,W as p,Q as q,X as r,ee as s,te as t,ie as u,k as v,le as w,se as x,re as y,Y as z};