@bedrockio/yada 1.0.31 → 1.0.32
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/dist/cjs/Schema.js +14 -3
- package/dist/cjs/date.js +16 -0
- package/package.json +1 -1
- package/src/Schema.js +11 -2
- package/src/date.js +11 -0
- package/types/Schema.d.ts +5 -0
- package/types/Schema.d.ts.map +1 -1
- package/types/date.d.ts.map +1 -1
package/dist/cjs/Schema.js
CHANGED
|
@@ -202,18 +202,29 @@ class Schema {
|
|
|
202
202
|
const {
|
|
203
203
|
required,
|
|
204
204
|
format,
|
|
205
|
-
tags
|
|
206
|
-
default: defaultValue
|
|
205
|
+
tags
|
|
207
206
|
} = this.meta;
|
|
208
207
|
return {
|
|
209
208
|
required,
|
|
210
|
-
default: defaultValue,
|
|
211
209
|
format,
|
|
212
210
|
...tags,
|
|
211
|
+
...this.getDefault(),
|
|
213
212
|
...this.enumToOpenApi(),
|
|
214
213
|
...this.expandExtra(extra)
|
|
215
214
|
};
|
|
216
215
|
}
|
|
216
|
+
getDefault() {
|
|
217
|
+
const {
|
|
218
|
+
default: defaultValue
|
|
219
|
+
} = this.meta;
|
|
220
|
+
if (typeof defaultValue === 'function') {
|
|
221
|
+
return {};
|
|
222
|
+
} else {
|
|
223
|
+
return {
|
|
224
|
+
default: defaultValue
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
217
228
|
inspect() {
|
|
218
229
|
return JSON.stringify(this.toOpenApi(), null, 2);
|
|
219
230
|
}
|
package/dist/cjs/date.js
CHANGED
|
@@ -159,6 +159,22 @@ class DateSchema extends _Schema.default {
|
|
|
159
159
|
...super.toOpenApi(extra)
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
|
+
getDefault() {
|
|
163
|
+
const {
|
|
164
|
+
default: defaultValue
|
|
165
|
+
} = this.meta;
|
|
166
|
+
if (defaultValue === Date.now) {
|
|
167
|
+
return {
|
|
168
|
+
default: 'now'
|
|
169
|
+
};
|
|
170
|
+
} else if (typeof defaultValue === 'function') {
|
|
171
|
+
return {
|
|
172
|
+
default: 'custom'
|
|
173
|
+
};
|
|
174
|
+
} else {
|
|
175
|
+
return super.getDefault();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
162
178
|
}
|
|
163
179
|
|
|
164
180
|
/**
|
package/package.json
CHANGED
package/src/Schema.js
CHANGED
|
@@ -190,17 +190,26 @@ export default class Schema {
|
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
toOpenApi(extra) {
|
|
193
|
-
const { required, format, tags
|
|
193
|
+
const { required, format, tags } = this.meta;
|
|
194
194
|
return {
|
|
195
195
|
required,
|
|
196
|
-
default: defaultValue,
|
|
197
196
|
format,
|
|
198
197
|
...tags,
|
|
198
|
+
...this.getDefault(),
|
|
199
199
|
...this.enumToOpenApi(),
|
|
200
200
|
...this.expandExtra(extra),
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
getDefault() {
|
|
205
|
+
const { default: defaultValue } = this.meta;
|
|
206
|
+
if (typeof defaultValue === 'function') {
|
|
207
|
+
return {};
|
|
208
|
+
} else {
|
|
209
|
+
return { default: defaultValue };
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
204
213
|
inspect() {
|
|
205
214
|
return JSON.stringify(this.toOpenApi(), null, 2);
|
|
206
215
|
}
|
package/src/date.js
CHANGED
|
@@ -149,6 +149,17 @@ class DateSchema extends Schema {
|
|
|
149
149
|
...super.toOpenApi(extra),
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
+
|
|
153
|
+
getDefault() {
|
|
154
|
+
const { default: defaultValue } = this.meta;
|
|
155
|
+
if (defaultValue === Date.now) {
|
|
156
|
+
return { default: 'now' };
|
|
157
|
+
} else if (typeof defaultValue === 'function') {
|
|
158
|
+
return { default: 'custom' };
|
|
159
|
+
} else {
|
|
160
|
+
return super.getDefault();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
152
163
|
}
|
|
153
164
|
|
|
154
165
|
/**
|
package/types/Schema.d.ts
CHANGED
package/types/Schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../src/Schema.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Schema.d.ts","sourceRoot":"","sources":["../src/Schema.js"],"names":[],"mappings":"AAgWA,4CAEC;AAtVD;;GAEG;AAEH;IACE,uBAGC;IAFC,kBAAoB;IACpB,SAAgB;IAKlB;;OAEG;IACH,YAFa,IAAI,CAQhB;IAED;;;OAGG;IACH,mBAFa,IAAI,CAShB;IAED;;;;OAIG;IACH,gBAHW,eAAe,GACb,IAAI,CAmBhB;IAED;;;;OAIG;IACH,mBAFa,IAAI,CAIhB;IAED;;;OAGG;IACH,sBAFa,IAAI,CAIhB;IAED;;;OAGG;IACH,uBAFa,IAAI,CAIhB;IAED;;OAEG;IACH,uBAFa,IAAI,CAIhB;IAED;;OAEG;IACH,gBAFa,IAAI,CAShB;IAED;;OAEG;IACH,+BAFa,IAAI,CAMhB;IAED;;OAEG;IACH,uBAFa,IAAI,CAIhB;IAED,iDAqCC;IAED;;OAEG;IACH,kBAFa,IAAI,CAOhB;IAED;;;OAGG;IACH,qBAFa,IAAI,CAMhB;IAED,2BAUC;IAED;;;;MAOC;IAED,kBAEC;IAED,4BAMC;IAID;;OAEG;IACH,kCAFa,IAAI,CAmChB;IAED;;OAEG;IACH,4BAFa,IAAI,CAUhB;IAED,oCAKC;IAED;;OAEG;IACH,oBAFa,IAAI,CAShB;IAED,gCAGC;IAED,qEAUC;IAED;;;;;;;;MAoCC;CACF;8BAjVY,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,UAAU,CAAC"}
|
package/types/date.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../src/date.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../src/date.js"],"names":[],"mappings":"AAoKA;;GAEG;AACH,+CAEC;AApKD;IACE,cAUC;IAED;;OAEG;IACH,SAFW,MAAM,GAAC,MAAM,GAAC,IAAI,cAY5B;IAED;;OAEG;IACH,SAFW,MAAM,GAAC,MAAM,GAAC,IAAI,cAY5B;IAED;;OAEG;IACH,YAFW,MAAM,GAAC,MAAM,GAAC,IAAI,cAY5B;IAED;;OAEG;IACH,WAFW,MAAM,GAAC,MAAM,GAAC,IAAI,cAY5B;IAED,mBAOC;IAED,qBAOC;IAED;;OAEG;IACH,aAFW,MAAM,GAAG,WAAW,cAa9B;IAED,wBAUC;IAED,mBAcC;CAwBF"}
|