@mono-lit/utility 0.0.1 → 0.0.3
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/LICENSE.md +54 -54
- package/README.md +156 -156
- package/dist/{app-roots-BJsIxzjk.d.ts → app-roots-DK41xMWj.d.ts} +1 -2
- package/dist/config-node.d.ts +134 -188
- package/dist/config-node.js +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/{create-config-D3m6xTaQ.d.ts → create-config-B8IhX4ht.d.ts} +5 -3
- package/dist/fetching.d.ts +51 -46
- package/dist/fetching.js +163 -15
- package/dist/{index-C2hZeNkq.d.ts → index-BAy6tbOG.d.ts} +12 -6
- package/dist/{index-ClrZbU7n.d.ts → index-DYlzhHq7.d.ts} +83 -87
- package/dist/index.d.ts +3 -7
- package/dist/index.js +5 -3
- package/dist/{merge-file-C5nzi_MY.d.ts → merge-file-CLc3wxY4.d.ts} +5 -28
- package/dist/{mock-db-5mJTObSC.js → mock-db-4tTWrF-P.js} +12 -12
- package/dist/mock-db.d.ts +1 -1
- package/dist/mock-db.js +1 -1
- package/dist/mono-db.d.ts +1 -1
- package/dist/mono-db.js +115 -108
- package/dist/mono-prepare.d.ts +1 -1
- package/dist/mono-prepare.js +3 -2
- package/dist/mono-skills.d.ts +1 -1
- package/dist/mono-skills.js +39 -32
- package/dist/nuxt-layers.d.ts +4 -2
- package/dist/nuxt-runtime.d.ts +4 -5
- package/dist/nuxt-runtime.js +1 -1
- package/dist/nuxt.d.ts +42 -38
- package/dist/nuxt.js +153 -6
- package/dist/{runtime-C_IWNrAG.js → runtime-vs7U9Ed4.js} +394 -157
- package/dist/runtime.d.ts +68 -133
- package/dist/runtime.js +2 -2
- package/dist/{session-Bk985AIM.js → session-Bcig-rPi.js} +4 -4
- package/dist/{universal-B2eD9xho.d.ts → universal-BR0O7Qwk.d.ts} +8 -46
- package/dist/{universal-BNTo_83u.js → universal-DIVEzCvN.js} +3 -2
- package/dist/vite.d.ts +44 -41
- package/package.json +11 -15
package/dist/config-node.js
CHANGED
|
@@ -2,6 +2,6 @@ import { a as missingPathMessage, c as resolveAppRoots, i as linkedAppRoots, n a
|
|
|
2
2
|
import { n as loadMonoConfig, t as getMonoConfig } from "./config-node-UzJrXg0Z.js";
|
|
3
3
|
import { a as extractTemplate, c as monoConfigFileFor, d as resolveFederatedRoots, f as stripCommentsSafe, i as extractSkill, l as monoMissingApps, n as extractConfig, o as formatMissingApps, r as extractConfigName, s as monoAlias, t as assertAppSources, u as monoStubAliases } from "./mono-alias-DNDm-jB_.js";
|
|
4
4
|
import { a as monoTsconfigPaths, i as buildMonoTsconfig, n as MONO_DIR, o as runMonoPrepare, r as MONO_TSCONFIG_REF, t as MONO_APPS_DIR } from "./mono-tsconfig-D2qRL9_R.js";
|
|
5
|
-
import { A as BASE_ARGS, B as refPatterns, C as commitAndPush, D as repoDir, E as readRepoFile, F as parseHeadSha, G as SKILLS_DEFAULTS, H as tokenRemote, I as parseLsRemote, J as loadSkillsEnv, K as isGenericAppName, L as parseSymref, M as firstFatal, N as gitEnv, O as resolveRemote, P as isNonFastForward, R as redactUrl, S as SkillsAccessError, T as listRepoFiles, U as ALLOWED_FLAGS, V as runGit, W as GENERIC_APP_NAMES, Y as resolveSkillTarget, _ as stagingRoot, a as applyPlan, b as resolveAppId, c as chunkConversation, d as REQUIRED_FILES, f as cacheDir, g as removeSession, h as moveToFailed, i as runSearch, j as classifyGitFailure, k as skillsRoot, l as redact, m as loadStagedSession, n as runCheck, o as buildSavePlan, p as listSessions, q as loadSkillConfig, r as runRead, s as runSave, t as runSessionShow, u as redactBuffer, v as validateStagedSession, w as ensureRepo, x as detectActor, y as normalizeAppId, z as refDirCandidates } from "./session-
|
|
5
|
+
import { A as BASE_ARGS, B as refPatterns, C as commitAndPush, D as repoDir, E as readRepoFile, F as parseHeadSha, G as SKILLS_DEFAULTS, H as tokenRemote, I as parseLsRemote, J as loadSkillsEnv, K as isGenericAppName, L as parseSymref, M as firstFatal, N as gitEnv, O as resolveRemote, P as isNonFastForward, R as redactUrl, S as SkillsAccessError, T as listRepoFiles, U as ALLOWED_FLAGS, V as runGit, W as GENERIC_APP_NAMES, Y as resolveSkillTarget, _ as stagingRoot, a as applyPlan, b as resolveAppId, c as chunkConversation, d as REQUIRED_FILES, f as cacheDir, g as removeSession, h as moveToFailed, i as runSearch, j as classifyGitFailure, k as skillsRoot, l as redact, m as loadStagedSession, n as runCheck, o as buildSavePlan, p as listSessions, q as loadSkillConfig, r as runRead, s as runSave, t as runSessionShow, u as redactBuffer, v as validateStagedSession, w as ensureRepo, x as detectActor, y as normalizeAppId, z as refDirCandidates } from "./session-Bcig-rPi.js";
|
|
6
6
|
|
|
7
7
|
export { ALLOWED_FLAGS, BASE_ARGS, GENERIC_APP_NAMES, MONO_APPS_DIR, MONO_DIR, MONO_TSCONFIG_REF, REQUIRED_FILES, SKILLS_DEFAULTS, SkillsAccessError, appRootDirs, applyPlan, assertAppSources, buildMonoTsconfig, buildSavePlan, cacheDir, chunkConversation, classifyGitFailure, commitAndPush, detectActor, ensureRepo, extractConfig, extractConfigName, extractSkill, extractTemplate, firstFatal, formatMissingApps, getMonoConfig, gitEnv, hasUrl, isGenericAppName, isMissingPathError, isNonFastForward, linkedAppRoots, listRepoFiles, listSessions, loadMonoConfig, loadSkillConfig, loadSkillsEnv, loadStagedSession, missingPathMessage, monoAlias, monoConfigFileFor, monoMissingApps, monoStubAliases, monoTsconfigPaths, moveToFailed, normalizeAppId, parseHeadSha, parseLsRemote, parseSymref, pathAppRoots, readRepoFile, redact, redactBuffer, redactUrl, refDirCandidates, refPatterns, removeSession, repoDir, resetAppPathWarnings, resolveAppId, resolveAppRoots, resolveFederatedRoots, resolveRemote, resolveSkillTarget, runCheck, runGit, runMonoPrepare, runRead, runSave, runSearch, runSessionShow, skillsRoot, stagingRoot, stripCommentsSafe, tokenRemote, validateStagedSession };
|
package/dist/config.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as resolveEnv, C as MonoSyncTransport, D as dedupeBy, E as SidebarMenu, M as resolveExtendsEcosystems, N as resolveMonoConfig, O as dedupeConfigArrays, P as srcDirForType, S as MonoSkillConfig, T as Permission, _ as MonoMergeableKey, a as MonoAppConfig, b as MonoOdataSource, c as MonoConfig, d as MonoConfigExtendsOptions, f as MonoConfigLayer, g as MonoJwtEntry, h as MonoJwtConfig, i as MonoApiEntry, j as resolveExtendsAppNames, k as defineConfig, l as MonoConfigExtends, m as MonoFetchingConfig, n as JWTCompleteTokenTypes, o as MonoAppType, p as MonoEnvConfig, r as MONO_SRC_DIR, s as MonoAuthConfig, t as DefaultJWTTokenTypes, u as MonoConfigExtendsEntry, v as MonoMockDbConfig, w as MonoTemplate, x as MonoRefreshRequestConfig, y as MonoMockEntity } from "./create-config-
|
|
1
|
+
import { A as resolveEnv, C as MonoSyncTransport, D as dedupeBy, E as SidebarMenu, M as resolveExtendsEcosystems, N as resolveMonoConfig, O as dedupeConfigArrays, P as srcDirForType, S as MonoSkillConfig, T as Permission, _ as MonoMergeableKey, a as MonoAppConfig, b as MonoOdataSource, c as MonoConfig, d as MonoConfigExtendsOptions, f as MonoConfigLayer, g as MonoJwtEntry, h as MonoJwtConfig, i as MonoApiEntry, j as resolveExtendsAppNames, k as defineConfig, l as MonoConfigExtends, m as MonoFetchingConfig, n as JWTCompleteTokenTypes, o as MonoAppType, p as MonoEnvConfig, r as MONO_SRC_DIR, s as MonoAuthConfig, t as DefaultJWTTokenTypes, u as MonoConfigExtendsEntry, v as MonoMockDbConfig, w as MonoTemplate, x as MonoRefreshRequestConfig, y as MonoMockEntity } from "./create-config-B8IhX4ht.js";
|
|
2
2
|
export { DefaultJWTTokenTypes, JWTCompleteTokenTypes, MONO_SRC_DIR, MonoApiEntry, MonoAppConfig, MonoAppType, MonoAuthConfig, MonoConfig, MonoConfigExtends, MonoConfigExtendsEntry, MonoConfigExtendsOptions, MonoConfigLayer, MonoEnvConfig, MonoFetchingConfig, MonoJwtConfig, MonoJwtEntry, MonoMergeableKey, MonoMockDbConfig, MonoMockEntity, MonoOdataSource, MonoRefreshRequestConfig, MonoSkillConfig, MonoSyncTransport, MonoTemplate, Permission, SidebarMenu, dedupeBy, dedupeConfigArrays, defineConfig, resolveEnv, resolveExtendsAppNames, resolveExtendsEcosystems, resolveMonoConfig, srcDirForType };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { VNode } from "vue";
|
|
2
|
-
|
|
3
2
|
//#region src/composables/create-config.d.ts
|
|
4
3
|
interface Permission {
|
|
5
4
|
permId: number;
|
|
@@ -281,7 +280,8 @@ interface MonoRefreshRequestConfig {
|
|
|
281
280
|
/** Defaults to whatever `cookie[]` declares for `name`. */
|
|
282
281
|
splitCookie?: boolean;
|
|
283
282
|
fetchParams: {
|
|
284
|
-
url: string;
|
|
283
|
+
url: string;
|
|
284
|
+
/** Any `RequestInit` field, plus `baseUrl` (defaults to the resolved REST base url). */
|
|
285
285
|
options?: Record<string, any> & {
|
|
286
286
|
baseUrl?: string;
|
|
287
287
|
};
|
|
@@ -527,7 +527,9 @@ interface MonoMockDbConfig {
|
|
|
527
527
|
* layers rather than override (see {@link deepMergeLayer}).
|
|
528
528
|
*/
|
|
529
529
|
type MonoEnvConfig = {
|
|
530
|
-
/** Shared values merged under every environment. */
|
|
530
|
+
/** Shared values merged under every environment. */
|
|
531
|
+
default?: Record<string, string | number | boolean>;
|
|
532
|
+
/** One block per `NODE_ENV` value, e.g. `development` / `production`. */
|
|
531
533
|
[nodeEnv: string]: Record<string, string | number | boolean> | undefined;
|
|
532
534
|
};
|
|
533
535
|
/**
|
package/dist/fetching.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { a as monoMockDb, n as MonoMockRequest, o as resetMonoMockDb, r as MonoMockResponse, t as MonoMockDb } from "./index-
|
|
2
|
-
import {
|
|
1
|
+
import { a as monoMockDb, n as MonoMockRequest, o as resetMonoMockDb, r as MonoMockResponse, t as MonoMockDb } from "./index-BAy6tbOG.js";
|
|
2
|
+
import { B as NormalFetchOptions, H as OdataFetchTypes, U as TanstackFetchOptions, Y as UseOdataStaticOpts, _ as getPrefetchBridge, a as TryCatchDatasourceParams, d as promiseWrapper, g as MonoPrefetchRequest, h as MonoPrefetchBridge, i as OdataFetchUniqueTypes, n as FetchOverrides, o as createFetcher, r as LoadChunkStoreArgs } from "./index-DYlzhHq7.js";
|
|
3
3
|
import DataSource from "devextreme/data/data_source";
|
|
4
4
|
import CustomStore from "devextreme/data/custom_store";
|
|
5
5
|
import ODataStore from "devextreme/data/odata/store";
|
|
6
|
-
|
|
7
6
|
//#region pkg/wrapper-fetching.d.ts
|
|
8
7
|
type FetchError = {
|
|
9
8
|
message: string;
|
|
@@ -52,7 +51,7 @@ type MonoNormalFetchParams = NormalFetchOptions & {
|
|
|
52
51
|
tanstack?: TanstackFetchOptions;
|
|
53
52
|
};
|
|
54
53
|
/** Options for `monoFetch(url, { tanstack })` / `monoOdataFetch({ tanstack })`. */
|
|
55
|
-
type MonoTanstackFetchOptions = TanstackFetchOptions;
|
|
54
|
+
export type MonoTanstackFetchOptions = TanstackFetchOptions;
|
|
56
55
|
type MonoCreateFetcherParams = Omit<OdataFetchTypes, 'source'> & {
|
|
57
56
|
source?: OdataFetchTypes['source'];
|
|
58
57
|
} & {
|
|
@@ -179,6 +178,8 @@ declare function getFetchingRuntime(configBaseUrl?: string): {
|
|
|
179
178
|
token: any;
|
|
180
179
|
};
|
|
181
180
|
declare const useCreateFetcher: <T>(base: MonoCreateFetcherParams) => {
|
|
181
|
+
prefetch: (_option?: FetchOverrides) => MonoPrefetchDescriptor;
|
|
182
|
+
prefetchLoad: (_loadOptions?: Record<string, unknown>, _option?: FetchOverrides) => MonoPrefetchDescriptor;
|
|
182
183
|
response(option?: any): FetchResult<T>;
|
|
183
184
|
};
|
|
184
185
|
declare function useTryCatchDatasource<T>(opt: TryCatchDatasourceParams<T>): Promise<T>;
|
|
@@ -192,48 +193,52 @@ declare const createStaticDataSource: <T extends Record<string, any>>(opt: UseOd
|
|
|
192
193
|
response: any;
|
|
193
194
|
};
|
|
194
195
|
}>;
|
|
195
|
-
declare const
|
|
196
|
-
url,
|
|
197
|
-
options,
|
|
198
|
-
type,
|
|
199
|
-
params,
|
|
200
|
-
notif,
|
|
201
|
-
headers,
|
|
202
|
-
selfProxy,
|
|
203
|
-
method,
|
|
204
|
-
force,
|
|
205
|
-
allowZero,
|
|
206
|
-
cache,
|
|
207
|
-
override,
|
|
208
|
-
baseUrl,
|
|
209
|
-
configBaseUrl,
|
|
210
|
-
source,
|
|
211
|
-
token,
|
|
212
|
-
payload,
|
|
213
|
-
...rest
|
|
214
|
-
}: MonoOdataFetchParams) => FetchResult<T>;
|
|
215
|
-
declare const useFetchOdataUnique: <T = any>({
|
|
216
|
-
url,
|
|
217
|
-
options,
|
|
218
|
-
type,
|
|
219
|
-
params,
|
|
220
|
-
notif,
|
|
221
|
-
headers,
|
|
222
|
-
selfProxy,
|
|
223
|
-
method,
|
|
224
|
-
force,
|
|
225
|
-
allowZero,
|
|
226
|
-
cache,
|
|
227
|
-
override,
|
|
228
|
-
baseUrl,
|
|
229
|
-
configBaseUrl,
|
|
230
|
-
source,
|
|
231
|
-
token,
|
|
232
|
-
unique,
|
|
233
|
-
payload,
|
|
234
|
-
...rest
|
|
235
|
-
}: MonoOdataUniqueParams<T>) => FetchResult<T>;
|
|
196
|
+
declare const useFetchOdataUnique: <T = any>({ url, options, type, params, notif, headers, selfProxy, method, force, allowZero, cache, override, baseUrl, configBaseUrl, source, token, unique, payload, ...rest }: MonoOdataUniqueParams<T>) => FetchResult<T>;
|
|
236
197
|
declare function useMyFetch<T = any>(url: string, opt: MonoNormalFetchParams): Promise<any>;
|
|
237
198
|
declare const loadChuckStores: <T>(opt: LoadChunkStoreArgs<T>) => Promise<T[]>;
|
|
199
|
+
/** Marks a `definePrefetch` descriptor (@mono-lit/nuxt-pre-fetch's protocol; no import needed). */
|
|
200
|
+
declare const PREFETCH_DESCRIPTOR: unique symbol;
|
|
201
|
+
/** A call described for `definePrefetch` (`monoFetch.prefetch`, …): emits the request(s) it would send. */
|
|
202
|
+
export interface MonoPrefetchDescriptor {
|
|
203
|
+
readonly [PREFETCH_DESCRIPTOR]: true;
|
|
204
|
+
collect: (context: unknown, emit: (request: MonoPrefetchRequest) => void) => Promise<void>;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* `definePrefetch` twin of `monoFetch(url, opt)`: the same arguments, nothing sent — describes
|
|
208
|
+
* the GET the browser's call will send (base url, headers and auth from `fetching` config).
|
|
209
|
+
*/
|
|
210
|
+
declare function prefetchMonoFetch(url: string, opt?: MonoNormalFetchParams): MonoPrefetchDescriptor;
|
|
211
|
+
/**
|
|
212
|
+
* `definePrefetch` twin of `monoFetchOdata(params)`: runs the same call in capture mode —
|
|
213
|
+
* the store builds exactly the request the browser will send (`data`: what the call loads;
|
|
214
|
+
* `datasource`: the first page a bound widget loads), nothing is fetched.
|
|
215
|
+
*/
|
|
216
|
+
declare function prefetchMonoFetchOdata(params: MonoOdataFetchParams): MonoPrefetchDescriptor;
|
|
217
|
+
/** `monoFetch` with its `definePrefetch` twin: `monoFetch.prefetch(url, opt)`. */
|
|
218
|
+
declare const monoFetch: typeof useMyFetch & {
|
|
219
|
+
prefetch: typeof prefetchMonoFetch;
|
|
220
|
+
};
|
|
221
|
+
/** `monoFetchOdata` / `monoOdataFetch` with `.prefetch(params)`. */
|
|
222
|
+
declare const monoFetchOdata: (<T = any>({ url, options, type, params, notif, headers, selfProxy, method, force, allowZero, cache, override, baseUrl, configBaseUrl, source, token, payload, ...rest }: MonoOdataFetchParams) => FetchResult<T>) & {
|
|
223
|
+
prefetch: typeof prefetchMonoFetchOdata;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Installs the `prefetch` host (e.g. `useNuxtApp().$nuxtPreFetch` from @mono-lit/nuxt-pre-fetch;
|
|
227
|
+
* `@mono-lit/utility/nuxt` does it for you). REST calls use it here; OData stores use it through
|
|
228
|
+
* the data layer when it supports it (`@mono-lit/data`'s `setPrefetchProvider`, detected like
|
|
229
|
+
* `tanstackRun`). `null` removes it.
|
|
230
|
+
*/
|
|
231
|
+
declare function monoSetPrefetchBridge(next: MonoPrefetchBridge | null): void;
|
|
232
|
+
/**
|
|
233
|
+
* Inside `definePrefetch(pattern, ctx => …)`: what the browser's `monoState()` would hold for
|
|
234
|
+
* this request — the claims of every `jwt` entry of `mono.config` (decoded from the page
|
|
235
|
+
* request's cookies; split cookies joined) and a cookie reader that understands `split`.
|
|
236
|
+
*/
|
|
237
|
+
declare function monoPrefetchContext(context: {
|
|
238
|
+
cookies?: Record<string, string>;
|
|
239
|
+
}): {
|
|
240
|
+
jwt: Record<string, Record<string, any>>;
|
|
241
|
+
cookie: (name: string, split?: boolean) => string | undefined;
|
|
242
|
+
};
|
|
238
243
|
//#endregion
|
|
239
|
-
export { type MonoMockDb, type MonoMockRequest, type MonoMockResponse,
|
|
244
|
+
export { type MonoMockDb, type MonoMockRequest, type MonoMockResponse, type MonoPrefetchBridge, type MonoPrefetchRequest, createFetcher, configureFetching as monoConfigureFetching, useCreateFetcher as monoCreateFetcher, monoFetch, monoFetchOdata, monoFetchOdata as monoOdataFetch, useFetchOdataUnique as monoFetchOdataUnique, useFetchOdataUnique as monoOdataFetchUnique, getFetchingRuntime as monoFetchingRuntime, loadChuckStores as monoLoadChuckStores, monoMockDb, getODataBaseUrl as monoOdataBaseUrl, getODataSource as monoOdataSource, getPrefetchBridge as monoPrefetchBridge, monoPrefetchContext, getRequestToken as monoRequestToken, resetFetchingConfig as monoResetFetchingConfig, getRestBaseUrl as monoRestBaseUrl, monoSetPrefetchBridge, createStaticDataSource as monoStaticDataSource, useTryCatchDatasource as monoTryCatchDatasource, promiseWrapper, resetMonoMockDb };
|
package/dist/fetching.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as monoCookie } from "./universal-
|
|
1
|
+
import { D as monoState, O as monoStatePatch, T as monoConfig, a as createUniqueFetcher, c as tryCatchDatasource, d as PREFETCH_SUPPORT, f as getPrefetchBridge, h as createStaticDatasource, i as createFetcher, l as useFetchOData, o as loadChuckStore, p as setPrefetchBridge, s as promiseWrapper, u as useNormalFetch } from "./runtime-vs7U9Ed4.js";
|
|
2
|
+
import { t as monoCookie, u as decodeJwt } from "./universal-DIVEzCvN.js";
|
|
3
3
|
import { i as matchMockRoute } from "./generate-CJ7MtcDd.js";
|
|
4
|
-
import { c as executeQuery, f as parseQuery, l as parseExpand, n as monoMockDb, r as resetMonoMockDb } from "./mock-db-
|
|
4
|
+
import { c as executeQuery, f as parseQuery, l as parseExpand, n as monoMockDb, r as resetMonoMockDb } from "./mock-db-4tTWrF-P.js";
|
|
5
5
|
import * as monoDevextremeModule from "@mono-lit/devextreme";
|
|
6
6
|
import { CustomStore, DataSource, ODataStore } from "@mono-lit/devextreme";
|
|
7
7
|
|
|
@@ -713,23 +713,60 @@ function getFetchingRuntime(configBaseUrl) {
|
|
|
713
713
|
const useCreateFetcher = (base) => {
|
|
714
714
|
const { configBaseUrl, ...rest } = base;
|
|
715
715
|
const mockRoute = resolveMockRoute(configBaseUrl, base.url);
|
|
716
|
-
if (mockRoute) return {
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
716
|
+
if (mockRoute) return {
|
|
717
|
+
prefetch: (_option) => describePrefetch(() => {}),
|
|
718
|
+
prefetchLoad: (_loadOptions, _option) => describePrefetch(() => {}),
|
|
719
|
+
async response(option) {
|
|
720
|
+
return await serveFromMock(mockRoute, {
|
|
721
|
+
type: option?.type ?? base.type ?? "datasource",
|
|
722
|
+
method: option?.method ?? base.method,
|
|
723
|
+
params: option?.params ?? base.params,
|
|
724
|
+
payload: option?.payload ?? base.payload,
|
|
725
|
+
options: option?.options ?? base.options
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
const resolved = (overrides = {}) => createFetcher({
|
|
726
730
|
...authArgs(configBaseUrl),
|
|
727
731
|
...rest,
|
|
728
732
|
token: getRequestToken(base.token),
|
|
729
733
|
notif: resolveNotif(Boolean(base.notif)),
|
|
730
734
|
baseUrl: getODataBaseUrl(configBaseUrl, base.baseUrl),
|
|
731
|
-
source: getODataSource(configBaseUrl, base.source)
|
|
735
|
+
source: getODataSource(configBaseUrl, base.source),
|
|
736
|
+
...overrides
|
|
732
737
|
});
|
|
738
|
+
let fetcher;
|
|
739
|
+
/** The same fetcher in capture mode (`definePrefetch` twins): nothing is sent, no token is read. */
|
|
740
|
+
const capturing = (emit, load) => createFetcher({
|
|
741
|
+
...authArgs(configBaseUrl),
|
|
742
|
+
...rest,
|
|
743
|
+
token: PREFETCH_CAPTURE_TOKEN,
|
|
744
|
+
baseUrl: getODataBaseUrl(configBaseUrl, base.baseUrl),
|
|
745
|
+
source: getODataSource(configBaseUrl, base.source),
|
|
746
|
+
__capture: {
|
|
747
|
+
emit,
|
|
748
|
+
auth: prefetchAuthHint(),
|
|
749
|
+
...load ? { load } : {}
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
return {
|
|
753
|
+
response: (option) => (fetcher ??= resolved()).response(option),
|
|
754
|
+
/**
|
|
755
|
+
* `definePrefetch` twin of `.response(option)`: describes the first load the browser's
|
|
756
|
+
* `.response(option)` (and the widget bound to it) will send, without sending anything.
|
|
757
|
+
*/
|
|
758
|
+
prefetch: (option) => describeOData(configBaseUrl, base.source, async (emit) => {
|
|
759
|
+
await capturing(emit).response(option);
|
|
760
|
+
}),
|
|
761
|
+
/**
|
|
762
|
+
* `definePrefetch` twin of `(await .response(option)).dataSource.store().load(loadOptions)`:
|
|
763
|
+
* describes ONE store load with exactly these load options (e.g. a session cache that keeps
|
|
764
|
+
* the store and loads it per query). `loadOptions` as DevExtreme's `store.load()` takes them.
|
|
765
|
+
*/
|
|
766
|
+
prefetchLoad: (loadOptions = {}, option) => describeOData(configBaseUrl, base.source, async (emit) => {
|
|
767
|
+
await capturing(emit, loadOptions).response(option);
|
|
768
|
+
})
|
|
769
|
+
};
|
|
733
770
|
};
|
|
734
771
|
function useTryCatchDatasource(opt) {
|
|
735
772
|
return tryCatchDatasource({
|
|
@@ -862,6 +899,117 @@ async function useMyFetch(url, opt) {
|
|
|
862
899
|
const loadChuckStores = async (opt) => {
|
|
863
900
|
return await loadChuckStore(opt);
|
|
864
901
|
};
|
|
902
|
+
/** Marks a `definePrefetch` descriptor (@mono-lit/nuxt-pre-fetch's protocol; no import needed). */
|
|
903
|
+
const PREFETCH_DESCRIPTOR = Symbol.for("nuxt-pre-fetch.descriptor");
|
|
904
|
+
/** Stands in for the token while a call is described (it never leaves the server). */
|
|
905
|
+
const PREFETCH_CAPTURE_TOKEN = "mono-prefetch-capture";
|
|
906
|
+
function describePrefetch(run) {
|
|
907
|
+
return {
|
|
908
|
+
[PREFETCH_DESCRIPTOR]: true,
|
|
909
|
+
collect: async (_context, emit) => {
|
|
910
|
+
await run(emit);
|
|
911
|
+
}
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* An OData twin. Describing an OData call on the server needs a data layer that builds its exact
|
|
916
|
+
* request there (`@mono-lit/data`, whose stores carry `Symbol.for('mono.prefetch')`). With plain
|
|
917
|
+
* DevExtreme stores (`@mono-lit/devextreme`) the twin describes nothing — no store is built, no
|
|
918
|
+
* error — and the call is learned instead (`prefetch: true`, see host-nuxt).
|
|
919
|
+
*/
|
|
920
|
+
function describeOData(configBaseUrl, source, run) {
|
|
921
|
+
return describePrefetch(async (emit) => {
|
|
922
|
+
if (!describesRequests(configBaseUrl, source)) return;
|
|
923
|
+
await run(emit);
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
/** The cookie API requests carry their Bearer from (`fetching.auth`) — read by the server per request. */
|
|
927
|
+
function prefetchAuthHint() {
|
|
928
|
+
const { apiCookie } = resolveAuthCookies();
|
|
929
|
+
if (!apiCookie) return void 0;
|
|
930
|
+
return getRefreshRequestOptions()?.splitCookie ?? cookieSplit(apiCookie) ? {
|
|
931
|
+
cookie: apiCookie,
|
|
932
|
+
split: true
|
|
933
|
+
} : { cookie: apiCookie };
|
|
934
|
+
}
|
|
935
|
+
/**
|
|
936
|
+
* `definePrefetch` twin of `monoFetch(url, opt)`: the same arguments, nothing sent — describes
|
|
937
|
+
* the GET the browser's call will send (base url, headers and auth from `fetching` config).
|
|
938
|
+
*/
|
|
939
|
+
function prefetchMonoFetch(url, opt = {}) {
|
|
940
|
+
return describePrefetch((emit) => {
|
|
941
|
+
if (resolveMockRoute(opt.configBaseUrl, url)) return;
|
|
942
|
+
if (String(opt.method ?? "GET").toUpperCase() !== "GET" || opt.body != null) return;
|
|
943
|
+
emit({
|
|
944
|
+
url: getRestBaseUrl(opt.configBaseUrl, opt.baseUrl) + url,
|
|
945
|
+
headers: mergeHeaders(getGlobalHeaders(), opt.headers),
|
|
946
|
+
auth: prefetchAuthHint()
|
|
947
|
+
});
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
/**
|
|
951
|
+
* `definePrefetch` twin of `monoFetchOdata(params)`: runs the same call in capture mode —
|
|
952
|
+
* the store builds exactly the request the browser will send (`data`: what the call loads;
|
|
953
|
+
* `datasource`: the first page a bound widget loads), nothing is fetched.
|
|
954
|
+
*/
|
|
955
|
+
function prefetchMonoFetchOdata(params) {
|
|
956
|
+
return describeOData(params.configBaseUrl, params.source, async (emit) => {
|
|
957
|
+
await useMyFetchOData({
|
|
958
|
+
...params,
|
|
959
|
+
token: PREFETCH_CAPTURE_TOKEN,
|
|
960
|
+
notif: false,
|
|
961
|
+
__capture: {
|
|
962
|
+
emit,
|
|
963
|
+
auth: prefetchAuthHint()
|
|
964
|
+
}
|
|
965
|
+
});
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
/** Whether the data layer these OData calls use can describe its requests (its ODataStore is flagged). */
|
|
969
|
+
function describesRequests(configBaseUrl, source) {
|
|
970
|
+
return !!(getODataSource(configBaseUrl, source)?.ODataStore)?.[PREFETCH_SUPPORT];
|
|
971
|
+
}
|
|
972
|
+
/** `monoFetch` with its `definePrefetch` twin: `monoFetch.prefetch(url, opt)`. */
|
|
973
|
+
const monoFetch = Object.assign(useMyFetch, { prefetch: prefetchMonoFetch });
|
|
974
|
+
/** `monoFetchOdata` / `monoOdataFetch` with `.prefetch(params)`. */
|
|
975
|
+
const monoFetchOdata = Object.assign(useMyFetchOData, { prefetch: prefetchMonoFetchOdata });
|
|
976
|
+
/**
|
|
977
|
+
* Installs the `prefetch` host (e.g. `useNuxtApp().$nuxtPreFetch` from @mono-lit/nuxt-pre-fetch;
|
|
978
|
+
* `@mono-lit/utility/nuxt` does it for you). REST calls use it here; OData stores use it through
|
|
979
|
+
* the data layer when it supports it (`@mono-lit/data`'s `setPrefetchProvider`, detected like
|
|
980
|
+
* `tanstackRun`). `null` removes it.
|
|
981
|
+
*/
|
|
982
|
+
function monoSetPrefetchBridge(next) {
|
|
983
|
+
setPrefetchBridge(next);
|
|
984
|
+
const setProvider = Reflect.get(monoDevextremeModule, "setPrefetchProvider");
|
|
985
|
+
if (typeof setProvider === "function") setProvider(next);
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* Inside `definePrefetch(pattern, ctx => …)`: what the browser's `monoState()` would hold for
|
|
989
|
+
* this request — the claims of every `jwt` entry of `mono.config` (decoded from the page
|
|
990
|
+
* request's cookies; split cookies joined) and a cookie reader that understands `split`.
|
|
991
|
+
*/
|
|
992
|
+
function monoPrefetchContext(context) {
|
|
993
|
+
const cookies = context?.cookies ?? {};
|
|
994
|
+
const cookie = (name, split) => {
|
|
995
|
+
if (split ?? cookieSplit(name)) {
|
|
996
|
+
const prefix = `${name}_split_`;
|
|
997
|
+
const chunks = Object.keys(cookies).filter((key) => key.startsWith(prefix) && /^\d+$/.test(key.slice(prefix.length))).sort((a, b) => Number(a.slice(prefix.length)) - Number(b.slice(prefix.length))).map((key) => cookies[key]);
|
|
998
|
+
if (chunks.length) return chunks.join("");
|
|
999
|
+
}
|
|
1000
|
+
return cookies[name] || void 0;
|
|
1001
|
+
};
|
|
1002
|
+
const jwt = {};
|
|
1003
|
+
for (const [key, entry] of Object.entries(monoConfig()?.jwt ?? {})) {
|
|
1004
|
+
if (!entry) continue;
|
|
1005
|
+
if (typeof entry.name === "object" && entry.name) jwt[key] = { ...entry.name };
|
|
1006
|
+
else if (typeof entry.name === "string") jwt[key] = { ...decodeJwt(cookie(entry.name, Boolean(entry.split))) ?? {} };
|
|
1007
|
+
}
|
|
1008
|
+
return {
|
|
1009
|
+
jwt,
|
|
1010
|
+
cookie
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
865
1013
|
|
|
866
1014
|
//#endregion
|
|
867
|
-
export { createFetcher, configureFetching as monoConfigureFetching, useCreateFetcher as monoCreateFetcher,
|
|
1015
|
+
export { createFetcher, configureFetching as monoConfigureFetching, useCreateFetcher as monoCreateFetcher, monoFetch, monoFetchOdata, monoFetchOdata as monoOdataFetch, useFetchOdataUnique as monoFetchOdataUnique, useFetchOdataUnique as monoOdataFetchUnique, getFetchingRuntime as monoFetchingRuntime, loadChuckStores as monoLoadChuckStores, monoMockDb, getODataBaseUrl as monoOdataBaseUrl, getODataSource as monoOdataSource, getPrefetchBridge as monoPrefetchBridge, monoPrefetchContext, getRequestToken as monoRequestToken, resetFetchingConfig as monoResetFetchingConfig, getRestBaseUrl as monoRestBaseUrl, monoSetPrefetchBridge, createStaticDataSource as monoStaticDataSource, useTryCatchDatasource as monoTryCatchDatasource, promiseWrapper, resetMonoMockDb };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { v as MonoMockDbConfig } from "./create-config-
|
|
2
|
-
|
|
1
|
+
import { v as MonoMockDbConfig } from "./create-config-B8IhX4ht.js";
|
|
3
2
|
//#region pkg/mock-db/schema.d.ts
|
|
4
3
|
type MonoMockFieldType = 'number' | 'string' | 'boolean' | 'date' | 'object' | 'array';
|
|
5
4
|
/** `A->B:C` — "rows of B where `B[C] === row[A]`". */
|
|
@@ -81,16 +80,22 @@ type FilterNode = {
|
|
|
81
80
|
} | {
|
|
82
81
|
kind: 'field';
|
|
83
82
|
name: string;
|
|
84
|
-
}
|
|
83
|
+
} |
|
|
84
|
+
/** `A/B/C` — a navigation path, or a lambda range variable (`d/Bulan`). */
|
|
85
|
+
{
|
|
85
86
|
kind: 'path';
|
|
86
87
|
segments: string[];
|
|
87
|
-
}
|
|
88
|
+
} |
|
|
89
|
+
/** `Nav/any(d: <predicate>)` — `nav` may be empty for a lambda on the row itself. */
|
|
90
|
+
{
|
|
88
91
|
kind: 'lambda';
|
|
89
92
|
op: 'any' | 'all';
|
|
90
93
|
nav: string[];
|
|
91
94
|
variable: string;
|
|
92
95
|
predicate: FilterNode;
|
|
93
|
-
}
|
|
96
|
+
} |
|
|
97
|
+
/** `Field in (1,2,3)` */
|
|
98
|
+
{
|
|
94
99
|
kind: 'in';
|
|
95
100
|
left: FilterNode;
|
|
96
101
|
values: FilterNode[];
|
|
@@ -197,7 +202,8 @@ interface ODataResult {
|
|
|
197
202
|
*/
|
|
198
203
|
declare function executeQuery(rows: Record<string, any>[], query: ODataQuery, context?: {
|
|
199
204
|
entity: MonoMockParsedEntity;
|
|
200
|
-
readEntity: (name: string) => Record<string, any>[];
|
|
205
|
+
readEntity: (name: string) => Record<string, any>[];
|
|
206
|
+
/** Resolves a child entity's schema — needed to recurse into a nested $expand. */
|
|
201
207
|
entityOf?: (name: string) => MonoMockParsedEntity | undefined;
|
|
202
208
|
}): ODataResult;
|
|
203
209
|
/** `Entity(1)` / `Entity('abc')` -> the key, or null for a collection request. */
|