@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.
Files changed (123) hide show
  1. package/README.md +106 -79
  2. package/dist/add.d.ts +59 -0
  3. package/dist/add.js +626 -0
  4. package/dist/build/artifacts.d.ts +115 -1
  5. package/dist/build/artifacts.js +4 -4
  6. package/dist/build/entries.js +1 -1
  7. package/dist/build/pipeline.d.ts +33 -1
  8. package/dist/build/pipeline.js +307 -65
  9. package/dist/cache/diff.js +9 -8
  10. package/dist/cache/reporters.js +1 -1
  11. package/dist/deploy-cli.d.ts +2 -0
  12. package/dist/deploy-cli.js +86 -0
  13. package/dist/diagnostics/summary.js +2 -2
  14. package/dist/index.d.ts +6 -0
  15. package/dist/index.js +4 -0
  16. package/dist/manifest/pipeline.js +103 -32
  17. package/dist/provider.js +35 -17
  18. package/dist/runtime/bun.d.ts +51 -0
  19. package/dist/runtime/bun.js +499 -0
  20. package/dist/runtime/core.d.ts +141 -0
  21. package/dist/runtime/core.js +316 -0
  22. package/dist/runtime/deploy-backend.d.ts +20 -0
  23. package/dist/runtime/deploy-backend.js +175 -0
  24. package/dist/runtime/deploy-shared.d.ts +43 -0
  25. package/dist/runtime/deploy-shared.js +75 -0
  26. package/dist/runtime/deploy-static.d.ts +2 -0
  27. package/dist/runtime/deploy-static.js +161 -0
  28. package/dist/runtime/deploy.d.ts +3 -0
  29. package/dist/runtime/deploy.js +91 -0
  30. package/dist/runtime/forms.d.ts +73 -0
  31. package/dist/runtime/forms.js +236 -0
  32. package/dist/runtime/request-hooks.d.ts +47 -0
  33. package/dist/runtime/request-hooks.js +102 -0
  34. package/dist/runtime/session-metadata.d.ts +13 -0
  35. package/dist/runtime/session-metadata.js +98 -0
  36. package/dist/runtime/session-runtime.d.ts +28 -0
  37. package/dist/runtime/session-runtime.js +180 -0
  38. package/dist/runtime/session.d.ts +83 -0
  39. package/dist/runtime/session.js +396 -0
  40. package/dist/runtime/views.d.ts +74 -0
  41. package/dist/runtime/views.js +221 -0
  42. package/dist/scaffold/assets.js +25 -21
  43. package/dist/testing/context.js +1 -1
  44. package/dist/testing/index.d.ts +1 -1
  45. package/dist/testing/index.js +100 -56
  46. package/dist/utils/bun.d.ts +2 -0
  47. package/dist/utils/bun.js +13 -0
  48. package/dist/watch.d.ts +13 -1
  49. package/dist/watch.js +345 -97
  50. package/dist/workspace.d.ts +8 -0
  51. package/dist/workspace.js +44 -3
  52. package/package.json +49 -14
  53. package/scripts/publish.sh +2 -92
  54. package/scripts/smoke.mjs +282 -107
  55. package/scripts/update-contract.sh +12 -10
  56. package/src/add.ts +964 -0
  57. package/src/build/artifacts.ts +49 -46
  58. package/src/build/entries.ts +12 -12
  59. package/src/build/pipeline.ts +779 -403
  60. package/src/cache/diff.ts +111 -105
  61. package/src/cache/reporters.ts +26 -26
  62. package/src/deploy-cli.ts +111 -0
  63. package/src/diagnostics/summary.ts +28 -22
  64. package/src/index.ts +11 -0
  65. package/src/manifest/pipeline.ts +328 -215
  66. package/src/provider.ts +115 -98
  67. package/src/runtime/bun.ts +793 -0
  68. package/src/runtime/core.ts +598 -0
  69. package/src/runtime/deploy-backend.ts +239 -0
  70. package/src/runtime/deploy-shared.ts +136 -0
  71. package/src/runtime/deploy-static.ts +191 -0
  72. package/src/runtime/deploy.ts +143 -0
  73. package/src/runtime/forms.ts +364 -0
  74. package/src/runtime/request-hooks.ts +165 -0
  75. package/src/runtime/session-metadata.ts +135 -0
  76. package/src/runtime/session-runtime.ts +267 -0
  77. package/src/runtime/session.ts +642 -0
  78. package/src/runtime/views.ts +385 -0
  79. package/src/scaffold/assets.ts +77 -73
  80. package/src/testing/context.js +8 -9
  81. package/src/testing/context.ts +9 -9
  82. package/src/testing/index.d.ts +14 -3
  83. package/src/testing/index.js +254 -175
  84. package/src/testing/index.ts +298 -195
  85. package/src/testing/types.d.ts +18 -19
  86. package/src/testing/types.ts +18 -18
  87. package/src/utils/bun.ts +26 -0
  88. package/src/watch.ts +503 -99
  89. package/src/workspace.ts +59 -3
  90. package/templates/backend/.env.example +15 -0
  91. package/templates/backend/auth/adapter.ts +335 -36
  92. package/templates/backend/db/connection.ts +190 -65
  93. package/templates/backend/db/migrate.ts +149 -43
  94. package/templates/backend/db/types.d.ts +1 -1
  95. package/templates/backend/env.ts +132 -20
  96. package/templates/backend/functions/hello/index.ts +1 -2
  97. package/templates/backend/index.ts +15 -508
  98. package/templates/backend/jobs/nightly/index.ts +1 -1
  99. package/templates/backend/jobs/runtime.ts +24 -11
  100. package/templates/backend/jobs/scheduler.ts +208 -46
  101. package/templates/backend/module.ts +227 -13
  102. package/templates/backend/observability/logger.ts +2 -12
  103. package/templates/backend/observability/metrics.ts +8 -5
  104. package/templates/backend/session/sqlite.ts +152 -0
  105. package/templates/backend/session/store.ts +45 -0
  106. package/templates/backend/tsconfig.json +1 -1
  107. package/tests/add.test.js +327 -0
  108. package/tests/authAdapter.test.js +315 -0
  109. package/tests/bundlerParity.test.js +217 -0
  110. package/tests/cacheReporter.test.js +10 -10
  111. package/tests/dbConnection.test.js +209 -0
  112. package/tests/deploy.test.js +357 -0
  113. package/tests/envLoader.test.js +271 -17
  114. package/tests/integration.test.js +2432 -3
  115. package/tests/jobsScheduler.test.js +253 -0
  116. package/tests/manifest.test.js +287 -12
  117. package/tests/migrationRunner.test.js +249 -0
  118. package/tests/sessionScaffoldStore.test.js +752 -0
  119. package/tests/sessionStore.test.js +490 -0
  120. package/tests/testing.test.js +252 -0
  121. package/tests/watch.test.js +192 -32
  122. package/tsconfig.json +3 -10
  123. package/templates/backend/server/fastify.ts +0 -288
@@ -9,9 +9,15 @@ export declare function createBuildManifest(buildRoot: string, artifacts: readon
9
9
  name: string;
10
10
  contractVersion: string;
11
11
  version: string;
12
+ requestHooks?: {
13
+ id: string;
14
+ phase: "beforeAuth" | "beforeHandler" | "afterHandler";
15
+ order: number;
16
+ summary?: string | undefined;
17
+ description?: string | undefined;
18
+ }[] | undefined;
12
19
  capabilities?: string[] | undefined;
13
20
  assets?: string[] | undefined;
14
- middlewares?: string[] | undefined;
15
21
  routes?: {
16
22
  name: string;
17
23
  path: string;
@@ -26,6 +32,43 @@ export declare function createBuildManifest(buildRoot: string, artifacts: readon
26
32
  cause?: unknown;
27
33
  correlationId?: string | undefined;
28
34
  }[] | undefined;
35
+ interaction?: "navigation" | "mutation" | undefined;
36
+ requestHooks?: {
37
+ id: string;
38
+ }[] | undefined;
39
+ session?: {
40
+ mode?: "optional" | "required" | undefined;
41
+ write?: boolean | undefined;
42
+ } | undefined;
43
+ flash?: {
44
+ consume?: string[] | undefined;
45
+ publish?: {
46
+ key: string;
47
+ level?: "info" | "success" | "warning" | "error" | undefined;
48
+ when?: "success" | "error" | "always" | undefined;
49
+ }[] | undefined;
50
+ } | undefined;
51
+ form?: {
52
+ session?: {
53
+ mode?: "optional" | "required" | undefined;
54
+ write?: boolean | undefined;
55
+ } | undefined;
56
+ flash?: {
57
+ consume?: string[] | undefined;
58
+ publish?: {
59
+ key: string;
60
+ level?: "info" | "success" | "warning" | "error" | undefined;
61
+ when?: "success" | "error" | "always" | undefined;
62
+ }[] | undefined;
63
+ } | undefined;
64
+ contentType?: "application/x-www-form-urlencoded" | "multipart/form-data" | "text/plain" | undefined;
65
+ csrf?: boolean | undefined;
66
+ } | undefined;
67
+ fragment?: {
68
+ target: string;
69
+ mode?: "replace" | "append" | "prepend" | undefined;
70
+ selector?: string | undefined;
71
+ } | undefined;
29
72
  input?: {
30
73
  params?: {
31
74
  kind: "zod" | "json-schema" | "ts-rest";
@@ -60,6 +103,76 @@ export declare function createBuildManifest(buildRoot: string, artifacts: readon
60
103
  name: string;
61
104
  source?: string | undefined;
62
105
  } | undefined;
106
+ } | {
107
+ redirect: {
108
+ status?: 301 | 302 | 303 | 307 | 308 | undefined;
109
+ location?: string | undefined;
110
+ };
111
+ status?: number | undefined;
112
+ headers?: {
113
+ kind: "zod" | "json-schema" | "ts-rest";
114
+ name: string;
115
+ source?: string | undefined;
116
+ } | undefined;
117
+ } | {
118
+ body: {
119
+ kind: "zod" | "json-schema" | "ts-rest";
120
+ name: string;
121
+ source?: string | undefined;
122
+ };
123
+ fragment: {
124
+ target: string;
125
+ mode?: "replace" | "append" | "prepend" | undefined;
126
+ selector?: string | undefined;
127
+ };
128
+ status?: number | undefined;
129
+ headers?: {
130
+ kind: "zod" | "json-schema" | "ts-rest";
131
+ name: string;
132
+ source?: string | undefined;
133
+ } | undefined;
134
+ } | {
135
+ responses: ({
136
+ body: {
137
+ kind: "zod" | "json-schema" | "ts-rest";
138
+ name: string;
139
+ source?: string | undefined;
140
+ };
141
+ status?: number | undefined;
142
+ headers?: {
143
+ kind: "zod" | "json-schema" | "ts-rest";
144
+ name: string;
145
+ source?: string | undefined;
146
+ } | undefined;
147
+ } | {
148
+ redirect: {
149
+ status?: 301 | 302 | 303 | 307 | 308 | undefined;
150
+ location?: string | undefined;
151
+ };
152
+ status?: number | undefined;
153
+ headers?: {
154
+ kind: "zod" | "json-schema" | "ts-rest";
155
+ name: string;
156
+ source?: string | undefined;
157
+ } | undefined;
158
+ } | {
159
+ body: {
160
+ kind: "zod" | "json-schema" | "ts-rest";
161
+ name: string;
162
+ source?: string | undefined;
163
+ };
164
+ fragment: {
165
+ target: string;
166
+ mode?: "replace" | "append" | "prepend" | undefined;
167
+ selector?: string | undefined;
168
+ };
169
+ status?: number | undefined;
170
+ headers?: {
171
+ kind: "zod" | "json-schema" | "ts-rest";
172
+ name: string;
173
+ source?: string | undefined;
174
+ } | undefined;
175
+ })[];
63
176
  } | undefined;
64
177
  ssg?: {
65
178
  revalidateSeconds?: number | undefined;
@@ -91,6 +204,7 @@ export declare function createBuildManifest(buildRoot: string, artifacts: readon
91
204
  }[] | undefined;
92
205
  jobs?: {
93
206
  name: string;
207
+ description?: string | undefined;
94
208
  schedule?: string | undefined;
95
209
  priority?: string | number | undefined;
96
210
  }[] | undefined;
@@ -12,7 +12,7 @@ export async function collectArtifacts(buildRoot, includeSourceMaps) {
12
12
  const files = await glob(pattern, {
13
13
  cwd: buildRoot,
14
14
  nodir: true,
15
- dot: false
15
+ dot: false,
16
16
  });
17
17
  for (const relativePath of files) {
18
18
  matches.add(relativePath);
@@ -20,7 +20,7 @@ export async function collectArtifacts(buildRoot, includeSourceMaps) {
20
20
  }
21
21
  return Array.from(matches).map((relativePath) => ({
22
22
  path: path.join(buildRoot, relativePath),
23
- type: relativePath.endsWith('.map') ? 'asset' : 'bundle'
23
+ type: relativePath.endsWith('.map') ? 'asset' : 'bundle',
24
24
  }));
25
25
  }
26
26
  export function createBuildManifest(buildRoot, artifacts, diagnostics, moduleManifest) {
@@ -39,7 +39,7 @@ export function createBuildManifest(buildRoot, artifacts, diagnostics, moduleMan
39
39
  else {
40
40
  diagnostics.push({
41
41
  severity: 'warn',
42
- message: 'No backend entry point found (expected index.js).'
42
+ message: 'No backend entry point found (expected index.js).',
43
43
  });
44
44
  }
45
45
  }
@@ -48,6 +48,6 @@ export function createBuildManifest(buildRoot, artifacts, diagnostics, moduleMan
48
48
  entryPoints,
49
49
  staticAssets: [],
50
50
  diagnostics,
51
- module: moduleManifest
51
+ module: moduleManifest,
52
52
  };
53
53
  }
@@ -4,7 +4,7 @@ export async function discoverEntryPoints(sourceRoot) {
4
4
  const patterns = [
5
5
  'index.{ts,tsx,js,mjs}',
6
6
  'functions/*/index.{ts,tsx,js,mjs}',
7
- 'jobs/*/index.{ts,tsx,js,mjs}'
7
+ 'jobs/*/index.{ts,tsx,js,mjs}',
8
8
  ];
9
9
  const entries = new Set();
10
10
  for (const pattern of patterns) {
@@ -8,14 +8,31 @@ export interface BackendBuildPipelineOptions {
8
8
  readonly env: Record<string, string | undefined>;
9
9
  readonly incremental: boolean;
10
10
  readonly diagnostics: ModuleDiagnostic[];
11
+ readonly bundler?: BackendBundler;
11
12
  }
12
13
  export interface BackendBuildPipelineResult {
13
14
  readonly entryPoints: readonly string[];
14
15
  readonly outputs?: Record<string, number>;
15
16
  readonly includePublishSourcemaps: boolean;
16
17
  }
18
+ export type BackendBundler = 'esbuild' | 'bun';
17
19
  export declare function runBackendBuildPipeline(options: BackendBuildPipelineOptions): Promise<BackendBuildPipelineResult>;
18
20
  export declare function shouldTypeCheck(mode: BackendBuildMode, env: Record<string, string | undefined>): boolean;
21
+ interface ResolveBackendBundlerOptions {
22
+ readonly env: Record<string, string | undefined>;
23
+ readonly incremental: boolean;
24
+ readonly diagnostics?: ModuleDiagnostic[];
25
+ }
26
+ export declare function resolveBackendBundler(options: ResolveBackendBundlerOptions): BackendBundler;
27
+ export interface EnsureModuleDefinitionBuildOptions {
28
+ readonly sourceRoot: string;
29
+ readonly buildRoot: string;
30
+ readonly tsconfigPath: string;
31
+ readonly mode: BackendBuildMode;
32
+ readonly env: Record<string, string | undefined>;
33
+ readonly diagnostics: ModuleDiagnostic[];
34
+ }
35
+ export declare function ensureModuleDefinitionBuild(options: EnsureModuleDefinitionBuildOptions): Promise<void>;
19
36
  interface SupportFileBuildOptions {
20
37
  readonly sourceFile: string;
21
38
  readonly sourceRoot: string;
@@ -24,8 +41,23 @@ interface SupportFileBuildOptions {
24
41
  readonly mode: BackendBuildMode;
25
42
  readonly env: Record<string, string | undefined>;
26
43
  readonly diagnostics: ModuleDiagnostic[];
44
+ readonly bundler?: BackendBundler;
27
45
  }
28
46
  export declare function buildSupportFile(options: SupportFileBuildOptions): Promise<void>;
47
+ interface BuildMessageLike {
48
+ readonly message?: string;
49
+ readonly text?: string;
50
+ readonly location?: {
51
+ readonly file?: string;
52
+ readonly line?: number;
53
+ readonly column?: number;
54
+ } | null;
55
+ readonly position?: {
56
+ readonly file?: string;
57
+ readonly line?: number;
58
+ readonly column?: number;
59
+ } | null;
60
+ }
29
61
  export declare function collectOutputSizes(metafile: unknown, buildRoot: string): Record<string, number>;
30
- export declare function formatEsbuildMessage(msg: any): string;
62
+ export declare function formatEsbuildMessage(msg: BuildMessageLike): string;
31
63
  export {};