monorise 1.15.0-dev.0 → 1.15.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/base/index.d.ts +105 -198
- package/dist/base/index.js +167 -380
- package/dist/base/index.js.map +1 -1
- package/dist/cli/cli.js +130 -192
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/templates/files/proxy-request.ts +50 -0
- package/dist/cli/templates/files/proxy-route.ts +22 -12
- package/dist/cli/templates/files/sst.config.ts +1 -4
- package/dist/core/index.d.ts +126 -72
- package/dist/core/index.js +640 -809
- package/dist/core/index.js.map +1 -1
- package/dist/index.d.ts +18 -23
- package/dist/proxy/index.d.ts +2 -270
- package/dist/proxy/index.js +37 -645
- package/dist/proxy/index.js.map +1 -1
- package/dist/react/actions/core.action.d.ts.map +1 -1
- package/dist/react/actions/websocket.action.d.ts.map +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +110 -22
- package/dist/react/index.js.map +1 -1
- package/dist/react/lib/search.d.ts +29 -0
- package/dist/react/lib/search.d.ts.map +1 -0
- package/dist/react/services/core.service.d.ts.map +1 -1
- package/dist/react/types/monorise.type.d.ts +1 -0
- package/dist/react/types/monorise.type.d.ts.map +1 -1
- package/dist/sst/components/monorise-core.d.ts +1 -0
- package/dist/sst/components/monorise-core.d.ts.map +1 -1
- package/dist/sst/index.js +66 -1
- package/dist/sst/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/cli/templates/files/ws-ticket-route.ts +0 -21
package/dist/cli/cli.js
CHANGED
|
@@ -107,16 +107,35 @@ function endpoints(entities) {
|
|
|
107
107
|
function fingerprint(datasets) {
|
|
108
108
|
return createHash("sha256").update(JSON.stringify(datasets)).digest("hex");
|
|
109
109
|
}
|
|
110
|
+
var typeChangeAdvice = "Analytics columns can't change type in place: add a field with a name this dataset has never used. If this project has never deployed analytics, delete .monorise/analytics-manifest.json and run the generator again.";
|
|
110
111
|
function validateSchemaEvolution(previous, next) {
|
|
112
|
+
const warnings = [];
|
|
113
|
+
const removedColumns = {};
|
|
114
|
+
for (const [identifier, columns2] of Object.entries(
|
|
115
|
+
previous.removedColumns ?? {}
|
|
116
|
+
)) {
|
|
117
|
+
removedColumns[identifier] = [...columns2];
|
|
118
|
+
}
|
|
119
|
+
const remember = (identifier, columns2) => {
|
|
120
|
+
const known = removedColumns[identifier] ?? [];
|
|
121
|
+
removedColumns[identifier] = [
|
|
122
|
+
...known,
|
|
123
|
+
...columns2.filter(
|
|
124
|
+
(column) => !known.some((existing) => existing.name === column.name)
|
|
125
|
+
)
|
|
126
|
+
];
|
|
127
|
+
};
|
|
111
128
|
const nextDatasets = new Map(
|
|
112
129
|
next.datasets.map((dataset) => [dataset.identifier, dataset])
|
|
113
130
|
);
|
|
114
131
|
for (const previousDataset of previous.datasets) {
|
|
115
132
|
const nextDataset = nextDatasets.get(previousDataset.identifier);
|
|
116
133
|
if (!nextDataset) {
|
|
117
|
-
|
|
118
|
-
`Analytics dataset ${previousDataset.name} was removed.
|
|
134
|
+
warnings.push(
|
|
135
|
+
`Analytics dataset ${previousDataset.name} was removed. If analytics is deployed, the next deploy drops its raw table; its S3 data and curated tables are kept.`
|
|
119
136
|
);
|
|
137
|
+
remember(previousDataset.identifier, previousDataset.columns);
|
|
138
|
+
continue;
|
|
120
139
|
}
|
|
121
140
|
const nextColumns = new Map(
|
|
122
141
|
nextDataset.columns.map((column) => [column.name, column])
|
|
@@ -124,17 +143,38 @@ function validateSchemaEvolution(previous, next) {
|
|
|
124
143
|
for (const previousColumn of previousDataset.columns) {
|
|
125
144
|
const nextColumn = nextColumns.get(previousColumn.name);
|
|
126
145
|
if (!nextColumn) {
|
|
127
|
-
|
|
128
|
-
`Analytics field ${previousDataset.name}.${previousColumn.sourceName} was removed or renamed.
|
|
146
|
+
warnings.push(
|
|
147
|
+
`Analytics field ${previousDataset.name}.${previousColumn.sourceName} was removed or renamed. Its column stays: new history records leave it empty, and in the current table existing rows keep their last value. A renamed field starts a new column.`
|
|
129
148
|
);
|
|
149
|
+
remember(previousDataset.identifier, [previousColumn]);
|
|
150
|
+
continue;
|
|
130
151
|
}
|
|
131
152
|
if (nextColumn.type !== previousColumn.type) {
|
|
132
153
|
throw new Error(
|
|
133
|
-
`Analytics field ${previousDataset.name}.${previousColumn.sourceName} changed from ${previousColumn.type} to ${nextColumn.type}.
|
|
154
|
+
`Analytics field ${previousDataset.name}.${previousColumn.sourceName} changed from ${previousColumn.type} to ${nextColumn.type}. ${typeChangeAdvice}`
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
for (const nextDataset of next.datasets) {
|
|
160
|
+
const removed = removedColumns[nextDataset.identifier];
|
|
161
|
+
if (!removed) continue;
|
|
162
|
+
for (const column of nextDataset.columns) {
|
|
163
|
+
const old = removed.find((candidate) => candidate.name === column.name);
|
|
164
|
+
if (!old) continue;
|
|
165
|
+
if (old.type !== column.type) {
|
|
166
|
+
throw new Error(
|
|
167
|
+
`Analytics field ${nextDataset.name}.${column.sourceName} was removed earlier as ${old.type}, and its column still has that type, so it can't come back as ${column.type}. ${typeChangeAdvice}`
|
|
134
168
|
);
|
|
135
169
|
}
|
|
136
170
|
}
|
|
171
|
+
const stillRemoved = removed.filter(
|
|
172
|
+
(old) => !nextDataset.columns.some((column) => column.name === old.name)
|
|
173
|
+
);
|
|
174
|
+
if (stillRemoved.length) removedColumns[nextDataset.identifier] = stillRemoved;
|
|
175
|
+
else delete removedColumns[nextDataset.identifier];
|
|
137
176
|
}
|
|
177
|
+
return { warnings, removedColumns };
|
|
138
178
|
}
|
|
139
179
|
function writeAnalyticsManifest(monoriseOutputDir, configs) {
|
|
140
180
|
const analyticsManifestPath = path.join(monoriseOutputDir, "analytics-manifest.json");
|
|
@@ -144,13 +184,17 @@ function writeAnalyticsManifest(monoriseOutputDir, configs) {
|
|
|
144
184
|
`Skipping unnamed mutual analytics datasets: ${manifest.unnamedMutuals.join(", ")}.`
|
|
145
185
|
);
|
|
146
186
|
}
|
|
187
|
+
let removedColumns = {};
|
|
147
188
|
if (fs.existsSync(analyticsManifestPath)) {
|
|
148
|
-
validateSchemaEvolution(
|
|
189
|
+
const evolution = validateSchemaEvolution(
|
|
149
190
|
JSON.parse(fs.readFileSync(analyticsManifestPath, "utf8")),
|
|
150
191
|
manifest
|
|
151
192
|
);
|
|
193
|
+
for (const warning of evolution.warnings) console.warn(warning);
|
|
194
|
+
removedColumns = evolution.removedColumns;
|
|
152
195
|
}
|
|
153
|
-
|
|
196
|
+
const written = Object.keys(removedColumns).length ? { ...manifest, removedColumns } : manifest;
|
|
197
|
+
fs.writeFileSync(analyticsManifestPath, `${JSON.stringify(written, null, 2)}
|
|
154
198
|
`);
|
|
155
199
|
}
|
|
156
200
|
function createAnalyticsManifest(configs) {
|
|
@@ -246,142 +290,65 @@ function createAnalyticsManifest(configs) {
|
|
|
246
290
|
// cli.ts
|
|
247
291
|
import { fileURLToPath } from "url";
|
|
248
292
|
|
|
249
|
-
// commands/utils/
|
|
293
|
+
// commands/utils/detect-package.ts
|
|
250
294
|
import fs2 from "fs";
|
|
251
|
-
import { createRequire } from "module";
|
|
252
295
|
import path2 from "path";
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
const fromConfigDir = path2.relative(configDir, absolutePath);
|
|
265
|
-
if (!fromConfigDir.startsWith("..") && !path2.isAbsolute(fromConfigDir)) {
|
|
266
|
-
throw new Error(
|
|
267
|
-
`API key policies file '${absolutePath}' is inside configDir '${configDir}', where every file is loaded as an entity config. Move it outside, e.g. './monorise/api-keys.ts'.`
|
|
268
|
-
);
|
|
296
|
+
function detectCombinedPackage(startDir) {
|
|
297
|
+
let dir = startDir;
|
|
298
|
+
while (true) {
|
|
299
|
+
if (fs2.existsSync(path2.join(dir, "node_modules", "monorise"))) {
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
const parent = path2.dirname(dir);
|
|
303
|
+
if (parent === dir) break;
|
|
304
|
+
dir = parent;
|
|
269
305
|
}
|
|
270
|
-
return
|
|
306
|
+
return false;
|
|
271
307
|
}
|
|
272
|
-
|
|
273
|
-
|
|
308
|
+
|
|
309
|
+
// commands/utils/search-manifest.ts
|
|
310
|
+
import fs3 from "fs";
|
|
311
|
+
import { createRequire } from "module";
|
|
312
|
+
import path3 from "path";
|
|
313
|
+
import { pathToFileURL } from "url";
|
|
314
|
+
function searchDefaultsDeclaration(defaults) {
|
|
315
|
+
return `const SearchDefaults = ${JSON.stringify(defaults ?? {})};`;
|
|
274
316
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
const { default: generatedConfig } = await importFresh(configOutputPath);
|
|
281
|
-
const { default: policies } = await importFresh(apiKeysFile(apiKeysPath));
|
|
282
|
-
const validate = policies?.[VALIDATE_API_KEY_POLICIES];
|
|
283
|
-
if (typeof validate !== "function") {
|
|
317
|
+
async function loadProjectBase(projectRoot) {
|
|
318
|
+
const name = detectCombinedPackage(projectRoot) ? "monorise/base" : "../base/index.js";
|
|
319
|
+
const require2 = createRequire(path3.join(projectRoot, "package.json"));
|
|
320
|
+
const base = await import(pathToFileURL(require2.resolve(name)).href);
|
|
321
|
+
if (typeof base.searchConfigHash !== "function") {
|
|
284
322
|
throw new Error(
|
|
285
|
-
`
|
|
323
|
+
`'search' needs a newer ${name}: this version doesn't support the search index.`
|
|
286
324
|
);
|
|
287
325
|
}
|
|
288
|
-
|
|
289
|
-
if (errors.length) {
|
|
290
|
-
throw new Error(
|
|
291
|
-
`Invalid API key policies in '${apiKeysPath}':
|
|
292
|
-
- ${errors.join("\n - ")}`
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
console.log("Validated API key policies.");
|
|
296
|
-
return policies;
|
|
326
|
+
return base;
|
|
297
327
|
}
|
|
298
|
-
function
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
328
|
+
async function writeSearchManifest(monoriseOutputDir, projectRoot, configs, defaults) {
|
|
329
|
+
const manifestPath = path3.join(monoriseOutputDir, "search-manifest.json");
|
|
330
|
+
const indexed = configs.filter((config) => config.search);
|
|
331
|
+
if (!indexed.length) {
|
|
332
|
+
fs3.rmSync(manifestPath, { force: true });
|
|
333
|
+
return;
|
|
305
334
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
(moduleName) => `
|
|
310
|
-
declare module '${moduleName}' {
|
|
311
|
-
interface ApiKeyRoutePermissions {
|
|
312
|
-
${members}
|
|
335
|
+
const base = await loadProjectBase(projectRoot);
|
|
336
|
+
if (defaults !== void 0) {
|
|
337
|
+
base.validateSearchSettings(defaults, "monorise.config.ts");
|
|
313
338
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
coreFactoryArg: "{ ...config, ApiKeyPolicies: apiKeyPolicies }"
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// commands/utils/api-key-types.ts
|
|
329
|
-
var literalUnion = (names) => names.length ? names.map((name) => JSON.stringify(name)).join(" | ") : "never";
|
|
330
|
-
function apiKeyTypeDeclarations(entities) {
|
|
331
|
-
const enumKeys = new Map(
|
|
332
|
-
entities.map((entity) => [entity.name, entity.enumKey])
|
|
333
|
-
);
|
|
334
|
-
const tagEntries = entities.map(
|
|
335
|
-
({ enumKey, config }) => `[Entity.${enumKey}]: ${literalUnion((config.tags ?? []).map((tag) => tag.name))};`
|
|
336
|
-
);
|
|
337
|
-
const mutualFields = /* @__PURE__ */ new Map();
|
|
338
|
-
const setDirection = (from, to, fields) => {
|
|
339
|
-
const targets = mutualFields.get(from) ?? /* @__PURE__ */ new Map();
|
|
340
|
-
if (!targets.has(to)) targets.set(to, fields);
|
|
341
|
-
mutualFields.set(from, targets);
|
|
339
|
+
const manifest = {
|
|
340
|
+
version: 1,
|
|
341
|
+
entities: Object.fromEntries(
|
|
342
|
+
indexed.map((config) => [
|
|
343
|
+
config.name,
|
|
344
|
+
base.searchConfigHash(
|
|
345
|
+
base.resolveSearchConfig(config.search, defaults)
|
|
346
|
+
)
|
|
347
|
+
])
|
|
348
|
+
)
|
|
342
349
|
};
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
for (const field of Object.values(config.mutual?.mutualFields ?? {})) {
|
|
346
|
-
const shape = field.mutual?.mutualDataSchema?.shape;
|
|
347
|
-
if (!shape || !enumKeys.has(field.entityType)) continue;
|
|
348
|
-
const fields = Object.keys(shape);
|
|
349
|
-
if (pass === "own") setDirection(name, field.entityType, fields);
|
|
350
|
-
else setDirection(field.entityType, name, fields);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
const mutualEntries = [...mutualFields].map(
|
|
355
|
-
([from, targets]) => `[Entity.${enumKeys.get(from)}]: {
|
|
356
|
-
${[...targets].map(
|
|
357
|
-
([to, fields]) => ` [Entity.${enumKeys.get(to)}]: ${literalUnion(fields)};`
|
|
358
|
-
).join("\n")}
|
|
359
|
-
};`
|
|
360
|
-
);
|
|
361
|
-
return `
|
|
362
|
-
export interface ApiKeyEntityTags {
|
|
363
|
-
${tagEntries.join("\n ")}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
export interface ApiKeyMutualDataFields {
|
|
367
|
-
${mutualEntries.join("\n ")}
|
|
368
|
-
}`;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
// commands/utils/detect-package.ts
|
|
372
|
-
import fs3 from "fs";
|
|
373
|
-
import path3 from "path";
|
|
374
|
-
function detectCombinedPackage(startDir) {
|
|
375
|
-
let dir = startDir;
|
|
376
|
-
while (true) {
|
|
377
|
-
if (fs3.existsSync(path3.join(dir, "node_modules", "monorise"))) {
|
|
378
|
-
return true;
|
|
379
|
-
}
|
|
380
|
-
const parent = path3.dirname(dir);
|
|
381
|
-
if (parent === dir) break;
|
|
382
|
-
dir = parent;
|
|
383
|
-
}
|
|
384
|
-
return false;
|
|
350
|
+
fs3.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}
|
|
351
|
+
`);
|
|
385
352
|
}
|
|
386
353
|
|
|
387
354
|
// templates/root-tsconfig.ts
|
|
@@ -421,7 +388,7 @@ function execCommand(command, cwd, stdio = "inherit") {
|
|
|
421
388
|
console.log(`Running: ${command}`);
|
|
422
389
|
execSync(command, { cwd, stdio });
|
|
423
390
|
}
|
|
424
|
-
async function generateConfigFile(configDir, monoriseOutputDir, projectRoot) {
|
|
391
|
+
async function generateConfigFile(configDir, monoriseOutputDir, projectRoot, searchDefaults) {
|
|
425
392
|
const configOutputPath = path4.join(monoriseOutputDir, "config.ts");
|
|
426
393
|
const initialConfigContent = `
|
|
427
394
|
export enum Entity {}
|
|
@@ -446,7 +413,7 @@ export { default } from './config';
|
|
|
446
413
|
const allowedEntityEntries = [];
|
|
447
414
|
const entityWithEmailAuthEntries = [];
|
|
448
415
|
const analyticsConfigs = [];
|
|
449
|
-
const
|
|
416
|
+
const searchConfigs = [];
|
|
450
417
|
const relativePathToConfigDir = path4.relative(monoriseOutputDir, configDir);
|
|
451
418
|
const importPathPrefix = relativePathToConfigDir ? `${relativePathToConfigDir}/` : "./";
|
|
452
419
|
for (const file of files) {
|
|
@@ -463,6 +430,7 @@ export { default } from './config';
|
|
|
463
430
|
}
|
|
464
431
|
names.add(config.name);
|
|
465
432
|
analyticsConfigs.push(config);
|
|
433
|
+
searchConfigs.push(config);
|
|
466
434
|
const fileName = file.replace(/\.ts$/, "");
|
|
467
435
|
const variableName = kebabToCamel(fileName);
|
|
468
436
|
imports.push(
|
|
@@ -481,7 +449,6 @@ export { default } from './config';
|
|
|
481
449
|
`[Entity.${enumKey}]: ${kebabToCamel(config.name)}.finalSchema,`
|
|
482
450
|
);
|
|
483
451
|
allowedEntityEntries.push(`Entity.${enumKey}`);
|
|
484
|
-
apiKeyTypeEntities.push({ name: config.name, enumKey, config });
|
|
485
452
|
if (config.authMethod?.email) {
|
|
486
453
|
entityWithEmailAuthEntries.push(`Entity.${enumKey}`);
|
|
487
454
|
}
|
|
@@ -498,7 +465,6 @@ declare module '${moduleName}' {
|
|
|
498
465
|
export interface EntitySchemaMap {
|
|
499
466
|
${schemaMapEntries.join("\n ")}
|
|
500
467
|
}
|
|
501
|
-
${apiKeyTypeDeclarations(apiKeyTypeEntities)}
|
|
502
468
|
}`;
|
|
503
469
|
const moduleAugmentations = usesCombinedPackage ? augmentationBlock("monorise/base") : augmentationBlock("../base/index.js");
|
|
504
470
|
const configOutputContent = `
|
|
@@ -529,11 +495,14 @@ const AllowedEntityTypes = [
|
|
|
529
495
|
|
|
530
496
|
const EmailAuthEnabledEntities: Entity[] = [${entityWithEmailAuthEntries.join(", ")}];
|
|
531
497
|
|
|
498
|
+
${searchDefaultsDeclaration(searchDefaults)}
|
|
499
|
+
|
|
532
500
|
export {
|
|
533
501
|
EntityConfig,
|
|
534
502
|
FormSchema,
|
|
535
503
|
AllowedEntityTypes,
|
|
536
504
|
EmailAuthEnabledEntities,
|
|
505
|
+
SearchDefaults,
|
|
537
506
|
};
|
|
538
507
|
|
|
539
508
|
const config = {
|
|
@@ -541,6 +510,7 @@ const config = {
|
|
|
541
510
|
FormSchema,
|
|
542
511
|
AllowedEntityTypes,
|
|
543
512
|
EmailAuthEnabledEntities,
|
|
513
|
+
SearchDefaults,
|
|
544
514
|
};
|
|
545
515
|
|
|
546
516
|
export default config;
|
|
@@ -548,6 +518,12 @@ ${moduleAugmentations}
|
|
|
548
518
|
`;
|
|
549
519
|
fs4.writeFileSync(configOutputPath, configOutputContent);
|
|
550
520
|
writeAnalyticsManifest(monoriseOutputDir, analyticsConfigs);
|
|
521
|
+
await writeSearchManifest(
|
|
522
|
+
monoriseOutputDir,
|
|
523
|
+
projectRoot,
|
|
524
|
+
searchConfigs,
|
|
525
|
+
searchDefaults
|
|
526
|
+
);
|
|
551
527
|
console.log("Successfully generated config.ts!");
|
|
552
528
|
const indexOutputPath = path4.join(monoriseOutputDir, "index.ts");
|
|
553
529
|
fs4.writeFileSync(
|
|
@@ -559,7 +535,7 @@ export { default } from './config';
|
|
|
559
535
|
console.log("Successfully generated index.ts!");
|
|
560
536
|
return configOutputPath;
|
|
561
537
|
}
|
|
562
|
-
async function generateHandleFile(monoriseConfig, projectRoot, monoriseOutputDir
|
|
538
|
+
async function generateHandleFile(monoriseConfig, projectRoot, monoriseOutputDir) {
|
|
563
539
|
const handleOutputPath = path4.join(monoriseOutputDir, "handle.ts");
|
|
564
540
|
const customRoutesPath = monoriseConfig.customRoutes;
|
|
565
541
|
let routesImportLine = "";
|
|
@@ -587,19 +563,15 @@ async function generateHandleFile(monoriseConfig, projectRoot, monoriseOutputDir
|
|
|
587
563
|
}
|
|
588
564
|
const usesCombinedPackage = detectCombinedPackage(projectRoot);
|
|
589
565
|
const coreImportPath = usesCombinedPackage ? "monorise/core" : "../core/index.js";
|
|
590
|
-
const apiKeyPolicies = apiKeyPoliciesHandleParts(
|
|
591
|
-
monoriseOutputDir,
|
|
592
|
-
apiKeysPath
|
|
593
|
-
);
|
|
594
566
|
const combinedContent = `
|
|
595
567
|
import CoreFactory, { analyticsMaterializationProcessor, analyticsModelProcessor, analyticsQueryHandler as createAnalyticsQueryHandler, analyticsViewProcessor } from '${coreImportPath}';
|
|
596
568
|
import config from './config';
|
|
597
569
|
import analyticsManifest from './analytics-manifest.json';
|
|
598
570
|
${routesImportLine ? `${routesImportLine}
|
|
599
|
-
` : ""}
|
|
600
|
-
` : ""}const coreFactory = new CoreFactory(${apiKeyPolicies.coreFactoryArg});
|
|
571
|
+
` : ""}const coreFactory = new CoreFactory(config);
|
|
601
572
|
|
|
602
573
|
export const replicationHandler = coreFactory.replicationProcessor;
|
|
574
|
+
export const searchReindexHandler = coreFactory.searchReindexProcessor;
|
|
603
575
|
export const analyticsHandler = coreFactory.analyticsProcessor;
|
|
604
576
|
export const analyticsBackfillHandler = coreFactory.analyticsBackfillProcessor;
|
|
605
577
|
export const analyticsMaterializationHandler = analyticsMaterializationProcessor(analyticsManifest);
|
|
@@ -641,38 +613,14 @@ async function generateFiles(rootPath) {
|
|
|
641
613
|
const configDir = path4.resolve(projectRoot, monoriseConfig.configDir);
|
|
642
614
|
const monoriseOutputDir = path4.join(projectRoot, ".monorise");
|
|
643
615
|
fs4.mkdirSync(monoriseOutputDir, { recursive: true });
|
|
644
|
-
|
|
645
|
-
projectRoot,
|
|
646
|
-
monoriseConfig.apiKeys,
|
|
647
|
-
configDir
|
|
648
|
-
);
|
|
649
|
-
const configOutputPath = await generateConfigFile(
|
|
616
|
+
await generateConfigFile(
|
|
650
617
|
configDir,
|
|
651
618
|
monoriseOutputDir,
|
|
652
|
-
projectRoot
|
|
653
|
-
);
|
|
654
|
-
if (apiKeysPath) {
|
|
655
|
-
const policies = await validateApiKeyPoliciesFile(
|
|
656
|
-
apiKeysPath,
|
|
657
|
-
configOutputPath
|
|
658
|
-
);
|
|
659
|
-
fs4.appendFileSync(
|
|
660
|
-
configOutputPath,
|
|
661
|
-
routePermissionDeclarations(policies, [
|
|
662
|
-
detectCombinedPackage(projectRoot) ? "monorise/base" : "../base/index.js"
|
|
663
|
-
])
|
|
664
|
-
);
|
|
665
|
-
}
|
|
666
|
-
await generateHandleFile(
|
|
667
|
-
monoriseConfig,
|
|
668
619
|
projectRoot,
|
|
669
|
-
|
|
670
|
-
apiKeysPath
|
|
620
|
+
monoriseConfig.search
|
|
671
621
|
);
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
apiKeysFile: apiKeysPath && apiKeysFile(apiKeysPath)
|
|
675
|
-
};
|
|
622
|
+
await generateHandleFile(monoriseConfig, projectRoot, monoriseOutputDir);
|
|
623
|
+
return configDir;
|
|
676
624
|
}
|
|
677
625
|
var MONORISE_LOGO = `
|
|
678
626
|
|
|
@@ -925,24 +873,16 @@ export default config;
|
|
|
925
873
|
);
|
|
926
874
|
}
|
|
927
875
|
console.log("\u{1F500} Creating API proxy routes...");
|
|
928
|
-
const
|
|
929
|
-
const
|
|
930
|
-
|
|
931
|
-
coreApiDir,
|
|
932
|
-
"ws",
|
|
933
|
-
"ticket",
|
|
934
|
-
"[entityType]",
|
|
935
|
-
"[entityId]"
|
|
936
|
-
);
|
|
937
|
-
fs4.mkdirSync(proxyDir, { recursive: true });
|
|
938
|
-
fs4.mkdirSync(ticketDir, { recursive: true });
|
|
876
|
+
const apiDir = path4.join(appDir, "api");
|
|
877
|
+
const catchAllDir = path4.join(apiDir, "[...proxy]");
|
|
878
|
+
fs4.mkdirSync(catchAllDir, { recursive: true });
|
|
939
879
|
fs4.writeFileSync(
|
|
940
|
-
path4.join(
|
|
941
|
-
readTemplate("proxy-
|
|
880
|
+
path4.join(apiDir, "proxy-request.ts"),
|
|
881
|
+
readTemplate("proxy-request.ts")
|
|
942
882
|
);
|
|
943
883
|
fs4.writeFileSync(
|
|
944
|
-
path4.join(
|
|
945
|
-
readTemplate("
|
|
884
|
+
path4.join(catchAllDir, "route.ts"),
|
|
885
|
+
readTemplate("proxy-route.ts")
|
|
946
886
|
);
|
|
947
887
|
}
|
|
948
888
|
console.log("\u2699\uFE0F Updating apps/web tsconfig.json...");
|
|
@@ -1003,13 +943,10 @@ export default config;
|
|
|
1003
943
|
console.log("\n\u{1F4DA} Documentation: https://monorise.dev");
|
|
1004
944
|
console.log("");
|
|
1005
945
|
}
|
|
1006
|
-
async function runDevCommand(
|
|
946
|
+
async function runDevCommand(configDir, rootPath) {
|
|
1007
947
|
console.log(MONORISE_LOGO);
|
|
1008
|
-
console.log(
|
|
1009
|
-
|
|
1010
|
-
);
|
|
1011
|
-
const watched = apiKeysFile2 ? [configDir, apiKeysFile2] : configDir;
|
|
1012
|
-
const watcher = chokidar.watch(watched, {
|
|
948
|
+
console.log(`Watching for changes in ${configDir}...`);
|
|
949
|
+
const watcher = chokidar.watch(configDir, {
|
|
1013
950
|
ignored: (watchedPath) => {
|
|
1014
951
|
const fileName = path4.basename(watchedPath);
|
|
1015
952
|
return fileName === "index.ts" || // Old name, still ignore in case it exists
|
|
@@ -1070,7 +1007,8 @@ async function main() {
|
|
|
1070
1007
|
}
|
|
1071
1008
|
try {
|
|
1072
1009
|
if (command === "dev") {
|
|
1073
|
-
|
|
1010
|
+
const configDir = await generateFiles(rootPath);
|
|
1011
|
+
await runDevCommand(configDir, rootPath);
|
|
1074
1012
|
} else if (command === "build") {
|
|
1075
1013
|
await runBuildCommand(rootPath);
|
|
1076
1014
|
} else if (command === "init") {
|