@naturalcycles/nodejs-lib 15.106.0 → 15.106.2

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.
@@ -78,7 +78,7 @@ export declare const j: {
78
78
  * Use `anyOf` when schemas may overlap (e.g., AccountId | PartnerId with same format).
79
79
  * Use `oneOf` when schemas are mutually exclusive.
80
80
  */
81
- oneOf<B extends readonly JSchema<any, boolean>[], OUT = BuilderOutUnion<B>>(items: [...B]): JBuilder<OUT, false>;
81
+ oneOf<B extends readonly JSchema<any, boolean>[]>(items: [...B]): JBuilder<BuilderOutUnion<B>, false>;
82
82
  /**
83
83
  * Use only with primitive values, otherwise this function will throw to avoid bugs.
84
84
  * To validate objects, use `anyOfBy` or `anyOfThese`.
@@ -90,7 +90,7 @@ export declare const j: {
90
90
  * Use `anyOf` when schemas may overlap (e.g., AccountId | PartnerId with same format).
91
91
  * Use `oneOf` when schemas are mutually exclusive.
92
92
  */
93
- anyOf<B extends readonly JSchema<any, boolean>[], OUT = BuilderOutUnion<B>>(items: [...B]): JBuilder<OUT, false>;
93
+ anyOf<B extends readonly JSchema<any, boolean>[]>(items: [...B]): JBuilder<BuilderOutUnion<B>, false>;
94
94
  /**
95
95
  * Pick validation schema for an object based on the value of a specific property.
96
96
  *
@@ -103,7 +103,7 @@ export declare const j: {
103
103
  * const schema = j.anyOfBy('success', schemaMap)
104
104
  * ```
105
105
  */
106
- anyOfBy<D extends Record<PropertyKey, JSchema<any, any>>, OUT = AnyOfByOut<D>>(propertyName: string, schemaDictionary: D): JBuilder<OUT, false>;
106
+ anyOfBy<D extends Record<PropertyKey, JSchema<any, any>>>(propertyName: string, schemaDictionary: D): JBuilder<AnyOfByOut<D>, false>;
107
107
  /**
108
108
  * Custom version of `anyOf` which - in contrast to the original function - does not mutate the input.
109
109
  * This comes with a performance penalty, so do not use it where performance matters.
@@ -112,7 +112,7 @@ export declare const j: {
112
112
  * const schema = j.anyOfThese([successSchema, errorSchema])
113
113
  * ```
114
114
  */
115
- anyOfThese<B extends readonly JSchema<any, boolean>[], OUT = BuilderOutUnion<B>>(items: [...B]): JBuilder<OUT, false>;
115
+ anyOfThese<B extends readonly JSchema<any, boolean>[]>(items: [...B]): JBuilder<BuilderOutUnion<B>, false>;
116
116
  and(): {
117
117
  silentBob: () => never;
118
118
  };
@@ -47,6 +47,8 @@ export function mergeJsonSchemaObjects(schema1, schema2) {
47
47
  const s1 = schema1;
48
48
  const s2 = schema2;
49
49
  // Merge `properties`
50
+ // Not vulnerable to prototype pollution: writes to s1.properties (a nested object),
51
+ // where __proto__ assignment only changes that object's prototype, not Object.prototype.
50
52
  Object.entries(s2.properties).forEach(([k, v]) => {
51
53
  s1.properties[k] = v;
52
54
  });
@@ -600,6 +600,7 @@ const TIMEZONES_FROM_WIKI = [
600
600
  'WET',
601
601
  'Zulu',
602
602
  ];
603
+ // oxlint-disable-next-line no-restricted-globals
603
604
  const TIMEZONES_FROM_JS = Intl.supportedValuesOf('timeZone');
604
605
  /**
605
606
  * A complicated merge of timezones from the underlying Javascript engine
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
3
  "type": "module",
4
- "version": "15.106.0",
4
+ "version": "15.106.2",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@standard-schema/spec": "^1",
@@ -219,16 +219,16 @@ export const j = {
219
219
  * Use `anyOf` when schemas may overlap (e.g., AccountId | PartnerId with same format).
220
220
  * Use `oneOf` when schemas are mutually exclusive.
221
221
  */
222
- oneOf<B extends readonly JSchema<any, boolean>[], OUT = BuilderOutUnion<B>>(
222
+ oneOf<B extends readonly JSchema<any, boolean>[]>(
223
223
  items: [...B],
224
- ): JBuilder<OUT, false> {
224
+ ): JBuilder<BuilderOutUnion<B>, false> {
225
225
  const schemas = items.map(b => b.build())
226
226
  _assert(
227
227
  schemas.every(hasNoObjectSchemas),
228
228
  'Do not use `oneOf` validation with non-primitive types!',
229
229
  )
230
230
 
231
- return new JBuilder<OUT, false>({
231
+ return new JBuilder<BuilderOutUnion<B>, false>({
232
232
  oneOf: schemas,
233
233
  })
234
234
  },
@@ -244,16 +244,16 @@ export const j = {
244
244
  * Use `anyOf` when schemas may overlap (e.g., AccountId | PartnerId with same format).
245
245
  * Use `oneOf` when schemas are mutually exclusive.
246
246
  */
247
- anyOf<B extends readonly JSchema<any, boolean>[], OUT = BuilderOutUnion<B>>(
247
+ anyOf<B extends readonly JSchema<any, boolean>[]>(
248
248
  items: [...B],
249
- ): JBuilder<OUT, false> {
249
+ ): JBuilder<BuilderOutUnion<B>, false> {
250
250
  const schemas = items.map(b => b.build())
251
251
  _assert(
252
252
  schemas.every(hasNoObjectSchemas),
253
253
  'Do not use `anyOf` validation with non-primitive types!',
254
254
  )
255
255
 
256
- return new JBuilder<OUT, false>({
256
+ return new JBuilder<BuilderOutUnion<B>, false>({
257
257
  anyOf: schemas,
258
258
  })
259
259
  },
@@ -270,16 +270,16 @@ export const j = {
270
270
  * const schema = j.anyOfBy('success', schemaMap)
271
271
  * ```
272
272
  */
273
- anyOfBy<D extends Record<PropertyKey, JSchema<any, any>>, OUT = AnyOfByOut<D>>(
273
+ anyOfBy<D extends Record<PropertyKey, JSchema<any, any>>>(
274
274
  propertyName: string,
275
275
  schemaDictionary: D,
276
- ): JBuilder<OUT, false> {
276
+ ): JBuilder<AnyOfByOut<D>, false> {
277
277
  const builtSchemaDictionary: Record<string, JsonSchema> = {}
278
278
  for (const [key, schema] of Object.entries(schemaDictionary)) {
279
279
  builtSchemaDictionary[key] = schema.build()
280
280
  }
281
281
 
282
- return new JBuilder<OUT, false>({
282
+ return new JBuilder<AnyOfByOut<D>, false>({
283
283
  type: 'object',
284
284
  hasIsOfTypeCheck: true,
285
285
  anyOfBy: {
@@ -297,10 +297,10 @@ export const j = {
297
297
  * const schema = j.anyOfThese([successSchema, errorSchema])
298
298
  * ```
299
299
  */
300
- anyOfThese<B extends readonly JSchema<any, boolean>[], OUT = BuilderOutUnion<B>>(
300
+ anyOfThese<B extends readonly JSchema<any, boolean>[]>(
301
301
  items: [...B],
302
- ): JBuilder<OUT, false> {
303
- return new JBuilder<OUT, false>({
302
+ ): JBuilder<BuilderOutUnion<B>, false> {
303
+ return new JBuilder<BuilderOutUnion<B>, false>({
304
304
  anyOfThese: items.map(b => b.build()),
305
305
  })
306
306
  },
@@ -55,6 +55,8 @@ export function mergeJsonSchemaObjects<T1 extends AnyObject, T2 extends AnyObjec
55
55
  const s2 = schema2 as any
56
56
 
57
57
  // Merge `properties`
58
+ // Not vulnerable to prototype pollution: writes to s1.properties (a nested object),
59
+ // where __proto__ assignment only changes that object's prototype, not Object.prototype.
58
60
  Object.entries(s2.properties).forEach(([k, v]) => {
59
61
  s1.properties[k] = v
60
62
  })
@@ -603,6 +603,7 @@ const TIMEZONES_FROM_WIKI = [
603
603
  'Zulu',
604
604
  ] as IANATimezone[]
605
605
 
606
+ // oxlint-disable-next-line no-restricted-globals
606
607
  const TIMEZONES_FROM_JS = Intl.supportedValuesOf('timeZone') as IANATimezone[]
607
608
 
608
609
  /**