@strifeapp/astro 1.0.27 → 1.0.28
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/README.md +90 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -361
- package/dist/services/ImageService.d.ts +1 -0
- package/dist/services/ImageService.d.ts.map +1 -0
- package/dist/vite-plugin-strife-store-B4EtLcP6.js +73 -0
- package/dist/vite-plugin-strife-store-entry.d.ts +6 -1
- package/dist/vite-plugin-strife-store-entry.d.ts.map +1 -0
- package/dist/vite-plugin-strife-store-entry.js +4 -0
- package/dist/vite-plugin-strife-store.d.ts +2 -1
- package/dist/vite-plugin-strife-store.d.ts.map +1 -0
- package/package.json +6 -11
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @strifeapp/astro - RECOVERED SOURCE CODE
|
|
2
|
+
|
|
3
|
+
This source code was recovered from the compiled distribution package v1.0.27.
|
|
4
|
+
|
|
5
|
+
## ⚠️ Important Notes
|
|
6
|
+
|
|
7
|
+
1. **ImageService**: The `src/services/ImageService.ts` file only had type definitions in the compiled version. The actual implementation needs to be filled in based on your requirements.
|
|
8
|
+
|
|
9
|
+
2. **indexMapping.js**: This file should NOT be converted to TypeScript as it runs inside RavenDB's JavaScript indexing engine. Keep it as plain JavaScript.
|
|
10
|
+
|
|
11
|
+
3. **Module References**: The vite plugin reads `indexMapping.js` at build time using `readFileSync`, so make sure the path resolution in `vite-plugin-strife-store.ts` is correct for your build setup.
|
|
12
|
+
|
|
13
|
+
## Structure
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
src/
|
|
17
|
+
├── index.ts # Main Astro integration export
|
|
18
|
+
├── vite-plugin-strife-store.ts # Vite plugin for virtual module
|
|
19
|
+
├── vite-plugin-strife-store-entry.ts # Entry point for standalone plugin export
|
|
20
|
+
├── env.ts # Environment variable loader
|
|
21
|
+
├── indexMapping.js # RavenDB index mapping functions (JavaScript!)
|
|
22
|
+
└── services/
|
|
23
|
+
└── ImageService.ts # Image service (needs implementation)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Building
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install
|
|
30
|
+
npm run build
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This will compile TypeScript and generate type definitions in the `dist/` folder.
|
|
34
|
+
|
|
35
|
+
## Environment Variables
|
|
36
|
+
|
|
37
|
+
Required environment variables:
|
|
38
|
+
|
|
39
|
+
- `STRIFE_DATABASE_URLS` - Comma-separated list of RavenDB URLs
|
|
40
|
+
- `STRIFE_DATABASE` - Database name
|
|
41
|
+
- `STRIFE_CERTIFICATE` - Base64-encoded PFX certificate (optional for development)
|
|
42
|
+
- `STRIFE_CERTIFICATE_PASSWORD` - Certificate password (optional for development)
|
|
43
|
+
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
In your Astro project:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { defineConfig } from 'astro/config';
|
|
50
|
+
import strifeIntegration from '@strifeapp/astro';
|
|
51
|
+
|
|
52
|
+
export default defineConfig({
|
|
53
|
+
integrations: [
|
|
54
|
+
strifeIntegration({
|
|
55
|
+
// Optional: Override environment variables
|
|
56
|
+
urls: ['https://your-ravendb.com'],
|
|
57
|
+
database: 'your-database',
|
|
58
|
+
collections: [
|
|
59
|
+
{ name: 'Posts' },
|
|
60
|
+
{ name: 'Pages' },
|
|
61
|
+
],
|
|
62
|
+
}),
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## What This Integration Does
|
|
68
|
+
|
|
69
|
+
1. **Connects to RavenDB** using environment variables or provided config
|
|
70
|
+
2. **Deploys a search index** called `Content_ByUrl` for content search
|
|
71
|
+
3. **Indexes documents** from specified collections (default: Posts)
|
|
72
|
+
4. **Creates a virtual module** `strife:store` that exports the RavenDB DocumentStore
|
|
73
|
+
5. **Bulk inserts templates** into the Templates collection
|
|
74
|
+
|
|
75
|
+
## Recovery Process
|
|
76
|
+
|
|
77
|
+
The source was recovered by:
|
|
78
|
+
|
|
79
|
+
1. Analyzing the minified compiled output
|
|
80
|
+
2. Identifying variable names and function patterns
|
|
81
|
+
3. Extracting the embedded index mapping source code
|
|
82
|
+
4. Reconstructing TypeScript types from `.d.ts` files
|
|
83
|
+
5. Reverse engineering the build configuration
|
|
84
|
+
|
|
85
|
+
## Next Steps
|
|
86
|
+
|
|
87
|
+
- [ ] Implement the ImageService if needed
|
|
88
|
+
- [ ] Verify the build output matches the original
|
|
89
|
+
- [ ] Add tests
|
|
90
|
+
- [ ] Update version number if making changes
|
package/dist/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI5C,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAMD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,gBAAgB,CAsCxF"}
|
package/dist/index.js
CHANGED
|
@@ -1,371 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
const
|
|
4
|
-
* Creates an indexed item that will be stored in the index.
|
|
5
|
-
* @param {string} name - Name of property to index
|
|
6
|
-
* @param {any} value - Value to index and store
|
|
7
|
-
* @returns a new object to index and store
|
|
8
|
-
*/
|
|
9
|
-
function storeAs(name, value) {
|
|
10
|
-
return {
|
|
11
|
-
$value: value,
|
|
12
|
-
$name: name,
|
|
13
|
-
$options: { storage: true },
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Create an indexed item without storing value in the index.
|
|
19
|
-
* @param {string} name - Name of the property to index
|
|
20
|
-
* @param {any} value - The value to index
|
|
21
|
-
* @returns a new object to index (no store)
|
|
22
|
-
*/
|
|
23
|
-
function indexAs(name, value) {
|
|
24
|
-
return {
|
|
25
|
-
$value: value,
|
|
26
|
-
$name: name,
|
|
27
|
-
$options: { storage: false },
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Loads the documents referenced by reference objects in the array
|
|
33
|
-
* @param {any} references - Array of document references: { id, collection }
|
|
34
|
-
* @returns The list of loaded documents.
|
|
35
|
-
*/
|
|
36
|
-
function loadRelatedDocuments(references) {
|
|
37
|
-
if (references == null) return null;
|
|
38
|
-
return references
|
|
39
|
-
.filter((item) => typeof item.id === 'string') // Ensure each ID is a string
|
|
40
|
-
.map((item) => load(item.id, 'Labels'))
|
|
41
|
-
.filter(Boolean); // Filter out any null/undefined values
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Builds an url for a document by traversing its ancestor origins
|
|
46
|
-
* @param {*} doc - The leaf document
|
|
47
|
-
* @returns The full url of the document
|
|
48
|
-
*/
|
|
49
|
-
function buildUrl(doc) {
|
|
50
|
-
const visited = {};
|
|
51
|
-
const slugs = [];
|
|
52
|
-
let c = doc;
|
|
53
|
-
|
|
54
|
-
do {
|
|
55
|
-
if (c.slug) {
|
|
56
|
-
slugs.unshift(c.slug);
|
|
57
|
-
}
|
|
58
|
-
if (!c.origin || visited[c.origin.id]) break;
|
|
59
|
-
visited[c.origin.id] = true;
|
|
60
|
-
c = load(c.origin.id, c.origin.collection);
|
|
61
|
-
} while (c);
|
|
62
|
-
|
|
63
|
-
return slugs.shift() + slugs.join('/');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Editor types that contains {collection, id} references that we want to load
|
|
68
|
-
*/
|
|
69
|
-
const RELATION_EDITORS = ['related', 'references'];
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Loads the template document of the specified document
|
|
73
|
-
* @param {any} document - The document to index
|
|
74
|
-
* @returns The document's template, loaded
|
|
75
|
-
*/
|
|
76
|
-
function loadTemplate(document) {
|
|
77
|
-
const collection = document['@metadata']['@collection'];
|
|
78
|
-
const template = load('templates/' + collection, 'templates');
|
|
79
|
-
return template;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Loads the metadata template
|
|
84
|
-
* @returns The metadata template
|
|
85
|
-
*/
|
|
86
|
-
function loadMetadataTemplate() {
|
|
87
|
-
const template = load('templates/metadata', 'templates');
|
|
88
|
-
return template;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Iterates the template's editors and copies the respective values to the
|
|
93
|
-
* result object. Properties containing references are resolved recursively.
|
|
94
|
-
* Mutually recursive with \`loadRelatedDocumentsRecurse\`.
|
|
95
|
-
* @param {*} document - The document to extract values from
|
|
96
|
-
* @param {*} template - The document's template
|
|
97
|
-
* @param {*} metadataTemplate - The metadata template
|
|
98
|
-
* @param {*} result - The populated result
|
|
99
|
-
*/
|
|
100
|
-
function populateValuesByEditor(document, template, metadataTemplate, result, loadedDocs) {
|
|
101
|
-
const aggregatedEditors = template.editors.concat(metadataTemplate.editors);
|
|
102
|
-
// Add dynamic fields and handle "related" type
|
|
103
|
-
aggregatedEditors.forEach((editor) => {
|
|
104
|
-
if (editor.editor && editor.editor.propertyName) {
|
|
105
|
-
const propertyName = editor.editor.propertyName;
|
|
106
|
-
|
|
107
|
-
if (RELATION_EDITORS.includes(editor.editor.type) && Array.isArray(document[propertyName])) {
|
|
108
|
-
// Load related documents in the array of document references
|
|
109
|
-
const relatedDocs = loadRelatedDocumentsRecurse(document[propertyName], metadataTemplate, loadedDocs);
|
|
110
|
-
result[propertyName] = relatedDocs;
|
|
111
|
-
} else if (editor.editor.type === 'content-template') {
|
|
112
|
-
const content = document[propertyName];
|
|
113
|
-
if (content) {
|
|
114
|
-
const contentTemplate = load(editor.editor.attributes.templateId, 'templates');
|
|
115
|
-
const docResult = {};
|
|
116
|
-
populateValuesByEditor(content, contentTemplate, metadataTemplate, docResult, loadedDocs);
|
|
117
|
-
result[propertyName] = docResult;
|
|
118
|
-
}
|
|
119
|
-
} else if (editor.editor.type === 'chapters') {
|
|
120
|
-
const chapters = document[propertyName];
|
|
121
|
-
if (chapters && Array.isArray(chapters)) {
|
|
122
|
-
const docResults = [];
|
|
123
|
-
chapters.forEach((chapter) => {
|
|
124
|
-
if (chapter['@strife'] && chapter['@strife'].templateId) {
|
|
125
|
-
const docResult = {};
|
|
126
|
-
const chaptersTemplate = load(chapter['@strife'].templateId, 'templates');
|
|
127
|
-
populateValuesByEditor(chapter, chaptersTemplate, metadataTemplate, docResult, loadedDocs);
|
|
128
|
-
docResults.push(docResult);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
result[propertyName] = docResults;
|
|
132
|
-
}
|
|
133
|
-
} else if (document[propertyName] !== undefined) {
|
|
134
|
-
// For other types, index the field value directly
|
|
135
|
-
result[propertyName] = document[propertyName];
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
if (document['@strife']) {
|
|
140
|
-
result['@strife'] = document['@strife'];
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Loads the documents referenced by the array of references. Mutually recursive
|
|
146
|
-
* with \`populateValuesByEditor\`.
|
|
147
|
-
* @param {*} references - List of references to load.
|
|
148
|
-
* @returns
|
|
149
|
-
*/
|
|
150
|
-
function loadRelatedDocumentsRecurse(references, metadataTemplate, loadedDocs) {
|
|
151
|
-
if (references == null) return null;
|
|
152
|
-
const documents = references
|
|
153
|
-
.map((id) => (typeof id === 'string' ? id : id.id))
|
|
154
|
-
.map((id) => {
|
|
155
|
-
if (loadedDocs.has(id)) return null;
|
|
156
|
-
|
|
157
|
-
const aDoc = load(id, '@all_docs');
|
|
158
|
-
|
|
159
|
-
if (aDoc) {
|
|
160
|
-
loadedDocs.add(id);
|
|
161
|
-
}
|
|
162
|
-
return aDoc;
|
|
163
|
-
})
|
|
164
|
-
.filter(Boolean); // Filter out any null/undefined values
|
|
165
|
-
|
|
166
|
-
const docResults = [];
|
|
167
|
-
documents.forEach((doc) => {
|
|
168
|
-
const template = loadTemplate(doc);
|
|
169
|
-
const docResult = {
|
|
170
|
-
id: Id(doc),
|
|
171
|
-
url: buildUrl(doc),
|
|
172
|
-
collection: doc['@metadata']['@collection'],
|
|
173
|
-
labels: loadRelatedDocuments(
|
|
174
|
-
doc.labels.map((l) => {
|
|
175
|
-
return { id: l, collection: 'Labels' };
|
|
176
|
-
}),
|
|
177
|
-
),
|
|
178
|
-
};
|
|
179
|
-
populateValuesByEditor(doc, template, metadataTemplate, docResult, loadedDocs);
|
|
180
|
-
docResults.push(docResult);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
return docResults;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Maps a document to an index entry for Strife's content index
|
|
188
|
-
* @param {any} document - The document to index
|
|
189
|
-
* @returns An object to be indexed by RavenDB
|
|
190
|
-
*/
|
|
191
|
-
function mapDocument(document) {
|
|
192
|
-
const collection = document['@metadata']['@collection'];
|
|
193
|
-
const template = load('templates/' + collection, 'templates');
|
|
194
|
-
|
|
195
|
-
if (!template || !template.editors || document.deleted || document.archived) {
|
|
196
|
-
return null;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const metadataTemplate = loadMetadataTemplate();
|
|
200
|
-
|
|
201
|
-
// Initialize result with static fields
|
|
202
|
-
const result = {
|
|
203
|
-
id: Id(document),
|
|
204
|
-
displayName: document.displayName,
|
|
205
|
-
url: storeAs('url', buildUrl(document)),
|
|
206
|
-
origin: document.origin,
|
|
207
|
-
collection: storeAs('collection', collection),
|
|
208
|
-
publishedDate: storeAs('publishedAt', document.publishedDate),
|
|
209
|
-
createdAt: storeAs('createdAt', document.createdAt),
|
|
210
|
-
changedAt: storeAs('changedAt', document.changedAt),
|
|
211
|
-
labels: storeAs(
|
|
212
|
-
'labels',
|
|
213
|
-
loadRelatedDocuments(
|
|
214
|
-
document.labels.map((l) => {
|
|
215
|
-
return { id: l, collection: 'Labels' };
|
|
216
|
-
}),
|
|
217
|
-
),
|
|
218
|
-
),
|
|
219
|
-
deleted: document.deleted,
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
// Keep tabs of loaded documents to avoid infinite recursion
|
|
223
|
-
const loadedDocuments = new Set(result.id);
|
|
224
|
-
|
|
225
|
-
// Add dynamic fields and handle "related" type
|
|
226
|
-
template.editors.forEach((editor) => {
|
|
227
|
-
if (editor.editor && editor.editor.propertyName) {
|
|
228
|
-
const propertyName = editor.editor.propertyName;
|
|
229
|
-
|
|
230
|
-
if (RELATION_EDITORS.includes(editor.editor.type) && Array.isArray(document[propertyName])) {
|
|
231
|
-
// Load related documents in the array of document references
|
|
232
|
-
const relatedDocs = loadRelatedDocumentsRecurse(document[propertyName], metadataTemplate, loadedDocuments);
|
|
233
|
-
result[propertyName] = storeAs(propertyName, relatedDocs);
|
|
234
|
-
} else if (editor.editor.type === 'content-template') {
|
|
235
|
-
const content = document[propertyName];
|
|
236
|
-
if (content) {
|
|
237
|
-
const template = load(editor.editor.attributes.templateId, 'templates');
|
|
238
|
-
const docResult = {};
|
|
239
|
-
populateValuesByEditor(content, template, metadataTemplate, docResult, loadedDocuments);
|
|
240
|
-
result[propertyName] = storeAs(propertyName, docResult);
|
|
241
|
-
}
|
|
242
|
-
} else if (editor.editor.type === 'chapters') {
|
|
243
|
-
const chapters = document[propertyName];
|
|
244
|
-
if (chapters && Array.isArray(chapters)) {
|
|
245
|
-
const docResults = [];
|
|
246
|
-
chapters.forEach((chapter) => {
|
|
247
|
-
if (chapter['@strife'] && chapter['@strife'].templateId) {
|
|
248
|
-
const docResult = {};
|
|
249
|
-
const template = load(chapter['@strife'].templateId, 'templates');
|
|
250
|
-
populateValuesByEditor(chapter, template, metadataTemplate, docResult, loadedDocuments);
|
|
251
|
-
docResults.push(docResult);
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
result[propertyName] = storeAs(propertyName, docResults);
|
|
255
|
-
}
|
|
256
|
-
} else if (document[propertyName] !== undefined) {
|
|
257
|
-
// For other types, index the field value directly
|
|
258
|
-
result[propertyName] = indexAs(propertyName, document[propertyName]);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
return result;
|
|
264
|
-
}`, m = "strife:store", p = "\0" + m;
|
|
265
|
-
function h(e) {
|
|
266
|
-
return {
|
|
267
|
-
name: "strife:store",
|
|
268
|
-
resolveId(s) {
|
|
269
|
-
if (s === m)
|
|
270
|
-
return p;
|
|
271
|
-
},
|
|
272
|
-
load(s) {
|
|
273
|
-
var o;
|
|
274
|
-
if (s === p)
|
|
275
|
-
return `
|
|
276
|
-
import { DocumentStore, AbstractJavaScriptMultiMapIndexCreationTask } from "ravendb";
|
|
277
|
-
|
|
278
|
-
${e.certificate && e.password ? `
|
|
279
|
-
const authOptions = {
|
|
280
|
-
type: 'pfx',
|
|
281
|
-
certificate: Buffer.from(${d(e.certificate)}, 'base64'),
|
|
282
|
-
password: ${d(e.password)},
|
|
283
|
-
};
|
|
284
|
-
` : ""}
|
|
285
|
-
|
|
286
|
-
const store = new DocumentStore(
|
|
287
|
-
${d(e.urls ? e.urls : [])},
|
|
288
|
-
${d(e.database || "")}${e.certificate && e.password ? `,
|
|
289
|
-
authOptions` : ""}
|
|
290
|
-
).initialize()
|
|
291
|
-
|
|
292
|
-
class Content_ByUrl extends AbstractJavaScriptMultiMapIndexCreationTask {
|
|
293
|
-
constructor() {
|
|
294
|
-
super();
|
|
295
|
-
|
|
296
|
-
this.additionalSources = {"Helper": ${d(y)}}
|
|
297
|
-
|
|
298
|
-
${(e.collections || ["Posts"]).map((t) => `this.map("${typeof t == "string" ? t : t.name}", (doc) => { return mapDocument(doc) });`).join(`
|
|
299
|
-
`)}
|
|
300
|
-
|
|
301
|
-
this.deploymentMode = 'Rolling';
|
|
302
|
-
this.searchEngineType = 'Lucene';
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
console.log('Deploying index...');
|
|
307
|
-
|
|
308
|
-
await store.executeIndex(new Content_ByUrl());
|
|
309
|
-
|
|
310
|
-
const bulkInsert = store.bulkInsert();
|
|
311
|
-
|
|
312
|
-
${(o = e.collections) == null ? void 0 : o.map((t) => `
|
|
313
|
-
await bulkInsert.store(${JSON.stringify(t)}, 'templates/${t.name}', { '@collection': 'Templates' });
|
|
314
|
-
`).join(`
|
|
315
|
-
`)}
|
|
316
|
-
|
|
317
|
-
await bulkInsert.finish();
|
|
318
|
-
|
|
319
|
-
export { store };
|
|
320
|
-
`;
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
const T = {
|
|
1
|
+
import { v as _ } from "./vite-plugin-strife-store-B4EtLcP6.js";
|
|
2
|
+
import { loadEnv as l } from "vite";
|
|
3
|
+
const a = {
|
|
325
4
|
type: "pfx"
|
|
326
5
|
};
|
|
327
|
-
function
|
|
328
|
-
let o = process.env.STRIFE_DATABASE_URLS, t = process.env.STRIFE_DATABASE, r = process.env.STRIFE_CERTIFICATE, l = process.env.STRIFE_CERTIFICATE_PASSWORD;
|
|
329
|
-
if (!o || !t || !r || !l) {
|
|
330
|
-
const n = f(e, s ?? "", "");
|
|
331
|
-
o = o || n.STRIFE_DATABASE_URLS, t = t || n.STRIFE_DATABASE, r = r || n.STRIFE_CERTIFICATE, l = l || n.STRIFE_CERTIFICATE_PASSWORD;
|
|
332
|
-
}
|
|
333
|
-
return console.log("[strifeIntegration] Loaded environment variables:"), console.log(` STRIFE_DATABASE_URLS: ${o ? "[SET]" : "[NOT SET]"}`), console.log(` STRIFE_DATABASE: ${t || "[NOT SET]"}`), console.log(` STRIFE_CERTIFICATE: ${r ? `[SET, length=${r.length}]` : "[NOT SET]"}`), console.log(` STRIFE_CERTIFICATE_PASSWORD: ${l ? "[SET]" : "[NOT SET]"}`), {
|
|
334
|
-
urls: o ? o.split(",").map((n) => n.trim()).filter(Boolean) : void 0,
|
|
335
|
-
database: t || void 0,
|
|
336
|
-
certificate: r || void 0,
|
|
337
|
-
password: l || void 0
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
function v(e) {
|
|
6
|
+
function d(e) {
|
|
341
7
|
return {
|
|
342
8
|
name: "@strife/astro",
|
|
343
9
|
hooks: {
|
|
344
|
-
"astro:config:setup": ({
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
...
|
|
348
|
-
|
|
349
|
-
),
|
|
10
|
+
"astro:config:setup": ({ config: c, updateConfig: f }) => {
|
|
11
|
+
const E = c.vite.envDir || process.cwd(), { STRIFE_CERTIFICATE: t, STRIFE_CERTIFICATE_PASSWORD: T, STRIFE_DATABASE_URLS: r, STRIFE_DATABASE: S } = l(process.env.NODE_ENV ?? "", E, "");
|
|
12
|
+
e = {
|
|
13
|
+
...e,
|
|
14
|
+
certificate: t ?? (e == null ? void 0 : e.certificate) ?? a.certificate,
|
|
15
|
+
password: T ?? (e == null ? void 0 : e.password),
|
|
16
|
+
urls: r ? r.split(",") : (e == null ? void 0 : e.urls) ?? [],
|
|
17
|
+
database: S ?? (e == null ? void 0 : e.database)
|
|
18
|
+
};
|
|
19
|
+
const A = {
|
|
20
|
+
...a,
|
|
350
21
|
...e ? Object.fromEntries(
|
|
351
|
-
Object.entries(e).filter(([
|
|
22
|
+
Object.entries(e).filter(([u, I]) => !!I)
|
|
352
23
|
) : {}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
);
|
|
356
|
-
if (u.length > 0)
|
|
357
|
-
throw new Error(
|
|
358
|
-
`[strifeIntegration] Missing required environment variables: ${u.join(", ")}.
|
|
359
|
-
Set them in your .env file (for local) or Vercel project settings (for deployment).
|
|
360
|
-
Current values:
|
|
361
|
-
` + c.map((a) => ` ${a}: ${JSON.stringify(n[a])}`).join(`
|
|
362
|
-
`)
|
|
363
|
-
);
|
|
364
|
-
t({
|
|
24
|
+
};
|
|
25
|
+
f({
|
|
365
26
|
vite: {
|
|
366
|
-
plugins: [
|
|
367
|
-
h(n)
|
|
368
|
-
]
|
|
27
|
+
plugins: [_(A)]
|
|
369
28
|
}
|
|
370
29
|
});
|
|
371
30
|
}
|
|
@@ -373,5 +32,5 @@ Current values:
|
|
|
373
32
|
};
|
|
374
33
|
}
|
|
375
34
|
export {
|
|
376
|
-
|
|
35
|
+
d as default
|
|
377
36
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageService.d.ts","sourceRoot":"","sources":["../../src/services/ImageService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI1C,QAAA,MAAM,OAAO,EAAE,YAGP,CAAC;AAET,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { readFileSync as c } from "fs";
|
|
2
|
+
import { dirname as m, resolve as u } from "path";
|
|
3
|
+
import { fileURLToPath as d } from "url";
|
|
4
|
+
import r from "serialize-javascript";
|
|
5
|
+
const n = "strife:store", o = "\0" + n;
|
|
6
|
+
function S(e) {
|
|
7
|
+
const i = d(import.meta.url), p = m(i), l = c(
|
|
8
|
+
u(p, "../../../../../../../data/ravendb/localized-content-index.js"),
|
|
9
|
+
"utf-8"
|
|
10
|
+
);
|
|
11
|
+
return {
|
|
12
|
+
name: "strife:store",
|
|
13
|
+
resolveId(s) {
|
|
14
|
+
if (s === n)
|
|
15
|
+
return o;
|
|
16
|
+
},
|
|
17
|
+
load(s) {
|
|
18
|
+
var a;
|
|
19
|
+
if (s === o)
|
|
20
|
+
return `
|
|
21
|
+
import { DocumentStore, AbstractJavaScriptMultiMapIndexCreationTask } from "ravendb";
|
|
22
|
+
|
|
23
|
+
${e.certificate && e.password ? `
|
|
24
|
+
const authOptions = {
|
|
25
|
+
type: 'pfx',
|
|
26
|
+
certificate: Buffer.from(${r(e.certificate)}, 'base64'),
|
|
27
|
+
password: ${r(e.password)},
|
|
28
|
+
};
|
|
29
|
+
` : ""}
|
|
30
|
+
|
|
31
|
+
const store = new DocumentStore(
|
|
32
|
+
${r(e.urls ? e.urls : [])},
|
|
33
|
+
${r(e.database || "")}${e.certificate && e.password ? `,
|
|
34
|
+
authOptions` : ""}
|
|
35
|
+
).initialize()
|
|
36
|
+
|
|
37
|
+
class Content_ByUrl extends AbstractJavaScriptMultiMapIndexCreationTask {
|
|
38
|
+
constructor() {
|
|
39
|
+
super();
|
|
40
|
+
|
|
41
|
+
this.additionalSources = {"Helper": ${r(l)}}
|
|
42
|
+
|
|
43
|
+
${(e.collections || ["Posts"]).map(
|
|
44
|
+
(t) => `this.map("${typeof t == "string" ? t : t.name}", (doc) => { return mapDocument(doc) });`
|
|
45
|
+
).join(`
|
|
46
|
+
`)}
|
|
47
|
+
|
|
48
|
+
this.deploymentMode = 'Rolling';
|
|
49
|
+
this.searchEngineType = 'Lucene';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log('Deploying index...');
|
|
54
|
+
|
|
55
|
+
await store.executeIndex(new Content_ByUrl());
|
|
56
|
+
|
|
57
|
+
const bulkInsert = store.bulkInsert();
|
|
58
|
+
|
|
59
|
+
${(a = e.collections) == null ? void 0 : a.map((t) => `
|
|
60
|
+
await bulkInsert.store(${JSON.stringify(t)}, 'templates/${t.name}', { '@collection': 'Templates' });
|
|
61
|
+
`).join(`
|
|
62
|
+
`)}
|
|
63
|
+
|
|
64
|
+
await bulkInsert.finish();
|
|
65
|
+
|
|
66
|
+
export { store };
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
S as v
|
|
73
|
+
};
|
|
@@ -1 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Entry point for importing the vite plugin directly
|
|
3
|
+
* Usage: import { vitePluginStrifeStore } from '@strifeapp/astro/vite-plugin-strife-store'
|
|
4
|
+
*/
|
|
5
|
+
export { vitePluginStrifeStore } from './vite-plugin-strife-store';
|
|
6
|
+
//# sourceMappingURL=vite-plugin-strife-store-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-strife-store-entry.d.ts","sourceRoot":"","sources":["../src/vite-plugin-strife-store-entry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { IntegrationOptions } from './index';
|
|
2
1
|
import { PluginOption } from 'vite';
|
|
2
|
+
import { IntegrationOptions } from './index';
|
|
3
3
|
export declare function vitePluginStrifeStore(config: IntegrationOptions): PluginOption;
|
|
4
|
+
//# sourceMappingURL=vite-plugin-strife-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-strife-store.d.ts","sourceRoot":"","sources":["../src/vite-plugin-strife-store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAKlD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAmE9E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strifeapp/astro",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
4
4
|
"description": "Official Strife Astro integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"astro-integration",
|
|
@@ -29,24 +29,19 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"astro": "^4.0.0 || ^5.0.0",
|
|
32
|
-
"dotenv": "^
|
|
33
|
-
"ravendb": "^
|
|
32
|
+
"dotenv": "^17.2.3",
|
|
33
|
+
"ravendb": "^7.1.4",
|
|
34
34
|
"serialize-javascript": "^6.0.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/dotenv": "^8.2.0",
|
|
38
|
+
"@types/serialize-javascript": "^5.0.4",
|
|
38
39
|
"rimraf": "^6.0.1",
|
|
39
40
|
"typescript": "^5.7.3",
|
|
40
|
-
"vite": "^6.
|
|
41
|
+
"vite": "^6.4.1",
|
|
41
42
|
"vite-plugin-dts": "^4.5.3"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
|
-
"astro": "^4.0.0 || ^5.0.0"
|
|
45
|
-
"ravendb": "^5.4.3"
|
|
46
|
-
},
|
|
47
|
-
"compilerOptions": {
|
|
48
|
-
"declaration": true,
|
|
49
|
-
"emitDeclarationOnly": false,
|
|
50
|
-
"outDir": "dist"
|
|
45
|
+
"astro": "^4.0.0 || ^5.0.0"
|
|
51
46
|
}
|
|
52
47
|
}
|