@hypelabs-llc/ts-sdk 0.1.3 → 0.1.4
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/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/plain.d.ts +15 -0
- package/dist/plain.js +11 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2,3 +2,6 @@ export { createPartnerClient } from "./partnerClient.js";
|
|
|
2
2
|
export { ApiKeyAuthenticationProvider } from "./apiKeyAuthenticationProvider.js";
|
|
3
3
|
// Re-export the generated models (Customer, Order, Proxy, …) so consumers import them from the package root.
|
|
4
4
|
export * from "./generated/models/index.js";
|
|
5
|
+
// Plain<T> / toPlain(): turn a generated model into its plain-data shape (no hand-written DTOs, safe for React
|
|
6
|
+
// Client Components).
|
|
7
|
+
export { toPlain } from "./plain.js";
|
package/dist/plain.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AdditionalDataHolder, Parsable } from "@microsoft/kiota-abstractions";
|
|
2
|
+
type KiotaParts = keyof AdditionalDataHolder | keyof Parsable;
|
|
3
|
+
/**
|
|
4
|
+
* The plain-data shape of a generated model: same fields, minus Kiota's `additionalData` and serialization
|
|
5
|
+
* methods. Use it so you never have to hand-write a DTO — `Plain<Location>` is exactly the model's data fields,
|
|
6
|
+
* and stays in sync when the API adds one.
|
|
7
|
+
*/
|
|
8
|
+
export type Plain<T> = Omit<T, KiotaParts>;
|
|
9
|
+
/**
|
|
10
|
+
* Returns a plain copy of a generated model — the data fields only, with `additionalData` and the Parsable
|
|
11
|
+
* methods dropped — so it can cross a React Server/Client boundary (Next.js "Only plain objects" error),
|
|
12
|
+
* be JSON-serialized, or be persisted without dragging the Kiota machinery along.
|
|
13
|
+
*/
|
|
14
|
+
export declare function toPlain<T extends AdditionalDataHolder>(model: T): Plain<T>;
|
|
15
|
+
export {};
|
package/dist/plain.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a plain copy of a generated model — the data fields only, with `additionalData` and the Parsable
|
|
3
|
+
* methods dropped — so it can cross a React Server/Client boundary (Next.js "Only plain objects" error),
|
|
4
|
+
* be JSON-serialized, or be persisted without dragging the Kiota machinery along.
|
|
5
|
+
*/
|
|
6
|
+
export function toPlain(model) {
|
|
7
|
+
// Spread copies only own enumerable properties (the data fields + additionalData); Parsable's methods live on
|
|
8
|
+
// the type, not as own enumerable props, so they're already gone. Then drop additionalData.
|
|
9
|
+
const { additionalData: _additionalData, ...rest } = model;
|
|
10
|
+
return rest;
|
|
11
|
+
}
|