on-zero 0.16.20 → 0.16.21
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/cjs/cli.cjs +6 -0
- package/dist/cjs/cli.native.js +6 -0
- package/dist/cjs/cli.native.js.map +1 -1
- package/dist/cjs/combineZeroClients.native.js.map +1 -1
- package/dist/cjs/config.native.js.map +1 -1
- package/dist/cjs/createPermissions.native.js.map +1 -1
- package/dist/cjs/createSchemaFromDrizzle.native.js.map +1 -1
- package/dist/cjs/createUseQuery.cjs +14 -4
- package/dist/cjs/createUseQuery.native.js +18 -5
- package/dist/cjs/createUseQuery.native.js.map +1 -1
- package/dist/cjs/createUseQueryDirect.cjs +13 -2
- package/dist/cjs/createUseQueryDirect.native.js +14 -2
- package/dist/cjs/createUseQueryDirect.native.js.map +1 -1
- package/dist/cjs/createZeroClient.authData.test.native.js.map +1 -1
- package/dist/cjs/createZeroClient.cjs +21 -3
- package/dist/cjs/createZeroClient.connection.test.native.js.map +1 -1
- package/dist/cjs/createZeroClient.exportProbe.test.native.js.map +1 -1
- package/dist/cjs/createZeroClient.headless.test.native.js.map +1 -1
- package/dist/cjs/createZeroClient.httpAuth.test.native.js.map +1 -1
- package/dist/cjs/createZeroClient.native.js +28 -3
- package/dist/cjs/createZeroClient.native.js.map +1 -1
- package/dist/cjs/createZeroClient.recovery.test.native.js.map +1 -1
- package/dist/cjs/generate-helpers.native.js.map +1 -1
- package/dist/cjs/generate-helpers.test.native.js.map +1 -1
- package/dist/cjs/generate-layout.native.js.map +1 -1
- package/dist/cjs/generate-lite.native.js.map +1 -1
- package/dist/cjs/generate-lite.test.native.js.map +1 -1
- package/dist/cjs/generate.cjs +57 -30
- package/dist/cjs/generate.native.js +92 -31
- package/dist/cjs/generate.native.js.map +1 -1
- package/dist/cjs/generate.test.cjs +147 -0
- package/dist/cjs/generate.test.native.js +147 -0
- package/dist/cjs/generate.test.native.js.map +1 -1
- package/dist/cjs/helpers/NullToOptional.native.js.map +1 -1
- package/dist/cjs/helpers/asyncContext.hostStorage.test.native.js.map +1 -1
- package/dist/cjs/helpers/batchQuery.native.js.map +1 -1
- package/dist/cjs/helpers/clearZeroClientData.native.js.map +1 -1
- package/dist/cjs/helpers/createMutators.native.js.map +1 -1
- package/dist/cjs/helpers/createMutators.test.native.js.map +1 -1
- package/dist/cjs/helpers/ellipsis.native.js.map +1 -1
- package/dist/cjs/helpers/emitter.native.js.map +1 -1
- package/dist/cjs/helpers/ensure.native.js.map +1 -1
- package/dist/cjs/helpers/ensureLoggedIn.native.js.map +1 -1
- package/dist/cjs/helpers/errors.native.js.map +1 -1
- package/dist/cjs/helpers/getAuth.native.js.map +1 -1
- package/dist/cjs/helpers/getCurrentComponentStack.native.js.map +1 -1
- package/dist/cjs/helpers/globalValue.native.js.map +1 -1
- package/dist/cjs/helpers/hostStorageScope.native.js.map +1 -1
- package/dist/cjs/helpers/mapObject.native.js.map +1 -1
- package/dist/cjs/helpers/mutationLifecycle.native.js.map +1 -1
- package/dist/cjs/helpers/mutationLifecycle.test.native.js.map +1 -1
- package/dist/cjs/helpers/mutatorContext.native.js.map +1 -1
- package/dist/cjs/helpers/mutatorContext.test.native.js.map +1 -1
- package/dist/cjs/helpers/prettyFormatZeroQuery.native.js.map +1 -1
- package/dist/cjs/helpers/queryContext.native.js.map +1 -1
- package/dist/cjs/helpers/recoverZeroClient.native.js.map +1 -1
- package/dist/cjs/helpers/recoverZeroClient.test.native.js.map +1 -1
- package/dist/cjs/helpers/showZeroClientError.native.js.map +1 -1
- package/dist/cjs/helpers/sleep.native.js.map +1 -1
- package/dist/cjs/helpers/time.native.js.map +1 -1
- package/dist/cjs/helpers/tuple.native.js.map +1 -1
- package/dist/cjs/helpers/useMutation.native.js.map +1 -1
- package/dist/cjs/helpers/useMutation.test.native.js.map +1 -1
- package/dist/cjs/helpers/useZeroDebug.native.js.map +1 -1
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/instanceRegistry.native.js.map +1 -1
- package/dist/cjs/modelRegistry.native.js.map +1 -1
- package/dist/cjs/multi.cjs +10 -5
- package/dist/cjs/multi.native.js +10 -5
- package/dist/cjs/multi.native.js.map +1 -1
- package/dist/cjs/multiInstance.test.native.js.map +1 -1
- package/dist/cjs/multiInstanceMutations.test.native.js.map +1 -1
- package/dist/cjs/multiInstanceNested.test.native.js.map +1 -1
- package/dist/cjs/multiPartition.test.cjs +46 -2
- package/dist/cjs/multiPartition.test.native.js +50 -2
- package/dist/cjs/multiPartition.test.native.js.map +1 -1
- package/dist/cjs/mutations.native.js.map +1 -1
- package/dist/cjs/mutations.test.native.js.map +1 -1
- package/dist/cjs/native-typescript.cjs +50 -11
- package/dist/cjs/native-typescript.native.js +158 -30
- package/dist/cjs/native-typescript.native.js.map +1 -1
- package/dist/cjs/provideZero.eagerInstance.test.cjs +22 -0
- package/dist/cjs/provideZero.eagerInstance.test.native.js +30 -0
- package/dist/cjs/provideZero.eagerInstance.test.native.js.map +1 -1
- package/dist/cjs/provideZero.hydration.test.native.js.map +1 -1
- package/dist/cjs/provideZero.ssr.test.native.js.map +1 -1
- package/dist/cjs/queryErrorRecovery.cjs +93 -0
- package/dist/cjs/queryErrorRecovery.native.js +205 -0
- package/dist/cjs/queryErrorRecovery.native.js.map +1 -0
- package/dist/cjs/queryJson.native.js.map +1 -1
- package/dist/cjs/queryRegistry.native.js.map +1 -1
- package/dist/cjs/resolveQuery.native.js.map +1 -1
- package/dist/cjs/run.native.js.map +1 -1
- package/dist/cjs/server.native.js.map +1 -1
- package/dist/cjs/server.test.native.js.map +1 -1
- package/dist/cjs/serverWhere.native.js.map +1 -1
- package/dist/cjs/serverWhere.test.native.js.map +1 -1
- package/dist/cjs/state.native.js.map +1 -1
- package/dist/cjs/streaming.native.js.map +1 -1
- package/dist/cjs/testSetup.native.js.map +1 -1
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/usePermission.test.native.js.map +1 -1
- package/dist/cjs/useQuery.aggregate.zero.test.cjs +199 -4
- package/dist/cjs/useQuery.aggregate.zero.test.native.js +212 -4
- package/dist/cjs/useQuery.aggregate.zero.test.native.js.map +1 -1
- package/dist/cjs/useQuery.empty.test.native.js.map +1 -1
- package/dist/cjs/useQuery.ssr.test.native.js.map +1 -1
- package/dist/cjs/useStreamingField.loop.test.native.js.map +1 -1
- package/dist/cjs/useStreamingField.native.js.map +1 -1
- package/dist/cjs/vite-plugin.cjs +10 -0
- package/dist/cjs/vite-plugin.native.js +10 -0
- package/dist/cjs/vite-plugin.native.js.map +1 -1
- package/dist/cjs/where.native.js.map +1 -1
- package/dist/cjs/zeroRunner.native.js.map +1 -1
- package/dist/cjs/zql.native.js.map +1 -1
- package/dist/esm/cli.mjs +6 -0
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/cli.native.js +7 -1
- package/dist/esm/cli.native.js.map +1 -1
- package/dist/esm/combineZeroClients.native.js +4 -4
- package/dist/esm/combineZeroClients.native.js.map +1 -1
- package/dist/esm/config.native.js.map +1 -1
- package/dist/esm/createPermissions.native.js +4 -4
- package/dist/esm/createPermissions.native.js.map +1 -1
- package/dist/esm/createSchemaFromDrizzle.native.js +1 -1
- package/dist/esm/createSchemaFromDrizzle.native.js.map +1 -1
- package/dist/esm/createUseQuery.mjs +16 -6
- package/dist/esm/createUseQuery.mjs.map +1 -1
- package/dist/esm/createUseQuery.native.js +24 -11
- package/dist/esm/createUseQuery.native.js.map +1 -1
- package/dist/esm/createUseQueryDirect.mjs +13 -2
- package/dist/esm/createUseQueryDirect.mjs.map +1 -1
- package/dist/esm/createUseQueryDirect.native.js +19 -7
- package/dist/esm/createUseQueryDirect.native.js.map +1 -1
- package/dist/esm/createZeroClient.authData.test.native.js +2 -2
- package/dist/esm/createZeroClient.authData.test.native.js.map +1 -1
- package/dist/esm/createZeroClient.connection.test.native.js +1 -1
- package/dist/esm/createZeroClient.connection.test.native.js.map +1 -1
- package/dist/esm/createZeroClient.exportProbe.test.native.js +1 -1
- package/dist/esm/createZeroClient.exportProbe.test.native.js.map +1 -1
- package/dist/esm/createZeroClient.headless.test.native.js +2 -2
- package/dist/esm/createZeroClient.headless.test.native.js.map +1 -1
- package/dist/esm/createZeroClient.httpAuth.test.native.js +1 -1
- package/dist/esm/createZeroClient.httpAuth.test.native.js.map +1 -1
- package/dist/esm/createZeroClient.mjs +21 -3
- package/dist/esm/createZeroClient.mjs.map +1 -1
- package/dist/esm/createZeroClient.native.js +49 -24
- package/dist/esm/createZeroClient.native.js.map +1 -1
- package/dist/esm/createZeroClient.recovery.test.native.js +2 -2
- package/dist/esm/createZeroClient.recovery.test.native.js.map +1 -1
- package/dist/esm/generate-helpers.native.js.map +1 -1
- package/dist/esm/generate-helpers.test.native.js +1 -1
- package/dist/esm/generate-helpers.test.native.js.map +1 -1
- package/dist/esm/generate-layout.native.js.map +1 -1
- package/dist/esm/generate-lite.native.js +1 -1
- package/dist/esm/generate-lite.native.js.map +1 -1
- package/dist/esm/generate-lite.test.native.js +1 -1
- package/dist/esm/generate-lite.test.native.js.map +1 -1
- package/dist/esm/generate.mjs +57 -30
- package/dist/esm/generate.mjs.map +1 -1
- package/dist/esm/generate.native.js +95 -34
- package/dist/esm/generate.native.js.map +1 -1
- package/dist/esm/generate.test.mjs +147 -0
- package/dist/esm/generate.test.mjs.map +1 -1
- package/dist/esm/generate.test.native.js +148 -1
- package/dist/esm/generate.test.native.js.map +1 -1
- package/dist/esm/helpers/NullToOptional.native.js.map +1 -1
- package/dist/esm/helpers/asyncContext.hostStorage.test.native.js +7 -7
- package/dist/esm/helpers/asyncContext.hostStorage.test.native.js.map +1 -1
- package/dist/esm/helpers/batchQuery.native.js +1 -1
- package/dist/esm/helpers/batchQuery.native.js.map +1 -1
- package/dist/esm/helpers/clearZeroClientData.native.js.map +1 -1
- package/dist/esm/helpers/createMutators.native.js +4 -4
- package/dist/esm/helpers/createMutators.native.js.map +1 -1
- package/dist/esm/helpers/createMutators.test.native.js +2 -2
- package/dist/esm/helpers/createMutators.test.native.js.map +1 -1
- package/dist/esm/helpers/ellipsis.native.js.map +1 -1
- package/dist/esm/helpers/emitter.native.js.map +1 -1
- package/dist/esm/helpers/ensure.native.js +1 -1
- package/dist/esm/helpers/ensure.native.js.map +1 -1
- package/dist/esm/helpers/ensureLoggedIn.native.js +2 -2
- package/dist/esm/helpers/ensureLoggedIn.native.js.map +1 -1
- package/dist/esm/helpers/errors.native.js.map +1 -1
- package/dist/esm/helpers/getAuth.native.js +3 -3
- package/dist/esm/helpers/getAuth.native.js.map +1 -1
- package/dist/esm/helpers/getCurrentComponentStack.native.js.map +1 -1
- package/dist/esm/helpers/globalValue.native.js.map +1 -1
- package/dist/esm/helpers/hostStorageScope.native.js.map +1 -1
- package/dist/esm/helpers/mapObject.native.js.map +1 -1
- package/dist/esm/helpers/mutationLifecycle.native.js +1 -1
- package/dist/esm/helpers/mutationLifecycle.native.js.map +1 -1
- package/dist/esm/helpers/mutationLifecycle.test.native.js +1 -1
- package/dist/esm/helpers/mutationLifecycle.test.native.js.map +1 -1
- package/dist/esm/helpers/mutatorContext.native.js +1 -1
- package/dist/esm/helpers/mutatorContext.native.js.map +1 -1
- package/dist/esm/helpers/mutatorContext.test.native.js +6 -6
- package/dist/esm/helpers/mutatorContext.test.native.js.map +1 -1
- package/dist/esm/helpers/prettyFormatZeroQuery.native.js +1 -1
- package/dist/esm/helpers/prettyFormatZeroQuery.native.js.map +1 -1
- package/dist/esm/helpers/queryContext.native.js +1 -1
- package/dist/esm/helpers/queryContext.native.js.map +1 -1
- package/dist/esm/helpers/recoverZeroClient.native.js +1 -1
- package/dist/esm/helpers/recoverZeroClient.native.js.map +1 -1
- package/dist/esm/helpers/recoverZeroClient.test.native.js +2 -2
- package/dist/esm/helpers/recoverZeroClient.test.native.js.map +1 -1
- package/dist/esm/helpers/showZeroClientError.native.js +1 -1
- package/dist/esm/helpers/showZeroClientError.native.js.map +1 -1
- package/dist/esm/helpers/sleep.native.js +1 -1
- package/dist/esm/helpers/sleep.native.js.map +1 -1
- package/dist/esm/helpers/time.native.js.map +1 -1
- package/dist/esm/helpers/tuple.native.js.map +1 -1
- package/dist/esm/helpers/useMutation.native.js.map +1 -1
- package/dist/esm/helpers/useMutation.test.native.js +1 -1
- package/dist/esm/helpers/useMutation.test.native.js.map +1 -1
- package/dist/esm/helpers/useZeroDebug.native.js +2 -2
- package/dist/esm/helpers/useZeroDebug.native.js.map +1 -1
- package/dist/esm/index.native.js +23 -23
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/instanceRegistry.native.js +2 -2
- package/dist/esm/instanceRegistry.native.js.map +1 -1
- package/dist/esm/modelRegistry.native.js.map +1 -1
- package/dist/esm/multi.mjs +10 -5
- package/dist/esm/multi.mjs.map +1 -1
- package/dist/esm/multi.native.js +15 -10
- package/dist/esm/multi.native.js.map +1 -1
- package/dist/esm/multiInstance.test.native.js +10 -10
- package/dist/esm/multiInstance.test.native.js.map +1 -1
- package/dist/esm/multiInstanceMutations.test.native.js +4 -4
- package/dist/esm/multiInstanceMutations.test.native.js.map +1 -1
- package/dist/esm/multiInstanceNested.test.native.js +3 -3
- package/dist/esm/multiInstanceNested.test.native.js.map +1 -1
- package/dist/esm/multiPartition.test.mjs +47 -3
- package/dist/esm/multiPartition.test.mjs.map +1 -1
- package/dist/esm/multiPartition.test.native.js +52 -4
- package/dist/esm/multiPartition.test.native.js.map +1 -1
- package/dist/esm/mutations.native.js +2 -2
- package/dist/esm/mutations.native.js.map +1 -1
- package/dist/esm/mutations.test.native.js +4 -4
- package/dist/esm/mutations.test.native.js.map +1 -1
- package/dist/esm/native-typescript.mjs +50 -11
- package/dist/esm/native-typescript.mjs.map +1 -1
- package/dist/esm/native-typescript.native.js +158 -30
- package/dist/esm/native-typescript.native.js.map +1 -1
- package/dist/esm/provideZero.eagerInstance.test.mjs +22 -0
- package/dist/esm/provideZero.eagerInstance.test.mjs.map +1 -1
- package/dist/esm/provideZero.eagerInstance.test.native.js +31 -1
- package/dist/esm/provideZero.eagerInstance.test.native.js.map +1 -1
- package/dist/esm/provideZero.hydration.test.native.js +2 -2
- package/dist/esm/provideZero.hydration.test.native.js.map +1 -1
- package/dist/esm/provideZero.ssr.test.native.js +2 -2
- package/dist/esm/provideZero.ssr.test.native.js.map +1 -1
- package/dist/esm/queryErrorRecovery.mjs +66 -0
- package/dist/esm/queryErrorRecovery.mjs.map +1 -0
- package/dist/esm/queryErrorRecovery.native.js +175 -0
- package/dist/esm/queryErrorRecovery.native.js.map +1 -0
- package/dist/esm/queryJson.native.js +1 -1
- package/dist/esm/queryJson.native.js.map +1 -1
- package/dist/esm/queryRegistry.native.js.map +1 -1
- package/dist/esm/resolveQuery.native.js +2 -2
- package/dist/esm/resolveQuery.native.js.map +1 -1
- package/dist/esm/run.native.js +4 -4
- package/dist/esm/run.native.js.map +1 -1
- package/dist/esm/server.native.js +10 -10
- package/dist/esm/server.native.js.map +1 -1
- package/dist/esm/server.test.native.js +2 -2
- package/dist/esm/server.test.native.js.map +1 -1
- package/dist/esm/serverWhere.native.js +1 -1
- package/dist/esm/serverWhere.native.js.map +1 -1
- package/dist/esm/serverWhere.test.native.js +3 -3
- package/dist/esm/serverWhere.test.native.js.map +1 -1
- package/dist/esm/state.native.js +1 -1
- package/dist/esm/state.native.js.map +1 -1
- package/dist/esm/streaming.native.js +1 -1
- package/dist/esm/streaming.native.js.map +1 -1
- package/dist/esm/testSetup.native.js.map +1 -1
- package/dist/esm/types.native.js.map +1 -1
- package/dist/esm/usePermission.test.native.js +3 -3
- package/dist/esm/usePermission.test.native.js.map +1 -1
- package/dist/esm/useQuery.aggregate.zero.test.mjs +197 -2
- package/dist/esm/useQuery.aggregate.zero.test.mjs.map +1 -1
- package/dist/esm/useQuery.aggregate.zero.test.native.js +212 -4
- package/dist/esm/useQuery.aggregate.zero.test.native.js.map +1 -1
- package/dist/esm/useQuery.empty.test.native.js +3 -3
- package/dist/esm/useQuery.empty.test.native.js.map +1 -1
- package/dist/esm/useQuery.ssr.test.native.js +2 -2
- package/dist/esm/useQuery.ssr.test.native.js.map +1 -1
- package/dist/esm/useStreamingField.loop.test.native.js +1 -1
- package/dist/esm/useStreamingField.loop.test.native.js.map +1 -1
- package/dist/esm/useStreamingField.native.js.map +1 -1
- package/dist/esm/vite-plugin.mjs +10 -0
- package/dist/esm/vite-plugin.mjs.map +1 -1
- package/dist/esm/vite-plugin.native.js +11 -1
- package/dist/esm/vite-plugin.native.js.map +1 -1
- package/dist/esm/where.native.js +3 -3
- package/dist/esm/where.native.js.map +1 -1
- package/dist/esm/zeroRunner.native.js +1 -1
- package/dist/esm/zeroRunner.native.js.map +1 -1
- package/dist/esm/zql.native.js +1 -1
- package/dist/esm/zql.native.js.map +1 -1
- package/package.json +4 -4
- package/src/cli.ts +6 -0
- package/src/createUseQuery.tsx +20 -5
- package/src/createUseQueryDirect.tsx +17 -1
- package/src/createZeroClient.tsx +37 -4
- package/src/generate.test.ts +116 -0
- package/src/generate.ts +109 -52
- package/src/multi.ts +11 -3
- package/src/multiPartition.test.ts +55 -11
- package/src/native-typescript.ts +64 -11
- package/src/provideZero.eagerInstance.test.tsx +27 -0
- package/src/queryErrorRecovery.ts +95 -0
- package/src/useQuery.aggregate.zero.test.tsx +187 -2
- package/src/vite-plugin.ts +10 -0
- package/types/createUseQuery.d.ts +3 -1
- package/types/createUseQuery.d.ts.map +1 -1
- package/types/createUseQueryDirect.d.ts +3 -1
- package/types/createUseQueryDirect.d.ts.map +1 -1
- package/types/createZeroClient.d.ts +3 -1
- package/types/createZeroClient.d.ts.map +1 -1
- package/types/generate.d.ts +4 -0
- package/types/generate.d.ts.map +1 -1
- package/types/multi.d.ts +3 -1
- package/types/multi.d.ts.map +1 -1
- package/types/native-typescript.d.ts +7 -1
- package/types/native-typescript.d.ts.map +1 -1
- package/types/queryErrorRecovery.d.ts +33 -0
- package/types/queryErrorRecovery.d.ts.map +1 -0
- package/types/useQuery.aggregate.zero.test.d.ts.map +1 -1
- package/types/vite-plugin.d.ts.map +1 -1
package/dist/cjs/generate.cjs
CHANGED
|
@@ -49,9 +49,9 @@ var import_generate_helpers = require("./generate-helpers.cjs");
|
|
|
49
49
|
var import_generate_layout = require("./generate-layout.cjs");
|
|
50
50
|
var import_native_typescript = require("./native-typescript.cjs");
|
|
51
51
|
const hash = s => (0, import_node_crypto.createHash)("sha256").update(s).digest("hex");
|
|
52
|
-
const GENERATOR_CACHE_VERSION = "
|
|
52
|
+
const GENERATOR_CACHE_VERSION = "10";
|
|
53
53
|
const isGeneratorSourceFile = name => name.endsWith(".ts") && !name.endsWith(".d.ts") && !name.endsWith(".test.ts") && !name.endsWith(".spec.ts");
|
|
54
|
-
function hashInputTree(sourceRoots, generatedDir) {
|
|
54
|
+
function hashInputTree(sourceRoots, generatedDir, dependencyPaths) {
|
|
55
55
|
const parts = [];
|
|
56
56
|
const seen = /* @__PURE__ */new Set();
|
|
57
57
|
const walk = dir => {
|
|
@@ -72,6 +72,11 @@ function hashInputTree(sourceRoots, generatedDir) {
|
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
74
|
for (const root of sourceRoots) walk(root);
|
|
75
|
+
for (const path of dependencyPaths) {
|
|
76
|
+
if (seen.has(path) || path.startsWith(`${generatedDir}/`) || !(0, import_node_fs.existsSync)(path)) continue;
|
|
77
|
+
seen.add(path);
|
|
78
|
+
parts.push(`${path}\0${(0, import_node_fs.readFileSync)(path, "utf-8")}`);
|
|
79
|
+
}
|
|
75
80
|
return hash(parts.join("\0"));
|
|
76
81
|
}
|
|
77
82
|
let generateCache = {};
|
|
@@ -338,11 +343,12 @@ function extractSchemaColumns(sourceFile, columns, primaryKeys) {
|
|
|
338
343
|
async function tsTypeToValibot(project, type, seen = /* @__PURE__ */new Set()) {
|
|
339
344
|
const checker = project.checker;
|
|
340
345
|
const flags = type.flags;
|
|
346
|
+
let path = seen;
|
|
341
347
|
if (flags & (import_async.TypeFlags.Object | import_async.TypeFlags.Intersection)) {
|
|
342
348
|
if (seen.has(type.id)) return "v.unknown()";
|
|
343
|
-
seen.add(type.id);
|
|
349
|
+
path = new Set(seen).add(type.id);
|
|
344
350
|
}
|
|
345
|
-
const recurse = value => tsTypeToValibot(project, value,
|
|
351
|
+
const recurse = value => tsTypeToValibot(project, value, path);
|
|
346
352
|
if (flags & import_async.TypeFlags.String) return "v.string()";
|
|
347
353
|
if (flags & import_async.TypeFlags.Number) return "v.number()";
|
|
348
354
|
if (flags & import_async.TypeFlags.Boolean) return "v.boolean()";
|
|
@@ -525,13 +531,16 @@ function dataMembershipFromLayout(layout) {
|
|
|
525
531
|
allTables: [...new Set(layout.instances.flatMap(instance => [...instance.syncTables, ...instance.supportTables]))].sort()
|
|
526
532
|
};
|
|
527
533
|
}
|
|
528
|
-
async function loadGeneratorProject(baseDir) {
|
|
534
|
+
async function loadGeneratorProject(baseDir, deferSources = false, tsconfig) {
|
|
529
535
|
const sourcePaths = (0, import_native_typescript.collectTypeScriptSourcePaths)([baseDir, (0, import_node_path.resolve)((0, import_node_path.dirname)(baseDir), "database")]);
|
|
530
|
-
return (0, import_native_typescript.createNativeTypeScriptProject)(baseDir, sourcePaths
|
|
536
|
+
return (0, import_native_typescript.createNativeTypeScriptProject)(baseDir, sourcePaths, {
|
|
537
|
+
deferSources,
|
|
538
|
+
tsconfig: tsconfig ? (0, import_node_path.resolve)(tsconfig) : void 0
|
|
539
|
+
});
|
|
531
540
|
}
|
|
532
541
|
async function deriveDataMembership(options) {
|
|
533
542
|
const baseDir = (0, import_node_path.resolve)(options.dir);
|
|
534
|
-
const project = await loadGeneratorProject(baseDir);
|
|
543
|
+
const project = await loadGeneratorProject(baseDir, false, options.tsconfig);
|
|
535
544
|
try {
|
|
536
545
|
const layout = (0, import_generate_layout.discoverDataLayout)(project, baseDir, options.config ? (0, import_node_path.resolve)(options.config) : void 0);
|
|
537
546
|
return dataMembershipFromLayout(layout);
|
|
@@ -541,7 +550,7 @@ async function deriveDataMembership(options) {
|
|
|
541
550
|
}
|
|
542
551
|
async function generateDrizzleSchemaInputFile(options) {
|
|
543
552
|
const baseDir = (0, import_node_path.resolve)(options.dir);
|
|
544
|
-
const project = await loadGeneratorProject(baseDir);
|
|
553
|
+
const project = await loadGeneratorProject(baseDir, false, options.tsconfig);
|
|
545
554
|
try {
|
|
546
555
|
return generateDrizzleSchemaInputFileWithProject(options, project);
|
|
547
556
|
} finally {
|
|
@@ -593,7 +602,7 @@ ${relations.map(relation => ` ${relation},`).join("\n")}
|
|
|
593
602
|
return ["// auto-generated from the on-zero data layout", `import { defineRelations } from 'drizzle-orm'`, `import * as schema from ${schemaImportPath}`, "", `export { ${tableNames.join(", ")} } from ${schemaImportPath}`, `export const relations = defineRelations(schema, (r) => ({`, ...relationEntries, `}))`, ""].join("\n");
|
|
594
603
|
}
|
|
595
604
|
async function generate(options) {
|
|
596
|
-
const project = await loadGeneratorProject((0, import_node_path.resolve)(options.dir));
|
|
605
|
+
const project = await loadGeneratorProject((0, import_node_path.resolve)(options.dir), true, options.tsconfig);
|
|
597
606
|
try {
|
|
598
607
|
return await generateWithProject(options, project);
|
|
599
608
|
} finally {
|
|
@@ -616,36 +625,44 @@ async function generateWithProject(options, project) {
|
|
|
616
625
|
});
|
|
617
626
|
}
|
|
618
627
|
loadCache();
|
|
619
|
-
const
|
|
620
|
-
|
|
628
|
+
const configPath = config ? (0, import_node_path.resolve)(config) : (0, import_node_path.resolve)(baseDir, "on-zero.config.ts");
|
|
629
|
+
let cachedInputs = null;
|
|
630
|
+
if (generateCache.__configPath === configPath) {
|
|
631
|
+
try {
|
|
632
|
+
const value = JSON.parse(generateCache.__layoutInputs || "null");
|
|
633
|
+
if (value && typeof value === "object" && "sourceRoots" in value && Array.isArray(value.sourceRoots) && value.sourceRoots.every(path => typeof path === "string") && "metadataPaths" in value && Array.isArray(value.metadataPaths) && value.metadataPaths.every(path => typeof path === "string")) {
|
|
634
|
+
cachedInputs = {
|
|
635
|
+
sourceRoots: value.sourceRoots,
|
|
636
|
+
metadataPaths: value.metadataPaths
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
} catch {}
|
|
640
|
+
}
|
|
641
|
+
const dependencyPaths = await project.sourceFilePaths();
|
|
642
|
+
const hashInputs = layout2 => {
|
|
643
|
+
const metadataHash = hash(layout2.metadataPaths.map(path => `${path}\0${(0, import_node_fs.readFileSync)(path, "utf8")}`).join("\0"));
|
|
644
|
+
return hash(`${hashInputTree(layout2.sourceRoots, generatedDir, dependencyPaths)}\0${metadataHash}\0${externalZeroConfig}\0${project.configurationKey}`);
|
|
645
|
+
};
|
|
621
646
|
const databaseSchemaPath = (0, import_node_path.resolve)((0, import_node_path.dirname)(baseDir), "database/schema.ts");
|
|
622
647
|
const needsDrizzleSchema = (0, import_node_fs.existsSync)(databaseSchemaPath);
|
|
623
648
|
const externalZeroConfigPath = (0, import_node_path.resolve)((0, import_node_path.dirname)(databaseSchemaPath), "drizzle-zero.config.ts");
|
|
624
649
|
const externalZeroConfig = (0, import_node_fs.existsSync)(externalZeroConfigPath) ? (0, import_node_fs.readFileSync)(externalZeroConfigPath, "utf8") : null;
|
|
625
650
|
const needsSqliteZeroSchema = needsDrizzleSchema && externalZeroConfig === null;
|
|
626
|
-
|
|
627
|
-
if (
|
|
651
|
+
let cachedInputHash = null;
|
|
652
|
+
if (cachedInputs) {
|
|
653
|
+
try {
|
|
654
|
+
cachedInputHash = hashInputs(cachedInputs);
|
|
655
|
+
} catch {}
|
|
656
|
+
}
|
|
657
|
+
if (!force && generateCache.__generatorVersion === GENERATOR_CACHE_VERSION && generateCache.__inputHash === cachedInputHash &&
|
|
628
658
|
// the input hash deliberately skips the generated directory, so it cannot
|
|
629
659
|
// notice that the outputs themselves moved. existence is not correctness
|
|
630
660
|
// either: a checkout, merge or revert leaves every file present and stale.
|
|
631
661
|
// confirm the bytes on disk still match what the cache says it wrote there
|
|
632
662
|
// before skipping the build, or the fast path serves someone else's output.
|
|
633
663
|
//
|
|
634
|
-
//
|
|
635
|
-
//
|
|
636
|
-
// holds the formatted ones. soot does exactly that, `on-zero generate &&
|
|
637
|
-
// generate-instance-tables && oxfmt src/data/generated/`, and the number is
|
|
638
|
-
// already taken: 2.50s median before, 3.69s after, four warm runs each in
|
|
639
|
-
// one checkout with only the pin swapped, so about 1.2 seconds or 47
|
|
640
|
-
// percent on this step. the full three-command script went 2.65s to 3.14s
|
|
641
|
-
// with a spread that swallows most of it.
|
|
642
|
-
//
|
|
643
|
-
// the shape matters more than the number. this is not a cache that hits
|
|
644
|
-
// less often, it is a cache that never hits, so the cost does not degrade
|
|
645
|
-
// gracefully and grows with the generated output rather than staying at
|
|
646
|
-
// 1.2s. correct and slower beats fast and stale, which is why it is written
|
|
647
|
-
// this way, but if generate time ever becomes the complaint, record the
|
|
648
|
-
// hash after the consumer's formatter runs rather than weakening this.
|
|
664
|
+
// successful after commands record their final output hashes. formatting
|
|
665
|
+
// therefore keeps the fast path without trusting stale generated bytes.
|
|
649
666
|
Object.entries(generateCache).every(([cachedPath, cachedHash]) => {
|
|
650
667
|
if (!cachedPath.startsWith(generatedDir)) return true;
|
|
651
668
|
try {
|
|
@@ -666,6 +683,9 @@ async function generateWithProject(options, project) {
|
|
|
666
683
|
mutationCount: counts.mutationCount ?? 0
|
|
667
684
|
};
|
|
668
685
|
}
|
|
686
|
+
await project.loadSources();
|
|
687
|
+
const layout = (0, import_generate_layout.discoverDataLayout)(project, baseDir, config ? (0, import_node_path.resolve)(config) : void 0);
|
|
688
|
+
const inputHash = hashInputs(layout);
|
|
669
689
|
const modelNamespaces = layout.namespaces.filter(namespace => namespace.modelPath !== null);
|
|
670
690
|
const filesWithSchema = modelNamespaces.filter(namespace => (0, import_node_fs.readFileSync)(namespace.modelPath, "utf-8").includes("export const schema = table("));
|
|
671
691
|
const modelModules = modelNamespaces.map(namespace => ({
|
|
@@ -855,11 +875,18 @@ async function generateWithProject(options, project) {
|
|
|
855
875
|
ON_ZERO_GENERATED_DIR: generatedDir
|
|
856
876
|
}
|
|
857
877
|
});
|
|
878
|
+
const outputHashes = Object.fromEntries(Object.keys(generateCache).filter(filePath => filePath.startsWith(generatedDir)).map(filePath => [filePath, hash((0, import_node_fs.readFileSync)(filePath, "utf-8"))]));
|
|
879
|
+
Object.assign(generateCache, outputHashes);
|
|
858
880
|
} catch (err) {
|
|
859
881
|
if (!silent) console.error(`Error running after command: ${err}`);
|
|
860
882
|
}
|
|
861
883
|
}
|
|
862
884
|
generateCache.__generatorVersion = GENERATOR_CACHE_VERSION;
|
|
885
|
+
generateCache.__configPath = configPath;
|
|
886
|
+
generateCache.__layoutInputs = JSON.stringify({
|
|
887
|
+
sourceRoots: layout.sourceRoots,
|
|
888
|
+
metadataPaths: layout.metadataPaths
|
|
889
|
+
});
|
|
863
890
|
generateCache.__inputHash = inputHash;
|
|
864
891
|
generateCache.__counts = JSON.stringify({
|
|
865
892
|
modelCount: modelNamespaces.length,
|
|
@@ -902,14 +929,14 @@ ${event} ${path}`);
|
|
|
902
929
|
}, debounce);
|
|
903
930
|
};
|
|
904
931
|
const databaseDir = (0, import_node_path.resolve)((0, import_node_path.dirname)(baseDir), "database");
|
|
905
|
-
const project = await loadGeneratorProject(baseDir);
|
|
932
|
+
const project = await loadGeneratorProject(baseDir, false, options.tsconfig);
|
|
906
933
|
let layout;
|
|
907
934
|
try {
|
|
908
935
|
layout = (0, import_generate_layout.discoverDataLayout)(project, baseDir, options.config ? (0, import_node_path.resolve)(options.config) : void 0);
|
|
909
936
|
} finally {
|
|
910
937
|
await project.close();
|
|
911
938
|
}
|
|
912
|
-
const watcher = chokidar.watch([... /* @__PURE__ */new Set([...layout.sourceRoots, ...((0, import_node_fs.existsSync)(databaseDir) ? [databaseDir] : [])])], {
|
|
939
|
+
const watcher = chokidar.watch([... /* @__PURE__ */new Set([...layout.sourceRoots, ...(options.tsconfig ? [(0, import_node_path.resolve)(options.tsconfig)] : []), ...((0, import_node_fs.existsSync)(databaseDir) ? [databaseDir] : [])])], {
|
|
913
940
|
persistent: true,
|
|
914
941
|
ignoreInitial: true,
|
|
915
942
|
ignored: [generatedDir, /node_modules/]
|
|
@@ -50,14 +50,19 @@ var import_async = require("typescript/unstable/async");
|
|
|
50
50
|
var import_generate_helpers = require("./generate-helpers.native.js");
|
|
51
51
|
var import_generate_layout = require("./generate-layout.native.js");
|
|
52
52
|
var import_native_typescript = require("./native-typescript.native.js");
|
|
53
|
+
function _type_of(obj) {
|
|
54
|
+
"@swc/helpers - typeof";
|
|
55
|
+
|
|
56
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
57
|
+
}
|
|
53
58
|
var hash = function hash2(s) {
|
|
54
59
|
return (0, import_crypto.createHash)("sha256").update(s).digest("hex");
|
|
55
60
|
};
|
|
56
|
-
var GENERATOR_CACHE_VERSION = "
|
|
61
|
+
var GENERATOR_CACHE_VERSION = "10";
|
|
57
62
|
var isGeneratorSourceFile = function isGeneratorSourceFile2(name) {
|
|
58
63
|
return name.endsWith(".ts") && !name.endsWith(".d.ts") && !name.endsWith(".test.ts") && !name.endsWith(".spec.ts");
|
|
59
64
|
};
|
|
60
|
-
function hashInputTree(sourceRoots, generatedDir) {
|
|
65
|
+
function hashInputTree(sourceRoots, generatedDir, dependencyPaths) {
|
|
61
66
|
var parts = [];
|
|
62
67
|
var seen = /* @__PURE__ */new Set();
|
|
63
68
|
var walk = function walk1(dir) {
|
|
@@ -120,6 +125,30 @@ function hashInputTree(sourceRoots, generatedDir) {
|
|
|
120
125
|
}
|
|
121
126
|
}
|
|
122
127
|
}
|
|
128
|
+
var _iteratorNormalCompletion1 = true,
|
|
129
|
+
_didIteratorError1 = false,
|
|
130
|
+
_iteratorError1 = void 0;
|
|
131
|
+
try {
|
|
132
|
+
for (var _iterator1 = dependencyPaths[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
133
|
+
var path = _step1.value;
|
|
134
|
+
if (seen.has(path) || path.startsWith(`${generatedDir}/`) || !(0, import_fs.existsSync)(path)) continue;
|
|
135
|
+
seen.add(path);
|
|
136
|
+
parts.push(`${path}\0${(0, import_fs.readFileSync)(path, "utf-8")}`);
|
|
137
|
+
}
|
|
138
|
+
} catch (err) {
|
|
139
|
+
_didIteratorError1 = true;
|
|
140
|
+
_iteratorError1 = err;
|
|
141
|
+
} finally {
|
|
142
|
+
try {
|
|
143
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
144
|
+
_iterator1.return();
|
|
145
|
+
}
|
|
146
|
+
} finally {
|
|
147
|
+
if (_didIteratorError1) {
|
|
148
|
+
throw _iteratorError1;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
123
152
|
return hash(parts.join("\0"));
|
|
124
153
|
}
|
|
125
154
|
var generateCache = {};
|
|
@@ -515,12 +544,13 @@ async function tsTypeToValibot(project, type) {
|
|
|
515
544
|
var seen = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : /* @__PURE__ */new Set();
|
|
516
545
|
var checker = project.checker;
|
|
517
546
|
var flags = type.flags;
|
|
547
|
+
var path = seen;
|
|
518
548
|
if (flags & (import_async.TypeFlags.Object | import_async.TypeFlags.Intersection)) {
|
|
519
549
|
if (seen.has(type.id)) return "v.unknown()";
|
|
520
|
-
seen.add(type.id);
|
|
550
|
+
path = new Set(seen).add(type.id);
|
|
521
551
|
}
|
|
522
552
|
var recurse = function recurse2(value) {
|
|
523
|
-
return tsTypeToValibot(project, value,
|
|
553
|
+
return tsTypeToValibot(project, value, path);
|
|
524
554
|
};
|
|
525
555
|
if (flags & import_async.TypeFlags.String) return "v.string()";
|
|
526
556
|
if (flags & import_async.TypeFlags.Number) return "v.number()";
|
|
@@ -819,12 +849,17 @@ function dataMembershipFromLayout(layout) {
|
|
|
819
849
|
};
|
|
820
850
|
}
|
|
821
851
|
async function loadGeneratorProject(baseDir) {
|
|
852
|
+
var deferSources = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false,
|
|
853
|
+
tsconfig = arguments.length > 2 ? arguments[2] : void 0;
|
|
822
854
|
var sourcePaths = (0, import_native_typescript.collectTypeScriptSourcePaths)([baseDir, (0, import_path.resolve)((0, import_path.dirname)(baseDir), "database")]);
|
|
823
|
-
return (0, import_native_typescript.createNativeTypeScriptProject)(baseDir, sourcePaths
|
|
855
|
+
return (0, import_native_typescript.createNativeTypeScriptProject)(baseDir, sourcePaths, {
|
|
856
|
+
deferSources,
|
|
857
|
+
tsconfig: tsconfig ? (0, import_path.resolve)(tsconfig) : void 0
|
|
858
|
+
});
|
|
824
859
|
}
|
|
825
860
|
async function deriveDataMembership(options) {
|
|
826
861
|
var baseDir = (0, import_path.resolve)(options.dir);
|
|
827
|
-
var project = await loadGeneratorProject(baseDir);
|
|
862
|
+
var project = await loadGeneratorProject(baseDir, false, options.tsconfig);
|
|
828
863
|
try {
|
|
829
864
|
var layout = (0, import_generate_layout.discoverDataLayout)(project, baseDir, options.config ? (0, import_path.resolve)(options.config) : void 0);
|
|
830
865
|
return dataMembershipFromLayout(layout);
|
|
@@ -834,7 +869,7 @@ async function deriveDataMembership(options) {
|
|
|
834
869
|
}
|
|
835
870
|
async function generateDrizzleSchemaInputFile(options) {
|
|
836
871
|
var baseDir = (0, import_path.resolve)(options.dir);
|
|
837
|
-
var project = await loadGeneratorProject(baseDir);
|
|
872
|
+
var project = await loadGeneratorProject(baseDir, false, options.tsconfig);
|
|
838
873
|
try {
|
|
839
874
|
return generateDrizzleSchemaInputFileWithProject(options, project);
|
|
840
875
|
} finally {
|
|
@@ -931,7 +966,7 @@ ${relations.map(function (relation) {
|
|
|
931
966
|
return ["// auto-generated from the on-zero data layout", `import { defineRelations } from 'drizzle-orm'`, `import * as schema from ${schemaImportPath}`, "", `export { ${tableNames.join(", ")} } from ${schemaImportPath}`, `export const relations = defineRelations(schema, (r) => ({`, ...relationEntries, `}))`, ""].join("\n");
|
|
932
967
|
}
|
|
933
968
|
async function generate(options) {
|
|
934
|
-
var project = await loadGeneratorProject((0, import_path.resolve)(options.dir));
|
|
969
|
+
var project = await loadGeneratorProject((0, import_path.resolve)(options.dir), true, options.tsconfig);
|
|
935
970
|
try {
|
|
936
971
|
return await generateWithProject(options, project);
|
|
937
972
|
} finally {
|
|
@@ -954,38 +989,50 @@ async function generateWithProject(options, project) {
|
|
|
954
989
|
});
|
|
955
990
|
}
|
|
956
991
|
loadCache();
|
|
957
|
-
var
|
|
958
|
-
var
|
|
959
|
-
|
|
960
|
-
|
|
992
|
+
var configPath = config ? (0, import_path.resolve)(config) : (0, import_path.resolve)(baseDir, "on-zero.config.ts");
|
|
993
|
+
var cachedInputs = null;
|
|
994
|
+
if (generateCache.__configPath === configPath) {
|
|
995
|
+
try {
|
|
996
|
+
var value = JSON.parse(generateCache.__layoutInputs || "null");
|
|
997
|
+
if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && "sourceRoots" in value && Array.isArray(value.sourceRoots) && value.sourceRoots.every(function (path) {
|
|
998
|
+
return typeof path === "string";
|
|
999
|
+
}) && "metadataPaths" in value && Array.isArray(value.metadataPaths) && value.metadataPaths.every(function (path) {
|
|
1000
|
+
return typeof path === "string";
|
|
1001
|
+
})) {
|
|
1002
|
+
cachedInputs = {
|
|
1003
|
+
sourceRoots: value.sourceRoots,
|
|
1004
|
+
metadataPaths: value.metadataPaths
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
} catch (unused) {}
|
|
1008
|
+
}
|
|
1009
|
+
var dependencyPaths = await project.sourceFilePaths();
|
|
1010
|
+
var hashInputs = function hashInputs2(layout2) {
|
|
1011
|
+
var metadataHash = hash(layout2.metadataPaths.map(function (path) {
|
|
1012
|
+
return `${path}\0${(0, import_fs.readFileSync)(path, "utf8")}`;
|
|
1013
|
+
}).join("\0"));
|
|
1014
|
+
return hash(`${hashInputTree(layout2.sourceRoots, generatedDir, dependencyPaths)}\0${metadataHash}\0${externalZeroConfig}\0${project.configurationKey}`);
|
|
1015
|
+
};
|
|
961
1016
|
var databaseSchemaPath = (0, import_path.resolve)((0, import_path.dirname)(baseDir), "database/schema.ts");
|
|
962
1017
|
var needsDrizzleSchema = (0, import_fs.existsSync)(databaseSchemaPath);
|
|
963
1018
|
var externalZeroConfigPath = (0, import_path.resolve)((0, import_path.dirname)(databaseSchemaPath), "drizzle-zero.config.ts");
|
|
964
1019
|
var externalZeroConfig = (0, import_fs.existsSync)(externalZeroConfigPath) ? (0, import_fs.readFileSync)(externalZeroConfigPath, "utf8") : null;
|
|
965
1020
|
var needsSqliteZeroSchema = needsDrizzleSchema && externalZeroConfig === null;
|
|
966
|
-
var
|
|
967
|
-
if (
|
|
1021
|
+
var cachedInputHash = null;
|
|
1022
|
+
if (cachedInputs) {
|
|
1023
|
+
try {
|
|
1024
|
+
cachedInputHash = hashInputs(cachedInputs);
|
|
1025
|
+
} catch (unused) {}
|
|
1026
|
+
}
|
|
1027
|
+
if (!force && generateCache.__generatorVersion === GENERATOR_CACHE_VERSION && generateCache.__inputHash === cachedInputHash &&
|
|
968
1028
|
// the input hash deliberately skips the generated directory, so it cannot
|
|
969
1029
|
// notice that the outputs themselves moved. existence is not correctness
|
|
970
1030
|
// either: a checkout, merge or revert leaves every file present and stale.
|
|
971
1031
|
// confirm the bytes on disk still match what the cache says it wrote there
|
|
972
1032
|
// before skipping the build, or the fast path serves someone else's output.
|
|
973
1033
|
//
|
|
974
|
-
//
|
|
975
|
-
//
|
|
976
|
-
// holds the formatted ones. soot does exactly that, `on-zero generate &&
|
|
977
|
-
// generate-instance-tables && oxfmt src/data/generated/`, and the number is
|
|
978
|
-
// already taken: 2.50s median before, 3.69s after, four warm runs each in
|
|
979
|
-
// one checkout with only the pin swapped, so about 1.2 seconds or 47
|
|
980
|
-
// percent on this step. the full three-command script went 2.65s to 3.14s
|
|
981
|
-
// with a spread that swallows most of it.
|
|
982
|
-
//
|
|
983
|
-
// the shape matters more than the number. this is not a cache that hits
|
|
984
|
-
// less often, it is a cache that never hits, so the cost does not degrade
|
|
985
|
-
// gracefully and grows with the generated output rather than staying at
|
|
986
|
-
// 1.2s. correct and slower beats fast and stale, which is why it is written
|
|
987
|
-
// this way, but if generate time ever becomes the complaint, record the
|
|
988
|
-
// hash after the consumer's formatter runs rather than weakening this.
|
|
1034
|
+
// successful after commands record their final output hashes. formatting
|
|
1035
|
+
// therefore keeps the fast path without trusting stale generated bytes.
|
|
989
1036
|
Object.entries(generateCache).every(function (param) {
|
|
990
1037
|
var [cachedPath, cachedHash] = param;
|
|
991
1038
|
if (!cachedPath.startsWith(generatedDir)) return true;
|
|
@@ -1008,6 +1055,9 @@ async function generateWithProject(options, project) {
|
|
|
1008
1055
|
mutationCount: (_counts_mutationCount = counts.mutationCount) !== null && _counts_mutationCount !== void 0 ? _counts_mutationCount : 0
|
|
1009
1056
|
};
|
|
1010
1057
|
}
|
|
1058
|
+
await project.loadSources();
|
|
1059
|
+
var layout = (0, import_generate_layout.discoverDataLayout)(project, baseDir, config ? (0, import_path.resolve)(config) : void 0);
|
|
1060
|
+
var inputHash = hashInputs(layout);
|
|
1011
1061
|
var modelNamespaces = layout.namespaces.filter(function (namespace2) {
|
|
1012
1062
|
return namespace2.modelPath !== null;
|
|
1013
1063
|
});
|
|
@@ -1356,11 +1406,22 @@ async function generateWithProject(options, project) {
|
|
|
1356
1406
|
ON_ZERO_GENERATED_DIR: generatedDir
|
|
1357
1407
|
}
|
|
1358
1408
|
});
|
|
1409
|
+
var outputHashes = Object.fromEntries(Object.keys(generateCache).filter(function (filePath2) {
|
|
1410
|
+
return filePath2.startsWith(generatedDir);
|
|
1411
|
+
}).map(function (filePath2) {
|
|
1412
|
+
return [filePath2, hash((0, import_fs.readFileSync)(filePath2, "utf-8"))];
|
|
1413
|
+
}));
|
|
1414
|
+
Object.assign(generateCache, outputHashes);
|
|
1359
1415
|
} catch (err) {
|
|
1360
1416
|
if (!silent) console.error(`Error running after command: ${err}`);
|
|
1361
1417
|
}
|
|
1362
1418
|
}
|
|
1363
1419
|
generateCache.__generatorVersion = GENERATOR_CACHE_VERSION;
|
|
1420
|
+
generateCache.__configPath = configPath;
|
|
1421
|
+
generateCache.__layoutInputs = JSON.stringify({
|
|
1422
|
+
sourceRoots: layout.sourceRoots,
|
|
1423
|
+
metadataPaths: layout.metadataPaths
|
|
1424
|
+
});
|
|
1364
1425
|
generateCache.__inputHash = inputHash;
|
|
1365
1426
|
generateCache.__counts = JSON.stringify({
|
|
1366
1427
|
modelCount: modelNamespaces.length,
|
|
@@ -1403,14 +1464,14 @@ ${event} ${path}`);
|
|
|
1403
1464
|
}, debounce);
|
|
1404
1465
|
};
|
|
1405
1466
|
var databaseDir = (0, import_path.resolve)((0, import_path.dirname)(baseDir), "database");
|
|
1406
|
-
var project = await loadGeneratorProject(baseDir);
|
|
1467
|
+
var project = await loadGeneratorProject(baseDir, false, options.tsconfig);
|
|
1407
1468
|
var layout;
|
|
1408
1469
|
try {
|
|
1409
1470
|
layout = (0, import_generate_layout.discoverDataLayout)(project, baseDir, options.config ? (0, import_path.resolve)(options.config) : void 0);
|
|
1410
1471
|
} finally {
|
|
1411
1472
|
await project.close();
|
|
1412
1473
|
}
|
|
1413
|
-
var watcher = chokidar.watch([... /* @__PURE__ */new Set([...layout.sourceRoots, ...((0, import_fs.existsSync)(databaseDir) ? [databaseDir] : [])])], {
|
|
1474
|
+
var watcher = chokidar.watch([... /* @__PURE__ */new Set([...layout.sourceRoots, ...(options.tsconfig ? [(0, import_path.resolve)(options.tsconfig)] : []), ...((0, import_fs.existsSync)(databaseDir) ? [databaseDir] : [])])], {
|
|
1414
1475
|
persistent: true,
|
|
1415
1476
|
ignoreInitial: true,
|
|
1416
1477
|
ignored: [generatedDir, /node_modules/]
|