@bidirekt/typescript-sdk-cli 0.1.0-rc.1 → 0.1.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.
package/README.md CHANGED
@@ -1825,21 +1825,43 @@ A handler declares one resource: its method, in uppercase (`GET`, `POST`, `PUT`,
1825
1825
 
1826
1826
  Without a request (no `request` option, no `@bidirekt request` tag), the resource has no `request` key. A tag names a schema by its name in the contract, which is not always its name in the code. A list is written once however many handlers use it.
1827
1827
 
1828
- A tag can't hold a path with a `*` before another segment (`/pets/*/photos`): its `*/` ends the comment, and the code left after it stops `generate`. Declare such a resource with `@BidirektProvider` or `@BidirektConsumer`:
1828
+ In a tag, write a `*` before another segment as `*\/` (`/pets/*\/photos`): a bare `*/` would end the comment. `generate` reads `*\/` as `*/`:
1829
1829
 
1830
1830
  ```ts
1831
1831
  // photos.ts
1832
+ import { BidirektField, BidirektSchema } from '@bidirekt/typescript-sdk'
1833
+
1834
+ @BidirektSchema()
1835
+ export class Photo {
1836
+ @BidirektField()
1837
+ url!: string
1838
+ }
1839
+
1832
1840
  /**
1833
- * @bidirekt provides GET /pets/*/photos
1834
- * @bidirekt response 200
1841
+ * @bidirekt provides GET /pets/*\/photos
1842
+ * @bidirekt response 200 Photo[]
1835
1843
  */
1836
1844
  export function listPhotos() {}
1837
1845
  ```
1838
1846
 
1839
- ```text
1840
- photos.ts:4 syntax error: expression expected: fix the code so TypeScript can parse it
1841
- photos.ts:4 syntax error: ';' expected: fix the code so TypeScript can parse it
1842
- photos.ts:5 syntax error: unterminated regular expression literal: fix the code so TypeScript can parse it
1847
+ ```yaml
1848
+ # Generated by @bidirekt/typescript-sdk. Do not edit.
1849
+ provides:
1850
+ rest:
1851
+ /pets/*/photos:
1852
+ get:
1853
+ responses:
1854
+ 200: PhotoList
1855
+ schemas:
1856
+ Photo:
1857
+ type: object
1858
+ properties:
1859
+ url:
1860
+ type: string
1861
+ PhotoList:
1862
+ type: array
1863
+ items:
1864
+ ref: Photo
1843
1865
  ```
1844
1866
 
1845
1867
  #### Providers
@@ -269,7 +269,10 @@ function tagToComment(tag) {
269
269
  }
270
270
  function textToArguments(text) {
271
271
  const [beforeFence] = text.split('```');
272
- return beforeFence.replace(/\r\n?/g, '\n').match(argumentPattern) ?? [];
272
+ return (beforeFence
273
+ .replace(/\r\n?/g, '\n')
274
+ .replaceAll('*\\/', '*/')
275
+ .match(argumentPattern) ?? []);
273
276
  }
274
277
  function warnUnreadComment(file, range, read) {
275
278
  if (!file.text.startsWith('/**', range.pos)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bidirekt/typescript-sdk-cli",
3
- "version": "0.1.0-rc.1",
3
+ "version": "0.1.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,7 +25,7 @@
25
25
  "prepublishOnly": "npm run build"
26
26
  },
27
27
  "dependencies": {
28
- "@bidirekt/typescript-sdk": "0.1.0-rc.1",
28
+ "@bidirekt/typescript-sdk": "0.1.0",
29
29
  "typescript": "~6.0.3",
30
30
  "yaml": "^2.9.1"
31
31
  }