@contractkit/plugin-csharp 0.1.4 → 0.1.5

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.
@@ -5,9 +5,9 @@ $ tsup src/index.ts --format esm --sourcemap --dts && tsc --emitDeclarationOnly
5
5
  CLI tsup v8.5.1
6
6
  CLI Target: esnext
7
7
  ESM Build start
8
- ESM dist/index.js 88.63 KB
9
- ESM dist/index.js.map 193.78 KB
10
- ESM ⚡️ Build success in 154ms
8
+ ESM dist/index.js 88.92 KB
9
+ ESM dist/index.js.map 194.67 KB
10
+ ESM ⚡️ Build success in 108ms
11
11
  DTS Build start
12
- DTS ⚡️ Build success in 6453ms
12
+ DTS ⚡️ Build success in 5348ms
13
13
  DTS dist/index.d.ts 1.50 KB
@@ -3,27 +3,27 @@ $ vitest run --coverage
3
3
   RUN  v4.1.5 /home/runner/work/ContractKit/ContractKit/packages/plugin-csharp
4
4
  Coverage enabled with v8
5
5
 
6
- ✓ tests/naming.test.ts (23 tests) 110ms
7
- ✓ tests/codegen-client.test.ts (40 tests) 305ms
8
- ✓ tests/codegen-models.test.ts (65 tests) 306ms
9
- ✓ tests/index.test.ts (10 tests) 199ms
10
- ✓ tests/runtime.test.ts (14 tests) 65ms
11
- ✓ tests/scaffold.test.ts (5 tests) 46ms
12
- ✓ tests/hoist.test.ts (10 tests) 54ms
6
+ ✓ tests/naming.test.ts (23 tests) 51ms
7
+ ✓ tests/codegen-client.test.ts (40 tests) 189ms
8
+ ✓ tests/codegen-models.test.ts (66 tests) 210ms
9
+ ✓ tests/index.test.ts (10 tests) 70ms
10
+ ✓ tests/runtime.test.ts (14 tests) 28ms
11
+ ✓ tests/scaffold.test.ts (5 tests) 43ms
12
+ ✓ tests/hoist.test.ts (10 tests) 25ms
13
13
 
14
14
   Test Files  7 passed (7)
15
-  Tests  167 passed (167)
16
-  Start at  17:55:57
17
-  Duration  13.21s (transform 4.92s, setup 0ms, import 21.10s, tests 1.08s, environment 1ms)
15
+  Tests  168 passed (168)
16
+  Start at  19:26:13
17
+  Duration  9.80s (transform 5.17s, setup 0ms, import 16.95s, tests 615ms, environment 12ms)
18
18
 
19
19
   % Coverage report from v8
20
20
  -------------------|---------|----------|---------|---------|-------------------
21
21
  File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
22
22
  -------------------|---------|----------|---------|---------|-------------------
23
- All files | 88.59 | 78.77 | 89.91 | 90.97 |
24
- src | 88.65 | 78.52 | 90.14 | 91.02 |
23
+ All files | 88.61 | 79.07 | 89.95 | 91 |
24
+ src | 88.68 | 78.83 | 90.19 | 91.05 |
25
25
  ...gen-client.ts | 95.91 | 90.87 | 95.38 | 97.67 | ...28-530,547-548
26
- ...gen-models.ts | 91.29 | 75.25 | 96.61 | 93.02 | ...05,907,929-932
26
+ ...gen-models.ts | 91.35 | 76.09 | 96.66 | 93.08 | ...18,920,942-945
27
27
  codegen-sdk.ts | 100 | 100 | 100 | 100 |
28
28
  hoist.ts | 78.66 | 61.9 | 93.1 | 79.06 | ...13-322,350-362
29
29
  index.ts | 70.74 | 71.21 | 58.06 | 75.59 | ...25-329,350-369
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @contractkit/plugin-csharp
2
2
 
3
+ ## 0.1.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 153134e: A default on a `bigint` field is parsed as an exact `bigint`, and the generated TypeScript for one compiles.
8
+
9
+ `quantity: bigint = 9007199254740993` used to parse to the JS number `9007199254740992`, so every generator emitted the rounded value and `pnpm format` wrote it back into the file. The parser now reads the literal's digits into a `bigint`, for a `bigint` field or a `bigint | null` one. A non-integer default such as `= 1.5` is reported as an error instead. `FieldNode.default` and `OpParamNode.default` are typed `FieldDefault`, which adds `bigint`, so plugins that read a default have one more case to handle. The new `coerceDefault` export applies the rule.
10
+
11
+ The TypeScript plugin wrote a bigint default as `.default(5)`. Zod requires a default to be the schema's output type, so every generated project with a bigint default failed to typecheck (TS2769). At runtime the handler would also have received a `number`, because Zod returns a default without parsing it. It now writes `.default(5n)`.
12
+
13
+ Every other consumer handles the new value: Kotlin, Swift and C# initialize from the exact digits, Bruno and the `openapi` target write the digit string a `bigint` travels as, `openapi-to-ck` reads that string back with `BigInt()` rather than `Number()`, and the VS Code hover no longer throws when a referenced model carries a bigint default.
14
+
15
+ A default on a field whose type is a `ref` to a `bigint` alias is still parsed as a number, because the alias is not resolved at parse time.
16
+
17
+ - Updated dependencies [a440886]
18
+ - Updated dependencies [153134e]
19
+ - @contractkit/core@0.31.0
20
+
3
21
  ## 0.1.4
4
22
 
5
23
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"codegen-models.d.ts","sourceRoot":"","sources":["../src/codegen-models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAa,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAElH,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,YAAY,CAAC;AAK3D,MAAM,WAAW,yBAAyB;IACtC,qFAAqF;IACrF,SAAS,EAAE,MAAM,CAAC;IAClB,gGAAgG;IAChG,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC;;;OAGG;IACH,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC5C,kGAAkG;IAClG,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAiBD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,yBAAyB,GAAG,MAAM,CAwBpG;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,EAAE,QAAQ,GAAE,WAAW,CAAC,MAAM,CAAa,GAAG,GAAG,CAAC,MAAM,CAAC,CAG3H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MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAYvI;AAID;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,EAAE,GAAG,EAAE,aAAa,EAAE,QAAQ,UAAQ,GAAG,MAAM,CAqDrG;AAqBD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,aAAa,GAAG,MAAM,CA2CrF;AA2qBD,YAAY,EAAE,aAAa,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -340,11 +340,16 @@ function literalCSharpType(value, ctx) {
340
340
  if (typeof value === "boolean") return qualify("bool", "System.Boolean", ctx);
341
341
  return Number.isInteger(value) ? qualify("long", "System.Int64", ctx) : qualify("double", "System.Double", ctx);
342
342
  }
343
+ var MIN_SAFE_BIGINT = BigInt(Number.MIN_SAFE_INTEGER);
344
+ var MAX_SAFE_BIGINT = BigInt(Number.MAX_SAFE_INTEGER);
345
+ function isSafeInteger(value) {
346
+ return typeof value === "bigint" ? value >= MIN_SAFE_BIGINT && value <= MAX_SAFE_BIGINT : Number.isSafeInteger(value);
347
+ }
343
348
  function renderDefault(value, type, ctx, memberNames = /* @__PURE__ */ new Set()) {
344
349
  const enumType = (name) => memberNames.has(name) ? `global::${ctx.namespace}.Models.${name}` : name;
345
350
  const inner = type.kind === "lazy" ? type.inner : type;
346
351
  if (typeof value === "boolean") return String(value);
347
- if (typeof value === "number") {
352
+ if (typeof value === "number" || typeof value === "bigint") {
348
353
  if (inner.kind === "scalar") {
349
354
  switch (inner.name) {
350
355
  case "int":
@@ -354,7 +359,7 @@ function renderDefault(value, type, ctx, memberNames = /* @__PURE__ */ new Set()
354
359
  case "decimal":
355
360
  return `${value}m`;
356
361
  case "bigint":
357
- return Number.isSafeInteger(value) ? `new BigInteger(${value})` : `BigInteger.Parse("${value}")`;
362
+ return isSafeInteger(value) ? `new BigInteger(${value})` : `BigInteger.Parse("${value}")`;
358
363
  }
359
364
  }
360
365
  return Number.isInteger(value) ? `${value}L` : `${value}d`;