@osdk/react 0.3.0-beta.3 → 0.3.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/CHANGELOG.md +115 -0
- package/build/browser/index.js +4 -0
- package/build/browser/index.js.map +1 -1
- package/build/browser/new/OsdkContext2.js +28 -0
- package/build/browser/new/OsdkContext2.js.map +1 -0
- package/build/browser/new/OsdkProvider2.js +31 -0
- package/build/browser/new/OsdkProvider2.js.map +1 -0
- package/build/browser/new/makeExternalStore.js +39 -0
- package/build/browser/new/makeExternalStore.js.map +1 -0
- package/build/browser/new/useOsdkAction.js +49 -0
- package/build/browser/new/useOsdkAction.js.map +1 -0
- package/build/browser/new/useOsdkList.js +40 -0
- package/build/browser/new/useOsdkList.js.map +1 -0
- package/build/browser/new/useOsdkObject.js +60 -0
- package/build/browser/new/useOsdkObject.js.map +1 -0
- package/build/browser/public/experimental.js +22 -0
- package/build/browser/public/experimental.js.map +1 -0
- package/build/cjs/chunk-2N32USW5.cjs +28 -0
- package/build/cjs/chunk-2N32USW5.cjs.map +1 -0
- package/build/cjs/index.cjs +6 -17
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +2 -3
- package/build/cjs/public/experimental.cjs +142 -0
- package/build/cjs/public/experimental.cjs.map +1 -0
- package/build/cjs/public/experimental.d.cts +71 -0
- package/build/cjs/useOsdkClient-B4iwHO1H.d.cts +5 -0
- package/build/esm/index.js +4 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/new/OsdkContext2.js +28 -0
- package/build/esm/new/OsdkContext2.js.map +1 -0
- package/build/esm/new/OsdkProvider2.js +31 -0
- package/build/esm/new/OsdkProvider2.js.map +1 -0
- package/build/esm/new/makeExternalStore.js +39 -0
- package/build/esm/new/makeExternalStore.js.map +1 -0
- package/build/esm/new/useOsdkAction.js +49 -0
- package/build/esm/new/useOsdkAction.js.map +1 -0
- package/build/esm/new/useOsdkList.js +40 -0
- package/build/esm/new/useOsdkList.js.map +1 -0
- package/build/esm/new/useOsdkObject.js +60 -0
- package/build/esm/new/useOsdkObject.js.map +1 -0
- package/build/esm/public/experimental.js +22 -0
- package/build/esm/public/experimental.js.map +1 -0
- package/build/types/OsdkContext.d.ts +3 -1
- package/build/types/OsdkContext.d.ts.map +1 -0
- package/build/types/OsdkProvider.d.ts +2 -2
- package/build/types/OsdkProvider.d.ts.map +1 -0
- package/build/types/index.d.ts +3 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/new/OsdkContext2.d.ts +9 -0
- package/build/types/new/OsdkContext2.d.ts.map +1 -0
- package/build/types/new/OsdkProvider2.d.ts +10 -0
- package/build/types/new/OsdkProvider2.d.ts.map +1 -0
- package/build/types/new/makeExternalStore.d.ts +5 -0
- package/build/types/new/makeExternalStore.d.ts.map +1 -0
- package/build/types/new/useOsdkAction.d.ts +12 -0
- package/build/types/new/useOsdkAction.d.ts.map +1 -0
- package/build/types/new/useOsdkList.d.ts +26 -0
- package/build/types/new/useOsdkList.d.ts.map +1 -0
- package/build/types/new/useOsdkObject.d.ts +21 -0
- package/build/types/new/useOsdkObject.d.ts.map +1 -0
- package/build/types/public/experimental.d.ts +5 -0
- package/build/types/public/experimental.d.ts.map +1 -0
- package/build/types/useOsdkClient.d.ts.map +1 -0
- package/build/types/useOsdkMetadata.d.ts +2 -2
- package/build/types/useOsdkMetadata.d.ts.map +1 -0
- package/experimental.d.ts +17 -0
- package/package.json +14 -4
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Client } from "@osdk/client";
|
|
2
|
+
import type { ObservableClient } from "@osdk/client/unstable-do-not-use";
|
|
3
|
+
import React from "react";
|
|
4
|
+
interface OsdkContextContents {
|
|
5
|
+
client: Client;
|
|
6
|
+
store: ObservableClient;
|
|
7
|
+
}
|
|
8
|
+
export declare const OsdkContext2: React.Context<OsdkContextContents>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,cAAc,cAAe;AAC3C,cAAc,wBAAwB,kCAAmC;AACzE,OAAO,WAAW,OAAQ;UAYhB,oBAAoB;CAC5B,QAAQ;CAKR,OAAO;AACR;AAED,OAAO,cAAMA,cAAc,MAAM,QAAQ","names":["OsdkContext2: React.Context<OsdkContextContents>"],"sources":["../../../src/new/OsdkContext2.ts"],"version":3,"file":"OsdkContext2.d.ts"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Client } from "@osdk/client";
|
|
2
|
+
import type { ObservableClient } from "@osdk/client/unstable-do-not-use";
|
|
3
|
+
import React from "react";
|
|
4
|
+
interface OsdkProviderOptions {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
client: Client;
|
|
7
|
+
store: ObservableClient;
|
|
8
|
+
}
|
|
9
|
+
export declare function OsdkProvider2({ children, client, store }: OsdkProviderOptions): React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,cAAc,cAAe;AAC3C,cAAc,wBAAwB,kCAAmC;AACzE,OAAO,WAAW,OAAQ;UAGhB,oBAAoB;CAC5B,UAAU,MAAM;CAChB,QAAQ;CACR,OAAO;AACR;AAED,OAAO,iBAAS,cAAc,EAC5B,UACA,QACA,OACoB,EAAnB,sBAAsB,MAAM,IAAI","names":[],"sources":["../../../src/new/OsdkProvider2.tsx"],"version":3,"file":"OsdkProvider2.d.ts"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Unsubscribable } from "@osdk/client/unstable-do-not-use";
|
|
2
|
+
export declare function makeExternalStore<X>(createObservation: (callback: (x: X | undefined) => void) => Unsubscribable, name?: string): {
|
|
3
|
+
subscribe: (notifyUpdate: () => void) => () => void
|
|
4
|
+
getSnapShot: () => X | undefined
|
|
5
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,sBAAsB,kCAAmC;AAEvE,OAAO,iBAAS,kBAAkB,GAChCA,oBAAoBC,WAAWC,GAAG,2BAA2B,gBAC7DC,gBACC;CACD,YAAYC;CACZ,mBAAmB;AACpB","names":["createObservation: (callback: (x: X | undefined) => void) => Unsubscribable","callback: (x: X | undefined) => void","x: X | undefined","name?: string","notifyUpdate: () => void"],"sources":["../../../src/new/makeExternalStore.ts"],"version":3,"file":"makeExternalStore.d.ts"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ActionDefinition } from "@osdk/client";
|
|
2
|
+
import { ActionValidationError } from "@osdk/client";
|
|
3
|
+
import type { ActionSignatureFromDef, ObservableClient } from "@osdk/client/unstable-do-not-use";
|
|
4
|
+
export interface UseOsdkActionResult<Q extends ActionDefinition<any>> {
|
|
5
|
+
applyAction: (args: Parameters<ActionSignatureFromDef<Q>["applyAction"]>[0], opts: ObservableClient.ApplyActionOptions) => Promise<unknown>;
|
|
6
|
+
error: undefined | Partial<{
|
|
7
|
+
actionValidation: ActionValidationError
|
|
8
|
+
unknown: unknown
|
|
9
|
+
}>;
|
|
10
|
+
data: unknown;
|
|
11
|
+
}
|
|
12
|
+
export declare function useOsdkAction<Q extends ActionDefinition<any>>(actionDef: Q): UseOsdkActionResult<Q>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,wBAAwB,cAAe;AACrD,SAAS,6BAA6B,cAAe;AACrD,cACE,wBACA,wBACK,kCAAmC;AAI1C,iBAAiB,oBAAoB,UAAU,uBAAuB;CACpE,cACEA,MAAM,WAAW,uBAAuB,GAAG,gBAAgB,IAC3DC,MAAM,iBAAiB,uBACpB;CAEL,mBAEI,QAAQ;EACR,kBAAkB;EAClB;CACD;CACH;AACD;AAED,OAAO,iBAAS,cAAc,UAAU,uBACtCC,WAAW,IACV,oBAAoB","names":["args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]","opts: ObservableClient.ApplyActionOptions","actionDef: Q"],"sources":["../../../src/new/useOsdkAction.ts"],"version":3,"file":"useOsdkAction.d.ts"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ObjectTypeDefinition, Osdk, WhereClause } from "@osdk/client";
|
|
2
|
+
export interface UseOsdkListOptions<T extends ObjectTypeDefinition> {
|
|
3
|
+
where: WhereClause<T>;
|
|
4
|
+
/**
|
|
5
|
+
* The number of milliseconds to wait after the last observed list change.
|
|
6
|
+
*
|
|
7
|
+
* Two uses of `useOsdkList` with the where clause will only trigger one
|
|
8
|
+
* network request if the second is within `dedupeIntervalMs`.
|
|
9
|
+
*/
|
|
10
|
+
dedupeIntervalMs?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface UseOsdkListResult<T extends ObjectTypeDefinition> {
|
|
13
|
+
fetchMore: (() => Promise<unknown>) | undefined;
|
|
14
|
+
data: Osdk.Instance<T>[];
|
|
15
|
+
isLoading: boolean;
|
|
16
|
+
error: undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Refers to whether the ordered list of objects (only considering the $primaryKey)
|
|
19
|
+
* is optimistic or not.
|
|
20
|
+
*
|
|
21
|
+
* If you need to know if the contents of the list are optimistic you can
|
|
22
|
+
* do that on a per object basis with useOsdkObject
|
|
23
|
+
*/
|
|
24
|
+
isOptimistic: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function useOsdkList<T extends ObjectTypeDefinition>(type: T, opts: UseOsdkListOptions<T>): UseOsdkListResult<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,sBAAsB,MAAM,mBAAmB,cAAe;AAM5E,iBAAiB,mBAAmB,UAAU,sBAAsB;CAClE,OAAO,YAAY;;;;;;;CAQnB;AACD;AACD,iBAAiB,kBAAkB,UAAU,sBAAsB;CACjE,kBAAkB;CAClB,MAAM,KAAK,SAAS;CACpB;CAGA;;;;;;;;CASA;AACD;AAED,OAAO,iBAAS,YAAY,UAAU,sBACpCA,MAAM,GACNC,MAAM,mBAAmB,KACxB,kBAAkB","names":["type: T","opts: UseOsdkListOptions<T>"],"sources":["../../../src/new/useOsdkList.ts"],"version":3,"file":"useOsdkList.d.ts"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ObjectTypeDefinition, Osdk, PrimaryKeyType } from "@osdk/api";
|
|
2
|
+
export interface UseOsdkObjectResult<Q extends ObjectTypeDefinition> {
|
|
3
|
+
object: Osdk.Instance<Q> | undefined;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Refers to whether the object is optimistic or not.
|
|
7
|
+
*/
|
|
8
|
+
isOptimistic: boolean;
|
|
9
|
+
forceUpdate: () => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @param obj an existing `Osdk.Instance` object to get metadata for.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useOsdkObject<Q extends ObjectTypeDefinition>(obj: Osdk.Instance<Q>): UseOsdkObjectResult<Q>;
|
|
15
|
+
/**
|
|
16
|
+
* Loads an object by type and primary key.
|
|
17
|
+
*
|
|
18
|
+
* @param type
|
|
19
|
+
* @param primaryKey
|
|
20
|
+
*/
|
|
21
|
+
export declare function useOsdkObject<Q extends ObjectTypeDefinition>(type: Q, primaryKey: PrimaryKeyType<Q>): UseOsdkObjectResult<Q>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,sBAAsB,MAAM,sBAAsB,WAAY;AAM5E,iBAAiB,oBAAoB,UAAU,sBAAsB;CACnE,QAAQ,KAAK,SAAS;CACtB;;;;CAKA;CACA;AACD;;;;AAKD,OAAO,iBAAS,cAAc,UAAU,sBACtCA,KAAK,KAAK,SAAS,KAClB,oBAAoB;;;;;;;AAOvB,OAAO,iBAAS,cAAc,UAAU,sBACtCC,MAAM,GACNC,YAAY,eAAe,KAC1B,oBAAoB","names":["obj: Osdk.Instance<Q>","type: Q","primaryKey: PrimaryKeyType<Q>"],"sources":["../../../src/new/useOsdkObject.ts"],"version":3,"file":"useOsdkObject.d.ts"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { OsdkProvider2 } from "../new/OsdkProvider2.js";
|
|
2
|
+
export { useOsdkAction } from "../new/useOsdkAction.js";
|
|
3
|
+
export { useOsdkList } from "../new/useOsdkList.js";
|
|
4
|
+
export { useOsdkObject } from "../new/useOsdkObject.js";
|
|
5
|
+
export { useOsdkClient } from "../useOsdkClient.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB","names":[],"sources":["../../../src/public/experimental.ts"],"version":3,"file":"experimental.d.ts"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,cAAc,cAAe;AAI3C,OAAO,iBAAS,iBAAiB","names":[],"sources":["../../src/useOsdkClient.ts"],"version":3,"file":"useOsdkClient.d.ts"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { InterfaceDefinition, InterfaceMetadata, ObjectMetadata, ObjectOrInterfaceDefinition, ObjectTypeDefinition } from "@osdk/api";
|
|
2
2
|
type MetadataFor<T extends ObjectOrInterfaceDefinition> = T extends InterfaceDefinition ? InterfaceMetadata : T extends ObjectTypeDefinition ? ObjectMetadata : never;
|
|
3
3
|
export declare function useOsdkMetadata<T extends ObjectOrInterfaceDefinition>(type: T): {
|
|
4
|
-
loading: boolean
|
|
5
|
-
metadata?: MetadataFor<T
|
|
4
|
+
loading: boolean
|
|
5
|
+
metadata?: MetadataFor<T>
|
|
6
6
|
};
|
|
7
7
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cACE,qBACA,mBACA,gBACA,6BACA,4BACK,WAAY;KAId,YAAY,UAAU,+BAA+B,UACxD,sBAAsB,oBACpB,UAAU,uBAAuB;AAGrC,OAAO,iBAAS,gBAAgB,UAAU,6BACxCA,MAAM,IACL;CACD;CACA,WAAW,YAAY;AACxB","names":["type: T"],"sources":["../../src/useOsdkMetadata.ts"],"version":3,"file":"useOsdkMetadata.d.ts"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export * from "./build/cjs/public/experimental.cjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdk/react",
|
|
3
|
-
"version": "0.3.0
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,6 +16,15 @@
|
|
|
16
16
|
"require": "./build/cjs/index.cjs",
|
|
17
17
|
"default": "./build/browser/index.js"
|
|
18
18
|
},
|
|
19
|
+
"./experimental": {
|
|
20
|
+
"browser": "./build/browser/public/experimental.js",
|
|
21
|
+
"import": {
|
|
22
|
+
"types": "./build/types/public/experimental.d.ts",
|
|
23
|
+
"default": "./build/esm/public/experimental.js"
|
|
24
|
+
},
|
|
25
|
+
"require": "./build/cjs/public/experimental.cjs",
|
|
26
|
+
"default": "./build/browser/public/experimental.js"
|
|
27
|
+
},
|
|
19
28
|
"./*": {
|
|
20
29
|
"browser": "./build/browser/public/*.js",
|
|
21
30
|
"import": {
|
|
@@ -36,13 +45,13 @@
|
|
|
36
45
|
"devDependencies": {
|
|
37
46
|
"@testing-library/react": "^16.0.1",
|
|
38
47
|
"@types/react": "^18.3.12",
|
|
39
|
-
"happy-dom": "^
|
|
48
|
+
"happy-dom": "^16.8.1",
|
|
40
49
|
"p-defer": "^4.0.1",
|
|
41
50
|
"react": "^18.0.0",
|
|
42
51
|
"typescript": "~5.5.4",
|
|
43
|
-
"@osdk/api": "2.1.0
|
|
52
|
+
"@osdk/api": "2.1.0",
|
|
44
53
|
"@osdk/monorepo.api-extractor": "~0.0.0",
|
|
45
|
-
"@osdk/client": "2.1.0
|
|
54
|
+
"@osdk/client": "2.1.0",
|
|
46
55
|
"@osdk/monorepo.tsconfig": "~0.0.0"
|
|
47
56
|
},
|
|
48
57
|
"publishConfig": {
|
|
@@ -63,6 +72,7 @@
|
|
|
63
72
|
"types": "./build/cjs/index.d.cts",
|
|
64
73
|
"type": "module",
|
|
65
74
|
"scripts": {
|
|
75
|
+
"apiDocs": "npx typedoc ",
|
|
66
76
|
"check-attw": "attw --pack .",
|
|
67
77
|
"check-spelling": "cspell --quiet .",
|
|
68
78
|
"clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
|