@webstir-io/webstir-backend 0.1.15 → 0.1.16
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 +106 -79
- package/dist/add.d.ts +59 -0
- package/dist/add.js +626 -0
- package/dist/build/artifacts.d.ts +115 -1
- package/dist/build/artifacts.js +4 -4
- package/dist/build/entries.js +1 -1
- package/dist/build/pipeline.d.ts +33 -1
- package/dist/build/pipeline.js +307 -65
- package/dist/cache/diff.js +9 -8
- package/dist/cache/reporters.js +1 -1
- package/dist/deploy-cli.d.ts +2 -0
- package/dist/deploy-cli.js +86 -0
- package/dist/diagnostics/summary.js +2 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4 -0
- package/dist/manifest/pipeline.js +103 -32
- package/dist/provider.js +35 -17
- package/dist/runtime/bun.d.ts +51 -0
- package/dist/runtime/bun.js +499 -0
- package/dist/runtime/core.d.ts +141 -0
- package/dist/runtime/core.js +316 -0
- package/dist/runtime/deploy-backend.d.ts +20 -0
- package/dist/runtime/deploy-backend.js +175 -0
- package/dist/runtime/deploy-shared.d.ts +43 -0
- package/dist/runtime/deploy-shared.js +75 -0
- package/dist/runtime/deploy-static.d.ts +2 -0
- package/dist/runtime/deploy-static.js +161 -0
- package/dist/runtime/deploy.d.ts +3 -0
- package/dist/runtime/deploy.js +91 -0
- package/dist/runtime/forms.d.ts +73 -0
- package/dist/runtime/forms.js +236 -0
- package/dist/runtime/request-hooks.d.ts +47 -0
- package/dist/runtime/request-hooks.js +102 -0
- package/dist/runtime/session-metadata.d.ts +13 -0
- package/dist/runtime/session-metadata.js +98 -0
- package/dist/runtime/session-runtime.d.ts +28 -0
- package/dist/runtime/session-runtime.js +180 -0
- package/dist/runtime/session.d.ts +83 -0
- package/dist/runtime/session.js +396 -0
- package/dist/runtime/views.d.ts +74 -0
- package/dist/runtime/views.js +221 -0
- package/dist/scaffold/assets.js +25 -21
- package/dist/testing/context.js +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +100 -56
- package/dist/utils/bun.d.ts +2 -0
- package/dist/utils/bun.js +13 -0
- package/dist/watch.d.ts +13 -1
- package/dist/watch.js +345 -97
- package/dist/workspace.d.ts +8 -0
- package/dist/workspace.js +44 -3
- package/package.json +49 -14
- package/scripts/publish.sh +2 -92
- package/scripts/smoke.mjs +282 -107
- package/scripts/update-contract.sh +12 -10
- package/src/add.ts +964 -0
- package/src/build/artifacts.ts +49 -46
- package/src/build/entries.ts +12 -12
- package/src/build/pipeline.ts +779 -403
- package/src/cache/diff.ts +111 -105
- package/src/cache/reporters.ts +26 -26
- package/src/deploy-cli.ts +111 -0
- package/src/diagnostics/summary.ts +28 -22
- package/src/index.ts +11 -0
- package/src/manifest/pipeline.ts +328 -215
- package/src/provider.ts +115 -98
- package/src/runtime/bun.ts +793 -0
- package/src/runtime/core.ts +598 -0
- package/src/runtime/deploy-backend.ts +239 -0
- package/src/runtime/deploy-shared.ts +136 -0
- package/src/runtime/deploy-static.ts +191 -0
- package/src/runtime/deploy.ts +143 -0
- package/src/runtime/forms.ts +364 -0
- package/src/runtime/request-hooks.ts +165 -0
- package/src/runtime/session-metadata.ts +135 -0
- package/src/runtime/session-runtime.ts +267 -0
- package/src/runtime/session.ts +642 -0
- package/src/runtime/views.ts +385 -0
- package/src/scaffold/assets.ts +77 -73
- package/src/testing/context.js +8 -9
- package/src/testing/context.ts +9 -9
- package/src/testing/index.d.ts +14 -3
- package/src/testing/index.js +254 -175
- package/src/testing/index.ts +298 -195
- package/src/testing/types.d.ts +18 -19
- package/src/testing/types.ts +18 -18
- package/src/utils/bun.ts +26 -0
- package/src/watch.ts +503 -99
- package/src/workspace.ts +59 -3
- package/templates/backend/.env.example +15 -0
- package/templates/backend/auth/adapter.ts +335 -36
- package/templates/backend/db/connection.ts +190 -65
- package/templates/backend/db/migrate.ts +149 -43
- package/templates/backend/db/types.d.ts +1 -1
- package/templates/backend/env.ts +132 -20
- package/templates/backend/functions/hello/index.ts +1 -2
- package/templates/backend/index.ts +15 -508
- package/templates/backend/jobs/nightly/index.ts +1 -1
- package/templates/backend/jobs/runtime.ts +24 -11
- package/templates/backend/jobs/scheduler.ts +208 -46
- package/templates/backend/module.ts +227 -13
- package/templates/backend/observability/logger.ts +2 -12
- package/templates/backend/observability/metrics.ts +8 -5
- package/templates/backend/session/sqlite.ts +152 -0
- package/templates/backend/session/store.ts +45 -0
- package/templates/backend/tsconfig.json +1 -1
- package/tests/add.test.js +327 -0
- package/tests/authAdapter.test.js +315 -0
- package/tests/bundlerParity.test.js +217 -0
- package/tests/cacheReporter.test.js +10 -10
- package/tests/dbConnection.test.js +209 -0
- package/tests/deploy.test.js +357 -0
- package/tests/envLoader.test.js +271 -17
- package/tests/integration.test.js +2432 -3
- package/tests/jobsScheduler.test.js +253 -0
- package/tests/manifest.test.js +287 -12
- package/tests/migrationRunner.test.js +249 -0
- package/tests/sessionScaffoldStore.test.js +752 -0
- package/tests/sessionStore.test.js +490 -0
- package/tests/testing.test.js +252 -0
- package/tests/watch.test.js +192 -32
- package/tsconfig.json +3 -10
- package/templates/backend/server/fastify.ts +0 -288
package/src/build/artifacts.ts
CHANGED
|
@@ -6,62 +6,65 @@ import type { ModuleArtifact, ModuleDiagnostic, ModuleManifest } from '@webstir-
|
|
|
6
6
|
|
|
7
7
|
import { pushEntryBucketSummary } from '../diagnostics/summary.js';
|
|
8
8
|
|
|
9
|
-
export async function collectArtifacts(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
export async function collectArtifacts(
|
|
10
|
+
buildRoot: string,
|
|
11
|
+
includeSourceMaps: boolean,
|
|
12
|
+
): Promise<ModuleArtifact[]> {
|
|
13
|
+
const patterns = ['**/*.js'];
|
|
14
|
+
if (includeSourceMaps) {
|
|
15
|
+
patterns.push('**/*.js.map');
|
|
16
|
+
}
|
|
17
|
+
const matches = new Set<string>();
|
|
18
|
+
for (const pattern of patterns) {
|
|
19
|
+
const files = await glob(pattern, {
|
|
20
|
+
cwd: buildRoot,
|
|
21
|
+
nodir: true,
|
|
22
|
+
dot: false,
|
|
23
|
+
});
|
|
24
|
+
for (const relativePath of files) {
|
|
25
|
+
matches.add(relativePath);
|
|
24
26
|
}
|
|
27
|
+
}
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
return Array.from(matches).map<ModuleArtifact>((relativePath) => ({
|
|
30
|
+
path: path.join(buildRoot, relativePath),
|
|
31
|
+
type: relativePath.endsWith('.map') ? 'asset' : 'bundle',
|
|
32
|
+
}));
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
export function createBuildManifest(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
buildRoot: string,
|
|
37
|
+
artifacts: readonly ModuleArtifact[],
|
|
38
|
+
diagnostics: ModuleDiagnostic[],
|
|
39
|
+
moduleManifest: ModuleManifest,
|
|
37
40
|
) {
|
|
38
|
-
|
|
41
|
+
const entryPoints: string[] = [];
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
43
|
+
for (const artifact of artifacts) {
|
|
44
|
+
const relative = path.relative(buildRoot, artifact.path);
|
|
45
|
+
if (relative.endsWith('index.js')) {
|
|
46
|
+
entryPoints.push(relative);
|
|
45
47
|
}
|
|
48
|
+
}
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
50
|
+
if (entryPoints.length === 0) {
|
|
51
|
+
const defaultEntry = path.join(buildRoot, 'index.js');
|
|
52
|
+
if (existsSync(defaultEntry)) {
|
|
53
|
+
entryPoints.push(path.relative(buildRoot, defaultEntry));
|
|
54
|
+
} else {
|
|
55
|
+
diagnostics.push({
|
|
56
|
+
severity: 'warn',
|
|
57
|
+
message: 'No backend entry point found (expected index.js).',
|
|
58
|
+
});
|
|
57
59
|
}
|
|
60
|
+
}
|
|
58
61
|
|
|
59
|
-
|
|
62
|
+
pushEntryBucketSummary(diagnostics, entryPoints);
|
|
60
63
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
return {
|
|
65
|
+
entryPoints,
|
|
66
|
+
staticAssets: [],
|
|
67
|
+
diagnostics,
|
|
68
|
+
module: moduleManifest,
|
|
69
|
+
};
|
|
67
70
|
}
|
package/src/build/entries.ts
CHANGED
|
@@ -3,17 +3,17 @@ import path from 'node:path';
|
|
|
3
3
|
import { glob } from 'glob';
|
|
4
4
|
|
|
5
5
|
export async function discoverEntryPoints(sourceRoot: string): Promise<string[]> {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
6
|
+
const patterns = [
|
|
7
|
+
'index.{ts,tsx,js,mjs}',
|
|
8
|
+
'functions/*/index.{ts,tsx,js,mjs}',
|
|
9
|
+
'jobs/*/index.{ts,tsx,js,mjs}',
|
|
10
|
+
];
|
|
11
|
+
const entries = new Set<string>();
|
|
12
|
+
for (const pattern of patterns) {
|
|
13
|
+
const matches = await glob(pattern, { cwd: sourceRoot, nodir: true, dot: false });
|
|
14
|
+
for (const rel of matches) {
|
|
15
|
+
entries.add(path.join(sourceRoot, rel));
|
|
17
16
|
}
|
|
18
|
-
|
|
17
|
+
}
|
|
18
|
+
return Array.from(entries);
|
|
19
19
|
}
|