@akanjs/test 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/sample.js DELETED
@@ -1,50 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var sample_exports = {};
30
- __export(sample_exports, {
31
- sample: () => sample
32
- });
33
- module.exports = __toCommonJS(sample_exports);
34
- var import_base = require("@akanjs/base");
35
- var import_common = require("@akanjs/common");
36
- var import_chance = __toESM(require("chance"));
37
- const chance = new import_chance.default();
38
- const sample = Object.assign(chance, {
39
- dayjs: /* @__PURE__ */ __name((opt) => (0, import_base.dayjs)(chance.date({
40
- ...opt,
41
- min: opt?.min?.toDate(),
42
- max: opt?.max?.toDate()
43
- })), "dayjs"),
44
- pick: import_common.randomPick,
45
- picks: import_common.randomPicks
46
- });
47
- // Annotate the CommonJS export names for ESM import in node:
48
- 0 && (module.exports = {
49
- sample
50
- });
package/src/sampleOf.js DELETED
@@ -1,110 +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 sampleOf_exports = {};
20
- __export(sampleOf_exports, {
21
- sampleOf: () => sampleOf
22
- });
23
- module.exports = __toCommonJS(sampleOf_exports);
24
- var import_base = require("@akanjs/base");
25
- var import_common = require("@akanjs/common");
26
- var import_constant = require("@akanjs/constant");
27
- var import_sample = require("./sample");
28
- const getFieldTypeExample = {
29
- email: /* @__PURE__ */ __name(() => import_sample.sample.email(), "email"),
30
- password: /* @__PURE__ */ __name(() => import_sample.sample.string({
31
- length: 8
32
- }), "password"),
33
- url: /* @__PURE__ */ __name(() => import_sample.sample.url(), "url")
34
- };
35
- const scalarSampleMap = /* @__PURE__ */ new Map([
36
- [
37
- import_base.ID,
38
- () => import_sample.sample.hash({
39
- length: 24
40
- })
41
- ],
42
- [
43
- import_base.Int,
44
- () => import_sample.sample.integer({
45
- min: -1e4,
46
- max: 1e4
47
- })
48
- ],
49
- [
50
- import_base.Float,
51
- () => import_sample.sample.floating({
52
- min: -1e4,
53
- max: 1e4
54
- })
55
- ],
56
- [
57
- String,
58
- () => import_sample.sample.string({
59
- length: 100
60
- })
61
- ],
62
- [
63
- Boolean,
64
- () => import_sample.sample.bool()
65
- ],
66
- [
67
- Date,
68
- () => import_sample.sample.dayjs()
69
- ],
70
- [
71
- import_base.Upload,
72
- () => "FileUpload"
73
- ],
74
- [
75
- import_base.JSON,
76
- () => ({})
77
- ]
78
- ]);
79
- const getScalarSample = /* @__PURE__ */ __name((ref, fieldMeta) => {
80
- if (fieldMeta.type) {
81
- return getFieldTypeExample[fieldMeta.type]();
82
- } else if (typeof fieldMeta.min === "number") {
83
- return fieldMeta.min;
84
- } else if (typeof fieldMeta.max === "number") {
85
- return fieldMeta.max;
86
- } else {
87
- return scalarSampleMap.get(ref)?.() ?? null;
88
- }
89
- }, "getScalarSample");
90
- const makeSample = /* @__PURE__ */ __name((fieldMeta) => {
91
- if (fieldMeta.default) return typeof fieldMeta.default === "function" ? fieldMeta.default() : fieldMeta.default;
92
- else if (fieldMeta.enum) return (0, import_common.randomPick)([
93
- ...fieldMeta.enum.values
94
- ]);
95
- if ((0, import_base.isGqlScalar)(fieldMeta.modelRef)) return getScalarSample(fieldMeta.modelRef, fieldMeta);
96
- return Object.fromEntries((0, import_constant.getFieldMetas)(fieldMeta.modelRef).map((fieldMeta2) => [
97
- fieldMeta2.key,
98
- fieldMeta2.arrDepth ? [] : fieldMeta2.isClass && !fieldMeta2.isScalar ? null : makeSample(fieldMeta2)
99
- ]));
100
- }, "makeSample");
101
- const sampleOf = /* @__PURE__ */ __name((modelRef) => {
102
- return Object.fromEntries((0, import_constant.getFieldMetas)(modelRef).map((fieldMeta) => [
103
- fieldMeta.key,
104
- fieldMeta.arrDepth ? [] : fieldMeta.isClass && !fieldMeta.isScalar ? null : makeSample(fieldMeta)
105
- ]));
106
- }, "sampleOf");
107
- // Annotate the CommonJS export names for ESM import in node:
108
- 0 && (module.exports = {
109
- sampleOf
110
- });