@akanjs/signal 0.0.96 → 0.0.98

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/src/immerify.js CHANGED
@@ -1,35 +1,16 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var immerify_exports = {};
19
- __export(immerify_exports, {
20
- immerify: () => immerify
21
- });
22
- module.exports = __toCommonJS(immerify_exports);
23
- var import_constant = require("@akanjs/constant");
24
- var import_immer = require("immer");
1
+ import { getFieldMetas } from "@akanjs/constant";
2
+ import { immerable } from "immer";
25
3
  const immerify = (modelRef, objOrArr) => {
26
4
  if (Array.isArray(objOrArr))
27
5
  return objOrArr.map((val) => immerify(modelRef, val));
28
- const fieldMetas = (0, import_constant.getFieldMetas)(modelRef);
29
- const immeredObj = Object.assign({}, objOrArr, { [import_immer.immerable]: true });
6
+ const fieldMetas = getFieldMetas(modelRef);
7
+ const immeredObj = Object.assign({}, objOrArr, { [immerable]: true });
30
8
  fieldMetas.forEach((fieldMeta) => {
31
9
  if (fieldMeta.isScalar && fieldMeta.isClass && !!objOrArr[fieldMeta.key])
32
10
  immeredObj[fieldMeta.key] = immerify(fieldMeta.modelRef, objOrArr[fieldMeta.key]);
33
11
  });
34
12
  return immeredObj;
35
13
  };
14
+ export {
15
+ immerify
16
+ };
package/src/index.cjs ADDED
@@ -0,0 +1,30 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var src_exports = {};
20
+ __export(src_exports, {
21
+ client: () => import_client.client,
22
+ immerify: () => import_immerify.immerify
23
+ });
24
+ module.exports = __toCommonJS(src_exports);
25
+ var import_client = require("./client");
26
+ var import_immerify = require("./immerify");
27
+ __reExport(src_exports, require("./gql"), module.exports);
28
+ __reExport(src_exports, require("./signalDecorators"), module.exports);
29
+ __reExport(src_exports, require("./doc"), module.exports);
30
+ __reExport(src_exports, require("./baseFetch"), module.exports);
package/src/index.js CHANGED
@@ -1,30 +1,10 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
1
+ import { client } from "./client";
2
+ import { immerify } from "./immerify";
3
+ export * from "./gql";
4
+ export * from "./signalDecorators";
5
+ export * from "./doc";
6
+ export * from "./baseFetch";
7
+ export {
8
+ client,
9
+ immerify
8
10
  };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var src_exports = {};
20
- __export(src_exports, {
21
- client: () => import_client.client,
22
- immerify: () => import_immerify.immerify
23
- });
24
- module.exports = __toCommonJS(src_exports);
25
- var import_client = require("./client");
26
- var import_immerify = require("./immerify");
27
- __reExport(src_exports, require("./gql"), module.exports);
28
- __reExport(src_exports, require("./signalDecorators"), module.exports);
29
- __reExport(src_exports, require("./doc"), module.exports);
30
- __reExport(src_exports, require("./baseFetch"), module.exports);
@@ -1,5 +1,20 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
3
18
  var __decorateClass = (decorators, target, key, kind) => {
4
19
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
20
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
@@ -10,20 +25,62 @@ var __decorateClass = (decorators, target, key, kind) => {
10
25
  return result;
11
26
  };
12
27
  var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
13
- import "reflect-metadata";
14
- import {
15
- baseEnv,
16
- getNonArrayModel,
17
- ID,
18
- Int,
19
- JSON,
20
- scalarArgMap
21
- } from "@akanjs/base";
22
- import { applyMixins, capitalize, lowerlize } from "@akanjs/common";
23
- import {
24
- getClassMeta
25
- } from "@akanjs/constant";
26
- import { makeDefault } from "./gql";
28
+ var signalDecorators_exports = {};
29
+ __export(signalDecorators_exports, {
30
+ Access: () => Access,
31
+ Account: () => Account,
32
+ Arg: () => Arg,
33
+ DbSignal: () => DbSignal,
34
+ Job: () => Job,
35
+ LogSignal: () => LogSignal,
36
+ Me: () => Me,
37
+ Message: () => Message,
38
+ Mutation: () => Mutation,
39
+ Parent: () => Parent,
40
+ Process: () => Process,
41
+ Pubsub: () => Pubsub,
42
+ Query: () => Query,
43
+ Req: () => Req,
44
+ Res: () => Res,
45
+ ResolveField: () => ResolveField,
46
+ Self: () => Self,
47
+ Signal: () => Signal,
48
+ SignalStorage: () => SignalStorage,
49
+ UserIp: () => UserIp,
50
+ Ws: () => Ws,
51
+ argTypes: () => argTypes,
52
+ copySignal: () => copySignal,
53
+ createArgMetaDecorator: () => createArgMetaDecorator,
54
+ defaultAccount: () => defaultAccount,
55
+ done: () => done,
56
+ emit: () => emit,
57
+ endpointTypes: () => endpointTypes,
58
+ getAllSignalRefs: () => getAllSignalRefs,
59
+ getArgMetas: () => getArgMetas,
60
+ getControllerPath: () => getControllerPath,
61
+ getControllerPrefix: () => getControllerPrefix,
62
+ getGqlMeta: () => getGqlMeta,
63
+ getGqlMetaMapOnPrototype: () => getGqlMetaMapOnPrototype,
64
+ getGqlMetas: () => getGqlMetas,
65
+ getResolveFieldMetas: () => getResolveFieldMetas,
66
+ getSigMeta: () => getSigMeta,
67
+ getSignalRefsOnStorage: () => getSignalRefsOnStorage,
68
+ guardTypes: () => guardTypes,
69
+ internalArgTypes: () => internalArgTypes,
70
+ resolve: () => resolve,
71
+ roleTypes: () => roleTypes,
72
+ setArgMetas: () => setArgMetas,
73
+ setGqlMetaMapOnPrototype: () => setGqlMetaMapOnPrototype,
74
+ signalTypes: () => signalTypes,
75
+ ssoTypes: () => ssoTypes,
76
+ subscribe: () => subscribe
77
+ });
78
+ module.exports = __toCommonJS(signalDecorators_exports);
79
+ var import_reflect_metadata = require("reflect-metadata");
80
+ var import_base = require("@akanjs/base");
81
+ var import_common = require("@akanjs/common");
82
+ var import_constant = require("@akanjs/constant");
83
+ var import_gql = require("./gql");
27
84
  const ssoTypes = ["github", "google", "facebook", "apple", "naver", "kakao"];
28
85
  class SignalStorage {
29
86
  }
@@ -61,10 +118,10 @@ const internalArgTypes = [
61
118
  "Job"
62
119
  ];
63
120
  const getDefaultArg = (argRef) => {
64
- const [modelRef, arrDepth] = getNonArrayModel(argRef);
121
+ const [modelRef, arrDepth] = (0, import_base.getNonArrayModel)(argRef);
65
122
  if (arrDepth)
66
123
  return [];
67
- const scalarArg = scalarArgMap.get(modelRef);
124
+ const scalarArg = import_base.scalarArgMap.get(modelRef);
68
125
  if (scalarArg)
69
126
  return scalarArg;
70
127
  else
@@ -76,9 +133,9 @@ function Signal(returnsOrObj) {
76
133
  return function(target) {
77
134
  if (returns) {
78
135
  const modelRef = returns();
79
- const classMeta = getClassMeta(modelRef);
136
+ const classMeta = (0, import_constant.getClassMeta)(modelRef);
80
137
  const gqlMetas = getGqlMetas(target);
81
- const modelName = lowerlize(classMeta.refName);
138
+ const modelName = (0, import_common.lowerlize)(classMeta.refName);
82
139
  const listName = `${modelName}ListIn`;
83
140
  const slices = [
84
141
  { refName: modelName, sliceName: modelName, argLength: 1, defaultArgs: [{}] },
@@ -86,7 +143,7 @@ function Signal(returnsOrObj) {
86
143
  const name = gqlMeta.signalOption.name ?? gqlMeta.key;
87
144
  if (!name.includes(listName))
88
145
  return false;
89
- const [retRef, arrDepth] = getNonArrayModel(gqlMeta.returns());
146
+ const [retRef, arrDepth] = (0, import_base.getNonArrayModel)(gqlMeta.returns());
90
147
  return retRef.prototype === modelRef.prototype && arrDepth === 1;
91
148
  }).map((gqlMeta) => {
92
149
  const name = gqlMeta.signalOption.name ?? gqlMeta.key;
@@ -106,7 +163,7 @@ function Signal(returnsOrObj) {
106
163
  setSigMeta(target, { returns, prefix, slices, refName: modelName });
107
164
  setSignalRefOnStorage(modelName, target);
108
165
  } else {
109
- const refName = typeof returnsOrObj === "object" ? lowerlize(returnsOrObj.name) : void 0;
166
+ const refName = typeof returnsOrObj === "object" ? (0, import_common.lowerlize)(returnsOrObj.name) : void 0;
110
167
  if (!refName)
111
168
  throw new Error("Signal name is required");
112
169
  setSigMeta(target, { returns, prefix, slices: [], refName });
@@ -126,8 +183,8 @@ const createArgMetaDecorator = (type) => {
126
183
  const Account = createArgMetaDecorator("Account");
127
184
  const defaultAccount = {
128
185
  __InternalArg__: "Account",
129
- appName: baseEnv.appName,
130
- environment: baseEnv.environment
186
+ appName: import_base.baseEnv.appName,
187
+ environment: import_base.baseEnv.environment
131
188
  };
132
189
  const Self = createArgMetaDecorator("Self");
133
190
  const Me = createArgMetaDecorator("Me");
@@ -198,7 +255,7 @@ const getProcess = (serverType) => function(returns, signalOption = {}) {
198
255
  const metadataMap = getGqlMetaMapOnPrototype(prototype);
199
256
  metadataMap.set(key, {
200
257
  returns,
201
- signalOption: { ...signalOption, serverType: lowerlize(serverType) },
258
+ signalOption: { ...signalOption, serverType: (0, import_common.lowerlize)(serverType) },
202
259
  key,
203
260
  descriptor,
204
261
  guards: ["None"],
@@ -284,9 +341,9 @@ function LogSignal(srv) {
284
341
  }
285
342
  function DbSignal(constant, srv, option) {
286
343
  var _a, _b, _c, _d, _e, _f, _g, _h;
287
- const meta = getClassMeta(constant.Full);
288
- const serviceName = `${lowerlize(meta.refName)}Service`;
289
- const [modelName, className] = [lowerlize(meta.refName), capitalize(meta.refName)];
344
+ const meta = (0, import_constant.getClassMeta)(constant.Full);
345
+ const serviceName = `${(0, import_common.lowerlize)(meta.refName)}Service`;
346
+ const [modelName, className] = [(0, import_common.lowerlize)(meta.refName), (0, import_common.capitalize)(meta.refName)];
290
347
  const names = {
291
348
  modelId: `${modelName}Id`,
292
349
  model: modelName,
@@ -317,7 +374,7 @@ function DbSignal(constant, srv, option) {
317
374
  }
318
375
  async [_d = names.modelInsight](query) {
319
376
  const service = this[serviceName];
320
- const insight = query.$search ? { ...makeDefault(constant.Insight), count: await service.__searchCount(query.$search) } : await service.__insight(query);
377
+ const insight = query.$search ? { ...(0, import_gql.makeDefault)(constant.Insight), count: await service.__searchCount(query.$search) } : await service.__insight(query);
321
378
  return resolve(insight);
322
379
  }
323
380
  async [_e = names.modelExists](query) {
@@ -343,26 +400,26 @@ function DbSignal(constant, srv, option) {
343
400
  }
344
401
  __decorateClass([
345
402
  option.guards.get(() => constant.Light),
346
- __decorateParam(0, Arg.Param(names.modelId, () => ID))
403
+ __decorateParam(0, Arg.Param(names.modelId, () => import_base.ID))
347
404
  ], BaseSignal.prototype, _a, 1);
348
405
  __decorateClass([
349
406
  option.guards.get(() => constant.Full),
350
- __decorateParam(0, Arg.Param(names.modelId, () => ID))
407
+ __decorateParam(0, Arg.Param(names.modelId, () => import_base.ID))
351
408
  ], BaseSignal.prototype, _b, 1);
352
409
  __decorateClass([
353
410
  Query.Admin(() => [constant.Full]),
354
- __decorateParam(0, Arg.Query("query", () => JSON)),
355
- __decorateParam(1, Arg.Query("skip", () => Int, { nullable: true, example: 0 })),
356
- __decorateParam(2, Arg.Query("limit", () => Int, { nullable: true, example: 20 })),
411
+ __decorateParam(0, Arg.Query("query", () => import_base.JSON)),
412
+ __decorateParam(1, Arg.Query("skip", () => import_base.Int, { nullable: true, example: 0 })),
413
+ __decorateParam(2, Arg.Query("limit", () => import_base.Int, { nullable: true, example: 20 })),
357
414
  __decorateParam(3, Arg.Query("sort", () => String, { nullable: true, example: "latest" }))
358
415
  ], BaseSignal.prototype, _c, 1);
359
416
  __decorateClass([
360
417
  Query.Admin(() => constant.Insight),
361
- __decorateParam(0, Arg.Query("query", () => JSON))
418
+ __decorateParam(0, Arg.Query("query", () => import_base.JSON))
362
419
  ], BaseSignal.prototype, _d, 1);
363
420
  __decorateClass([
364
421
  Query.Admin(() => Boolean),
365
- __decorateParam(0, Arg.Query("query", () => JSON))
422
+ __decorateParam(0, Arg.Query("query", () => import_base.JSON))
366
423
  ], BaseSignal.prototype, _e, 1);
367
424
  __decorateClass([
368
425
  option.guards.cru(() => constant.Full),
@@ -370,12 +427,12 @@ function DbSignal(constant, srv, option) {
370
427
  ], BaseSignal.prototype, _f, 1);
371
428
  __decorateClass([
372
429
  option.guards.cru(() => constant.Full),
373
- __decorateParam(0, Arg.Param(names.modelId, () => ID)),
430
+ __decorateParam(0, Arg.Param(names.modelId, () => import_base.ID)),
374
431
  __decorateParam(1, Arg.Body("data", () => constant.Input))
375
432
  ], BaseSignal.prototype, _g, 1);
376
433
  __decorateClass([
377
434
  option.guards.cru(() => constant.Full, { partial: ["status", "removedAt"] }),
378
- __decorateParam(0, Arg.Param(names.modelId, () => ID))
435
+ __decorateParam(0, Arg.Param(names.modelId, () => import_base.ID))
379
436
  ], BaseSignal.prototype, _h, 1);
380
437
  return BaseSignal;
381
438
  }
@@ -435,7 +492,7 @@ const setResolveFieldMetaMapOnPrototype = (prototype, resolveFieldMetaMap) => {
435
492
  Reflect.defineMetadata("resolveField", resolveFieldMetaMap, prototype);
436
493
  };
437
494
  const getControllerPrefix = (sigMeta) => {
438
- return sigMeta.returns ? lowerlize(getClassMeta(sigMeta.returns()).refName) : sigMeta.prefix;
495
+ return sigMeta.returns ? (0, import_common.lowerlize)((0, import_constant.getClassMeta)(sigMeta.returns()).refName) : sigMeta.prefix;
439
496
  };
440
497
  const getControllerPath = (gqlMeta, paramArgMetas) => {
441
498
  return gqlMeta.signalOption.path ?? [gqlMeta.signalOption.name ?? gqlMeta.key, ...paramArgMetas.map((argMeta) => `:${argMeta.name}`)].join("/");
@@ -443,7 +500,7 @@ const getControllerPath = (gqlMeta, paramArgMetas) => {
443
500
  const copySignal = (sigRef) => {
444
501
  class CopiedSignal {
445
502
  }
446
- applyMixins(CopiedSignal, [sigRef]);
503
+ (0, import_common.applyMixins)(CopiedSignal, [sigRef]);
447
504
  const sigMeta = getSigMeta(sigRef);
448
505
  setSigMeta(CopiedSignal, sigMeta);
449
506
  const gqlMetaMap = getGqlMetaMapOnPrototype(sigRef.prototype);
@@ -461,52 +518,3 @@ const copySignal = (sigRef) => {
461
518
  }
462
519
  return CopiedSignal;
463
520
  };
464
- export {
465
- Access,
466
- Account,
467
- Arg,
468
- DbSignal,
469
- Job,
470
- LogSignal,
471
- Me,
472
- Message,
473
- Mutation,
474
- Parent,
475
- Process,
476
- Pubsub,
477
- Query,
478
- Req,
479
- Res,
480
- ResolveField,
481
- Self,
482
- Signal,
483
- SignalStorage,
484
- UserIp,
485
- Ws,
486
- argTypes,
487
- copySignal,
488
- createArgMetaDecorator,
489
- defaultAccount,
490
- done,
491
- emit,
492
- endpointTypes,
493
- getAllSignalRefs,
494
- getArgMetas,
495
- getControllerPath,
496
- getControllerPrefix,
497
- getGqlMeta,
498
- getGqlMetaMapOnPrototype,
499
- getGqlMetas,
500
- getResolveFieldMetas,
501
- getSigMeta,
502
- getSignalRefsOnStorage,
503
- guardTypes,
504
- internalArgTypes,
505
- resolve,
506
- roleTypes,
507
- setArgMetas,
508
- setGqlMetaMapOnPrototype,
509
- signalTypes,
510
- ssoTypes,
511
- subscribe
512
- };