@naturalcycles/nodejs-lib 15.62.0 → 15.63.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.
@@ -20,6 +20,7 @@ declare class Git2 {
20
20
  getCurrentCommitTimestamp(): UnixTimestamp;
21
21
  getCurrentBranchName(): string;
22
22
  getCurrentRepoName(): string;
23
+ getAllBranchesNames(): string[];
23
24
  }
24
25
  export declare const git2: Git2;
25
26
  export {};
package/dist/util/git2.js CHANGED
@@ -86,5 +86,30 @@ class Git2 {
86
86
  const originUrl = exec2.exec('git config --get remote.origin.url');
87
87
  return basename(originUrl, '.git');
88
88
  }
89
+ getAllBranchesNames() {
90
+ /**
91
+ * Raw output example from this repository:
92
+ * $ git branch -r
93
+ * origin/DEV-22569-zod-isoDate-params
94
+ * origin/DEV-23052-git2-add-method
95
+ * origin/HEAD -> origin/main
96
+ * origin/add-requiredpick-type-helper
97
+ * origin/better-object-keys
98
+ * origin/feat/immutable-j-1
99
+ * origin/feat/immutable-j-2
100
+ * origin/feat/random-string-util
101
+ * origin/fix-vsc-red-line
102
+ * origin/generic-cachekey-function-2
103
+ * origin/gh-pages
104
+ * origin/main
105
+ * origin/stringify-or-undefined
106
+ */
107
+ return exec2
108
+ .exec('git branch -r')
109
+ .split('\n')
110
+ .map(s => s.trim())
111
+ .filter(s => !s.includes(' -> '))
112
+ .map(s => s.split('/')[1]);
113
+ }
89
114
  }
90
115
  export const git2 = new Git2();
@@ -242,7 +242,9 @@ export declare class JsonSchemaObjectBuilder<IN extends AnyObject, OUT extends A
242
242
  /**
243
243
  * Concatenates another schema to the current schema.
244
244
  *
245
- * It expects a type to be passed in as a generic, and this type should be the expected final type.
245
+ * It expects 2 types to be passed in as a generic:
246
+ * 1) the expected final type,
247
+ * 2) the type of the passed in schema.
246
248
  *
247
249
  * ```ts
248
250
  * interface Foo { foo: string }
@@ -252,11 +254,11 @@ export declare class JsonSchemaObjectBuilder<IN extends AnyObject, OUT extends A
252
254
  * const barSchema = j.object<Bar>({ bar: j.number() })
253
255
  *
254
256
  * interface Shu { foo: string, bar: number }
255
- * const shuSchema = fooSchema.concat<Shu>(barSchema)
257
+ * const shuSchema = fooSchema.concat<Shu, Bar>(barSchema)
256
258
  * ```
257
259
  */
258
260
  concat(other: any): never;
259
- concat<FINAL extends AnyObject>(other: JsonSchemaObjectBuilder<any, any, any>): JsonSchemaObjectBuilder<FINAL, FINAL, false>;
261
+ concat<NEW_TYPE extends AnyObject, OUT2 extends AnyObject>(other: JsonSchemaObjectBuilder<any, OUT2, any>): ExactMatch<NEW_TYPE, OUT & OUT2> extends true ? JsonSchemaObjectBuilder<NEW_TYPE, NEW_TYPE, false> : never;
260
262
  /**
261
263
  * Extends the current schema with `id`, `created` and `updated` according to NC DB conventions.
262
264
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
3
  "type": "module",
4
- "version": "15.62.0",
4
+ "version": "15.63.0",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@types/js-yaml": "^4",
package/src/util/git2.ts CHANGED
@@ -99,6 +99,32 @@ class Git2 {
99
99
  const originUrl = exec2.exec('git config --get remote.origin.url')
100
100
  return basename(originUrl, '.git')
101
101
  }
102
+
103
+ getAllBranchesNames(): string[] {
104
+ /**
105
+ * Raw output example from this repository:
106
+ * $ git branch -r
107
+ * origin/DEV-22569-zod-isoDate-params
108
+ * origin/DEV-23052-git2-add-method
109
+ * origin/HEAD -> origin/main
110
+ * origin/add-requiredpick-type-helper
111
+ * origin/better-object-keys
112
+ * origin/feat/immutable-j-1
113
+ * origin/feat/immutable-j-2
114
+ * origin/feat/random-string-util
115
+ * origin/fix-vsc-red-line
116
+ * origin/generic-cachekey-function-2
117
+ * origin/gh-pages
118
+ * origin/main
119
+ * origin/stringify-or-undefined
120
+ */
121
+ return exec2
122
+ .exec('git branch -r')
123
+ .split('\n')
124
+ .map(s => s.trim())
125
+ .filter(s => !s.includes(' -> '))
126
+ .map(s => s.split('/')[1]!)
127
+ }
102
128
  }
103
129
 
104
130
  export const git2 = new Git2()
@@ -851,7 +851,9 @@ export class JsonSchemaObjectBuilder<
851
851
  /**
852
852
  * Concatenates another schema to the current schema.
853
853
  *
854
- * It expects a type to be passed in as a generic, and this type should be the expected final type.
854
+ * It expects 2 types to be passed in as a generic:
855
+ * 1) the expected final type,
856
+ * 2) the type of the passed in schema.
855
857
  *
856
858
  * ```ts
857
859
  * interface Foo { foo: string }
@@ -861,13 +863,15 @@ export class JsonSchemaObjectBuilder<
861
863
  * const barSchema = j.object<Bar>({ bar: j.number() })
862
864
  *
863
865
  * interface Shu { foo: string, bar: number }
864
- * const shuSchema = fooSchema.concat<Shu>(barSchema)
866
+ * const shuSchema = fooSchema.concat<Shu, Bar>(barSchema)
865
867
  * ```
866
868
  */
867
869
  concat(other: any): never
868
- concat<FINAL extends AnyObject>(
869
- other: JsonSchemaObjectBuilder<any, any, any>,
870
- ): JsonSchemaObjectBuilder<FINAL, FINAL, false>
870
+ concat<NEW_TYPE extends AnyObject, OUT2 extends AnyObject>(
871
+ other: JsonSchemaObjectBuilder<any, OUT2, any>,
872
+ ): ExactMatch<NEW_TYPE, OUT & OUT2> extends true
873
+ ? JsonSchemaObjectBuilder<NEW_TYPE, NEW_TYPE, false>
874
+ : never
871
875
  concat(other: any): any {
872
876
  const clone = this.clone()
873
877
  mergeJsonSchemaObjects(clone.schema as any, other.schema)