@heyo-sh/heyo-cms 0.1.0 → 0.3.0
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/adapters/astro.d.ts +12 -5
- package/dist/adapters/astro.d.ts.map +1 -1
- package/dist/adapters/astro.js +1 -1
- package/dist/adapters/deliver.d.ts +26 -0
- package/dist/adapters/deliver.d.ts.map +1 -0
- package/dist/adapters/next.d.ts +26 -12
- package/dist/adapters/next.d.ts.map +1 -1
- package/dist/adapters/next.js +1 -1
- package/dist/adapters/nuxt.d.ts +10 -6
- package/dist/adapters/nuxt.d.ts.map +1 -1
- package/dist/adapters/nuxt.js +1 -1
- package/dist/adapters/react-router.d.ts +12 -5
- package/dist/adapters/react-router.d.ts.map +1 -1
- package/dist/adapters/react-router.js +1 -1
- package/dist/adapters/sveltekit.d.ts +9 -5
- package/dist/adapters/sveltekit.d.ts.map +1 -1
- package/dist/adapters/sveltekit.js +1 -1
- package/dist/ai/assistant/schema.d.ts +10 -0
- package/dist/ai/assistant/schema.d.ts.map +1 -1
- package/dist/ai/service.d.ts.map +1 -1
- package/dist/ai.js +1 -1
- package/dist/auth.js +1 -1
- package/dist/cli.js +2 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/types.d.ts +24 -1
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/content/import.d.ts.map +1 -1
- package/dist/content.js +1 -1
- package/dist/db/d1.js +1 -1
- package/dist/db/mongodb.js +2 -2
- package/dist/db/postgres.js +1 -1
- package/dist/db/sql/dialect.d.ts +2 -0
- package/dist/db/sql/dialect.d.ts.map +1 -1
- package/dist/db/sqlite.d.ts +13 -2
- package/dist/db/sqlite.d.ts.map +1 -1
- package/dist/db/sqlite.js +1 -1
- package/dist/editor/builtin.d.ts.map +1 -1
- package/dist/editor/serialize.d.ts.map +1 -1
- package/dist/editor.d.ts +1 -1
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +1 -1
- package/dist/engine/documents.d.ts.map +1 -1
- package/dist/engine/engine.d.ts +19 -0
- package/dist/engine/engine.d.ts.map +1 -1
- package/dist/engine/slugs.d.ts +124 -0
- package/dist/engine/slugs.d.ts.map +1 -0
- package/dist/fields/builtin.d.ts +86 -16
- package/dist/fields/builtin.d.ts.map +1 -1
- package/dist/fields/registry.d.ts.map +1 -1
- package/dist/fields.d.ts +1 -0
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +1 -1
- package/dist/http/handler.d.ts.map +1 -1
- package/dist/http/rich-text.d.ts +12 -1
- package/dist/http/rich-text.d.ts.map +1 -1
- package/dist/http/routes/ai.d.ts +1 -1
- package/dist/http/routes/documents.d.ts.map +1 -1
- package/dist/http/routes/media.d.ts +30 -0
- package/dist/http/routes/media.d.ts.map +1 -1
- package/dist/http.js +1 -1
- package/dist/index-1xz3pmtk.js +3 -0
- package/dist/index-2ddk43me.js +2 -0
- package/dist/index-385ggnge.js +2 -0
- package/dist/{index-7k091gpe.js → index-466cwb0b.js} +2 -2
- package/dist/{index-b2ecggck.js → index-4qrep5f0.js} +6 -6
- package/dist/{index-vq2978e7.js → index-63x90ejh.js} +8 -8
- package/dist/index-6m1kjq9g.js +2 -0
- package/dist/index-761dec5z.js +2 -0
- package/dist/{index-2kb5nbxx.js → index-8nzmqy0f.js} +2 -2
- package/dist/index-91fa1gzf.js +2 -0
- package/dist/index-a1jv6396.js +18 -0
- package/dist/index-a8jcwqsf.js +2 -0
- package/dist/index-abfzb1ve.js +2 -0
- package/dist/index-axpzy2hj.js +2 -0
- package/dist/index-b79c3k6g.js +2 -0
- package/dist/index-dtwe2z69.js +5 -0
- package/dist/index-eqfcxn71.js +2 -0
- package/dist/{index-9x1z3b85.js → index-mpkhjgvk.js} +4 -4
- package/dist/index-p2cqsmvw.js +2 -0
- package/dist/index-ptttzgtp.js +7 -0
- package/dist/{index-cbwwtcm4.js → index-rw0hze6x.js} +2 -2
- package/dist/index-s9x07zb3.js +2 -0
- package/dist/{index-34s342fz.js → index-szaq03qq.js} +2 -2
- package/dist/index-vf163r10.js +2 -0
- package/dist/{index-gpwcmmvr.js → index-vzhxn50e.js} +2 -2
- package/dist/index-wbc2xh4h.js +40 -0
- package/dist/index-y8kzzn94.js +2 -0
- package/dist/{index-7a231xfp.js → index-ypcmns0v.js} +2 -2
- package/dist/index-zyg6bfdq.js +2 -0
- package/dist/index.js +1 -1
- package/dist/jobs.js +1 -1
- package/dist/media/cloudflare.d.ts +58 -0
- package/dist/media/cloudflare.d.ts.map +1 -0
- package/dist/media/document.d.ts +7 -6
- package/dist/media/document.d.ts.map +1 -1
- package/dist/media/gc.d.ts.map +1 -1
- package/dist/media/pipeline.d.ts +19 -0
- package/dist/media/pipeline.d.ts.map +1 -1
- package/dist/media/service.d.ts.map +1 -1
- package/dist/media/urls.d.ts +77 -0
- package/dist/media/urls.d.ts.map +1 -0
- package/dist/media/usages.d.ts +9 -1
- package/dist/media/usages.d.ts.map +1 -1
- package/dist/media/variants.d.ts +11 -0
- package/dist/media/variants.d.ts.map +1 -1
- package/dist/migrations.js +1 -1
- package/dist/plugins/indexnow.d.ts +82 -0
- package/dist/plugins/indexnow.d.ts.map +1 -0
- package/dist/plugins.d.ts +9 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +1 -0
- package/dist/query.js +1 -1
- package/dist/{run-3r72dwhs.js → run-rqmtv3cn.js} +4 -4
- package/dist/schema/snapshot.d.ts +2 -0
- package/dist/schema/snapshot.d.ts.map +1 -1
- package/dist/schema/system.d.ts +9 -0
- package/dist/schema/system.d.ts.map +1 -1
- package/dist/schema.js +1 -1
- package/dist/slugify.d.ts +31 -0
- package/dist/slugify.d.ts.map +1 -0
- package/dist/telemetry.js +1 -1
- package/dist/types/api.d.ts +56 -0
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/config.d.ts +15 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/editor.d.ts +26 -0
- package/dist/types/editor.d.ts.map +1 -1
- package/dist/types/fields.d.ts +2 -2
- package/dist/types/fields.d.ts.map +1 -1
- package/dist/types/media.d.ts +97 -0
- package/dist/types/media.d.ts.map +1 -1
- package/dist/types/panel.d.ts +2 -0
- package/dist/types/panel.d.ts.map +1 -1
- package/dist/types/plugin.d.ts +23 -1
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/uploads.d.ts +1 -0
- package/dist/uploads.d.ts.map +1 -1
- package/dist/uploads.js +4 -4
- package/dist/webhooks.js +1 -1
- package/package.json +9 -5
- package/dist/index-2757kej5.js +0 -2
- package/dist/index-2z1qe5mw.js +0 -2
- package/dist/index-5ngtc7gy.js +0 -2
- package/dist/index-9zqnf6gx.js +0 -23
- package/dist/index-hq05mc1n.js +0 -3
- package/dist/index-hy1x46nf.js +0 -2
- package/dist/index-k8wbg1dw.js +0 -2
- package/dist/index-kbsgt44t.js +0 -2
- package/dist/index-m82a0shw.js +0 -2
- package/dist/index-md79xr6h.js +0 -5
- package/dist/index-nvgwyykk.js +0 -40
- package/dist/index-ty698y02.js +0 -2
- package/dist/index-vxw0a03g.js +0 -2
- package/dist/index-wj8y1xcj.js +0 -2
- package/dist/index-y5mwknr9.js +0 -2
- package/dist/index-ymq6jsar.js +0 -2
package/dist/db/mongodb.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`,summary:i}}async applyMigration(o){let t=JSON.parse(o.content);for(let i of t.steps)await this.applyStep(i)}async listAppliedMigrations(){return(await this.database.collection(
|
|
1
|
+
import{Ce,Oe}from"../index-vzhxn50e.js";import{z}from"../index-761dec5z.js";import{e,n}from"../index-x72d1hzh.js";class b{id;real;constructor(o,t){this.id=o;this.real=t}}class h{database;id="mongodb";capabilities;schema={version:1,tables:[],collections:[]};documentColumns=new Map;columnNames=new Map;constructor(o,t={}){this.database=o;this.capabilities={transactions:t.transactions===!0,sqlMigrations:!1,jsonQuery:!0}}useSchema(o){this.schema=o,this.documentColumns=new Map(o.tables.filter((t)=>t.documentColumn!==void 0).map((t)=>[t.name,t.documentColumn])),this.columnNames=new Map(o.tables.map((t)=>[t.name,new Set(t.columns.map((i)=>i.name))]))}async introspect(){let o=(await this.database.listCollections().toArray()).map((i)=>i.name).filter((i)=>i!==z).sort(),t=[];for(let i of o){let r=await this.database.collection(i).listIndexes().toArray();t.push({name:i,columns:[],primaryKey:["id"],indexes:r.filter((a)=>a.name!=="_id_").map((a)=>({name:a.name,table:i,targets:Object.keys(a.key).map((c)=>({kind:"column",column:c})),unique:a.unique===!0})).sort((a,c)=>a.name.localeCompare(c.name))})}return{version:1,tables:t,collections:[]}}plan(o,t){return Ce(o,t)}render(o,t){let i=o.map(Oe);return{id:t,extension:"json",content:`${JSON.stringify({id:t,summary:i,steps:o},null,2)}
|
|
2
|
+
`,summary:i}}async applyMigration(o){let t=JSON.parse(o.content);for(let i of t.steps)await this.applyStep(i)}async listAppliedMigrations(){return(await this.database.collection(z).find({},{sort:{_id:1}}).toArray()).map((t)=>({id:String(t._id),checksum:String(t.checksum),appliedAt:new Date(String(t.applied_at))}))}async recordMigration(o,t){await this.database.collection(z).insertOne({_id:o,checksum:t,applied_at:new Date().toISOString()})}async transaction(o){return o(new b(x(),this.capabilities.transactions))}async query(o,t){let i=this.database.collection(t.table),r=this.filter(t.table,t.where);if(t.count===!0)return[{count:await i.countDocuments(r)}];let a={};if(t.orderBy&&t.orderBy.length>0)a.sort=Object.fromEntries(t.orderBy.map((s)=>[this.path(t.table,s.path),s.direction==="desc"?-1:1]));if(t.limit!==void 0)a.limit=t.limit;if(t.offset!==void 0)a.skip=t.offset;return(await i.find(r,a).toArray()).map((s)=>this.decode(t.table,s,t.select,t.table))}async mutate(o,t){let i=this.database.collection(t.table);if(t.kind==="insert"){let s=this.encode(t.values);return await i.insertOne(s),{rows:t.returning===!1?[]:[this.decode(t.table,s)],count:1}}if(t.kind==="update"){let s=this.filter(t.table,t.where),l=this.encode(t.set),u=t.returning===!1?[]:await i.find(s,{projection:{_id:1}}).toArray(),m=await i.updateMany(s,{$set:l}),p=m.modifiedCount??m.matchedCount??0;if(t.returning===!1)return{rows:[],count:p};let g=u.length===0?[]:await i.find({_id:{$in:u.map((d)=>d._id)}}).toArray();return{rows:g.map((d)=>this.decode(t.table,d)),count:Math.max(p,g.length)}}let r=this.filter(t.table,t.where),a=t.returning===!0?await i.find(r).toArray():[],c=await i.deleteMany(r);return{rows:a.map((s)=>this.decode(t.table,s)),count:c.deletedCount??a.length}}async applyStep(o){switch(o.kind){case"create_table":{if(!(await this.database.listCollections().toArray()).map((i)=>i.name).includes(o.table.name))await this.database.createCollection(o.table.name);return}case"drop_table":await this.database.dropCollection(o.table).catch(()=>{return});return;case"add_column":{if(o.column.default===void 0)return;await this.database.collection(o.table).updateMany({[o.column.name]:{$exists:!1}},{$set:{[o.column.name]:o.column.default}});return}case"drop_column":await this.database.collection(o.table).updateMany({},{$unset:{[o.column]:""}});return;case"alter_column":return;case"create_index":{let t={};for(let i of o.index.targets)t[i.kind==="column"?i.column:[i.column,...i.path].join(".")]=1;await this.database.collection(o.index.table).createIndex(t,{name:o.index.name,unique:o.index.unique,...o.index.where?{partialFilterExpression:{[o.index.where.column]:o.index.where.equals}}:{}});return}case"drop_index":await this.database.collection(o.table).dropIndex(o.index).catch(()=>{return});return;case"set_document_field":{let t=[o.documentColumn,...o.path].join(".");await this.database.collection(o.table).updateMany({collection:o.collection,[t]:{$exists:!1}},{$set:{[t]:o.value}});return}case"unset_document_field":{let t=[o.documentColumn,...o.path].join(".");await this.database.collection(o.table).updateMany({collection:o.collection},{$unset:{[t]:""}});return}}}filter(o,t){if(!t)return{};if(t.kind==="and"){if(t.conditions.length===0)return{};return{$and:t.conditions.map((c)=>this.filter(o,c))}}if(t.kind==="or"){if(t.conditions.length===0)return{_id:{$exists:!1}};return{$or:t.conditions.map((c)=>this.filter(o,c))}}if(t.kind==="not")return{$nor:[this.filter(o,t.condition)]};let i=this.path(o,t.path),r=this.documentColumns.get(o),a=r!==void 0&&i.startsWith(`${r}.`)?w(t.value):t.value;return{[i]:this.condition(t.operator,a)}}condition(o,t){switch(o){case"eq":return{$eq:t};case"ne":return{$ne:t};case"gt":return{$gt:t};case"gte":return{$gte:t};case"lt":return{$lt:t};case"lte":return{$lte:t};case"in":return{$in:Array.isArray(t)?t:[t]};case"nin":return{$nin:Array.isArray(t)?t:[t]};case"like":case"ilike":return{$regex:y(String(t)),...o==="ilike"?{$options:"i"}:{}};case"contains":return{$eq:t};case"exists":return t===!1?{$in:[null]}:{$nin:[null]}}}path(o,t){let[i,...r]=t.split("."),a=i;if(this.columnNames.get(o)?.has(a))return[a==="id"?"_id":a,...r].join(".");let c=this.documentColumns.get(o);if(!c)throw new e(`Unknown column ${o}.${t}`,{status:400,code:"unknown_column"});return[c,...t.split(".")].join(".")}encode(o){let t={};for(let[i,r]of Object.entries(o))t[i==="id"?"_id":i]=r;return t}decode(o,t,i,r){let a={};for(let[s,l]of Object.entries(t))a[s==="_id"?"id":s]=l;if(!i||i.length===0||r===void 0)return a;let c={};for(let s of i){let l=this.path(r,s).replace(/^_id\b/,"id");c[s]=M(a,l.split("."))}return c}}function M(o,t){let i=o;for(let r of t){if(i===null||typeof i!=="object")return null;i=i[r]}return i??null}function w(o){if(o instanceof Date)return o.toISOString();return Array.isArray(o)?o.map((t)=>t instanceof Date?t.toISOString():t):o}function y(o){return`^${o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replaceAll("%",".*").replaceAll("_",".")}$`}var f=0;function x(){return f+=1,`mongo_tx_${f}`}function k(o,t={}){if(typeof o==="string")return async()=>k(await C(o,t),t);return new h(o,t)}async function C(o,t){let r;try{r=await import("mongodb")}catch{throw new n("database",'mongodb(url) needs the "mongodb" package; install it, or pass a Db you built yourself')}let a=new r.MongoClient(o);return await a.connect(),t.database?a.db(t.database):a.db()}export{h as MongoDatabaseAdapter,k as mongodb};
|
package/dist/db/postgres.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ce,Hn}from"../index-4qrep5f0.js";import{n}from"../index-x72d1hzh.js";class a{client;id;constructor(t,e="postgres"){this.client=t;this.id=e}async all(t,e){return(await this.client.query(t,e)).rows}async run(t,e){return{rowsAffected:(await this.client.query(t,e)).rowCount??0}}async exec(t){await this.client.query(t)}async close(){await this.client.end?.()}}function u(t,e={}){if(typeof t==="string")return async()=>u(await g(t),e);let r=t,o=new a(r,e.id??"postgres");if(r.connect){let l=r.connect.bind(r);o.transaction=async(p)=>{let c=await l(),s=new a(c,o.id);try{await s.exec("BEGIN");let i=await p(s);return await s.exec("COMMIT"),i}catch(i){throw await s.exec("ROLLBACK").catch(()=>{return}),i}finally{c.release?.()}}}return new ce(o,Hn)}async function g(t){let r;try{r=await import("pg")}catch{throw new n("database",'postgres(url) needs the "pg" package; install it, or pass a client you built yourself')}return new r.Pool({connectionString:t})}export{u as postgres};
|
package/dist/db/sql/dialect.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export interface SqlDialect {
|
|
|
22
22
|
decode(value: unknown, type: ColumnType): ColumnValue;
|
|
23
23
|
/** True when `ALTER TABLE ... ALTER COLUMN` exists. */
|
|
24
24
|
readonly supportsAlterColumn: boolean;
|
|
25
|
+
/** The statement that opens a transaction; `BEGIN` when absent. */
|
|
26
|
+
readonly beginTransaction?: string;
|
|
25
27
|
}
|
|
26
28
|
export declare const postgresDialect: SqlDialect;
|
|
27
29
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialect.d.ts","sourceRoot":"","sources":["../../../src/db/sql/dialect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErE;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,UAAU,GAAG,QAAQ,CAAC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AC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,MAAM,CAAC;IACnE,kDAAkD;IAClD,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC;IACtE,gEAAgE;IAChE,mBAAmB,CACjB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAAE,EACd,WAAW,EAAE,MAAM,GAClB,MAAM,CAAC;IACV,oEAAoE;IACpE,YAAY,CAAC,eAAe,EAAE,OAAO,GAAG,MAAM,CAAC;IAC/C,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC;IAClE,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,GAAG,WAAW,CAAC;IACtD,uDAAuD;IACvD,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACtC,mEAAmE;IACnE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAiCD,eAAO,MAAM,eAAe,EAAE,UAgD7B,CAAC;AAyBF;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,EAAE,UAwD3B,CAAC"}
|
package/dist/db/sqlite.d.ts
CHANGED
|
@@ -19,6 +19,15 @@ export interface SqliteStatement {
|
|
|
19
19
|
}
|
|
20
20
|
export interface SqliteOptions {
|
|
21
21
|
id?: string;
|
|
22
|
+
/**
|
|
23
|
+
* How long a write waits for another connection's lock, in milliseconds,
|
|
24
|
+
* before it fails with "database is locked". Defaults to 5000, the value
|
|
25
|
+
* `better-sqlite3` uses; `bun:sqlite` and `node:sqlite` start at 0, which
|
|
26
|
+
* fails the moment a second process — the CLI next to a dev server — is
|
|
27
|
+
* writing. A timeout the database was already given is kept unless this
|
|
28
|
+
* is set.
|
|
29
|
+
*/
|
|
30
|
+
busyTimeout?: number;
|
|
22
31
|
}
|
|
23
32
|
export interface SqliteFileOptions extends SqliteOptions {
|
|
24
33
|
/** Path on disk. `:memory:` is accepted and is what the tests use. */
|
|
@@ -27,8 +36,10 @@ export interface SqliteFileOptions extends SqliteOptions {
|
|
|
27
36
|
/**
|
|
28
37
|
* Creates the SQLite adapter.
|
|
29
38
|
*
|
|
30
|
-
* Transactions use the generic `BEGIN`/`COMMIT` path in the adapter
|
|
31
|
-
*
|
|
39
|
+
* Transactions use the generic `BEGIN`/`COMMIT` path in the adapter, opened
|
|
40
|
+
* as `BEGIN IMMEDIATE` (see `sqliteDialect`): SQLite has exactly one writer,
|
|
41
|
+
* so there is no pool to pin a transaction to, and the write lock is better
|
|
42
|
+
* taken up front, where the busy timeout below can wait for it.
|
|
32
43
|
*
|
|
33
44
|
* Passing `{ file }` opens the database on first use through whichever SQLite
|
|
34
45
|
* the runtime provides — `bun:sqlite` or `node:sqlite` — so a configuration
|
package/dist/db/sqlite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../src/db/sqlite.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAK3B;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAC;IACtC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,IAAI,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;IACrC,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG;QAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CAC1D;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../src/db/sqlite.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAK3B;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAC;IACtC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,IAAI,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;IACrC,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG;QAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CAC1D;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAID,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;CACd;AAoCD;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,sBAAsB,CAAC;AAC3E,wBAAgB,MAAM,CACpB,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,aAAa,GACtB,eAAe,CAAC"}
|
package/dist/db/sqlite.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ce,st}from"../index-4qrep5f0.js";import{n}from"../index-x72d1hzh.js";var r=5000;class s{database;id;constructor(e,t="sqlite"){this.database=e;this.id=t}async all(e,t){return this.database.prepare(e).all(...t)}async run(e,t){let a=this.database.prepare(e).run(...t);return{rowsAffected:Number(a.changes??0)}}async exec(e){this.database.exec(e)}async close(){this.database.close?.()}}function o(e,t={}){if("file"in e&&typeof e.file==="string")return async()=>o(await u(e.file),e);let a=e;return l(a,t.busyTimeout),new ce(new s(a,t.id??"sqlite"),st)}function l(e,t){if(t===void 0){let[a]=e.prepare("PRAGMA busy_timeout").all();if(Number(a?.timeout??0)>0)return}else if(!Number.isFinite(t)||t<0)throw new n("database","busyTimeout must be a number of milliseconds, 0 or more");e.exec(`PRAGMA busy_timeout = ${Math.trunc(t??r)}`)}async function u(e){for(let t of["bun:sqlite","node:sqlite"])try{let a=await import(t),i=a.Database??a.DatabaseSync;if(i)return new i(e)}catch{}throw new n("database","no SQLite is available in this runtime; pass a database instance instead")}export{o as sqlite};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtin.d.ts","sourceRoot":"","sources":["../../src/editor/builtin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"builtin.d.ts","sourceRoot":"","sources":["../../src/editor/builtin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EAErB,MAAM,iBAAiB,CAAC;AASzB;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,OAAO,EAAE,oBAKpB,CAAC;AAEH,eAAO,MAAM,aAAa,EAAE,oBAQ1B,CAAC;AAEH,eAAO,MAAM,WAAW,EAAE,oBAWxB,CAAC;AAEH,eAAO,MAAM,cAAc,EAAE,oBAU3B,CAAC;AAEH,eAAO,MAAM,cAAc,EAAE,oBAO3B,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,oBAkB5B,CAAC;AAEH,eAAO,MAAM,YAAY,EAAE,oBAKzB,CAAC;AAEH,eAAO,MAAM,YAAY,EAAE,oBAMzB,CAAC;AAEH,eAAO,MAAM,YAAY,EAAE,oBAQzB,CAAC;AAEH,eAAO,MAAM,aAAa,EAAE,oBAyB1B,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,oBAO/B,CAAC;AAEH,eAAO,MAAM,aAAa,EAAE,oBAQ1B,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,EAAE,oBAqCtB,CAAC;AAEH,eAAO,MAAM,SAAS,EAAE,oBAsBtB,CAAC;AAEH,eAAO,MAAM,YAAY,EAAE,oBAMzB,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,oBAU5B,CAAC;AAEH,eAAO,MAAM,aAAa,EAAE,oBAU1B,CAAC;AAMH,eAAO,MAAM,QAAQ,EAAE,oBAIrB,CAAC;AAEH,eAAO,MAAM,UAAU,EAAE,oBAIvB,CAAC;AAEH,eAAO,MAAM,aAAa,EAAE,oBAM1B,CAAC;AAEH,eAAO,MAAM,UAAU,EAAE,oBAIvB,CAAC;AAEH,eAAO,MAAM,QAAQ,EAAE,oBAIrB,CAAC;AAEH,eAAO,MAAM,QAAQ,EAAE,oBAWrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/editor/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/editor/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EAMrB,YAAY,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG/C;;;;;;;;;;;;GAYG;AAEH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,qBAAqB,GAC7B,MAAM,CAaR;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CAAM,GAClD,MAAM,CAER;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CAAM,GAClD,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,IAAI,CAAC,qBAAqB,EAAE,QAAQ,CAAM,GAClD,MAAM,CAER;AA2GD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMhD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,6DAA6D;AAC7D,wBAAgB,cAAc,CAC5B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC,GAChD,MAAM,CAWR;AAED,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGxE;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAE5E;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAGpB"}
|
package/dist/editor.d.ts
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* HTML, Markdown or plain text without a browser.
|
|
7
7
|
*/
|
|
8
8
|
export * from "./editor/index";
|
|
9
|
-
export type { EditorMarkDefinition, EditorNodeDefinition, EditorSchemaDescription, MarkSerializer, MarkSerializerContext, NodeSerializer, NodeSerializerContext, RenderRichTextOptions, RichTextDocument, RichTextFormat, RichTextMark, RichTextNode, } from "./types/editor";
|
|
9
|
+
export type { EditorMarkDefinition, EditorNodeDefinition, EditorSchemaDescription, MarkSerializer, MarkSerializerContext, NodeSerializer, NodeSerializerContext, RenderRichTextOptions, RichTextDocument, RichTextFormat, RichTextImageOptions, RichTextMark, RichTextMediaImage, RichTextNode, } from "./types/editor";
|
|
10
10
|
//# sourceMappingURL=editor.d.ts.map
|
package/dist/editor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,gBAAgB,CAAC;AAC/B,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,YAAY,GACb,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,gBAAgB,CAAC;AAC/B,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,YAAY,GACb,MAAM,gBAAgB,CAAC"}
|
package/dist/editor.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{So,To,Co,Oo,Po,_o,$o,jo,Io,Eo,Mo,Do,qo,Lo,Fo,No,Uo,Jo,Wo,zo,Ho,Bo,Vo,he,En}from"./index-a1jv6396.js";import{k,Y,Ot,rn,ao,lo,Te,Q,co,X,uo,Fe,Go,Ne,Xe,ee}from"./index-ptttzgtp.js";export{Oo as blockquoteNode,Jo as boldMark,Po as bulletListNode,Eo as codeBlockNode,Bo as codeMark,Y as defineEditorMark,k as defineEditorNode,Te as describeEditorSchema,So as docNode,Fe as escapeHtml,Go as escapeMarkdown,rn as getEditorMark,Ot as getEditorNode,Do as hardBreakNode,Co as headingNode,Mo as horizontalRuleNode,Ne as htmlAttributes,qo as imageNode,Xe as indentContinuation,Wo as italicMark,Vo as linkMark,$o as listItemNode,_o as orderedListNode,To as paragraphNode,lo as registeredEditorMarks,ao as registeredEditorNodes,Q as renderRichText,he as richTextFromMarkdown,En as richTextFromText,co as richTextToHtml,X as richTextToMarkdown,uo as richTextToPlainText,Ho as strikeMark,ee as stringAttr,Uo as tableCellNode,No as tableHeaderNode,Lo as tableNode,Fo as tableRowNode,Io as taskItemNode,jo as taskListNode,zo as underlineMark};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../src/engine/documents.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AAEnB;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,YAC/B,IAAI,EACJ,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,WAAW,EACX,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,eAAe,CACP,CAAC;AAIX;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,kBAAkB,EAC9B,MAAM,EAAE,aAAa,GACpB,UAAU,CA2DZ;AAED,MAAM,WAAW,UAAU;IACzB,yEAAyE;IACzE,IAAI,EAAE,UAAU,CAAC;IACjB,mEAAmE;IACnE,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,kBAAkB,EAC9B,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,aAAa,EACrB,QAAQ,CAAC,EAAE,UAAU,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B,EAC9B,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,EAAE,GACf,IAAI,CA2BN;AAwBD,sEAAsE;AACtE,wBAAgB,aAAa,CAC3B,UAAU,EAAE,kBAAkB,EAC9B,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,UAAU,GACf,MAAM,EAAE,CAIV;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU,CAWpD;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,cAAc,GAAG,IAAI,CAQ9D;AAsBD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAGjE;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAInE;AAED,wBAAgB,QAAQ,CACtB,KAAK,EAAE,WAAW,GAAG,SAAS,GAAG,SAAS,GACzC,UAAU,CAKZ"}
|
package/dist/engine/engine.d.ts
CHANGED
|
@@ -90,6 +90,19 @@ export declare class CmsEngine {
|
|
|
90
90
|
/** Delivers what the last committed transaction queued, in the background. */
|
|
91
91
|
deliverSoon(): void;
|
|
92
92
|
private collectionApi;
|
|
93
|
+
/**
|
|
94
|
+
* The slug field a slug operation is about: the one named, or the
|
|
95
|
+
* collection's first — with `history`, when the operation needs one.
|
|
96
|
+
*/
|
|
97
|
+
private slugField;
|
|
98
|
+
private resolveSlug;
|
|
99
|
+
private previousSlugs;
|
|
100
|
+
/**
|
|
101
|
+
* Adds or removes one previous address, under the rules of an update to
|
|
102
|
+
* the slug field: the actor must be allowed to update the document and to
|
|
103
|
+
* write that field.
|
|
104
|
+
*/
|
|
105
|
+
private changePreviousSlug;
|
|
93
106
|
private find;
|
|
94
107
|
private findOne;
|
|
95
108
|
private findById;
|
|
@@ -212,6 +225,12 @@ export declare class CmsEngine {
|
|
|
212
225
|
* once, and `media-gc` only ever acts on what it says.
|
|
213
226
|
*/
|
|
214
227
|
private syncMedia;
|
|
228
|
+
/**
|
|
229
|
+
* Keeps `slug_history` in step with the write, in its transaction: a
|
|
230
|
+
* rolled back rename must not leave its old address behind as a redirect.
|
|
231
|
+
*/
|
|
232
|
+
private syncSlugs;
|
|
233
|
+
private keepsSlugHistory;
|
|
215
234
|
private referencesMedia;
|
|
216
235
|
/**
|
|
217
236
|
* The activity log, written by the engine inside the transaction.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/engine/engine.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,aAAa,EAOb,SAAS,
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/engine/engine.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,aAAa,EAOb,SAAS,EAaV,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAEV,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAgB,EAAE,EAAS,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAkC,MAAM,gBAAgB,CAAC;AA4B/E,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,M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,OAAO,CAAC,OAAO;YAMD,MAAM;IAwBpB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM;IAYd,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,UAAU;YAWJ,YAAY;IAO1B;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,QAAQ;CASjB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAE9D"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { ResolvedCollection } from "../types/config";
|
|
2
|
+
import type { FieldDefinition } from "../types/fields";
|
|
3
|
+
import type { ScopedDb } from "../types/hooks";
|
|
4
|
+
import type { JsonObject } from "../types/json";
|
|
5
|
+
/**
|
|
6
|
+
* The `slug` field's behaviour: made from another field when empty, cleaned
|
|
7
|
+
* when typed, unique where it has to be, and remembered when it changes.
|
|
8
|
+
*
|
|
9
|
+
* Here rather than in a hook because every one of those has to happen on
|
|
10
|
+
* every write path — the panel, the REST API, an import, a scheduled change,
|
|
11
|
+
* a script — and a hook is something a project can forget to register.
|
|
12
|
+
*
|
|
13
|
+
* The history lives in its own table, `slug_history`, one row per previous
|
|
14
|
+
* address: a real column with a unique index answers "who owned this URL"
|
|
15
|
+
* in one lookup on every engine, where a list inside the document body would
|
|
16
|
+
* be a `LIKE` over every row of the collection.
|
|
17
|
+
*/
|
|
18
|
+
export declare const slugHistoryTable = "slug_history";
|
|
19
|
+
export interface SlugFieldOptions {
|
|
20
|
+
from?: string;
|
|
21
|
+
history?: boolean;
|
|
22
|
+
unique?: boolean;
|
|
23
|
+
maxLength?: number;
|
|
24
|
+
slugify?: (text: string) => string;
|
|
25
|
+
}
|
|
26
|
+
/** The field's own `slugify`, or the built-in one at its `maxLength`. */
|
|
27
|
+
export declare function slugCleaner(field: FieldDefinition): (text: string) => string;
|
|
28
|
+
export declare function slugFields(collection: ResolvedCollection): [string, FieldDefinition][];
|
|
29
|
+
export declare function slugOptions(field: FieldDefinition): SlugFieldOptions;
|
|
30
|
+
/** One slug that stopped being a document's address in a write. */
|
|
31
|
+
export interface SlugMove {
|
|
32
|
+
field: string;
|
|
33
|
+
/** Empty for a field that is not localized, like `media_usages`. */
|
|
34
|
+
locale: string;
|
|
35
|
+
from: string;
|
|
36
|
+
to: string;
|
|
37
|
+
}
|
|
38
|
+
export interface PrepareSlugsOptions {
|
|
39
|
+
db: ScopedDb;
|
|
40
|
+
collection: ResolvedCollection;
|
|
41
|
+
/** What the write asks for, after the `before` hooks. */
|
|
42
|
+
input: JsonObject;
|
|
43
|
+
/** The stored body before this write; null for a create. */
|
|
44
|
+
stored: JsonObject | null;
|
|
45
|
+
locale: string;
|
|
46
|
+
/** Null for a create whose id is not known to the caller yet. */
|
|
47
|
+
documentId: string | null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Fills in, cleans and checks every slug field a write touches.
|
|
51
|
+
*
|
|
52
|
+
* Returns the input with the slugs settled and the moves the write implies,
|
|
53
|
+
* which `recordSlugMoves` writes once the document row exists.
|
|
54
|
+
*/
|
|
55
|
+
export declare function prepareSlugs(options: PrepareSlugsOptions): Promise<{
|
|
56
|
+
input: JsonObject;
|
|
57
|
+
moves: SlugMove[];
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Writes what `prepareSlugs` decided, inside the same transaction.
|
|
61
|
+
*
|
|
62
|
+
* The old slug becomes a previous address of the document; a slug the
|
|
63
|
+
* document moves back to stops being one, so an address is never both.
|
|
64
|
+
*/
|
|
65
|
+
export declare function recordSlugMoves(db: ScopedDb, collection: ResolvedCollection, documentId: string, moves: SlugMove[], now: Date): Promise<void>;
|
|
66
|
+
export declare function removePreviousSlugRow(db: ScopedDb, collection: ResolvedCollection, documentId: string, field: string, locale: string, slug: string): Promise<void>;
|
|
67
|
+
/** Every previous address of one document goes when the document does. */
|
|
68
|
+
export declare function releaseSlugs(db: ScopedDb, collection: ResolvedCollection, documentId: string): Promise<void>;
|
|
69
|
+
interface SlugScope {
|
|
70
|
+
db: ScopedDb;
|
|
71
|
+
collection: ResolvedCollection;
|
|
72
|
+
documentId: string | null;
|
|
73
|
+
field: string;
|
|
74
|
+
/** Empty for a field that is not localized. */
|
|
75
|
+
locale: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Refuses a slug another document uses, as its address or as a previous one.
|
|
79
|
+
*
|
|
80
|
+
* Trashed documents count: restoring a page must never bring back a URL
|
|
81
|
+
* somebody else has taken since. A previous address is not taken over
|
|
82
|
+
* silently either — it is a redirect somebody relies on — so the message
|
|
83
|
+
* says where it leads and how to free it.
|
|
84
|
+
*/
|
|
85
|
+
export declare function assertFree(scope: SlugScope & {
|
|
86
|
+
slug: string;
|
|
87
|
+
}): Promise<void>;
|
|
88
|
+
export interface SlugCandidate {
|
|
89
|
+
id: string;
|
|
90
|
+
/** The locale the slug matched in; null for a field that is not localized. */
|
|
91
|
+
locale: string | null;
|
|
92
|
+
current: boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Every document a slug points at, best match first: a current address in
|
|
96
|
+
* the requested locale, then in another locale, then a previous address in
|
|
97
|
+
* the requested locale, then in another.
|
|
98
|
+
*
|
|
99
|
+
* Trashed documents are left out — a trashed page has no address — and so
|
|
100
|
+
* is anything that is not a slug at all, before a query is spent on it.
|
|
101
|
+
*/
|
|
102
|
+
export declare function slugCandidates(options: {
|
|
103
|
+
db: ScopedDb;
|
|
104
|
+
collection: ResolvedCollection;
|
|
105
|
+
field: string;
|
|
106
|
+
slug: string;
|
|
107
|
+
locale: string | null;
|
|
108
|
+
locales: string[];
|
|
109
|
+
}): Promise<SlugCandidate[]>;
|
|
110
|
+
export interface PreviousSlugRow {
|
|
111
|
+
slug: string;
|
|
112
|
+
field: string;
|
|
113
|
+
locale: string | null;
|
|
114
|
+
createdAt: string | null;
|
|
115
|
+
}
|
|
116
|
+
export declare function previousSlugRows(options: {
|
|
117
|
+
db: ScopedDb;
|
|
118
|
+
collection: ResolvedCollection;
|
|
119
|
+
documentId: string;
|
|
120
|
+
field?: string;
|
|
121
|
+
locale?: string | null;
|
|
122
|
+
}): Promise<PreviousSlugRow[]>;
|
|
123
|
+
export {};
|
|
124
|
+
//# sourceMappingURL=slugs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slugs.d.ts","sourceRoot":"","sources":["../../src/engine/slugs.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAIhD;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAK/C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC;AAED,yEAAyE;AACzE,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAK5E;AAED,wBAAgB,UAAU,CACxB,UAAU,EAAE,kBAAkB,GAC7B,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,CAI7B;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB,CAEpE;AAED,mEAAmE;AACnE,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MA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M,EAAE,MAAM,CAAC;CAChB;AAQD;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,KAAK,EAAE,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAClC,OAAO,CAAC,IAAI,CAAC,CAcf;AA6FD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,8EAA8E;IAC9E,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE;IAC5C,EAAE,EAAE,QAAQ,CAAC;IACb,UAAU,EAAE,kBAAkB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CA4D3B;AAmBD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAC9C,EAAE,EAAE,QAAQ,CAAC;IACb,UAAU,EAAE,kBAAkB,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAsB7B"}
|
package/dist/fields/builtin.d.ts
CHANGED
|
@@ -95,6 +95,10 @@ export interface RelationOptions extends FieldOptions {
|
|
|
95
95
|
/** Many-to-many: the value is an array of ids. */
|
|
96
96
|
many?: boolean;
|
|
97
97
|
}
|
|
98
|
+
/** The stored value of a relation: a list of ids with `many: true`, one id otherwise. */
|
|
99
|
+
type RelationValue<TOptions> = TOptions extends {
|
|
100
|
+
many: true;
|
|
101
|
+
} ? string[] : string;
|
|
98
102
|
/**
|
|
99
103
|
* A reference to another collection.
|
|
100
104
|
*
|
|
@@ -102,30 +106,95 @@ export interface RelationOptions extends FieldOptions {
|
|
|
102
106
|
* depth level works the same on all three engines and removes the N+1 problem
|
|
103
107
|
* that Payload users hit with `depth` (section 12).
|
|
104
108
|
*/
|
|
105
|
-
export declare function relation<const TOptions extends RelationOptions>(to: string, options?: TOptions): FieldDefinition<FieldValue<
|
|
109
|
+
export declare function relation<const TOptions extends RelationOptions>(to: string, options?: TOptions): FieldDefinition<FieldValue<RelationValue<TOptions>, TOptions>>;
|
|
110
|
+
export interface SlugOptions extends FieldOptions {
|
|
111
|
+
/**
|
|
112
|
+
* The field a slug is made from while it is empty: `"title"`.
|
|
113
|
+
*
|
|
114
|
+
* Made once, on the write that first has a value for it, and then left
|
|
115
|
+
* alone: retitling a page must not move its URL. Clearing the slug makes
|
|
116
|
+
* it again. The same function is the panel's "Generate" button.
|
|
117
|
+
*/
|
|
118
|
+
from?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Keep every slug a document stops using as a previous address of it.
|
|
121
|
+
*
|
|
122
|
+
* `cms.api.<collection>.resolveSlug()` finds a document by a previous
|
|
123
|
+
* address too, which is what a 301 from an old URL is built on; a new
|
|
124
|
+
* document cannot take an address an old one still redirects from. Needs
|
|
125
|
+
* the `slug_history` table, which `heyo-cms generate` adds.
|
|
126
|
+
*/
|
|
127
|
+
history?: boolean;
|
|
128
|
+
/** The longest slug produced; longer input is cut at a hyphen. 96 by default. */
|
|
129
|
+
maxLength?: number;
|
|
130
|
+
/**
|
|
131
|
+
* Your own transliteration, when the built-in one is not the house style:
|
|
132
|
+
* `&` as `and`, a language's own rules. Used everywhere a slug is made or
|
|
133
|
+
* cleaned — writes, the Generate button, previous slugs. Its output must
|
|
134
|
+
* still match `slugPattern`; `maxLength` is then yours to apply.
|
|
135
|
+
*/
|
|
136
|
+
slugify?: (text: string) => string;
|
|
137
|
+
default?: string;
|
|
138
|
+
}
|
|
106
139
|
/**
|
|
107
|
-
*
|
|
140
|
+
* A URL slug: `"lodz-in-autumn"`.
|
|
141
|
+
*
|
|
142
|
+
* What makes it more than `text` with a pattern is the engine, on every
|
|
143
|
+
* write path — the panel, the REST API, an import, a scheduled change:
|
|
108
144
|
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
145
|
+
* - a typed slug is cleaned (`"Łódź in Autumn!"` becomes `lodz-in-autumn`);
|
|
146
|
+
* - an empty one is made `from` another field, with `-2`, `-3`… until free;
|
|
147
|
+
* - it is unique within the collection — per language when localized, which
|
|
148
|
+
* a database index cannot express, so the engine checks it, trashed
|
|
149
|
+
* documents included;
|
|
150
|
+
* - with `history`, a changed slug stays a previous address of the document,
|
|
151
|
+
* which `resolveSlug()` finds and nobody else may take.
|
|
115
152
|
*
|
|
116
153
|
* ```ts
|
|
117
|
-
*
|
|
118
|
-
* unique: true,
|
|
119
|
-
* index: true,
|
|
120
|
-
* pattern: "^[a-z0-9]+(?:-[a-z0-9]+)*$",
|
|
121
|
-
* })
|
|
154
|
+
* slug: slug({ from: "title", localized: true, history: true })
|
|
122
155
|
* ```
|
|
123
|
-
*
|
|
124
|
-
* and generating it from the title is a `create.before` hook, which runs
|
|
125
|
-
* before validation precisely so that it can fill a required field.
|
|
126
156
|
*/
|
|
157
|
+
export declare function slug<const TOptions extends SlugOptions>(options?: TOptions): FieldDefinition<FieldValue<string, TOptions>>;
|
|
127
158
|
export declare const email: import("./registry").FieldBuilder<string, TextOptions>;
|
|
128
159
|
export declare const url: import("./registry").FieldBuilder<string, TextOptions>;
|
|
160
|
+
export interface ListOptions extends FieldOptions {
|
|
161
|
+
/**
|
|
162
|
+
* The fields of one row:
|
|
163
|
+
* `{ question: text({ required: true }), answer: textarea() }`.
|
|
164
|
+
*/
|
|
165
|
+
fields: Record<string, FieldDefinition>;
|
|
166
|
+
minItems?: number;
|
|
167
|
+
maxItems?: number;
|
|
168
|
+
default?: JsonObject[];
|
|
169
|
+
}
|
|
170
|
+
type RowValue<TField> = TField extends FieldDefinition<infer TValue> ? TValue : never;
|
|
171
|
+
/** One row of a list: a required field is always there, an optional one may be missing or `null`. */
|
|
172
|
+
export type ListRow<TFields extends Record<string, FieldDefinition>> = {
|
|
173
|
+
[K in keyof TFields as null extends RowValue<TFields[K]> ? never : K]: RowValue<TFields[K]>;
|
|
174
|
+
} & {
|
|
175
|
+
[K in keyof TFields as null extends RowValue<TFields[K]> ? K : never]?: RowValue<TFields[K]>;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* An ordered list of rows, each with the same small set of fields: questions
|
|
179
|
+
* and answers, sources, a change log.
|
|
180
|
+
*
|
|
181
|
+
* ```ts
|
|
182
|
+
* faq: list({
|
|
183
|
+
* localized: true,
|
|
184
|
+
* fields: {
|
|
185
|
+
* question: text({ required: true }),
|
|
186
|
+
* answer: textarea({ required: true }),
|
|
187
|
+
* },
|
|
188
|
+
* }),
|
|
189
|
+
* ```
|
|
190
|
+
*
|
|
191
|
+
* The value is an array of objects, stored as JSON in the document and
|
|
192
|
+
* validated row by row with the fields' own schemas. The list is the field:
|
|
193
|
+
* it is localized as a whole, and it carries `required`, `access` and the
|
|
194
|
+
* rest. A row holds text, textarea, email, url, number, boolean, date, select
|
|
195
|
+
* and multiselect fields.
|
|
196
|
+
*/
|
|
197
|
+
export declare function list<const TOptions extends ListOptions>(options: TOptions): FieldDefinition<FieldValue<ListRow<TOptions["fields"]>[], TOptions>>;
|
|
129
198
|
/**
|
|
130
199
|
* SEO as fields, not as a plugin.
|
|
131
200
|
*
|
|
@@ -139,4 +208,5 @@ export declare function seoFields(): {
|
|
|
139
208
|
ogImage: FieldDefinition<string | null>;
|
|
140
209
|
canonical: FieldDefinition<string | null>;
|
|
141
210
|
};
|
|
211
|
+
export {};
|
|
142
212
|
//# sourceMappingURL=builtin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtin.d.ts","sourceRoot":"","sources":["../../src/fields/builtin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"builtin.d.ts","sourceRoot":"","sources":["../../src/fields/builtin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAsC1D,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,IAAI,wDAsBf,CAAC;AAEH,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAClD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,QAAQ,4DAanB,CAAC;AAMH,yEAAyE;AACzE,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC;AAEvC,MAAM,WAAW,eAAgB,SAAQ,YAAY;IACnD,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAED,eAAO,MAAM,QAAQ,gEASnB,CAAC;AAMH,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AA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,YAAY,CAAC,MAAM,GAAG,OAAO,EAC3C,IAAI,EAAE,MAAM,GACX,SAAS,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,SAAS,CAE7C;AAED,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAE/C;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,QAAQ,SAAS,YAAY,EAC/D,IAAI,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,GAChC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CA4FhC"}
|
package/dist/fields.d.ts
CHANGED
package/dist/fields.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/fields.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Mn,sn,ye}from"./index-abfzb1ve.js";import{po,Ko,Zo,C}from"./index-vf163r10.js";import{n}from"./index-x72d1hzh.js";import{z as e}from"zod";var o=e.looseObject({label:e.string().optional(),description:e.string().optional(),localized:e.boolean().optional(),required:e.boolean().optional(),unique:e.boolean().optional(),index:e.boolean().optional(),readOnly:e.boolean().optional()}),d=e.lazy(()=>e.union([e.string(),e.number(),e.boolean(),e.null(),e.array(d),e.record(e.string(),d)])),O=C({name:"text",optionsSchema:o.extend({default:e.string().optional(),minLength:e.number().int().nonnegative().optional(),maxLength:e.number().int().positive().optional(),pattern:e.string().optional()}),schema:(t)=>{let i=e.string();if(t.minLength!==void 0)i=i.min(t.minLength);if(t.maxLength!==void 0)i=i.max(t.maxLength);if(t.pattern!==void 0)i=i.regex(new RegExp(t.pattern));return i},column:(t)=>({type:"text",...t.default===void 0?{}:{default:t.default}}),aiActions:["improve","summarize","translate"]}),y=C({name:"textarea",optionsSchema:o.extend({default:e.string().optional(),maxLength:e.number().int().positive().optional(),rows:e.number().int().positive().optional()}),schema:(t)=>t.maxLength===void 0?e.string():e.string().max(t.maxLength),column:()=>({type:"text"}),aiActions:["improve","summarize","translate"]}),j=C({name:"richText",optionsSchema:o.extend({nodes:e.array(e.string()).optional()}),schema:()=>e.looseObject({type:e.string()}),column:()=>({type:"json"}),aiActions:["improve","summarize","translate"]}),I=C({name:"number",optionsSchema:o.extend({default:e.number().optional(),min:e.number().optional(),max:e.number().optional(),integer:e.boolean().optional()}),schema:(t)=>{let i=t.integer===!0?e.number().int():e.number();if(t.min!==void 0)i=i.min(t.min);if(t.max!==void 0)i=i.max(t.max);return i},column:(t)=>({type:t.integer===!0?"integer":"real",...t.default===void 0?{}:{default:t.default}})}),Z=C({name:"boolean",optionsSchema:o.extend({default:e.boolean().optional()}),schema:()=>e.boolean(),column:(t)=>({type:"boolean",...t.default===void 0?{}:{default:t.default}})}),v=C({name:"date",optionsSchema:o.extend({default:e.string().optional(),mode:e.enum(["date","datetime"]).optional()}),schema:()=>e.string().refine((t)=>!Number.isNaN(Date.parse(t)),"must be an ISO 8601 date"),column:()=>({type:"timestamp"})}),f=(t)=>t.map((i)=>typeof i==="string"?i:i.value),x=o.extend({options:e.array(e.union([e.string(),e.strictObject({label:e.string(),value:e.string()})])).min(1),default:e.string().optional()}),T=C({name:"select",optionsSchema:x,schema:(t)=>e.enum(f(t.options)),column:(t)=>({type:"text",...t.default===void 0?{}:{default:t.default}})});function J(t){return T(t)}var h=C({name:"multiselect",optionsSchema:x.extend({default:e.array(e.string()).optional(),minItems:e.number().int().nonnegative().optional(),maxItems:e.number().int().positive().optional()}),schema:(t)=>{let i=e.array(e.enum(f(t.options)));if(t.minItems!==void 0)i=i.min(t.minItems);if(t.maxItems!==void 0)i=i.max(t.maxItems);return i},column:()=>({type:"json",array:!0}),aiActions:["tags"]});function q(t){return h(t)}var B=C({name:"json",optionsSchema:o,schema:()=>d,column:()=>({type:"json"})}),b=C({name:"media",optionsSchema:o.extend({accept:e.string().optional()}),schema:()=>e.string().min(1),column:()=>({type:"text"}),aiActions:["alt"]}),F=C({name:"relation",optionsSchema:o.extend({relationTo:e.string().min(1),many:e.boolean().optional()}),schema:(t)=>t.many===!0?e.array(e.string().min(1)):e.string().min(1),column:(t)=>({type:"text",...t.many===!0?{type:"json",array:!0}:{}}),aiActions:["tags"]});function A(t,i){return F({...i??{},relationTo:t})}var w=C({name:"slug",optionsSchema:o.extend({from:e.string().min(1).optional(),history:e.boolean().optional(),maxLength:e.number().int().min(8).max(512).optional(),slugify:e.function().optional(),default:e.string().optional()}),schema:(t)=>e.string().max(t.maxLength??96).regex(new RegExp(Mn),"lowercase letters, digits and single hyphens only"),column:(t)=>({type:"text",...t.default===void 0?{}:{default:t.default}})});function K(t){let i={...t??{}},s=i.localized===!0,{maxLength:l,from:a}=i,r=i.slugify??((u)=>ye(u,l===void 0?{}:{maxLength:l}));return w({...i,unique:s?i.unique===!1?!1:void 0:i.unique??!0,index:s?void 0:i.index??!0,...i.generate===void 0&&a!==void 0?{generate:({fields:u})=>{let p=u[a],m=typeof p==="string"?r(p):"";return m===""?null:m}}:{}})}var E=C({name:"email",optionsSchema:o,schema:()=>e.string().email(),column:()=>({type:"text"})}),S=C({name:"url",optionsSchema:o,schema:()=>e.string().url(),column:()=>({type:"text"})}),c=new Set(["text","textarea","email","url","number","boolean","date","select","multiselect"]),V=["localized","unique","index","access","generate","aiGenerate","ai"],g=(t)=>typeof t==="object"&&t!==null&&typeof t.type==="string"&&typeof t.schema?.safeParse==="function",z=C({name:"list",optionsSchema:o.extend({fields:e.record(e.string(),e.custom(g,"must be a field, such as text()")),minItems:e.number().int().nonnegative().optional(),maxItems:e.number().int().positive().optional(),default:e.array(e.record(e.string(),d)).optional()}),schema:(t)=>{let i={};for(let[l,a]of Object.entries(t.fields))i[l]=a.required?a.schema:a.schema.optional();let s=e.array(e.strictObject(i));if(t.minItems!==void 0)s=s.min(t.minItems);if(t.maxItems!==void 0)s=s.max(t.maxItems);return s},column:()=>({type:"json",array:!0})});function M(t){let i=t?.fields;if(!i||typeof i!=="object"||Object.keys(i).length===0)throw new n("fields.list.fields","a list needs at least one field in a row");for(let[s,l]of Object.entries(i)){let a=`fields.list.fields.${s}`;if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(s))throw new n(a,"a row's field name must be an identifier (letters, digits, _)");if(!g(l))throw new n(a,"must be a field, such as text()");if(!c.has(l.type))throw new n(a,`a list row cannot hold a ${l.type} field; use ${[...c].join(", ")}`);for(let r of V)if(l.options[r]!==void 0)throw new n(`${a}.${r}`,r==="localized"?"a list is localized as a whole: set localized on the list":"not supported inside a list row")}if(t.unique===!0||t.index===!0)throw new n("fields.list","a list cannot be unique or indexed");if(t.minItems!==void 0&&t.maxItems!==void 0&&t.minItems>t.maxItems)throw new n("fields.list.minItems","cannot be more than maxItems");return z(t)}function N(){return{seoTitle:O({label:"SEO title",localized:!0,maxLength:70,aiGenerate:{label:"Suggest an SEO title",prompt:"Write a search-friendly title under 60 characters."}}),seoDescription:y({label:"SEO description",localized:!0,maxLength:160,aiGenerate:{label:"Suggest an SEO description",prompt:"Summarise the article in one sentence under 155 characters."}}),ogImage:b({label:"Social image",accept:"image/*"}),canonical:S({label:"Canonical URL"})}}export{Z as boolean,v as date,C as defineField,E as email,Ko as getFieldType,sn as isSlug,B as json,M as list,b as media,q as multiselect,I as number,po as registerFieldType,Zo as registeredFieldTypes,A as relation,j as richText,J as select,N as seoFields,K as slug,Mn as slugPattern,ye as slugify,O as text,y as textarea,S as url};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/http/handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/http/handler.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AA0BhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,UAAU,CAAC;IACpB,0CAA0C;IAC1C,MAAM,IAAI,eAAe,EAAE,CAAC;IAC5B,wCAAwC;IACxC,OAAO,IAAI,UAAU,CAAC;CACvB;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAkHvD"}
|
package/dist/http/rich-text.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ResolvedCollection } from "../types/config";
|
|
2
|
-
import type { RichTextFormat } from "../types/editor";
|
|
2
|
+
import type { RichTextFormat, RichTextMediaImage } from "../types/editor";
|
|
3
|
+
import type { CmsInstance } from "../types/instance";
|
|
3
4
|
import type { JsonObject } from "../types/json";
|
|
4
5
|
/**
|
|
5
6
|
* `?richText=html` on a read.
|
|
@@ -21,10 +22,20 @@ export interface RenderOptions {
|
|
|
21
22
|
format: RichTextFormat;
|
|
22
23
|
/** Resolves a `mediaId` on an image node to a URL this deployment serves. */
|
|
23
24
|
mediaUrl: (id: string) => string;
|
|
25
|
+
/** Resolves a `mediaId` to a whole `<img>`: dimensions, `srcset`, alt. */
|
|
26
|
+
mediaImage?: (id: string) => RichTextMediaImage | null;
|
|
24
27
|
}
|
|
25
28
|
/** Renders every rich-text field of one document, in place. */
|
|
26
29
|
export declare function renderDocumentRichText(document: JsonObject, options: RenderOptions): JsonObject;
|
|
27
30
|
export declare function renderPageRichText(documents: JsonObject[], options: RenderOptions): void;
|
|
28
31
|
/** The URL the CMS itself serves a file from, for an image inside prose. */
|
|
29
32
|
export declare function mediaUrlResolver(basePath: string): (id: string) => string;
|
|
33
|
+
/**
|
|
34
|
+
* Every library image the rich-text fields of these documents show, loaded
|
|
35
|
+
* in one query and described for an `<img>`.
|
|
36
|
+
*
|
|
37
|
+
* Undefined without `uploads`: there is no library to look in, and the
|
|
38
|
+
* serialiser's plain `mediaUrl` fallback is the whole answer.
|
|
39
|
+
*/
|
|
40
|
+
export declare function richTextMediaResolver(cms: CmsInstance, documents: JsonObject[], collection: ResolvedCollection, locale: string | null): Promise<((id: string) => RichTextMediaImage | null) | undefined>;
|
|
30
41
|
//# sourceMappingURL=rich-text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich-text.d.ts","sourceRoot":"","sources":["../../src/http/rich-text.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rich-text.d.ts","sourceRoot":"","sources":["../../src/http/rich-text.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,GACnB,cAAc,GAAG,SAAS,CAQ5B;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,MAAM,EAAE,cAAc,CAAC;IACvB,6EAA6E;IAC7E,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;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