@intijs/core 0.1.0 → 0.1.1
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/package.json +2 -2
- package/dist/actions/local-fallback.d.ts +0 -23
- package/dist/actions/local-fallback.d.ts.map +0 -1
- package/dist/actions/local-fallback.js +0 -104
- package/dist/api/endpoint.d.ts +0 -13
- package/dist/api/endpoint.d.ts.map +0 -1
- package/dist/api/endpoint.js +0 -43
- package/dist/api/render-block.d.ts +0 -8
- package/dist/api/render-block.d.ts.map +0 -1
- package/dist/api/render-block.js +0 -44
- package/dist/api/types.d.ts +0 -6
- package/dist/api/types.d.ts.map +0 -1
- package/dist/api/types.js +0 -57
- package/dist/api/upload.d.ts +0 -7
- package/dist/api/upload.d.ts.map +0 -1
- package/dist/api/upload.js +0 -64
- package/dist/cache/adapter-cache.d.ts +0 -41
- package/dist/cache/adapter-cache.d.ts.map +0 -1
- package/dist/cache/adapter-cache.js +0 -123
- package/dist/db/index.d.ts +0 -2
- package/dist/db/index.d.ts.map +0 -1
- package/dist/db/index.js +0 -4
- package/dist/db/schema.d.ts +0 -20
- package/dist/db/schema.d.ts.map +0 -1
- package/dist/db/schema.js +0 -69
- package/dist/islands/auto-detect-framework.d.ts +0 -51
- package/dist/islands/auto-detect-framework.d.ts.map +0 -1
- package/dist/islands/auto-detect-framework.js +0 -322
- package/dist/islands/index.d.ts +0 -145
- package/dist/islands/index.d.ts.map +0 -1
- package/dist/islands/index.js +0 -263
- package/dist/islands/renderers/alpine.d.ts +0 -11
- package/dist/islands/renderers/alpine.d.ts.map +0 -1
- package/dist/islands/renderers/alpine.js +0 -25
- package/dist/islands/renderers/react.d.ts +0 -12
- package/dist/islands/renderers/react.d.ts.map +0 -1
- package/dist/islands/renderers/react.js +0 -23
- package/dist/islands/renderers/solid.d.ts +0 -12
- package/dist/islands/renderers/solid.d.ts.map +0 -1
- package/dist/islands/renderers/solid.js +0 -21
- package/dist/islands/renderers/svelte.d.ts +0 -8
- package/dist/islands/renderers/svelte.d.ts.map +0 -1
- package/dist/islands/renderers/svelte.js +0 -15
- package/dist/islands/renderers/vue.d.ts +0 -11
- package/dist/islands/renderers/vue.d.ts.map +0 -1
- package/dist/islands/renderers/vue.js +0 -19
- package/dist/logger.d.ts +0 -43
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -72
- package/dist/middleware/index.d.ts +0 -8
- package/dist/middleware/index.d.ts.map +0 -1
- package/dist/middleware/index.js +0 -43
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intijs/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AI for any CMS, without changing the CMS: edit on the page and compose with AI on Astro sites, saving to WordPress, Kitsuden, Strapi, Keystatic…",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"homepage": "https://github.com/intijs/inti/tree/main/packages/core#readme",
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
33
|
-
"url": "https://github.com/intijs/inti.git",
|
|
33
|
+
"url": "git+https://github.com/intijs/inti.git",
|
|
34
34
|
"directory": "packages/core"
|
|
35
35
|
},
|
|
36
36
|
"bugs": {
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Meta-CMS local sobre Astro DB.
|
|
3
|
-
*
|
|
4
|
-
* Este módulo es el ÚNICO del camino de escritura que toca `astro:db`, y
|
|
5
|
-
* se carga de forma perezosa (ver `loadLocalFallback` en index.ts). Así,
|
|
6
|
-
* un proyecto que use WordPress o Strapi no necesita tener @astrojs/db
|
|
7
|
-
* instalado: sin él, la importación falla y las actions responden con un
|
|
8
|
-
* error claro en vez de romper el build.
|
|
9
|
-
*/
|
|
10
|
-
import type { WriteResult, EntrySummary } from '../adapters/index.js';
|
|
11
|
-
/** Actualiza un campo de un bloque en IntiDocument.data.blocks */
|
|
12
|
-
export declare function updateBlockFieldLocal(documentId: string, blockIndex: number, field: string, value: any): Promise<WriteResult>;
|
|
13
|
-
/** Reordena bloques en IntiDocument.data.blocks */
|
|
14
|
-
export declare function moveBlockLocal(documentId: string, fromIndex: number, toIndex: number): Promise<WriteResult>;
|
|
15
|
-
/** Muta el array de bloques de un documento y persiste con versión nueva */
|
|
16
|
-
export declare function spliceBlocksLocal(documentId: string, mutate: (blocks: any[]) => void): Promise<WriteResult>;
|
|
17
|
-
/** Busca documentos de una colección por título */
|
|
18
|
-
export declare function searchEntriesLocal(collection: string, query: string): Promise<EntrySummary[]>;
|
|
19
|
-
/** Lista los documentos de una colección por nombre */
|
|
20
|
-
export declare function getDocumentsLocal(collectionName: string): Promise<any>;
|
|
21
|
-
/** Obtiene un documento por id */
|
|
22
|
-
export declare function getDocumentByIdLocal(documentId: string): Promise<any>;
|
|
23
|
-
//# sourceMappingURL=local-fallback.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"local-fallback.d.ts","sourceRoot":"","sources":["../../src/actions/local-fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEtE,kEAAkE;AAClE,wBAAsB,qBAAqB,CACvC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,GAAG,GACX,OAAO,CAAC,WAAW,CAAC,CA+BtB;AAED,mDAAmD;AACnD,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAQjH;AAED,4EAA4E;AAC5E,wBAAsB,iBAAiB,CACnC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,IAAI,GAChC,OAAO,CAAC,WAAW,CAAC,CA2BtB;AAED,mDAAmD;AACnD,wBAAsB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAWnG;AAED,uDAAuD;AACvD,wBAAsB,iBAAiB,CAAC,cAAc,EAAE,MAAM,gBAa7D;AAED,kCAAkC;AAClC,wBAAsB,oBAAoB,CAAC,UAAU,EAAE,MAAM,gBAG5D"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Meta-CMS local sobre Astro DB.
|
|
3
|
-
*
|
|
4
|
-
* Este módulo es el ÚNICO del camino de escritura que toca `astro:db`, y
|
|
5
|
-
* se carga de forma perezosa (ver `loadLocalFallback` en index.ts). Así,
|
|
6
|
-
* un proyecto que use WordPress o Strapi no necesita tener @astrojs/db
|
|
7
|
-
* instalado: sin él, la importación falla y las actions responden con un
|
|
8
|
-
* error claro en vez de romper el build.
|
|
9
|
-
*/
|
|
10
|
-
import { db, eq } from 'astro:db';
|
|
11
|
-
import { IntiDocument, IntiCollection } from '../db/schema.js';
|
|
12
|
-
/** Actualiza un campo de un bloque en IntiDocument.data.blocks */
|
|
13
|
-
export async function updateBlockFieldLocal(documentId, blockIndex, field, value) {
|
|
14
|
-
const docs = await db.select().from(IntiDocument).where(eq(IntiDocument.id, documentId));
|
|
15
|
-
if (docs.length === 0) {
|
|
16
|
-
return { success: false, documentId, error: `Document ${documentId} not found in Astro DB`, source: 'local' };
|
|
17
|
-
}
|
|
18
|
-
const data = docs[0].data || {};
|
|
19
|
-
const blocks = Array.isArray(data.blocks) ? [...data.blocks] : [];
|
|
20
|
-
if (blockIndex < 0 || blockIndex >= blocks.length) {
|
|
21
|
-
return { success: false, documentId, error: `Block index ${blockIndex} out of range`, source: 'local' };
|
|
22
|
-
}
|
|
23
|
-
// Patch del campo (soporta dot-path: 'cta.label')
|
|
24
|
-
const block = JSON.parse(JSON.stringify(blocks[blockIndex]));
|
|
25
|
-
const parts = field.split('.');
|
|
26
|
-
let cursor = block.data ?? block;
|
|
27
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
28
|
-
if (cursor[parts[i]] === null || typeof cursor[parts[i]] !== 'object')
|
|
29
|
-
cursor[parts[i]] = {};
|
|
30
|
-
cursor = cursor[parts[i]];
|
|
31
|
-
}
|
|
32
|
-
cursor[parts[parts.length - 1]] = value;
|
|
33
|
-
blocks[blockIndex] = block;
|
|
34
|
-
await db
|
|
35
|
-
.update(IntiDocument)
|
|
36
|
-
.set({ data: { ...data, blocks }, updatedAt: new Date(), version: (docs[0].version ?? 1) + 1 })
|
|
37
|
-
.where(eq(IntiDocument.id, documentId));
|
|
38
|
-
return { success: true, documentId, value, source: 'local' };
|
|
39
|
-
}
|
|
40
|
-
/** Reordena bloques en IntiDocument.data.blocks */
|
|
41
|
-
export async function moveBlockLocal(documentId, fromIndex, toIndex) {
|
|
42
|
-
return spliceBlocksLocal(documentId, (blocks) => {
|
|
43
|
-
if (fromIndex < 0 || fromIndex >= blocks.length || toIndex < 0 || toIndex >= blocks.length) {
|
|
44
|
-
throw new Error('Move indexes out of range');
|
|
45
|
-
}
|
|
46
|
-
const [moved] = blocks.splice(fromIndex, 1);
|
|
47
|
-
blocks.splice(toIndex, 0, moved);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
/** Muta el array de bloques de un documento y persiste con versión nueva */
|
|
51
|
-
export async function spliceBlocksLocal(documentId, mutate) {
|
|
52
|
-
const docs = await db.select().from(IntiDocument).where(eq(IntiDocument.id, documentId));
|
|
53
|
-
if (docs.length === 0) {
|
|
54
|
-
return { success: false, documentId, error: `Document ${documentId} not found in Astro DB`, source: 'local' };
|
|
55
|
-
}
|
|
56
|
-
const data = docs[0].data || {};
|
|
57
|
-
const blocks = Array.isArray(data.blocks) ? [...data.blocks] : [];
|
|
58
|
-
try {
|
|
59
|
-
mutate(blocks);
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
return {
|
|
63
|
-
success: false,
|
|
64
|
-
documentId,
|
|
65
|
-
error: error instanceof Error ? error.message : String(error),
|
|
66
|
-
source: 'local'
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
await db
|
|
70
|
-
.update(IntiDocument)
|
|
71
|
-
.set({ data: { ...data, blocks }, updatedAt: new Date(), version: (docs[0].version ?? 1) + 1 })
|
|
72
|
-
.where(eq(IntiDocument.id, documentId));
|
|
73
|
-
return { success: true, documentId, source: 'local' };
|
|
74
|
-
}
|
|
75
|
-
/** Busca documentos de una colección por título */
|
|
76
|
-
export async function searchEntriesLocal(collection, query) {
|
|
77
|
-
const collections = await db.select().from(IntiCollection).where(eq(IntiCollection.slug, collection));
|
|
78
|
-
if (collections.length === 0)
|
|
79
|
-
return [];
|
|
80
|
-
const docs = await db.select().from(IntiDocument).where(eq(IntiDocument.collectionId, collections[0].id));
|
|
81
|
-
const q = query.toLowerCase();
|
|
82
|
-
return docs
|
|
83
|
-
.filter((doc) => !q || doc.title.toLowerCase().includes(q))
|
|
84
|
-
.slice(0, 10)
|
|
85
|
-
.map((doc) => ({ id: doc.id, title: doc.title, subtitle: doc.slug }));
|
|
86
|
-
}
|
|
87
|
-
/** Lista los documentos de una colección por nombre */
|
|
88
|
-
export async function getDocumentsLocal(collectionName) {
|
|
89
|
-
const collections = await db.select().from(IntiCollection).where(eq(IntiCollection.name, collectionName));
|
|
90
|
-
if (collections.length === 0) {
|
|
91
|
-
throw new Error(`Collection ${collectionName} not found`);
|
|
92
|
-
}
|
|
93
|
-
const docs = await db.select().from(IntiDocument).where(eq(IntiDocument.collectionId, collections[0].id));
|
|
94
|
-
return docs.map((doc) => ({
|
|
95
|
-
id: doc.id,
|
|
96
|
-
data: doc.data,
|
|
97
|
-
createdAt: doc.createdAt
|
|
98
|
-
}));
|
|
99
|
-
}
|
|
100
|
-
/** Obtiene un documento por id */
|
|
101
|
-
export async function getDocumentByIdLocal(documentId) {
|
|
102
|
-
const docs = await db.select().from(IntiDocument).where(eq(IntiDocument.id, documentId));
|
|
103
|
-
return docs[0] ?? null;
|
|
104
|
-
}
|
package/dist/api/endpoint.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { APIRoute } from 'astro';
|
|
2
|
-
/**
|
|
3
|
-
* Inti Meta-CMS Generic API Endpoint
|
|
4
|
-
* Handles requests to /api/inti/[...path]
|
|
5
|
-
*
|
|
6
|
-
* This is the Federation Engine at work. It will:
|
|
7
|
-
* 1. Check if the path matches a local Astro DB collection.
|
|
8
|
-
* 2. If not, check if it matches an external CMS connector (Strapi, etc).
|
|
9
|
-
* 3. Fetch, merge, and return JSON.
|
|
10
|
-
*/
|
|
11
|
-
export declare const GET: APIRoute;
|
|
12
|
-
export declare const POST: APIRoute;
|
|
13
|
-
//# sourceMappingURL=endpoint.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/api/endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC;;;;;;;;GAQG;AACH,eAAO,MAAM,GAAG,EAAE,QA8BjB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,QAMlB,CAAC"}
|
package/dist/api/endpoint.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Inti Meta-CMS Generic API Endpoint
|
|
3
|
-
* Handles requests to /api/inti/[...path]
|
|
4
|
-
*
|
|
5
|
-
* This is the Federation Engine at work. It will:
|
|
6
|
-
* 1. Check if the path matches a local Astro DB collection.
|
|
7
|
-
* 2. If not, check if it matches an external CMS connector (Strapi, etc).
|
|
8
|
-
* 3. Fetch, merge, and return JSON.
|
|
9
|
-
*/
|
|
10
|
-
export const GET = async ({ params, request }) => {
|
|
11
|
-
const path = params.path;
|
|
12
|
-
// Example path parsing: /api/inti/collections/posts
|
|
13
|
-
if (!path) {
|
|
14
|
-
return new Response(JSON.stringify({ error: 'Path required' }), {
|
|
15
|
-
status: 400,
|
|
16
|
-
headers: { 'Content-Type': 'application/json' }
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
// Placeholder logic for Federation
|
|
20
|
-
const responseData = {
|
|
21
|
-
meta: {
|
|
22
|
-
source: path.includes('products') ? 'federated:shopify' : 'local:astrodb',
|
|
23
|
-
timestamp: Date.now()
|
|
24
|
-
},
|
|
25
|
-
data: [
|
|
26
|
-
{ id: 1, title: 'Sample content', path }
|
|
27
|
-
]
|
|
28
|
-
};
|
|
29
|
-
return new Response(JSON.stringify(responseData), {
|
|
30
|
-
status: 200,
|
|
31
|
-
headers: {
|
|
32
|
-
'Content-Type': 'application/json',
|
|
33
|
-
'Cache-Control': 'public, max-age=60, s-maxage=60' // SWR enabled
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
export const POST = async ({ request }) => {
|
|
38
|
-
// Handlers for creating content via API
|
|
39
|
-
return new Response(JSON.stringify({ success: true, message: 'Content created' }), {
|
|
40
|
-
status: 201,
|
|
41
|
-
headers: { 'Content-Type': 'application/json' }
|
|
42
|
-
});
|
|
43
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { APIRoute } from 'astro';
|
|
2
|
-
/**
|
|
3
|
-
* Server Islands Visual Builder API
|
|
4
|
-
* This powers the WYSIWYG editor by asking the Astro server to render
|
|
5
|
-
* an exact HTML string of a block on demand.
|
|
6
|
-
*/
|
|
7
|
-
export declare const POST: APIRoute;
|
|
8
|
-
//# sourceMappingURL=render-block.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"render-block.d.ts","sourceRoot":"","sources":["../../src/api/render-block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAKtC;;;;GAIG;AACH,eAAO,MAAM,IAAI,EAAE,QAuClB,CAAC"}
|
package/dist/api/render-block.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// In a real implementation, we would dynamically import the specific block component.
|
|
2
|
-
// For this POC, we use a mock representation.
|
|
3
|
-
/**
|
|
4
|
-
* Server Islands Visual Builder API
|
|
5
|
-
* This powers the WYSIWYG editor by asking the Astro server to render
|
|
6
|
-
* an exact HTML string of a block on demand.
|
|
7
|
-
*/
|
|
8
|
-
export const POST = async ({ request }) => {
|
|
9
|
-
try {
|
|
10
|
-
const { blockType, data } = await request.json();
|
|
11
|
-
if (!blockType) {
|
|
12
|
-
return new Response(JSON.stringify({ error: 'Missing blockType' }), { status: 400 });
|
|
13
|
-
}
|
|
14
|
-
// 🚀 ASTRO 7 SERVER ISLANDS POWER:
|
|
15
|
-
// 1. Initialize the internal Astro Container (which compiles and runs Astro files)
|
|
16
|
-
// 2. We normally dynamically import: const Component = await import(`../../src/blocks/${blockType}.astro`);
|
|
17
|
-
// 3. Render it to string!
|
|
18
|
-
/*
|
|
19
|
-
const container = await AstroContainer.create();
|
|
20
|
-
const html = await container.renderToString(Component, {
|
|
21
|
-
props: { data }
|
|
22
|
-
});
|
|
23
|
-
*/
|
|
24
|
-
// Mock HTML Response for the POC
|
|
25
|
-
let html = '';
|
|
26
|
-
if (blockType === 'Hero') {
|
|
27
|
-
html = `<section class="hero-block" style="padding: 4rem; background: #f3f4f6; text-align: center;">
|
|
28
|
-
<h1 style="font-size: 2.5rem; font-weight: bold;">${data.headline || 'Hero Headline'}</h1>
|
|
29
|
-
<p style="color: #4b5563; font-size: 1.25rem;">${data.subheadline || ''}</p>
|
|
30
|
-
</section>`;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
html = `<div style="padding: 2rem; border: 1px solid #ccc;">Rendered ${blockType} block</div>`;
|
|
34
|
-
}
|
|
35
|
-
return new Response(JSON.stringify({ success: true, html }), {
|
|
36
|
-
status: 200,
|
|
37
|
-
headers: { 'Content-Type': 'application/json' }
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
console.error('[Inti Render API] Error:', error);
|
|
42
|
-
return new Response(JSON.stringify({ error: 'Render failed' }), { status: 500 });
|
|
43
|
-
}
|
|
44
|
-
};
|
package/dist/api/types.d.ts
DELETED
package/dist/api/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAItC;;GAEG;AACH,eAAO,MAAM,GAAG,EAAE,QAwDjB,CAAC"}
|
package/dist/api/types.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { db } from 'astro:db';
|
|
2
|
-
import { IntiCollection } from '../db/schema.js';
|
|
3
|
-
/**
|
|
4
|
-
* Auto-generates TypeScript definitions based on IntiCollection schemas
|
|
5
|
-
*/
|
|
6
|
-
export const GET = async () => {
|
|
7
|
-
try {
|
|
8
|
-
const collections = await db.select().from(IntiCollection);
|
|
9
|
-
let dtsContent = `// Auto-generated by Inti CMS
|
|
10
|
-
// Do not edit this file directly.
|
|
11
|
-
|
|
12
|
-
export interface IntiDocumentBase {
|
|
13
|
-
id: string;
|
|
14
|
-
slug: string;
|
|
15
|
-
title: string;
|
|
16
|
-
status: 'draft' | 'published' | 'archived';
|
|
17
|
-
createdAt: Date;
|
|
18
|
-
updatedAt: Date;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
`;
|
|
22
|
-
for (const col of collections) {
|
|
23
|
-
const interfaceName = col.name.replace(/[^a-zA-Z0-9]/g, '');
|
|
24
|
-
const schema = col.schema || [];
|
|
25
|
-
dtsContent += `export interface Inti${interfaceName} extends IntiDocumentBase {\n data: {\n`;
|
|
26
|
-
// We assume fields array inside schema
|
|
27
|
-
if (Array.isArray(schema)) {
|
|
28
|
-
for (const field of schema) {
|
|
29
|
-
const typeMap = {
|
|
30
|
-
'string': 'string',
|
|
31
|
-
'richtext': 'string',
|
|
32
|
-
'media': 'string', // URL
|
|
33
|
-
'number': 'number',
|
|
34
|
-
'boolean': 'boolean'
|
|
35
|
-
};
|
|
36
|
-
const tsType = typeMap[field.type] || 'any';
|
|
37
|
-
const optional = field.required ? '' : '?';
|
|
38
|
-
dtsContent += ` ${field.name}${optional}: ${tsType};\n`;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
// Multi-language support signature
|
|
42
|
-
dtsContent += ` [locale: string]: any; // Fallback for i18n locales\n`;
|
|
43
|
-
dtsContent += ` }\n}\n\n`;
|
|
44
|
-
}
|
|
45
|
-
// Return plain text .d.ts file
|
|
46
|
-
return new Response(dtsContent, {
|
|
47
|
-
status: 200,
|
|
48
|
-
headers: {
|
|
49
|
-
'Content-Type': 'text/plain',
|
|
50
|
-
'Content-Disposition': 'attachment; filename="inti-types.d.ts"'
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
return new Response('Error generating types', { status: 500 });
|
|
56
|
-
}
|
|
57
|
-
};
|
package/dist/api/upload.d.ts
DELETED
package/dist/api/upload.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/api/upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAItC;;;GAGG;AACH,eAAO,MAAM,IAAI,EAAE,QAmElB,CAAC"}
|
package/dist/api/upload.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
/**
|
|
4
|
-
* Inti Meta-CMS Media Upload API
|
|
5
|
-
* Handles POST requests to /api/inti/upload
|
|
6
|
-
*/
|
|
7
|
-
export const POST = async ({ request }) => {
|
|
8
|
-
try {
|
|
9
|
-
const data = await request.formData();
|
|
10
|
-
const file = data.get('file');
|
|
11
|
-
if (!file) {
|
|
12
|
-
return new Response(JSON.stringify({ error: 'No file uploaded' }), { status: 400 });
|
|
13
|
-
}
|
|
14
|
-
// El comportamiento se dicta EXCLUSIVAMENTE por variables de entorno (.env)
|
|
15
|
-
const USE_EDGE_STORAGE = import.meta.env.USE_EDGE_STORAGE === 'true';
|
|
16
|
-
const safeName = `${Date.now()}-${file.name.replace(/[^a-zA-Z0-9.-]/g, '_')}`;
|
|
17
|
-
let publicUrl = '';
|
|
18
|
-
if (USE_EDGE_STORAGE) {
|
|
19
|
-
// 🚀 EDGE MEDIA 2.0: Streaming directo a S3/Cloudflare R2
|
|
20
|
-
// Las claves se leen de forma segura del archivo .env o Docker, nunca del código
|
|
21
|
-
const { S3Client, PutObjectCommand } = await import('@aws-sdk/client-s3');
|
|
22
|
-
const s3Client = new S3Client({
|
|
23
|
-
region: import.meta.env.S3_REGION || 'auto',
|
|
24
|
-
endpoint: import.meta.env.S3_ENDPOINT, // Ej: https://<account_id>.r2.cloudflarestorage.com
|
|
25
|
-
credentials: {
|
|
26
|
-
accessKeyId: import.meta.env.S3_ACCESS_KEY_ID,
|
|
27
|
-
secretAccessKey: import.meta.env.S3_SECRET_ACCESS_KEY,
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
const buffer = await file.arrayBuffer();
|
|
31
|
-
await s3Client.send(new PutObjectCommand({
|
|
32
|
-
Bucket: import.meta.env.S3_BUCKET_NAME,
|
|
33
|
-
Key: safeName,
|
|
34
|
-
Body: Buffer.from(buffer),
|
|
35
|
-
ContentType: file.type,
|
|
36
|
-
}));
|
|
37
|
-
const cdnUrl = import.meta.env.S3_PUBLIC_DOMAIN;
|
|
38
|
-
publicUrl = `${cdnUrl}/${safeName}`;
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
// Fallback: Modo Desarrollo Local (guardado en disco)
|
|
42
|
-
const uploadDir = path.join(process.cwd(), 'public', 'uploads');
|
|
43
|
-
await fs.mkdir(uploadDir, { recursive: true });
|
|
44
|
-
const filePath = path.join(uploadDir, safeName);
|
|
45
|
-
const arrayBuffer = await file.arrayBuffer();
|
|
46
|
-
await fs.writeFile(filePath, Buffer.from(arrayBuffer));
|
|
47
|
-
publicUrl = `/uploads/${safeName}`;
|
|
48
|
-
}
|
|
49
|
-
return new Response(JSON.stringify({
|
|
50
|
-
success: true,
|
|
51
|
-
url: publicUrl,
|
|
52
|
-
name: file.name,
|
|
53
|
-
size: file.size,
|
|
54
|
-
type: file.type
|
|
55
|
-
}), {
|
|
56
|
-
status: 200,
|
|
57
|
-
headers: { 'Content-Type': 'application/json' }
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
console.error('[Inti Upload API] Error:', error);
|
|
62
|
-
return new Response(JSON.stringify({ error: 'Upload failed' }), { status: 500 });
|
|
63
|
-
}
|
|
64
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { CacheSetOptions } from './types.js';
|
|
2
|
-
import type { CacheManager } from './cache-manager.js';
|
|
3
|
-
export declare class CachedAdapter {
|
|
4
|
-
private adapter;
|
|
5
|
-
private cache;
|
|
6
|
-
private adapterName;
|
|
7
|
-
constructor(adapter: any, cacheManager?: CacheManager);
|
|
8
|
-
/**
|
|
9
|
-
* Get unique cache key for a page
|
|
10
|
-
*/
|
|
11
|
-
getPageKey(slug: string, collection?: string): string;
|
|
12
|
-
/**
|
|
13
|
-
* Get unique cache key for a collection
|
|
14
|
-
*/
|
|
15
|
-
getCollectionKey(collection: string, query?: any): string;
|
|
16
|
-
/**
|
|
17
|
-
* Get tags for a page entry
|
|
18
|
-
*/
|
|
19
|
-
getPageTags(slug: string, collection?: string): string[];
|
|
20
|
-
/**
|
|
21
|
-
* Get tags for a collection entry
|
|
22
|
-
*/
|
|
23
|
-
getCollectionTags(collection: string): string[];
|
|
24
|
-
/**
|
|
25
|
-
* Fetch a page with caching
|
|
26
|
-
*/
|
|
27
|
-
cachedFetchPage(slug: string, collection?: string, options?: CacheSetOptions): Promise<unknown>;
|
|
28
|
-
/**
|
|
29
|
-
* Fetch a collection with caching
|
|
30
|
-
*/
|
|
31
|
-
cachedFetchCollection(collection: string, query?: any, options?: CacheSetOptions): Promise<unknown>;
|
|
32
|
-
/**
|
|
33
|
-
* Invalidate cache entries based on a CMS webhook payload
|
|
34
|
-
*/
|
|
35
|
-
invalidateOnWebhook(payload: any, cmsType?: string): Promise<void>;
|
|
36
|
-
private detectCmsFromPayload;
|
|
37
|
-
private handleStrapiWebhook;
|
|
38
|
-
private handleContentfulWebhook;
|
|
39
|
-
private handleSanityWebhook;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=adapter-cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-cache.d.ts","sourceRoot":"","sources":["../../src/cache/adapter-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,qBAAa,aAAa;IACtB,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,WAAW,CAAS;gBAEhB,OAAO,EAAE,GAAG,EAAE,YAAY,CAAC,EAAE,YAAY;IAMrD;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,GAAE,MAAgB,GAAG,MAAM;IAI9D;;OAEG;IACH,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,MAAM;IAKzD;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,GAAE,MAAgB,GAAG,MAAM,EAAE;IASjE;;OAEG;IACH,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE;IAQ/C;;OAEG;IACG,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,GAAE,MAAgB,EAAE,OAAO,CAAC,EAAE,eAAe;IAW3F;;OAEG;IACG,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,eAAe;IAWtF;;OAEG;IACG,mBAAmB,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBxE,OAAO,CAAC,oBAAoB;YAOd,mBAAmB;YAanB,uBAAuB;YAavB,mBAAmB;CAWpC"}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { getGlobalCache } from './cache-manager.js';
|
|
2
|
-
export class CachedAdapter {
|
|
3
|
-
adapter; // Type should be IntiAdapter but avoiding circular dependency
|
|
4
|
-
cache;
|
|
5
|
-
adapterName;
|
|
6
|
-
constructor(adapter, cacheManager) {
|
|
7
|
-
this.adapter = adapter;
|
|
8
|
-
this.cache = cacheManager || getGlobalCache();
|
|
9
|
-
this.adapterName = adapter.name || 'unknown';
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Get unique cache key for a page
|
|
13
|
-
*/
|
|
14
|
-
getPageKey(slug, collection = 'pages') {
|
|
15
|
-
return `page:${this.adapterName}:${collection}:${slug}`;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Get unique cache key for a collection
|
|
19
|
-
*/
|
|
20
|
-
getCollectionKey(collection, query) {
|
|
21
|
-
const queryStr = query ? JSON.stringify(query) : 'all';
|
|
22
|
-
return `collection:${this.adapterName}:${collection}:${queryStr}`;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Get tags for a page entry
|
|
26
|
-
*/
|
|
27
|
-
getPageTags(slug, collection = 'pages') {
|
|
28
|
-
return [
|
|
29
|
-
`adapter:${this.adapterName}`,
|
|
30
|
-
`collection:${collection}`,
|
|
31
|
-
`slug:${slug}`,
|
|
32
|
-
`page`
|
|
33
|
-
];
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Get tags for a collection entry
|
|
37
|
-
*/
|
|
38
|
-
getCollectionTags(collection) {
|
|
39
|
-
return [
|
|
40
|
-
`adapter:${this.adapterName}`,
|
|
41
|
-
`collection:${collection}`,
|
|
42
|
-
`list`
|
|
43
|
-
];
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Fetch a page with caching
|
|
47
|
-
*/
|
|
48
|
-
async cachedFetchPage(slug, collection = 'pages', options) {
|
|
49
|
-
const key = this.getPageKey(slug, collection);
|
|
50
|
-
const tags = this.getPageTags(slug, collection);
|
|
51
|
-
return this.cache.getOrSet(key, () => this.adapter.fetchPage(slug, collection), { tags, ...options });
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Fetch a collection with caching
|
|
55
|
-
*/
|
|
56
|
-
async cachedFetchCollection(collection, query, options) {
|
|
57
|
-
const key = this.getCollectionKey(collection, query);
|
|
58
|
-
const tags = this.getCollectionTags(collection);
|
|
59
|
-
return this.cache.getOrSet(key, () => this.adapter.fetchCollection(collection, query), { tags, ...options });
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Invalidate cache entries based on a CMS webhook payload
|
|
63
|
-
*/
|
|
64
|
-
async invalidateOnWebhook(payload, cmsType) {
|
|
65
|
-
const type = cmsType || this.detectCmsFromPayload(payload);
|
|
66
|
-
switch (type) {
|
|
67
|
-
case 'strapi':
|
|
68
|
-
await this.handleStrapiWebhook(payload);
|
|
69
|
-
break;
|
|
70
|
-
case 'contentful':
|
|
71
|
-
await this.handleContentfulWebhook(payload);
|
|
72
|
-
break;
|
|
73
|
-
case 'sanity':
|
|
74
|
-
await this.handleSanityWebhook(payload);
|
|
75
|
-
break;
|
|
76
|
-
default:
|
|
77
|
-
// Generic invalidation if CMS unknown
|
|
78
|
-
console.warn(`[Inti Cache] Unknown CMS webhook type: ${type}. Invalidating entire adapter cache.`);
|
|
79
|
-
await this.cache.invalidateByTag(`adapter:${this.adapterName}`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
detectCmsFromPayload(payload) {
|
|
83
|
-
if (payload.event && payload.model)
|
|
84
|
-
return 'strapi';
|
|
85
|
-
if (payload.sys && payload.sys.space)
|
|
86
|
-
return 'contentful';
|
|
87
|
-
if (payload._type && payload._id)
|
|
88
|
-
return 'sanity';
|
|
89
|
-
return 'unknown';
|
|
90
|
-
}
|
|
91
|
-
async handleStrapiWebhook(payload) {
|
|
92
|
-
const { model, entry } = payload;
|
|
93
|
-
if (!model)
|
|
94
|
-
return;
|
|
95
|
-
// Invalidate specific page if it has a slug
|
|
96
|
-
if (entry && entry.slug) {
|
|
97
|
-
await this.cache.invalidateByTag(`slug:${entry.slug}`);
|
|
98
|
-
}
|
|
99
|
-
// Always invalidate the collection lists
|
|
100
|
-
await this.cache.invalidateByTag(`collection:${model}`);
|
|
101
|
-
}
|
|
102
|
-
async handleContentfulWebhook(payload) {
|
|
103
|
-
const contentType = payload.sys?.contentType?.sys?.id;
|
|
104
|
-
if (!contentType)
|
|
105
|
-
return;
|
|
106
|
-
// Contentful usually sends fields
|
|
107
|
-
const slug = payload.fields?.slug?.['en-US'] || payload.fields?.slug;
|
|
108
|
-
if (slug) {
|
|
109
|
-
await this.cache.invalidateByTag(`slug:${slug}`);
|
|
110
|
-
}
|
|
111
|
-
await this.cache.invalidateByTag(`collection:${contentType}`);
|
|
112
|
-
}
|
|
113
|
-
async handleSanityWebhook(payload) {
|
|
114
|
-
const type = payload._type;
|
|
115
|
-
if (!type)
|
|
116
|
-
return;
|
|
117
|
-
const slug = payload.slug?.current || payload.slug;
|
|
118
|
-
if (slug) {
|
|
119
|
-
await this.cache.invalidateByTag(`slug:${slug}`);
|
|
120
|
-
}
|
|
121
|
-
await this.cache.invalidateByTag(`collection:${type}`);
|
|
122
|
-
}
|
|
123
|
-
}
|
package/dist/db/index.d.ts
DELETED
package/dist/db/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/db/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/db/index.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
// Export the Astro DB schema definitions for Inti Meta-CMS
|
|
2
|
-
export { IntiUser, IntiCollection, IntiDocument, IntiBranch, IntiLog } from './schema.js';
|
|
3
|
-
// Here we could also export utility functions for querying the DB
|
|
4
|
-
// e.g. export const getDocument = async (slug) => { ... }
|
package/dist/db/schema.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Users table for the Admin UI and API access
|
|
3
|
-
*/
|
|
4
|
-
export declare const IntiLog: any;
|
|
5
|
-
export declare const IntiUser: any;
|
|
6
|
-
/**
|
|
7
|
-
* Registry of dynamic collections that the user defines in the Meta-CMS
|
|
8
|
-
* (In a full dynamic CMS, documents reference collections)
|
|
9
|
-
*/
|
|
10
|
-
export declare const IntiCollection: any;
|
|
11
|
-
/**
|
|
12
|
-
* Branches for Content Versioning (e.g., 'main', 'black-friday-promo')
|
|
13
|
-
*/
|
|
14
|
-
export declare const IntiBranch: any;
|
|
15
|
-
/**
|
|
16
|
-
* The actual content documents
|
|
17
|
-
* They hold dynamic data in a JSON column to allow schema flexibility
|
|
18
|
-
*/
|
|
19
|
-
export declare const IntiDocument: any;
|
|
20
|
-
//# sourceMappingURL=schema.d.ts.map
|
package/dist/db/schema.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,OAAO,KAQlB,CAAC;AAEH,eAAO,MAAM,QAAQ,KAUnB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc,KASzB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU,KAOrB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,YAAY,KAevB,CAAC"}
|