@akanjs/signal 0.0.40 → 0.0.41

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/doc.js DELETED
@@ -1,100 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var doc_exports = {};
20
- __export(doc_exports, {
21
- getExampleData: () => getExampleData,
22
- makeRequestExample: () => makeRequestExample,
23
- makeResponseExample: () => makeResponseExample
24
- });
25
- module.exports = __toCommonJS(doc_exports);
26
- var import_base = require("@akanjs/base");
27
- var import_constant = require("@akanjs/constant");
28
- var import_signalDecorators = require("./signalDecorators");
29
- let ResponseExampleStorage = class ResponseExampleStorage2 {
30
- static {
31
- __name(this, "ResponseExampleStorage");
32
- }
33
- };
34
- const getPredefinedRequestExample = /* @__PURE__ */ __name((modelRef) => {
35
- return Reflect.getMetadata(modelRef, ResponseExampleStorage.prototype);
36
- }, "getPredefinedRequestExample");
37
- const getPredefinedResponseExample = /* @__PURE__ */ __name((modelRef) => {
38
- return Reflect.getMetadata(modelRef, ResponseExampleStorage.prototype);
39
- }, "getPredefinedResponseExample");
40
- const getResponseExample = /* @__PURE__ */ __name((ref) => {
41
- const [modelRef, arrDepth] = (0, import_base.getNonArrayModel)(ref);
42
- const existing = getPredefinedRequestExample(modelRef);
43
- if (existing) return existing;
44
- const isScalar = (0, import_base.isGqlScalar)(modelRef);
45
- if (isScalar) return (0, import_base.arraiedModel)((0, import_constant.getScalarExample)(modelRef), arrDepth);
46
- const fieldMetas = (0, import_constant.getFieldMetas)(modelRef);
47
- const example = {};
48
- fieldMetas.forEach((fieldMeta) => {
49
- if (fieldMeta.example) example[fieldMeta.key] = fieldMeta.example;
50
- else if (fieldMeta.enum) example[fieldMeta.key] = (0, import_base.arraiedModel)(fieldMeta.enum.values[0], fieldMeta.arrDepth);
51
- else example[fieldMeta.key] = getResponseExample(fieldMeta.modelRef);
52
- });
53
- const result = (0, import_base.arraiedModel)(example, arrDepth);
54
- Reflect.defineMetadata(ref, result, ResponseExampleStorage.prototype);
55
- return result;
56
- }, "getResponseExample");
57
- let RequestExampleStorage = class RequestExampleStorage2 {
58
- static {
59
- __name(this, "RequestExampleStorage");
60
- }
61
- };
62
- const getRequestExample = /* @__PURE__ */ __name((ref) => {
63
- const existing = getPredefinedRequestExample(ref);
64
- if (existing) return existing;
65
- const fieldMetas = (0, import_constant.getFieldMetas)(ref);
66
- const example = {};
67
- const isScalar = (0, import_base.isGqlScalar)(ref);
68
- if (isScalar) return (0, import_constant.getScalarExample)(ref);
69
- else {
70
- fieldMetas.forEach((fieldMeta) => {
71
- if (!fieldMeta.isScalar && fieldMeta.isClass) example[fieldMeta.key] = "ObjectID";
72
- else example[fieldMeta.key] = fieldMeta.example ?? fieldMeta.enum ? (0, import_base.arraiedModel)(fieldMeta.example ?? (fieldMeta.enum?.values)[0], fieldMeta.optArrDepth) : (0, import_base.arraiedModel)(getRequestExample(fieldMeta.modelRef), fieldMeta.arrDepth);
73
- });
74
- }
75
- Reflect.defineMetadata(ref, example, RequestExampleStorage.prototype);
76
- return example;
77
- }, "getRequestExample");
78
- const makeRequestExample = /* @__PURE__ */ __name((sigRef, key) => {
79
- const [argMetas] = (0, import_signalDecorators.getArgMetas)(sigRef, key);
80
- return getExampleData(argMetas);
81
- }, "makeRequestExample");
82
- const getExampleData = /* @__PURE__ */ __name((argMetas, signalType = "graphql") => Object.fromEntries(argMetas.filter((argMeta) => argMeta.type !== "Upload").map((argMeta) => {
83
- const [argRef, argArrDepth] = (0, import_base.getNonArrayModel)(argMeta.returns());
84
- const example = argMeta.argsOption.example ?? getRequestExample(argRef);
85
- return [
86
- argMeta.name,
87
- (0, import_base.arraiedModel)(signalType === "restapi" && argRef.prototype === import_base.JSON.prototype ? JSON.stringify(example, null, 2) : example, argArrDepth)
88
- ];
89
- })), "getExampleData");
90
- const makeResponseExample = /* @__PURE__ */ __name((sigRef, key) => {
91
- const gqlMeta = (0, import_signalDecorators.getGqlMeta)(sigRef, key);
92
- const example = getResponseExample(gqlMeta.returns());
93
- return example;
94
- }, "makeResponseExample");
95
- // Annotate the CommonJS export names for ESM import in node:
96
- 0 && (module.exports = {
97
- getExampleData,
98
- makeRequestExample,
99
- makeResponseExample
100
- });