akanjs 3.4.0-rc.5 → 3.4.0-rc.6
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/dictionary/dictInfo.ts +18 -2
- package/fetch/client/fetchClient.ts +3 -3
- package/index.ts +6 -0
- package/package.json +1 -1
- package/server/resolver/databaseModelInstance.ts +5 -1
- package/signal/serializer/fetch.serializer.ts +1 -0
- package/signal/types.ts +2 -0
- package/types/fetch/client/fetchClient.d.ts +1 -1
- package/types/index.d.ts +8 -0
- package/types/signal/types.d.ts +2 -0
package/dictionary/dictInfo.ts
CHANGED
|
@@ -75,6 +75,22 @@ const rootWriter = (rootDict: RootDictionary, languages: readonly string[], refN
|
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
+
const pageArgTrans = (
|
|
79
|
+
languages: readonly string[],
|
|
80
|
+
pageKey: string,
|
|
81
|
+
sortDictionary: { [key: string]: Translated },
|
|
82
|
+
) => ({
|
|
83
|
+
trans: languages.map(() => pageKey),
|
|
84
|
+
descTrans: languages.map((_, idx) => {
|
|
85
|
+
if (pageKey !== "sort") return pageKey;
|
|
86
|
+
const keys = Object.entries(sortDictionary).map(([key, { trans, descTrans }]) => {
|
|
87
|
+
const meaning = (descTrans ?? trans)[idx];
|
|
88
|
+
return meaning ? `${key} (${meaning})` : key;
|
|
89
|
+
});
|
|
90
|
+
return keys.length ? keys.join(", ") : pageKey;
|
|
91
|
+
}),
|
|
92
|
+
});
|
|
93
|
+
|
|
78
94
|
const registerEnums = (rootDict: RootDictionary, languages: readonly string[], enumDictionary: object) => {
|
|
79
95
|
for (const [refName, enumTrans] of Object.entries(enumDictionary as { [key: string]: object }))
|
|
80
96
|
rootWriter(rootDict, languages, refName).fields([], enumTrans);
|
|
@@ -444,10 +460,10 @@ export class ModelDictInfo<
|
|
|
444
460
|
root.head(["signal"], insightKey, sliceTrans, (t) => `Slice Insight - ${t}`);
|
|
445
461
|
for (const [argKey, argTrans] of Object.entries(sliceTrans.argTrans as { [key: string]: Translated })) {
|
|
446
462
|
root.field(["signal", listKey, "arg"], argKey, argTrans);
|
|
447
|
-
for (const pageKey of ["skip", "limit", "sort"])
|
|
448
|
-
root.field(["signal", listKey, "arg"], pageKey, argTrans, () => pageKey);
|
|
449
463
|
root.field(["signal", insightKey, "arg"], argKey, argTrans);
|
|
450
464
|
}
|
|
465
|
+
for (const pageKey of ["skip", "limit", "sort"])
|
|
466
|
+
root.field(["signal", listKey, "arg"], pageKey, pageArgTrans(this.languages, pageKey, this.sortDictionary));
|
|
451
467
|
}
|
|
452
468
|
root.fns(["signal"], this.endpointDictionary);
|
|
453
469
|
|
|
@@ -561,10 +561,10 @@ export class FetchClient {
|
|
|
561
561
|
}
|
|
562
562
|
}
|
|
563
563
|
|
|
564
|
-
static paginationArgs: SerializedArg[]
|
|
564
|
+
static paginationArgs = (sortKeys?: string[]): SerializedArg[] => [
|
|
565
565
|
{ type: "search", name: "skip", refName: "Int" },
|
|
566
566
|
{ type: "search", name: "limit", refName: "Int" },
|
|
567
|
-
{ type: "search", name: "sort", refName: "String" },
|
|
567
|
+
{ type: "search", name: "sort", refName: "String", ...(sortKeys?.length ? { oneOf: sortKeys } : {}) },
|
|
568
568
|
];
|
|
569
569
|
|
|
570
570
|
static makeHttpUrl(
|
|
@@ -766,7 +766,7 @@ export class FetchClient {
|
|
|
766
766
|
const endpoint: { [key: string]: SerializedEndpoint } = {
|
|
767
767
|
[names.list]: {
|
|
768
768
|
type: "query",
|
|
769
|
-
args: [...slice.args, ...FetchClient.paginationArgs],
|
|
769
|
+
args: [...slice.args, ...FetchClient.paginationArgs(slice.sortKeys)],
|
|
770
770
|
returns: { refName, modelType: "light", arrDepth: 1 },
|
|
771
771
|
guards: slice.guards,
|
|
772
772
|
...mcp,
|
package/index.ts
CHANGED
|
@@ -350,6 +350,12 @@ export interface AkanNativeDmgConfig {
|
|
|
350
350
|
export interface AkanNativeSettings {
|
|
351
351
|
/** The client the app opens, a basePath the routes declare; an app without basePaths leaves it out. */
|
|
352
352
|
basePath?: string;
|
|
353
|
+
/**
|
|
354
|
+
* The server a build for each environment calls, an origin such as `https://api.example.com`. Default: the first
|
|
355
|
+
* domain the routes give the target's basePath for that environment, else `<app>-<env>.<serveDomain>`.
|
|
356
|
+
* `AKAN_PUBLIC_SERVER_URL` at build time wins over both.
|
|
357
|
+
*/
|
|
358
|
+
serverUrl?: { [env in Exclude<NativeEnv, "local">]?: string };
|
|
353
359
|
/**
|
|
354
360
|
* Where the app starts, and falls back to for a deep link's stack and a back with no history. Default `/`. A platform
|
|
355
361
|
* section's own `indexPath` (`desktop.indexPath`) wins on that platform.
|
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
type DocumentTouchOptions,
|
|
11
11
|
type DocumentUpdateInput,
|
|
12
12
|
type FindQueryOption,
|
|
13
|
+
getFilterMeta,
|
|
13
14
|
getFilterSortByKey,
|
|
14
15
|
getLoaderInfos,
|
|
15
16
|
type ListQueryOption,
|
|
@@ -38,7 +39,10 @@ const modelQueryOptionsOf = (database: DatabaseModel) => {
|
|
|
38
39
|
const resolveSort = (sortKey?: string | null): { [key: string]: 1 | -1 } | null => {
|
|
39
40
|
if (!sortKey) return null;
|
|
40
41
|
const sort = getFilterSortByKey(database.filter, sortKey) as { [key: string]: 1 | -1 } | undefined;
|
|
41
|
-
if (!sort)
|
|
42
|
+
if (!sort) {
|
|
43
|
+
const known = Object.keys(getFilterMeta(database.filter).sort).join(", ");
|
|
44
|
+
throw new Exception.BadRequest(`Unknown sort key for ${modelName}: ${sortKey}. Sort by one of: ${known}.`);
|
|
45
|
+
}
|
|
42
46
|
return sort;
|
|
43
47
|
};
|
|
44
48
|
const getListQuery = (query?: QueryOf<any>, queryOption?: ListQueryOption) => ({
|
|
@@ -138,6 +138,7 @@ export class FetchSerializer {
|
|
|
138
138
|
|
|
139
139
|
const queryKeyArg = slice[""]?.args.find((arg) => arg.name === "queryKey");
|
|
140
140
|
if (queryKeyArg && filter) queryKeyArg.oneOf = Object.keys(filter.filter);
|
|
141
|
+
if (filter) for (const serialized of Object.values(slice)) serialized.sortKeys = filter.sortKeys;
|
|
141
142
|
return {
|
|
142
143
|
...(prefix ? { prefix } : {}),
|
|
143
144
|
...(Object.keys(slice).length ? { slice } : {}),
|
package/signal/types.ts
CHANGED
|
@@ -167,6 +167,8 @@ interface SerializedSignalOption {
|
|
|
167
167
|
export interface SerializedSlice extends SerializedSignalOption {
|
|
168
168
|
/** `sort`: keys a subscriber may place a new row under itself (others refetch); `pauseOn` travels only when set. */
|
|
169
169
|
live?: { sort: string[]; pauseOn?: string[] };
|
|
170
|
+
/** The model filter's sort keys, the values its list's `sort` argument takes. */
|
|
171
|
+
sortKeys?: string[];
|
|
170
172
|
}
|
|
171
173
|
|
|
172
174
|
export interface SerializedReturns {
|
|
@@ -81,7 +81,7 @@ export declare class FetchClient {
|
|
|
81
81
|
/** Every socket this client holds or opens later: its own and one per `FetchPolicy.origin`. */
|
|
82
82
|
configureWs(options: WsClientOptions): void;
|
|
83
83
|
setJwt(jwt: string | null): void;
|
|
84
|
-
static paginationArgs: SerializedArg[];
|
|
84
|
+
static paginationArgs: (sortKeys?: string[]) => SerializedArg[];
|
|
85
85
|
static makeHttpUrl(key: string, endpoint: SerializedEndpoint, prefix: string | undefined, argMap: Map<string, unknown>): string;
|
|
86
86
|
static getBaseEndpoint(refName: string, signal: SerializedSignal): {
|
|
87
87
|
[key: string]: SerializedEndpoint;
|
package/types/index.d.ts
CHANGED
|
@@ -356,6 +356,14 @@ export interface AkanNativeDmgConfig {
|
|
|
356
356
|
export interface AkanNativeSettings {
|
|
357
357
|
/** The client the app opens, a basePath the routes declare; an app without basePaths leaves it out. */
|
|
358
358
|
basePath?: string;
|
|
359
|
+
/**
|
|
360
|
+
* The server a build for each environment calls, an origin such as `https://api.example.com`. Default: the first
|
|
361
|
+
* domain the routes give the target's basePath for that environment, else `<app>-<env>.<serveDomain>`.
|
|
362
|
+
* `AKAN_PUBLIC_SERVER_URL` at build time wins over both.
|
|
363
|
+
*/
|
|
364
|
+
serverUrl?: {
|
|
365
|
+
[env in Exclude<NativeEnv, "local">]?: string;
|
|
366
|
+
};
|
|
359
367
|
/**
|
|
360
368
|
* Where the app starts, and falls back to for a deep link's stack and a back with no history. Default `/`. A platform
|
|
361
369
|
* section's own `indexPath` (`desktop.indexPath`) wins on that platform.
|
package/types/signal/types.d.ts
CHANGED
|
@@ -155,6 +155,8 @@ export interface SerializedSlice extends SerializedSignalOption {
|
|
|
155
155
|
sort: string[];
|
|
156
156
|
pauseOn?: string[];
|
|
157
157
|
};
|
|
158
|
+
/** The model filter's sort keys, the values its list's `sort` argument takes. */
|
|
159
|
+
sortKeys?: string[];
|
|
158
160
|
}
|
|
159
161
|
export interface SerializedReturns {
|
|
160
162
|
refName: Exclude<DefaultPrimitiveName, "Map" | "Upload"> | (string & {});
|