@akanjs/signal 0.9.51 → 0.9.53

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.
@@ -226,7 +226,8 @@ const databaseFetchOf = (signal, option = {}) => {
226
226
  initModel: `init${className}`,
227
227
  getModelInit: `get${className}Init`,
228
228
  addModelFiles: `add${className}Files`,
229
- addFiles: `addFiles`
229
+ addFiles: `addFiles`,
230
+ modelSortKeys: `${fieldName}SortKeys`
230
231
  };
231
232
  const fetch = serviceFetchOf(signal);
232
233
  const util = {
@@ -281,7 +282,8 @@ const databaseFetchOf = (signal, option = {}) => {
281
282
  [names.getModelEdit]: async (id, option2) => {
282
283
  const modelEdit = await global.builtFetch[names.editModel](id, option2);
283
284
  return modelEdit[names.modelEdit];
284
- }
285
+ },
286
+ [names.modelSortKeys]: signal.filter?.sortKeys
285
287
  };
286
288
  const sliceUtil = Object.fromEntries(
287
289
  signal.slices.reduce((acc, { sliceName, argLength, defaultArgs }) => {
@@ -66,29 +66,29 @@ class InternalApiInfo {
66
66
  };
67
67
  applyApiMeta(sigRef, key) {
68
68
  if (this.type === "resolveField") {
69
- const metadataMap2 = (0, import_signalDecorators.getResolveFieldMetaMapOnPrototype)(sigRef.prototype);
70
- metadataMap2.set(key, {
69
+ const metadataMap = (0, import_signalDecorators.getResolveFieldMetaMapOnPrototype)(sigRef.prototype);
70
+ metadataMap.set(key, {
71
71
  returns: () => this.returnRef,
72
72
  argsOption: this.signalOption,
73
73
  key,
74
74
  descriptor: { value: this.execFn, writable: true, enumerable: false, configurable: true }
75
75
  });
76
76
  sigRef.prototype[key] = this.execFn;
77
- Reflect.defineMetadata("resolveField", metadataMap2, sigRef.prototype);
78
- return;
77
+ Reflect.defineMetadata("resolveField", metadataMap, sigRef.prototype);
78
+ } else {
79
+ const metadataMap = (0, import_signalDecorators.getGqlMetaMapOnPrototype)(sigRef.prototype);
80
+ const internalApiMeta = {
81
+ returns: () => this.returnRef instanceof import_base.Enum ? this.returnRef.type : this.returnRef,
82
+ signalOption: this.signalOption,
83
+ key,
84
+ descriptor: { value: this.execFn, writable: true, enumerable: false, configurable: true },
85
+ guards: ["None"],
86
+ type: InternalApiInfo.#typeTempMap[this.type]
87
+ };
88
+ sigRef.prototype[key] = this.execFn;
89
+ metadataMap.set(key, internalApiMeta);
90
+ (0, import_signalDecorators.setGqlMetaMapOnPrototype)(sigRef.prototype, metadataMap);
79
91
  }
80
- const internalApiMeta = {
81
- returns: () => this.returnRef instanceof import_base.Enum ? this.returnRef.type : this.returnRef,
82
- signalOption: this.signalOption,
83
- key,
84
- descriptor: { value: this.execFn, writable: true, enumerable: false, configurable: true },
85
- guards: ["None"],
86
- type: InternalApiInfo.#typeTempMap[this.type]
87
- };
88
- sigRef.prototype[key] = this.execFn;
89
- const metadataMap = (0, import_signalDecorators.getGqlMetaMapOnPrototype)(sigRef.prototype);
90
- metadataMap.set(key, internalApiMeta);
91
- (0, import_signalDecorators.setGqlMetaMapOnPrototype)(sigRef.prototype, metadataMap);
92
92
  const argMetas = this.args.map((arg, idx) => ({
93
93
  name: arg.name,
94
94
  returns: () => arg.argRef,
@@ -432,7 +432,7 @@ function endpoint(srv, builder, ...libSignals) {
432
432
  return sigRef;
433
433
  }
434
434
  const mergeSignals = (signalRef, internalRef, sliceRef) => {
435
- (0, import_common.applyMixins)(signalRef, [internalRef, ...sliceRef ? [sliceRef] : []]);
435
+ (0, import_common.applyMixins)(signalRef, [internalRef]);
436
436
  const gqlMetaMap = getGqlMetaMapOnPrototype(signalRef.prototype);
437
437
  const resolveFieldMetaMap = getResolveFieldMetaMapOnPrototype(signalRef.prototype);
438
438
  setResolveFieldMetaMapOnPrototype(signalRef.prototype, resolveFieldMetaMap);
@@ -445,9 +445,12 @@ const mergeSignals = (signalRef, internalRef, sliceRef) => {
445
445
  });
446
446
  internalResolveFieldMetaMap.forEach((value, key) => {
447
447
  resolveFieldMetaMap.set(key, value);
448
+ const [argMetas, internalArgMetas] = getArgMetas(internalRef, key);
449
+ setArgMetas(signalRef, key, argMetas, internalArgMetas);
448
450
  });
449
451
  if (sliceRef) {
450
452
  const sliceGqlMetaMap = getGqlMetaMapOnPrototype(sliceRef.prototype);
453
+ (0, import_common.applyMixins)(signalRef, [sliceRef], /* @__PURE__ */ new Set([...gqlMetaMap.keys()]));
451
454
  sliceGqlMetaMap.forEach((value, key) => {
452
455
  if (gqlMetaMap.has(key))
453
456
  return;
@@ -459,13 +462,6 @@ const mergeSignals = (signalRef, internalRef, sliceRef) => {
459
462
  setGqlMetaMapOnPrototype(signalRef.prototype, gqlMetaMap);
460
463
  return signalRef;
461
464
  };
462
- function LogSignal(refName, srv, option) {
463
- class BaseSignal {
464
- }
465
- import_signalInfo.signalInfo.setRefNameTemp(BaseSignal, refName);
466
- import_signalInfo.signalInfo.setPrefixTemp(BaseSignal, option?.prefix ?? "");
467
- return BaseSignal;
468
- }
469
465
  const getSigMeta = (sigRef) => {
470
466
  const sigMeta = Reflect.getMetadata("signal", sigRef.prototype);
471
467
  if (!sigMeta)
@@ -23,6 +23,7 @@ module.exports = __toCommonJS(signalInfo_exports);
23
23
  var import_base = require("@akanjs/base");
24
24
  var import_common = require("@akanjs/common");
25
25
  var import_constant = require("@akanjs/constant");
26
+ var import_document = require("@akanjs/document");
26
27
  var import_client = require("./client");
27
28
  var import_fetchInfo = require("./fetchInfo");
28
29
  var import_signalDecorators = require("./signalDecorators");
@@ -124,7 +125,13 @@ const signalInfo = {
124
125
  const refName = signalInfo.getRefNameTemp(sigRef);
125
126
  const { slices, prefix } = (0, import_signalDecorators.getSigMeta)(sigRef);
126
127
  const gqlMetaMap = (0, import_signalDecorators.getGqlMetaMapOnPrototype)(sigRef.prototype);
127
- const serializedSignal = { refName, slices, prefix, endpoint: {} };
128
+ const serializedSignal = {
129
+ refName,
130
+ slices,
131
+ prefix,
132
+ endpoint: {},
133
+ filter: import_document.documentInfo.getSerializedFilter(refName)
134
+ };
128
135
  gqlMetaMap.forEach((gqlMeta, key) => {
129
136
  if (!["Query", "Mutation", "Pubsub", "Message"].includes(gqlMeta.type))
130
137
  return;
@@ -203,7 +203,8 @@ const databaseFetchOf = (signal, option = {}) => {
203
203
  initModel: `init${className}`,
204
204
  getModelInit: `get${className}Init`,
205
205
  addModelFiles: `add${className}Files`,
206
- addFiles: `addFiles`
206
+ addFiles: `addFiles`,
207
+ modelSortKeys: `${fieldName}SortKeys`
207
208
  };
208
209
  const fetch = serviceFetchOf(signal);
209
210
  const util = {
@@ -258,7 +259,8 @@ const databaseFetchOf = (signal, option = {}) => {
258
259
  [names.getModelEdit]: async (id, option2) => {
259
260
  const modelEdit = await global.builtFetch[names.editModel](id, option2);
260
261
  return modelEdit[names.modelEdit];
261
- }
262
+ },
263
+ [names.modelSortKeys]: signal.filter?.sortKeys
262
264
  };
263
265
  const sliceUtil = Object.fromEntries(
264
266
  signal.slices.reduce((acc, { sliceName, argLength, defaultArgs }) => {
@@ -48,29 +48,29 @@ class InternalApiInfo {
48
48
  };
49
49
  applyApiMeta(sigRef, key) {
50
50
  if (this.type === "resolveField") {
51
- const metadataMap2 = getResolveFieldMetaMapOnPrototype(sigRef.prototype);
52
- metadataMap2.set(key, {
51
+ const metadataMap = getResolveFieldMetaMapOnPrototype(sigRef.prototype);
52
+ metadataMap.set(key, {
53
53
  returns: () => this.returnRef,
54
54
  argsOption: this.signalOption,
55
55
  key,
56
56
  descriptor: { value: this.execFn, writable: true, enumerable: false, configurable: true }
57
57
  });
58
58
  sigRef.prototype[key] = this.execFn;
59
- Reflect.defineMetadata("resolveField", metadataMap2, sigRef.prototype);
60
- return;
59
+ Reflect.defineMetadata("resolveField", metadataMap, sigRef.prototype);
60
+ } else {
61
+ const metadataMap = getGqlMetaMapOnPrototype(sigRef.prototype);
62
+ const internalApiMeta = {
63
+ returns: () => this.returnRef instanceof Enum ? this.returnRef.type : this.returnRef,
64
+ signalOption: this.signalOption,
65
+ key,
66
+ descriptor: { value: this.execFn, writable: true, enumerable: false, configurable: true },
67
+ guards: ["None"],
68
+ type: InternalApiInfo.#typeTempMap[this.type]
69
+ };
70
+ sigRef.prototype[key] = this.execFn;
71
+ metadataMap.set(key, internalApiMeta);
72
+ setGqlMetaMapOnPrototype(sigRef.prototype, metadataMap);
61
73
  }
62
- const internalApiMeta = {
63
- returns: () => this.returnRef instanceof Enum ? this.returnRef.type : this.returnRef,
64
- signalOption: this.signalOption,
65
- key,
66
- descriptor: { value: this.execFn, writable: true, enumerable: false, configurable: true },
67
- guards: ["None"],
68
- type: InternalApiInfo.#typeTempMap[this.type]
69
- };
70
- sigRef.prototype[key] = this.execFn;
71
- const metadataMap = getGqlMetaMapOnPrototype(sigRef.prototype);
72
- metadataMap.set(key, internalApiMeta);
73
- setGqlMetaMapOnPrototype(sigRef.prototype, metadataMap);
74
74
  const argMetas = this.args.map((arg, idx) => ({
75
75
  name: arg.name,
76
76
  returns: () => arg.argRef,
@@ -364,7 +364,7 @@ function endpoint(srv, builder, ...libSignals) {
364
364
  return sigRef;
365
365
  }
366
366
  const mergeSignals = (signalRef, internalRef, sliceRef) => {
367
- applyMixins(signalRef, [internalRef, ...sliceRef ? [sliceRef] : []]);
367
+ applyMixins(signalRef, [internalRef]);
368
368
  const gqlMetaMap = getGqlMetaMapOnPrototype(signalRef.prototype);
369
369
  const resolveFieldMetaMap = getResolveFieldMetaMapOnPrototype(signalRef.prototype);
370
370
  setResolveFieldMetaMapOnPrototype(signalRef.prototype, resolveFieldMetaMap);
@@ -377,9 +377,12 @@ const mergeSignals = (signalRef, internalRef, sliceRef) => {
377
377
  });
378
378
  internalResolveFieldMetaMap.forEach((value, key) => {
379
379
  resolveFieldMetaMap.set(key, value);
380
+ const [argMetas, internalArgMetas] = getArgMetas(internalRef, key);
381
+ setArgMetas(signalRef, key, argMetas, internalArgMetas);
380
382
  });
381
383
  if (sliceRef) {
382
384
  const sliceGqlMetaMap = getGqlMetaMapOnPrototype(sliceRef.prototype);
385
+ applyMixins(signalRef, [sliceRef], /* @__PURE__ */ new Set([...gqlMetaMap.keys()]));
383
386
  sliceGqlMetaMap.forEach((value, key) => {
384
387
  if (gqlMetaMap.has(key))
385
388
  return;
@@ -391,13 +394,6 @@ const mergeSignals = (signalRef, internalRef, sliceRef) => {
391
394
  setGqlMetaMapOnPrototype(signalRef.prototype, gqlMetaMap);
392
395
  return signalRef;
393
396
  };
394
- function LogSignal(refName, srv, option) {
395
- class BaseSignal {
396
- }
397
- signalInfo.setRefNameTemp(BaseSignal, refName);
398
- signalInfo.setPrefixTemp(BaseSignal, option?.prefix ?? "");
399
- return BaseSignal;
400
- }
401
397
  const getSigMeta = (sigRef) => {
402
398
  const sigMeta = Reflect.getMetadata("signal", sigRef.prototype);
403
399
  if (!sigMeta)
@@ -1,6 +1,7 @@
1
1
  import { baseClientEnv, getNonArrayModel, scalarNameMap } from "@akanjs/base";
2
2
  import { lowerlize } from "@akanjs/common";
3
3
  import { constantInfo } from "@akanjs/constant";
4
+ import { documentInfo } from "@akanjs/document";
4
5
  import { client } from "./client";
5
6
  import { databaseFetchOf, serviceFetchOf } from "./fetchInfo";
6
7
  import {
@@ -110,7 +111,13 @@ const signalInfo = {
110
111
  const refName = signalInfo.getRefNameTemp(sigRef);
111
112
  const { slices, prefix } = getSigMeta(sigRef);
112
113
  const gqlMetaMap = getGqlMetaMapOnPrototype(sigRef.prototype);
113
- const serializedSignal = { refName, slices, prefix, endpoint: {} };
114
+ const serializedSignal = {
115
+ refName,
116
+ slices,
117
+ prefix,
118
+ endpoint: {},
119
+ filter: documentInfo.getSerializedFilter(refName)
120
+ };
114
121
  gqlMetaMap.forEach((gqlMeta, key) => {
115
122
  if (!["Query", "Mutation", "Pubsub", "Message"].includes(gqlMeta.type))
116
123
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/signal",
3
- "version": "0.9.51",
3
+ "version": "0.9.53",
4
4
  "sourceType": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/gql.d.ts CHANGED
@@ -77,6 +77,8 @@ type BasicMethods<T extends string, Input, Full, Light extends {
77
77
  [K in `add${_CapitalizedT}Files`]: (fileList: FileList, parentId?: string, option?: FetchPolicy) => Promise<ProtoFile[]>;
78
78
  } & {
79
79
  [K in `merge${_CapitalizedT}`]: (modelOrId: Full | string, data: Partial<DocumentModel<Input>>, option?: FetchPolicy) => Promise<Full>;
80
+ } & {
81
+ [K in `${T}SortKeys`]?: string[];
80
82
  };
81
83
  type ViewEditMethods<T extends string, Full, _CapitalizedT extends string = Capitalize<T>> = {
82
84
  [K in `view${_CapitalizedT}`]: (id: string, option?: FetchPolicy) => Promise<ViewReturn<T, Full>>;
@@ -68,6 +68,12 @@ export interface SerializedEndpoint {
68
68
  returns: SerializedReturns;
69
69
  args: SerializedArg[];
70
70
  }
71
+ export interface SerializedFilter {
72
+ filter: {
73
+ [key: string]: SerializedArg[];
74
+ };
75
+ sortKeys: string[];
76
+ }
71
77
  export interface SerializedSignal {
72
78
  refName: string;
73
79
  slices: SliceMeta[];
@@ -75,4 +81,5 @@ export interface SerializedSignal {
75
81
  endpoint: {
76
82
  [key: string]: SerializedEndpoint;
77
83
  };
84
+ filter?: SerializedFilter;
78
85
  }