@happyvertical/smrt-core 0.37.8 → 0.37.9
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/AGENTS.md +10 -0
- package/dist/change-feed.d.ts +261 -0
- package/dist/change-feed.d.ts.map +1 -0
- package/dist/change-feed.js +482 -0
- package/dist/change-feed.js.map +1 -0
- package/dist/class.d.ts.map +1 -1
- package/dist/class.js +4 -2
- package/dist/class.js.map +1 -1
- package/dist/collection.js +2 -2
- package/dist/consumer-plugin/index.d.ts.map +1 -1
- package/dist/consumer-plugin/index.js +24 -19
- package/dist/consumer-plugin/index.js.map +1 -1
- package/dist/dispatch/bus.js +2 -2
- package/dist/dispatch/index.js +1 -1
- package/dist/generated-client-runtime.d.ts +26 -0
- package/dist/generated-client-runtime.d.ts.map +1 -0
- package/dist/generated-client-runtime.js +88 -0
- package/dist/generated-client-runtime.js.map +1 -0
- package/dist/generators/changes-route.d.ts +52 -0
- package/dist/generators/changes-route.d.ts.map +1 -0
- package/dist/generators/changes-route.js +111 -0
- package/dist/generators/changes-route.js.map +1 -0
- package/dist/generators/rest.d.ts +28 -0
- package/dist/generators/rest.d.ts.map +1 -1
- package/dist/generators/rest.js +53 -15
- package/dist/generators/rest.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/manifest/static-manifest.js +2 -2
- package/dist/manifest/static-manifest.js.map +1 -1
- package/dist/manifest/store.js +1 -1
- package/dist/manifest/test-manifest-stub.d.ts.map +1 -1
- package/dist/manifest/test-manifest-stub.js +502 -2
- package/dist/manifest/test-manifest-stub.js.map +1 -1
- package/dist/manifest.json +2 -2
- package/dist/object.js +2 -2
- package/dist/prebuild/index.d.ts.map +1 -1
- package/dist/prebuild/index.js +14 -7
- package/dist/prebuild/index.js.map +1 -1
- package/dist/smrt-knowledge.json +6 -6
- package/dist/system/schema.d.ts +24 -1
- package/dist/system/schema.d.ts.map +1 -1
- package/dist/system/schema.js +45 -3
- package/dist/system/schema.js.map +1 -1
- package/dist/testing/database.js +1 -1
- package/dist/vite-plugin/changes-route.d.ts +10 -0
- package/dist/vite-plugin/changes-route.d.ts.map +1 -0
- package/dist/vite-plugin/changes-route.js +174 -0
- package/dist/vite-plugin/changes-route.js.map +1 -0
- package/dist/vite-plugin/index.d.ts +7 -0
- package/dist/vite-plugin/index.d.ts.map +1 -1
- package/dist/vite-plugin/index.js +38 -20
- package/dist/vite-plugin/index.js.map +1 -1
- package/dist/vite-plugin/route-header.d.ts +10 -0
- package/dist/vite-plugin/route-header.d.ts.map +1 -0
- package/dist/vite-plugin/route-header.js +14 -0
- package/dist/vite-plugin/route-header.js.map +1 -0
- package/dist/vite-plugin/sveltekit-generator.d.ts +7 -0
- package/dist/vite-plugin/sveltekit-generator.d.ts.map +1 -1
- package/dist/vite-plugin/sveltekit-generator.js +5 -3
- package/dist/vite-plugin/sveltekit-generator.js.map +1 -1
- package/dist/vite-plugin/sync-apply-route.d.ts.map +1 -1
- package/dist/vite-plugin/sync-apply-route.js +2 -2
- package/dist/vite-plugin/sync-apply-route.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { buildDomainKnowledgeManifest } from "../knowledge.js";
|
|
2
2
|
import { importWorkspaceModule } from "../utils/import-workspace-module.js";
|
|
3
3
|
import { discoverSmrtPackages } from "../manifest/discover-smrt-packages.js";
|
|
4
|
+
import { CLIENT_FETCH_RUNTIME } from "../generated-client-runtime.js";
|
|
4
5
|
import { importBuildAwareModule } from "./import-build-aware.js";
|
|
5
6
|
import { findCliApiCoherenceViolations, generateSvelteKitRoutes, methodNameToKebab, resolveApiActionSet, validateCliIncludeAgainstApi } from "./sveltekit-generator.js";
|
|
6
7
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -256,6 +257,7 @@ function smrtPlugin(options = {}) {
|
|
|
256
257
|
configPath: svelteKit.configPath || "src/lib/server",
|
|
257
258
|
configFileName: svelteKit.configFileName || "smrt.ts",
|
|
258
259
|
kebabRoutes: svelteKit.kebabRoutes ?? false,
|
|
260
|
+
changesRoute: svelteKit.changesRoute,
|
|
259
261
|
knowledge: await resolveKnowledgeConfig(resolvedConfig.root, manifest)
|
|
260
262
|
});
|
|
261
263
|
},
|
|
@@ -319,6 +321,7 @@ function smrtPlugin(options = {}) {
|
|
|
319
321
|
configPath: svelteKit.configPath || "src/lib/server",
|
|
320
322
|
configFileName: svelteKit.configFileName || "smrt.ts",
|
|
321
323
|
kebabRoutes: svelteKit.kebabRoutes ?? false,
|
|
324
|
+
changesRoute: svelteKit.changesRoute,
|
|
322
325
|
knowledge: await resolveKnowledgeConfig(server.config.root, manifest)
|
|
323
326
|
});
|
|
324
327
|
Object.values(VIRTUAL_MODULES).forEach((id) => {
|
|
@@ -346,6 +349,7 @@ function smrtPlugin(options = {}) {
|
|
|
346
349
|
configPath: svelteKit.configPath || "src/lib/server",
|
|
347
350
|
configFileName: svelteKit.configFileName || "smrt.ts",
|
|
348
351
|
kebabRoutes: svelteKit.kebabRoutes ?? false,
|
|
352
|
+
changesRoute: svelteKit.changesRoute,
|
|
349
353
|
knowledge: await resolveKnowledgeConfig(server.config.root, manifest)
|
|
350
354
|
});
|
|
351
355
|
}
|
|
@@ -369,6 +373,7 @@ function smrtPlugin(options = {}) {
|
|
|
369
373
|
configPath: svelteKit.configPath || "src/lib/server",
|
|
370
374
|
configFileName: svelteKit.configFileName || "smrt.ts",
|
|
371
375
|
kebabRoutes: svelteKit.kebabRoutes ?? false,
|
|
376
|
+
changesRoute: svelteKit.changesRoute,
|
|
372
377
|
knowledge: await resolveKnowledgeConfig(server.config.root, manifest)
|
|
373
378
|
});
|
|
374
379
|
}
|
|
@@ -600,6 +605,8 @@ function generateClientModule(manifest, options = {}) {
|
|
|
600
605
|
// Auto-generated API client from SMRT objects
|
|
601
606
|
// This file is generated automatically - do not edit
|
|
602
607
|
|
|
608
|
+
${CLIENT_FETCH_RUNTIME}
|
|
609
|
+
|
|
603
610
|
export function createClient(basePath = '/api/v1') {
|
|
604
611
|
return {${uniqueApiClientEntries(Object.entries(manifest.objects)).map(({ obj, clientKey }) => {
|
|
605
612
|
const { collection, methods = {} } = obj;
|
|
@@ -616,45 +623,45 @@ export function createClient(basePath = '/api/v1') {
|
|
|
616
623
|
return options.kebabRoutes ? methodNameToKebab(methodName) : methodName;
|
|
617
624
|
};
|
|
618
625
|
const customMethodImpls = customMethods.map(([methodName, _method]) => {
|
|
619
|
-
return ` ${methodName}: (id, options) =>
|
|
626
|
+
return ` ${methodName}: (id, options) => __smrtFetchJson(basePath + '/${collection}/' + id + '/${segmentFor(methodName)}', {
|
|
620
627
|
method: 'POST',
|
|
621
628
|
headers: { 'Content-Type': 'application/json' },
|
|
622
629
|
body: JSON.stringify(options || {})
|
|
623
|
-
})
|
|
630
|
+
})`;
|
|
624
631
|
}).join(",\n");
|
|
625
632
|
return `
|
|
626
633
|
${clientKey}: {
|
|
627
|
-
list: (params) =>
|
|
634
|
+
list: (params) => __smrtFetchJson(basePath + '/${collection}', {
|
|
628
635
|
method: 'GET',
|
|
629
636
|
headers: { 'Content-Type': 'application/json' }
|
|
630
|
-
})
|
|
637
|
+
}),
|
|
631
638
|
|
|
632
|
-
get: (id) =>
|
|
639
|
+
get: (id) => __smrtFetchJson(basePath + '/${collection}/' + id, {
|
|
633
640
|
method: 'GET',
|
|
634
641
|
headers: { 'Content-Type': 'application/json' }
|
|
635
|
-
})
|
|
642
|
+
}),
|
|
636
643
|
|
|
637
|
-
create: (data) =>
|
|
644
|
+
create: (data) => __smrtFetchJson(basePath + '/${collection}', {
|
|
638
645
|
method: 'POST',
|
|
639
646
|
headers: { 'Content-Type': 'application/json' },
|
|
640
647
|
body: JSON.stringify(data)
|
|
641
|
-
})
|
|
648
|
+
}),
|
|
642
649
|
|
|
643
|
-
update: (id, data) =>
|
|
650
|
+
update: (id, data) => __smrtFetchJson(basePath + '/${collection}/' + id, {
|
|
644
651
|
method: 'PUT',
|
|
645
652
|
headers: { 'Content-Type': 'application/json' },
|
|
646
653
|
body: JSON.stringify(data)
|
|
647
|
-
})
|
|
654
|
+
}),
|
|
648
655
|
|
|
649
|
-
delete: (id) =>
|
|
656
|
+
delete: (id) => __smrtFetchOk(basePath + '/${collection}/' + id, {
|
|
650
657
|
method: 'DELETE',
|
|
651
658
|
headers: { 'Content-Type': 'application/json' }
|
|
652
|
-
})
|
|
659
|
+
}),
|
|
653
660
|
|
|
654
|
-
search: (query) =>
|
|
661
|
+
search: (query) => __smrtFetchJson(basePath + '/${collection}/search?q=' + encodeURIComponent(query), {
|
|
655
662
|
method: 'GET',
|
|
656
663
|
headers: { 'Content-Type': 'application/json' }
|
|
657
|
-
})
|
|
664
|
+
})${customMethods.length > 0 ? `,\n${customMethodImpls}` : ""}
|
|
658
665
|
}`;
|
|
659
666
|
}).join(",")}
|
|
660
667
|
};
|
|
@@ -835,8 +842,8 @@ async function generateTypeDeclarationFile(manifest, projectRoot, typeDeclaratio
|
|
|
835
842
|
${Object.entries(obj.fields).map(([fieldName, field]) => {
|
|
836
843
|
return ` ${fieldName}${field.required === false ? "?" : ""}: ${mapTypeScriptType(field.type)};`;
|
|
837
844
|
}).join("\n")}
|
|
838
|
-
|
|
839
|
-
|
|
845
|
+
created_at?: string;
|
|
846
|
+
updated_at?: string;
|
|
840
847
|
}`;
|
|
841
848
|
}).join("\n\n");
|
|
842
849
|
const apiClientInterface = uniqueApiClientEntries(Object.entries(manifest.objects)).map(({ obj, clientKey }) => {
|
|
@@ -922,15 +929,26 @@ declare module '@happyvertical/smrt-virt-routes' {
|
|
|
922
929
|
export default setupRoutes;
|
|
923
930
|
}
|
|
924
931
|
|
|
925
|
-
// Client module - Auto-generated API client
|
|
932
|
+
// Client module - Auto-generated API client
|
|
933
|
+
// Wire-shape policy (#1797): the server returns BARE JSON — a bare array for
|
|
934
|
+
// list/search, a bare object for get/create/update — with snake_case field
|
|
935
|
+
// names (created_at, updated_at). These declarations match that shape (no
|
|
936
|
+
// envelope, no camelCase). Fetchers reject on non-2xx with a SmrtClientError
|
|
937
|
+
// (#1796). This is byte-identical to the prebuild declaration path.
|
|
926
938
|
declare module '@happyvertical/smrt-virt-client' {
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
data?: T;
|
|
939
|
+
/** Shape of a JSON error body carried by a rejected request (SmrtClientError.body). */
|
|
940
|
+
export interface ApiError {
|
|
930
941
|
error?: string;
|
|
931
942
|
message?: string;
|
|
932
943
|
}
|
|
933
944
|
|
|
945
|
+
/** Typed error thrown by every fetcher on a non-2xx response (#1796). */
|
|
946
|
+
export interface SmrtClientError extends Error {
|
|
947
|
+
name: 'SmrtClientError';
|
|
948
|
+
status: number;
|
|
949
|
+
body?: ApiError | string;
|
|
950
|
+
}
|
|
951
|
+
|
|
934
952
|
export interface CrudOperations<T = any> {
|
|
935
953
|
list(params?: Record<string, any>): Promise<T[]>;
|
|
936
954
|
get(id: string): Promise<T>;
|