@naturalcycles/nodejs-lib 15.78.2 → 15.79.0

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.
@@ -65,6 +65,7 @@ export declare const j: {
65
65
  and(): {
66
66
  silentBob: () => never;
67
67
  };
68
+ literal<const V extends string | number | boolean | null>(v: V): JsonSchemaEnumBuilder<V, V, false>;
68
69
  };
69
70
  export declare class JsonSchemaTerminal<IN, OUT, Opt> {
70
71
  protected schema: JsonSchema;
@@ -138,6 +138,14 @@ export const j = {
138
138
  },
139
139
  };
140
140
  },
141
+ literal(v) {
142
+ let baseType = 'other';
143
+ if (typeof v === 'string')
144
+ baseType = 'string';
145
+ if (typeof v === 'number')
146
+ baseType = 'number';
147
+ return new JsonSchemaEnumBuilder([v], baseType);
148
+ },
141
149
  };
142
150
  const TS_2500 = 16725225600; // 2500-01-01
143
151
  const TS_2500_MILLIS = TS_2500 * 1000;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
3
  "type": "module",
4
- "version": "15.78.2",
4
+ "version": "15.79.0",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@types/js-yaml": "^4",
@@ -223,6 +223,13 @@ export const j = {
223
223
  },
224
224
  }
225
225
  },
226
+
227
+ literal<const V extends string | number | boolean | null>(v: V) {
228
+ let baseType: EnumBaseType = 'other'
229
+ if (typeof v === 'string') baseType = 'string'
230
+ if (typeof v === 'number') baseType = 'number'
231
+ return new JsonSchemaEnumBuilder<V>([v], baseType)
232
+ },
226
233
  }
227
234
 
228
235
  const TS_2500 = 16725225600 // 2500-01-01