@akanjs/constant 0.0.102 → 0.0.103

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.
@@ -1,4 +1,27 @@
1
- import "reflect-metadata";
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 constantDecorator_exports = {};
19
+ __export(constantDecorator_exports, {
20
+ cnstOf: () => cnstOf,
21
+ getCnstMeta: () => getCnstMeta
22
+ });
23
+ module.exports = __toCommonJS(constantDecorator_exports);
24
+ var import_reflect_metadata = require("reflect-metadata");
2
25
  class CnstStorage {
3
26
  }
4
27
  const setCnstMeta = (refName, cnst) => {
@@ -15,7 +38,3 @@ const cnstOf = (refName, Input, Full, Light, Insight, Filter, Summary) => {
15
38
  setCnstMeta(refName, cnst);
16
39
  return cnst;
17
40
  };
18
- export {
19
- cnstOf,
20
- getCnstMeta
21
- };
@@ -0,0 +1,21 @@
1
+ import "reflect-metadata";
2
+ class CnstStorage {
3
+ }
4
+ const setCnstMeta = (refName, cnst) => {
5
+ Reflect.defineMetadata(refName, cnst, CnstStorage.prototype);
6
+ };
7
+ const getCnstMeta = (refName) => {
8
+ const cnst = Reflect.getMetadata(refName, CnstStorage.prototype);
9
+ if (!cnst)
10
+ throw new Error(`No cnst meta for ${refName}`);
11
+ return cnst;
12
+ };
13
+ const cnstOf = (refName, Input, Full, Light, Insight, Filter, Summary) => {
14
+ const cnst = { refName, Input, Full, Light, Insight, Filter, Summary };
15
+ setCnstMeta(refName, cnst);
16
+ return cnst;
17
+ };
18
+ export {
19
+ cnstOf,
20
+ getCnstMeta
21
+ };
package/src/fieldMeta.js CHANGED
@@ -1,15 +1,33 @@
1
- import { getNonArrayModel, isGqlMap, isGqlScalar, scalarNameMap } from "@akanjs/base";
2
- import {
3
- getClassMeta,
4
- getFieldMetaMapOnPrototype,
5
- setFieldMetaMapOnPrototype
6
- } from "./scalar";
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 fieldMeta_exports = {};
19
+ __export(fieldMeta_exports, {
20
+ Field: () => Field
21
+ });
22
+ module.exports = __toCommonJS(fieldMeta_exports);
23
+ var import_base = require("@akanjs/base");
24
+ var import_scalar = require("./scalar");
7
25
  const applyFieldMeta = (modelRef, arrDepth, option, optionArrDepth) => {
8
26
  const isArray = arrDepth > 0;
9
- const isClass = !isGqlScalar(modelRef);
10
- const isMap = isGqlMap(modelRef);
11
- const { refName, type } = isClass ? getClassMeta(modelRef) : { refName: "", type: "scalar" };
12
- const name = isClass ? refName : scalarNameMap.get(modelRef) ?? "Unknown";
27
+ const isClass = !(0, import_base.isGqlScalar)(modelRef);
28
+ const isMap = (0, import_base.isGqlMap)(modelRef);
29
+ const { refName, type } = isClass ? (0, import_scalar.getClassMeta)(modelRef) : { refName: "", type: "scalar" };
30
+ const name = isClass ? refName : import_base.scalarNameMap.get(modelRef) ?? "Unknown";
13
31
  if (isMap && !option.of)
14
32
  throw new Error("Map type must have 'of' option");
15
33
  return (prototype, key) => {
@@ -44,16 +62,16 @@ const applyFieldMeta = (modelRef, arrDepth, option, optionArrDepth) => {
44
62
  of: option.of,
45
63
  text: option.text
46
64
  };
47
- const metadataMap = getFieldMetaMapOnPrototype(prototype);
65
+ const metadataMap = (0, import_scalar.getFieldMetaMapOnPrototype)(prototype);
48
66
  metadataMap.set(key, metadata);
49
- setFieldMetaMapOnPrototype(prototype, metadataMap);
67
+ (0, import_scalar.setFieldMetaMapOnPrototype)(prototype, metadataMap);
50
68
  };
51
69
  };
52
70
  const makeField = (customOption) => (returns, fieldOption) => {
53
- const [modelRef, arrDepth] = getNonArrayModel(returns());
71
+ const [modelRef, arrDepth] = (0, import_base.getNonArrayModel)(returns());
54
72
  if (!fieldOption)
55
73
  return applyFieldMeta(modelRef, arrDepth, { ...customOption }, arrDepth);
56
- const [opt, optArrDepth] = getNonArrayModel(fieldOption);
74
+ const [opt, optArrDepth] = (0, import_base.getNonArrayModel)(fieldOption);
57
75
  return applyFieldMeta(modelRef, arrDepth, { ...opt, ...customOption }, optArrDepth);
58
76
  };
59
77
  const Field = {
@@ -62,6 +80,3 @@ const Field = {
62
80
  Secret: makeField({ fieldType: "hidden", select: false, nullable: true }),
63
81
  Resolve: makeField({ fieldType: "resolve" })
64
82
  };
65
- export {
66
- Field
67
- };
@@ -0,0 +1,67 @@
1
+ import { getNonArrayModel, isGqlMap, isGqlScalar, scalarNameMap } from "@akanjs/base";
2
+ import {
3
+ getClassMeta,
4
+ getFieldMetaMapOnPrototype,
5
+ setFieldMetaMapOnPrototype
6
+ } from "./scalar";
7
+ const applyFieldMeta = (modelRef, arrDepth, option, optionArrDepth) => {
8
+ const isArray = arrDepth > 0;
9
+ const isClass = !isGqlScalar(modelRef);
10
+ const isMap = isGqlMap(modelRef);
11
+ const { refName, type } = isClass ? getClassMeta(modelRef) : { refName: "", type: "scalar" };
12
+ const name = isClass ? refName : scalarNameMap.get(modelRef) ?? "Unknown";
13
+ if (isMap && !option.of)
14
+ throw new Error("Map type must have 'of' option");
15
+ return (prototype, key) => {
16
+ const metadata = {
17
+ nullable: option.nullable ?? false,
18
+ ref: option.ref,
19
+ refPath: option.refPath,
20
+ refType: option.refType,
21
+ default: option.default ?? (isArray ? [] : null),
22
+ type: option.type,
23
+ fieldType: option.fieldType ?? "property",
24
+ immutable: option.immutable ?? false,
25
+ min: option.min,
26
+ max: option.max,
27
+ enum: option.enum,
28
+ select: option.select ?? true,
29
+ minlength: option.minlength,
30
+ maxlength: option.maxlength,
31
+ query: option.query,
32
+ accumulate: option.accumulate,
33
+ example: option.example,
34
+ validate: option.validate,
35
+ key,
36
+ name,
37
+ isClass,
38
+ isScalar: type === "scalar",
39
+ modelRef,
40
+ arrDepth,
41
+ isArray,
42
+ optArrDepth: optionArrDepth,
43
+ isMap,
44
+ of: option.of,
45
+ text: option.text
46
+ };
47
+ const metadataMap = getFieldMetaMapOnPrototype(prototype);
48
+ metadataMap.set(key, metadata);
49
+ setFieldMetaMapOnPrototype(prototype, metadataMap);
50
+ };
51
+ };
52
+ const makeField = (customOption) => (returns, fieldOption) => {
53
+ const [modelRef, arrDepth] = getNonArrayModel(returns());
54
+ if (!fieldOption)
55
+ return applyFieldMeta(modelRef, arrDepth, { ...customOption }, arrDepth);
56
+ const [opt, optArrDepth] = getNonArrayModel(fieldOption);
57
+ return applyFieldMeta(modelRef, arrDepth, { ...opt, ...customOption }, optArrDepth);
58
+ };
59
+ const Field = {
60
+ Prop: makeField({ fieldType: "property" }),
61
+ Hidden: makeField({ fieldType: "hidden", nullable: true }),
62
+ Secret: makeField({ fieldType: "hidden", select: false, nullable: true }),
63
+ Resolve: makeField({ fieldType: "resolve" })
64
+ };
65
+ export {
66
+ Field
67
+ };
package/src/filterMeta.js CHANGED
@@ -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,10 +25,26 @@ 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 { getNonArrayModel } from "@akanjs/base";
14
- import {
15
- getFieldMetaMap
16
- } from "./scalar";
28
+ var filterMeta_exports = {};
29
+ __export(filterMeta_exports, {
30
+ BaseFilter: () => BaseFilter,
31
+ Filter: () => Filter,
32
+ getFilterArgMetas: () => getFilterArgMetas,
33
+ getFilterKeyMetaMapOnPrototype: () => getFilterKeyMetaMapOnPrototype,
34
+ getFilterMeta: () => getFilterMeta,
35
+ getFilterQuery: () => getFilterQuery,
36
+ getFilterQueryMap: () => getFilterQueryMap,
37
+ getFilterSort: () => getFilterSort,
38
+ getFilterSortMap: () => getFilterSortMap,
39
+ isFilterModel: () => isFilterModel,
40
+ setFilterArgMetasOnPrototype: () => setFilterArgMetasOnPrototype,
41
+ setFilterKeyMetaMapOnPrototype: () => setFilterKeyMetaMapOnPrototype,
42
+ setFilterMeta: () => setFilterMeta,
43
+ sortOf: () => sortOf
44
+ });
45
+ module.exports = __toCommonJS(filterMeta_exports);
46
+ var import_base = require("@akanjs/base");
47
+ var import_scalar = require("./scalar");
17
48
  const isFilterModel = (filterRef) => {
18
49
  return Reflect.getMetadata("filter", filterRef.prototype) !== void 0;
19
50
  };
@@ -60,8 +91,8 @@ const getFilterArgMetas = (filterRef, key) => {
60
91
  };
61
92
  const applyFilterArgMeta = (name, returns, argOption) => {
62
93
  return (prototype, key, idx) => {
63
- const [modelRef, arrDepth] = getNonArrayModel(returns());
64
- const [opt, optArrDepth] = getNonArrayModel(argOption ?? {});
94
+ const [modelRef, arrDepth] = (0, import_base.getNonArrayModel)(returns());
95
+ const [opt, optArrDepth] = (0, import_base.getNonArrayModel)(argOption ?? {});
65
96
  const filterArgMeta = { name, ...opt, modelRef, arrDepth, isArray: arrDepth > 0, optArrDepth };
66
97
  const filterArgMetas = getFilterArgMetasOnPrototype(prototype, key);
67
98
  filterArgMetas[idx] = filterArgMeta;
@@ -94,7 +125,7 @@ const Filter = {
94
125
  Arg: applyFilterArgMeta
95
126
  };
96
127
  const sortOf = (modelRef, sort) => {
97
- const fieldMetaMap = getFieldMetaMap(modelRef);
128
+ const fieldMetaMap = (0, import_scalar.getFieldMetaMap)(modelRef);
98
129
  const statusFieldMeta = fieldMetaMap.get("status");
99
130
  if (!statusFieldMeta)
100
131
  throw new Error(`No status field meta fount in ${modelRef.name}`);
@@ -123,7 +154,7 @@ const sortOf = (modelRef, sort) => {
123
154
  return BaseFilter2;
124
155
  };
125
156
  function BaseFilter(modelRef, sort) {
126
- const fieldMetaMap = getFieldMetaMap(modelRef);
157
+ const fieldMetaMap = (0, import_scalar.getFieldMetaMap)(modelRef);
127
158
  const statusFieldMeta = fieldMetaMap.get("status");
128
159
  if (!statusFieldMeta)
129
160
  throw new Error(`No status field meta fount in ${modelRef.name}`);
@@ -151,19 +182,3 @@ function BaseFilter(modelRef, sort) {
151
182
  });
152
183
  return BaseFilter2;
153
184
  }
154
- export {
155
- BaseFilter,
156
- Filter,
157
- getFilterArgMetas,
158
- getFilterKeyMetaMapOnPrototype,
159
- getFilterMeta,
160
- getFilterQuery,
161
- getFilterQueryMap,
162
- getFilterSort,
163
- getFilterSortMap,
164
- isFilterModel,
165
- setFilterArgMetasOnPrototype,
166
- setFilterKeyMetaMapOnPrototype,
167
- setFilterMeta,
168
- sortOf
169
- };
@@ -1,20 +1,5 @@
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);
18
3
  var __decorateClass = (decorators, target, key, kind) => {
19
4
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
20
5
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
@@ -25,26 +10,10 @@ var __decorateClass = (decorators, target, key, kind) => {
25
10
  return result;
26
11
  };
27
12
  var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
28
- var filterMeta_exports = {};
29
- __export(filterMeta_exports, {
30
- BaseFilter: () => BaseFilter,
31
- Filter: () => Filter,
32
- getFilterArgMetas: () => getFilterArgMetas,
33
- getFilterKeyMetaMapOnPrototype: () => getFilterKeyMetaMapOnPrototype,
34
- getFilterMeta: () => getFilterMeta,
35
- getFilterQuery: () => getFilterQuery,
36
- getFilterQueryMap: () => getFilterQueryMap,
37
- getFilterSort: () => getFilterSort,
38
- getFilterSortMap: () => getFilterSortMap,
39
- isFilterModel: () => isFilterModel,
40
- setFilterArgMetasOnPrototype: () => setFilterArgMetasOnPrototype,
41
- setFilterKeyMetaMapOnPrototype: () => setFilterKeyMetaMapOnPrototype,
42
- setFilterMeta: () => setFilterMeta,
43
- sortOf: () => sortOf
44
- });
45
- module.exports = __toCommonJS(filterMeta_exports);
46
- var import_base = require("@akanjs/base");
47
- var import_scalar = require("./scalar");
13
+ import { getNonArrayModel } from "@akanjs/base";
14
+ import {
15
+ getFieldMetaMap
16
+ } from "./scalar";
48
17
  const isFilterModel = (filterRef) => {
49
18
  return Reflect.getMetadata("filter", filterRef.prototype) !== void 0;
50
19
  };
@@ -91,8 +60,8 @@ const getFilterArgMetas = (filterRef, key) => {
91
60
  };
92
61
  const applyFilterArgMeta = (name, returns, argOption) => {
93
62
  return (prototype, key, idx) => {
94
- const [modelRef, arrDepth] = (0, import_base.getNonArrayModel)(returns());
95
- const [opt, optArrDepth] = (0, import_base.getNonArrayModel)(argOption ?? {});
63
+ const [modelRef, arrDepth] = getNonArrayModel(returns());
64
+ const [opt, optArrDepth] = getNonArrayModel(argOption ?? {});
96
65
  const filterArgMeta = { name, ...opt, modelRef, arrDepth, isArray: arrDepth > 0, optArrDepth };
97
66
  const filterArgMetas = getFilterArgMetasOnPrototype(prototype, key);
98
67
  filterArgMetas[idx] = filterArgMeta;
@@ -125,7 +94,7 @@ const Filter = {
125
94
  Arg: applyFilterArgMeta
126
95
  };
127
96
  const sortOf = (modelRef, sort) => {
128
- const fieldMetaMap = (0, import_scalar.getFieldMetaMap)(modelRef);
97
+ const fieldMetaMap = getFieldMetaMap(modelRef);
129
98
  const statusFieldMeta = fieldMetaMap.get("status");
130
99
  if (!statusFieldMeta)
131
100
  throw new Error(`No status field meta fount in ${modelRef.name}`);
@@ -154,7 +123,7 @@ const sortOf = (modelRef, sort) => {
154
123
  return BaseFilter2;
155
124
  };
156
125
  function BaseFilter(modelRef, sort) {
157
- const fieldMetaMap = (0, import_scalar.getFieldMetaMap)(modelRef);
126
+ const fieldMetaMap = getFieldMetaMap(modelRef);
158
127
  const statusFieldMeta = fieldMetaMap.get("status");
159
128
  if (!statusFieldMeta)
160
129
  throw new Error(`No status field meta fount in ${modelRef.name}`);
@@ -182,3 +151,19 @@ function BaseFilter(modelRef, sort) {
182
151
  });
183
152
  return BaseFilter2;
184
153
  }
154
+ export {
155
+ BaseFilter,
156
+ Filter,
157
+ getFilterArgMetas,
158
+ getFilterKeyMetaMapOnPrototype,
159
+ getFilterMeta,
160
+ getFilterQuery,
161
+ getFilterQueryMap,
162
+ getFilterSort,
163
+ getFilterSortMap,
164
+ isFilterModel,
165
+ setFilterArgMetasOnPrototype,
166
+ setFilterKeyMetaMapOnPrototype,
167
+ setFilterMeta,
168
+ sortOf
169
+ };
package/src/index.js CHANGED
@@ -1,7 +1,23 @@
1
- export * from "./types";
2
- export * from "./fieldMeta";
3
- export * from "./scalar";
4
- export * from "./constantDecorator";
5
- export * from "./filterMeta";
6
- export * from "./baseGql";
7
- export * from "./classMeta";
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var src_exports = {};
16
+ module.exports = __toCommonJS(src_exports);
17
+ __reExport(src_exports, require("./types"), module.exports);
18
+ __reExport(src_exports, require("./fieldMeta"), module.exports);
19
+ __reExport(src_exports, require("./scalar"), module.exports);
20
+ __reExport(src_exports, require("./constantDecorator"), module.exports);
21
+ __reExport(src_exports, require("./filterMeta"), module.exports);
22
+ __reExport(src_exports, require("./baseGql"), module.exports);
23
+ __reExport(src_exports, require("./classMeta"), module.exports);
package/src/index.mjs ADDED
@@ -0,0 +1,7 @@
1
+ export * from "./types";
2
+ export * from "./fieldMeta";
3
+ export * from "./scalar";
4
+ export * from "./constantDecorator";
5
+ export * from "./filterMeta";
6
+ export * from "./baseGql";
7
+ export * from "./classMeta";
package/src/scalar.js CHANGED
@@ -1,36 +1,61 @@
1
- import "reflect-metadata";
2
- import {
3
- Float,
4
- getNonArrayModel,
5
- ID,
6
- Int,
7
- JSON,
8
- scalarNameMap,
9
- Upload
10
- } from "@akanjs/base";
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 scalar_exports = {};
19
+ __export(scalar_exports, {
20
+ fieldTypes: () => fieldTypes,
21
+ getClassMeta: () => getClassMeta,
22
+ getFieldMetaMap: () => getFieldMetaMap,
23
+ getFieldMetaMapOnPrototype: () => getFieldMetaMapOnPrototype,
24
+ getFieldMetas: () => getFieldMetas,
25
+ getGqlTypeStr: () => getGqlTypeStr,
26
+ getQueryMap: () => getQueryMap,
27
+ getScalarExample: () => getScalarExample,
28
+ isConstantModel: () => isConstantModel,
29
+ scalarExampleMap: () => scalarExampleMap,
30
+ setFieldMetaMap: () => setFieldMetaMap,
31
+ setFieldMetaMapOnPrototype: () => setFieldMetaMapOnPrototype
32
+ });
33
+ module.exports = __toCommonJS(scalar_exports);
34
+ var import_reflect_metadata = require("reflect-metadata");
35
+ var import_base = require("@akanjs/base");
11
36
  const scalarExampleMap = /* @__PURE__ */ new Map([
12
- [ID, "1234567890abcdef12345678"],
13
- [Int, 0],
14
- [Float, 0],
37
+ [import_base.ID, "1234567890abcdef12345678"],
38
+ [import_base.Int, 0],
39
+ [import_base.Float, 0],
15
40
  [String, "String"],
16
41
  [Boolean, true],
17
42
  [Date, (/* @__PURE__ */ new Date()).toISOString()],
18
- [Upload, "FileUpload"],
19
- [JSON, {}],
43
+ [import_base.Upload, "FileUpload"],
44
+ [import_base.JSON, {}],
20
45
  [Map, {}]
21
46
  ]);
22
47
  const getScalarExample = (ref) => scalarExampleMap.get(ref) ?? null;
23
- const getGqlTypeStr = (ref) => scalarNameMap.get(ref) ?? getClassMeta(ref).refName;
48
+ const getGqlTypeStr = (ref) => import_base.scalarNameMap.get(ref) ?? getClassMeta(ref).refName;
24
49
  const fieldTypes = ["email", "password", "url"];
25
50
  const getClassMeta = (modelRef) => {
26
- const [target] = getNonArrayModel(modelRef);
51
+ const [target] = (0, import_base.getNonArrayModel)(modelRef);
27
52
  const classMeta = Reflect.getMetadata("class", target.prototype);
28
53
  if (!classMeta)
29
54
  throw new Error(`No ClassMeta for this target ${target.name}`);
30
55
  return classMeta;
31
56
  };
32
57
  const getFieldMetas = (modelRef) => {
33
- const [target] = getNonArrayModel(modelRef);
58
+ const [target] = (0, import_base.getNonArrayModel)(modelRef);
34
59
  const metadataMap = Reflect.getMetadata("fields", target.prototype) ?? /* @__PURE__ */ new Map();
35
60
  const keySortMap = { id: -1, createdAt: 1, updatedAt: 2, removedAt: 3 };
36
61
  return [...metadataMap.values()].sort((a, b) => (keySortMap[a.key] ?? 0) - (keySortMap[b.key] ?? 0));
@@ -39,12 +64,12 @@ const isConstantModel = (modelRef) => {
39
64
  return Reflect.getMetadata("class", modelRef.prototype) !== void 0;
40
65
  };
41
66
  const getFieldMetaMap = (modelRef) => {
42
- const [target] = getNonArrayModel(modelRef);
67
+ const [target] = (0, import_base.getNonArrayModel)(modelRef);
43
68
  const metadataMap = Reflect.getMetadata("fields", target.prototype) ?? /* @__PURE__ */ new Map();
44
69
  return new Map(metadataMap);
45
70
  };
46
71
  const setFieldMetaMap = (modelRef, metadataMap) => {
47
- const [target] = getNonArrayModel(modelRef);
72
+ const [target] = (0, import_base.getNonArrayModel)(modelRef);
48
73
  Reflect.defineMetadata("fields", new Map(metadataMap), target.prototype);
49
74
  };
50
75
  const getFieldMetaMapOnPrototype = (prototype) => {
@@ -60,17 +85,3 @@ const getQueryMap = (modelRef) => {
60
85
  fieldMetas.filter((fieldMeta) => !!fieldMeta.query).map((fieldMeta) => [fieldMeta.key, fieldMeta.query])
61
86
  );
62
87
  };
63
- export {
64
- fieldTypes,
65
- getClassMeta,
66
- getFieldMetaMap,
67
- getFieldMetaMapOnPrototype,
68
- getFieldMetas,
69
- getGqlTypeStr,
70
- getQueryMap,
71
- getScalarExample,
72
- isConstantModel,
73
- scalarExampleMap,
74
- setFieldMetaMap,
75
- setFieldMetaMapOnPrototype
76
- };
package/src/scalar.mjs ADDED
@@ -0,0 +1,76 @@
1
+ import "reflect-metadata";
2
+ import {
3
+ Float,
4
+ getNonArrayModel,
5
+ ID,
6
+ Int,
7
+ JSON,
8
+ scalarNameMap,
9
+ Upload
10
+ } from "@akanjs/base";
11
+ const scalarExampleMap = /* @__PURE__ */ new Map([
12
+ [ID, "1234567890abcdef12345678"],
13
+ [Int, 0],
14
+ [Float, 0],
15
+ [String, "String"],
16
+ [Boolean, true],
17
+ [Date, (/* @__PURE__ */ new Date()).toISOString()],
18
+ [Upload, "FileUpload"],
19
+ [JSON, {}],
20
+ [Map, {}]
21
+ ]);
22
+ const getScalarExample = (ref) => scalarExampleMap.get(ref) ?? null;
23
+ const getGqlTypeStr = (ref) => scalarNameMap.get(ref) ?? getClassMeta(ref).refName;
24
+ const fieldTypes = ["email", "password", "url"];
25
+ const getClassMeta = (modelRef) => {
26
+ const [target] = getNonArrayModel(modelRef);
27
+ const classMeta = Reflect.getMetadata("class", target.prototype);
28
+ if (!classMeta)
29
+ throw new Error(`No ClassMeta for this target ${target.name}`);
30
+ return classMeta;
31
+ };
32
+ const getFieldMetas = (modelRef) => {
33
+ const [target] = getNonArrayModel(modelRef);
34
+ const metadataMap = Reflect.getMetadata("fields", target.prototype) ?? /* @__PURE__ */ new Map();
35
+ const keySortMap = { id: -1, createdAt: 1, updatedAt: 2, removedAt: 3 };
36
+ return [...metadataMap.values()].sort((a, b) => (keySortMap[a.key] ?? 0) - (keySortMap[b.key] ?? 0));
37
+ };
38
+ const isConstantModel = (modelRef) => {
39
+ return Reflect.getMetadata("class", modelRef.prototype) !== void 0;
40
+ };
41
+ const getFieldMetaMap = (modelRef) => {
42
+ const [target] = getNonArrayModel(modelRef);
43
+ const metadataMap = Reflect.getMetadata("fields", target.prototype) ?? /* @__PURE__ */ new Map();
44
+ return new Map(metadataMap);
45
+ };
46
+ const setFieldMetaMap = (modelRef, metadataMap) => {
47
+ const [target] = getNonArrayModel(modelRef);
48
+ Reflect.defineMetadata("fields", new Map(metadataMap), target.prototype);
49
+ };
50
+ const getFieldMetaMapOnPrototype = (prototype) => {
51
+ const metadataMap = Reflect.getMetadata("fields", prototype) ?? /* @__PURE__ */ new Map();
52
+ return new Map(metadataMap);
53
+ };
54
+ const setFieldMetaMapOnPrototype = (prototype, metadataMap) => {
55
+ Reflect.defineMetadata("fields", new Map(metadataMap), prototype);
56
+ };
57
+ const getQueryMap = (modelRef) => {
58
+ const fieldMetas = getFieldMetas(modelRef);
59
+ return Object.fromEntries(
60
+ fieldMetas.filter((fieldMeta) => !!fieldMeta.query).map((fieldMeta) => [fieldMeta.key, fieldMeta.query])
61
+ );
62
+ };
63
+ export {
64
+ fieldTypes,
65
+ getClassMeta,
66
+ getFieldMetaMap,
67
+ getFieldMetaMapOnPrototype,
68
+ getFieldMetas,
69
+ getGqlTypeStr,
70
+ getQueryMap,
71
+ getScalarExample,
72
+ isConstantModel,
73
+ scalarExampleMap,
74
+ setFieldMetaMap,
75
+ setFieldMetaMapOnPrototype
76
+ };
package/src/types.js CHANGED
@@ -1,10 +1,29 @@
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 types_exports = {};
19
+ __export(types_exports, {
20
+ DEFAULT_PAGE_SIZE: () => DEFAULT_PAGE_SIZE,
21
+ defaultListOption: () => defaultListOption
22
+ });
23
+ module.exports = __toCommonJS(types_exports);
1
24
  const defaultListOption = {
2
25
  limit: 20,
3
26
  skip: 0,
4
27
  sort: "latest"
5
28
  };
6
29
  const DEFAULT_PAGE_SIZE = 20;
7
- export {
8
- DEFAULT_PAGE_SIZE,
9
- defaultListOption
10
- };
package/src/types.mjs ADDED
@@ -0,0 +1,10 @@
1
+ const defaultListOption = {
2
+ limit: 20,
3
+ skip: 0,
4
+ sort: "latest"
5
+ };
6
+ const DEFAULT_PAGE_SIZE = 20;
7
+ export {
8
+ DEFAULT_PAGE_SIZE,
9
+ defaultListOption
10
+ };