zitejs 0.9.106 → 0.9.107

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.
@@ -99,15 +99,37 @@ export interface TableFindAllOptions<T = Record<string, unknown>> {
99
99
  filter?: unknown;
100
100
  fields?: Array<FieldSelector<T>>;
101
101
  }
102
+ /**
103
+ * Both write results carry the record twice — flat, and again under `fields`.
104
+ *
105
+ * That is not a quirk of the type. Both dispatchers build it deliberately, with
106
+ * the same code and the same comment ("Return both flat fields and nested
107
+ * fields for backwards compatibility"):
108
+ * `cloudflare-lambda/src/integrations/databases.ts` and
109
+ * `workflow-runner/src/sdk/databases.ts`.
110
+ *
111
+ * The types said otherwise, each in a different direction — `BulkCreateResult`
112
+ * declared only the flat form, `UpdateResult` only the nested one. So a 1.0 app
113
+ * reading `created.fields.token`, which is what 1.0's SDK typed, stopped
114
+ * compiling after migrating even though the value was sitting right there at
115
+ * runtime. DSA Employee Portal migrated "successfully" and then would not build.
116
+ *
117
+ * Declaring both is the whole fix: nothing about the running code changes, and
118
+ * no app source has to be rewritten to match a type narrower than what the
119
+ * runtime actually returns.
120
+ */
102
121
  export interface BulkCreateResult<T> {
103
122
  /** Absent when `records: []` was passed — the dispatch short-circuits before setting it. */
104
123
  success?: boolean;
105
- records: T[];
124
+ records: Array<T & {
125
+ fields: T;
126
+ }>;
106
127
  }
107
- export interface UpdateResult<T> {
128
+ /** A type alias, not an interface: an interface cannot extend a generic `Partial<T>`. */
129
+ export type UpdateResult<T> = Partial<T> & {
108
130
  id: string;
109
131
  fields: Partial<T>;
110
- }
132
+ };
111
133
  export interface DeleteResult {
112
134
  success: true;
113
135
  id: string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ (0, vitest_1.describe)("BulkCreateResult", () => {
5
+ // The 1.0 spelling. This is the one that regressed.
6
+ (0, vitest_1.it)("reads through .fields", () => {
7
+ (0, vitest_1.expectTypeOf)().toEqualTypeOf();
8
+ (0, vitest_1.expectTypeOf)().toEqualTypeOf();
9
+ });
10
+ // The 2.0 spelling, which must keep working — apps written since migration
11
+ // use it, so this is not a case of swapping one shape for the other.
12
+ (0, vitest_1.it)("reads flat", () => {
13
+ (0, vitest_1.expectTypeOf)().toEqualTypeOf();
14
+ (0, vitest_1.expectTypeOf)().toEqualTypeOf();
15
+ });
16
+ (0, vitest_1.it)("keeps success optional", () => {
17
+ (0, vitest_1.expectTypeOf)().toEqualTypeOf();
18
+ });
19
+ });
20
+ (0, vitest_1.describe)("UpdateResult", () => {
21
+ // The mirror image: `update` returned `{ ...transformed, fields: transformed }`
22
+ // but the type declared only `id` and `fields`, so reading a column straight
23
+ // off an update result failed to compile.
24
+ (0, vitest_1.it)("reads flat and through .fields", () => {
25
+ (0, vitest_1.expectTypeOf)().toEqualTypeOf();
26
+ (0, vitest_1.expectTypeOf)().toEqualTypeOf();
27
+ (0, vitest_1.expectTypeOf)().toEqualTypeOf();
28
+ });
29
+ });
@@ -99,15 +99,37 @@ export interface TableFindAllOptions<T = Record<string, unknown>> {
99
99
  filter?: unknown;
100
100
  fields?: Array<FieldSelector<T>>;
101
101
  }
102
+ /**
103
+ * Both write results carry the record twice — flat, and again under `fields`.
104
+ *
105
+ * That is not a quirk of the type. Both dispatchers build it deliberately, with
106
+ * the same code and the same comment ("Return both flat fields and nested
107
+ * fields for backwards compatibility"):
108
+ * `cloudflare-lambda/src/integrations/databases.ts` and
109
+ * `workflow-runner/src/sdk/databases.ts`.
110
+ *
111
+ * The types said otherwise, each in a different direction — `BulkCreateResult`
112
+ * declared only the flat form, `UpdateResult` only the nested one. So a 1.0 app
113
+ * reading `created.fields.token`, which is what 1.0's SDK typed, stopped
114
+ * compiling after migrating even though the value was sitting right there at
115
+ * runtime. DSA Employee Portal migrated "successfully" and then would not build.
116
+ *
117
+ * Declaring both is the whole fix: nothing about the running code changes, and
118
+ * no app source has to be rewritten to match a type narrower than what the
119
+ * runtime actually returns.
120
+ */
102
121
  export interface BulkCreateResult<T> {
103
122
  /** Absent when `records: []` was passed — the dispatch short-circuits before setting it. */
104
123
  success?: boolean;
105
- records: T[];
124
+ records: Array<T & {
125
+ fields: T;
126
+ }>;
106
127
  }
107
- export interface UpdateResult<T> {
128
+ /** A type alias, not an interface: an interface cannot extend a generic `Partial<T>`. */
129
+ export type UpdateResult<T> = Partial<T> & {
108
130
  id: string;
109
131
  fields: Partial<T>;
110
- }
132
+ };
111
133
  export interface DeleteResult {
112
134
  success: true;
113
135
  id: string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,27 @@
1
+ import { describe, it, expectTypeOf } from "vitest";
2
+ describe("BulkCreateResult", () => {
3
+ // The 1.0 spelling. This is the one that regressed.
4
+ it("reads through .fields", () => {
5
+ expectTypeOf().toEqualTypeOf();
6
+ expectTypeOf().toEqualTypeOf();
7
+ });
8
+ // The 2.0 spelling, which must keep working — apps written since migration
9
+ // use it, so this is not a case of swapping one shape for the other.
10
+ it("reads flat", () => {
11
+ expectTypeOf().toEqualTypeOf();
12
+ expectTypeOf().toEqualTypeOf();
13
+ });
14
+ it("keeps success optional", () => {
15
+ expectTypeOf().toEqualTypeOf();
16
+ });
17
+ });
18
+ describe("UpdateResult", () => {
19
+ // The mirror image: `update` returned `{ ...transformed, fields: transformed }`
20
+ // but the type declared only `id` and `fields`, so reading a column straight
21
+ // off an update result failed to compile.
22
+ it("reads flat and through .fields", () => {
23
+ expectTypeOf().toEqualTypeOf();
24
+ expectTypeOf().toEqualTypeOf();
25
+ expectTypeOf().toEqualTypeOf();
26
+ });
27
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.9.106",
3
+ "version": "0.9.107",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",