@osdk/unit-testing 1.0.0-main-ffa3daa062ea7db7f93d9dc1b1768d2b0f01878d → 1.0.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 +131 -4
- package/build/browser/api/MockClient.js.map +1 -1
- package/build/browser/api/MockWriteableClient.js +2 -0
- package/build/browser/api/MockWriteableClient.js.map +1 -0
- package/build/browser/api/index.js.map +1 -1
- package/build/browser/example-function-tests/basicAggregate/basicAggregate.js.map +1 -1
- package/build/browser/example-function-tests/basicFetchPage/basicFetchPage.js.map +1 -1
- package/build/browser/example-function-tests/objectAsInput/objectAsInput.js.map +1 -1
- package/build/browser/example-function-tests/objectSetArithmetic/objectSetArithmetic.js +28 -0
- package/build/browser/example-function-tests/objectSetArithmetic/objectSetArithmetic.js.map +1 -0
- package/build/browser/example-function-tests/objectSetAsInput/objectSetAsInput.js.map +1 -1
- package/build/browser/example-function-tests/objectWithLinks/objectWithLinks.js.map +1 -1
- package/build/browser/example-function-tests/ontologyEdits/ontologyEdits.js.map +1 -1
- package/build/browser/example-function-tests/queryWithArrayParams/queryWithArrayParams.js.map +1 -1
- package/build/browser/{public/experimental.js → example-function-tests/writeableClientEdits/writeableClientEdits.js} +17 -5
- package/build/browser/example-function-tests/writeableClientEdits/writeableClientEdits.js.map +1 -0
- package/build/browser/index.js +1 -0
- package/build/browser/index.js.map +1 -1
- package/build/browser/mock/createMockAttachment.js.map +1 -1
- package/build/browser/mock/createMockClient.js +2 -4
- package/build/browser/mock/createMockClient.js.map +1 -1
- package/build/browser/mock/createMockObjectSet.js.map +1 -1
- package/build/browser/mock/createMockObjectSetWithResolver.js +16 -7
- package/build/browser/mock/createMockObjectSetWithResolver.js.map +1 -1
- package/build/browser/mock/createMockOsdkObject.js.map +1 -1
- package/build/browser/mock/createMockWriteableClient.js +60 -0
- package/build/browser/mock/createMockWriteableClient.js.map +1 -0
- package/build/cjs/index.cjs +501 -17
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +10 -1
- package/build/esm/api/MockClient.js.map +1 -1
- package/build/esm/api/MockWriteableClient.js +2 -0
- package/build/esm/api/MockWriteableClient.js.map +1 -0
- package/build/esm/api/index.js.map +1 -1
- package/build/esm/example-function-tests/basicAggregate/basicAggregate.js.map +1 -1
- package/build/esm/example-function-tests/basicFetchPage/basicFetchPage.js.map +1 -1
- package/build/esm/example-function-tests/objectAsInput/objectAsInput.js.map +1 -1
- package/build/esm/example-function-tests/objectSetArithmetic/objectSetArithmetic.js +28 -0
- package/build/esm/example-function-tests/objectSetArithmetic/objectSetArithmetic.js.map +1 -0
- package/build/esm/example-function-tests/objectSetAsInput/objectSetAsInput.js.map +1 -1
- package/build/esm/example-function-tests/objectWithLinks/objectWithLinks.js.map +1 -1
- package/build/esm/example-function-tests/ontologyEdits/ontologyEdits.js.map +1 -1
- package/build/esm/example-function-tests/queryWithArrayParams/queryWithArrayParams.js.map +1 -1
- package/build/esm/{public/experimental.js → example-function-tests/writeableClientEdits/writeableClientEdits.js} +17 -5
- package/build/esm/example-function-tests/writeableClientEdits/writeableClientEdits.js.map +1 -0
- package/build/esm/index.js +1 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/mock/createMockAttachment.js.map +1 -1
- package/build/esm/mock/createMockClient.js +2 -4
- package/build/esm/mock/createMockClient.js.map +1 -1
- package/build/esm/mock/createMockObjectSet.js.map +1 -1
- package/build/esm/mock/createMockObjectSetWithResolver.js +16 -7
- package/build/esm/mock/createMockObjectSetWithResolver.js.map +1 -1
- package/build/esm/mock/createMockOsdkObject.js.map +1 -1
- package/build/esm/mock/createMockWriteableClient.js +60 -0
- package/build/esm/mock/createMockWriteableClient.js.map +1 -0
- package/build/types/api/MockWriteableClient.d.ts +7 -0
- package/build/types/api/MockWriteableClient.d.ts.map +1 -0
- package/build/types/api/index.d.ts +1 -0
- package/build/types/api/index.d.ts.map +1 -1
- package/build/types/example-function-tests/objectSetArithmetic/objectSetArithmetic.d.ts +9 -0
- package/build/types/example-function-tests/objectSetArithmetic/objectSetArithmetic.d.ts.map +1 -0
- package/build/types/example-function-tests/writeableClientEdits/writeableClientEdits.d.ts +4 -0
- package/build/types/example-function-tests/writeableClientEdits/writeableClientEdits.d.ts.map +1 -0
- package/build/types/index.d.ts +2 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/mock/createMockObjectSetWithResolver.d.ts.map +1 -1
- package/build/types/mock/createMockWriteableClient.d.ts +3 -0
- package/build/types/mock/createMockWriteableClient.d.ts.map +1 -0
- package/package.json +11 -20
- package/build/browser/public/experimental.js.map +0 -1
- package/build/cjs/chunk-DABCNUHL.cjs +0 -453
- package/build/cjs/chunk-DABCNUHL.cjs.map +0 -1
- package/build/cjs/public/experimental.cjs +0 -24
- package/build/cjs/public/experimental.cjs.map +0 -1
- package/build/cjs/public/experimental.d.cts +0 -3
- package/build/esm/public/experimental.js.map +0 -1
- package/build/types/public/experimental.d.ts +0 -5
- package/build/types/public/experimental.d.ts.map +0 -1
- package/experimental.d.ts +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,143 @@
|
|
|
1
1
|
# @osdk/unit-testing
|
|
2
2
|
|
|
3
|
-
## 1.0.0
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- e20b58d: Make `@osdk/unit-testing` generally available with the 1.0.0 release. Remove the `@osdk/unit-testing/experimental` entry point. Replace imports from `@osdk/unit-testing/experimental` with `@osdk/unit-testing`; all mock factories and types are available from the main entry point.
|
|
8
|
+
|
|
9
|
+
## 0.27.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- d72c082: add createMockWriteableClient that records create/update/delete/link/unlink edits via getEdits() and no-ops flushEdits
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [d72c082]
|
|
18
|
+
- @osdk/functions@1.29.0
|
|
19
|
+
- @osdk/client@2.78.0
|
|
20
|
+
- @osdk/api@2.78.0
|
|
21
|
+
|
|
22
|
+
## 0.26.0
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- 488376f: Configure the CI JUnit reporter in each package's vitest config instead of passing it as a turbo `--` argument. Turbo folds passthrough arguments into its global hash, so passing them there made every task in a `turbo run test` invocation a cache miss rather than only the `test` tasks. Test configuration only; no runtime or API changes.
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
6
29
|
|
|
30
|
+
- Updated dependencies [aec9d54]
|
|
31
|
+
- Updated dependencies [488376f]
|
|
32
|
+
- @osdk/client@2.67.0
|
|
33
|
+
- @osdk/api@2.67.0
|
|
34
|
+
- @osdk/functions@1.23.0
|
|
35
|
+
|
|
36
|
+
## 0.25.0
|
|
37
|
+
|
|
38
|
+
### Minor Changes
|
|
39
|
+
|
|
40
|
+
- e3a381d: Bump the `@osdk/foundry.*` and `@osdk/internal.foundry.*` catalog entries to `2.77.0`. Generated experimental ontology metadata now includes full action type metadata and logic rules.
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Updated dependencies [e3a381d]
|
|
45
|
+
- Updated dependencies [b1bb84a]
|
|
46
|
+
- Updated dependencies [aacb86b]
|
|
47
|
+
- @osdk/api@2.65.0
|
|
48
|
+
- @osdk/client@2.65.0
|
|
49
|
+
|
|
50
|
+
## 0.24.0
|
|
51
|
+
|
|
52
|
+
### Minor Changes
|
|
53
|
+
|
|
54
|
+
- bbbeca8: Bump the `@osdk/foundry.*` and `@osdk/internal.foundry.*` catalog entries to `2.75.0`, which reinstates the `streamingExecute` query endpoint as a Server-Sent Events (`text/event-stream`) stream. The experimental `executeStreamingFunction` helper is reimplemented on top of it and no longer throws: it yields each result as it arrives, flattening batched results so array-returning queries emit one element at a time.
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- Updated dependencies [e879ad7]
|
|
59
|
+
- Updated dependencies [bbbeca8]
|
|
60
|
+
- Updated dependencies [6cf2be9]
|
|
61
|
+
- @osdk/client@2.60.0
|
|
62
|
+
- @osdk/api@2.60.0
|
|
63
|
+
|
|
64
|
+
## 0.23.0
|
|
65
|
+
|
|
66
|
+
### Minor Changes
|
|
67
|
+
|
|
68
|
+
- 109b7f1: Add support for stubbing unioned, intersected, and subtracted mock object sets.
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- Updated dependencies [4ae6d8b]
|
|
73
|
+
- Updated dependencies [1aff7f4]
|
|
74
|
+
- @osdk/api@2.59.0
|
|
75
|
+
- @osdk/client@2.59.0
|
|
76
|
+
|
|
77
|
+
## 0.22.0
|
|
78
|
+
|
|
79
|
+
### Minor Changes
|
|
80
|
+
|
|
81
|
+
- ab557b4: Bump the `@osdk/foundry.*` and `@osdk/internal.foundry.*` catalog entries to `2.73.0`. `ObjectTypeInterfaceImplementation` now requires an `actionTypes` field, and the generally available media set `read`, `info`, `metadata` and `uploadMedia` endpoints no longer accept a `preview` parameter.
|
|
82
|
+
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- Updated dependencies [ab557b4]
|
|
86
|
+
- @osdk/client@2.58.0
|
|
87
|
+
- @osdk/api@2.58.0
|
|
88
|
+
|
|
89
|
+
## 0.21.0
|
|
90
|
+
|
|
91
|
+
### Minor Changes
|
|
92
|
+
|
|
93
|
+
- c14abb8: Streaming query execution is not currently supported in the TypeScript OSDK, so the experimental `executeStreamingFunction` helper now throws. Bump the `@osdk/foundry.*` and `@osdk/internal.foundry.*` catalog entries to `2.70.0`. The ontology-as-code full-metadata converters now populate the object type `aliases` and `datasources` fields.
|
|
94
|
+
|
|
95
|
+
### Patch Changes
|
|
96
|
+
|
|
97
|
+
- Updated dependencies [feaf298]
|
|
98
|
+
- Updated dependencies [c14abb8]
|
|
99
|
+
- @osdk/functions@1.20.0
|
|
100
|
+
- @osdk/client@2.53.0
|
|
101
|
+
- @osdk/api@2.53.0
|
|
102
|
+
|
|
103
|
+
## 0.20.0
|
|
104
|
+
|
|
105
|
+
### Minor Changes
|
|
106
|
+
|
|
107
|
+
- 27d7469: Export `MockClient`, `StubClient`, and `MockOsdkObjectOptions` types from the `@osdk/unit-testing/experimental` entry point so callers can annotate the value returned by `createMockClient` directly instead of `ReturnType<typeof createMockClient>`.
|
|
108
|
+
|
|
109
|
+
### Patch Changes
|
|
110
|
+
|
|
111
|
+
- @osdk/api@2.49.0
|
|
112
|
+
- @osdk/client@2.49.0
|
|
113
|
+
|
|
114
|
+
## 0.19.0
|
|
115
|
+
|
|
116
|
+
### Minor Changes
|
|
117
|
+
|
|
118
|
+
- 765ae4e: Re-registering a mock client stub with the same pattern now overrides the previous stub (latest registered wins) instead of being shadowed by it.
|
|
119
|
+
|
|
120
|
+
### Patch Changes
|
|
121
|
+
|
|
122
|
+
- Updated dependencies [db2bfa2]
|
|
123
|
+
- Updated dependencies [cbf692b]
|
|
124
|
+
- @osdk/client@2.45.0
|
|
125
|
+
- @osdk/api@2.45.0
|
|
126
|
+
|
|
127
|
+
## 0.18.0
|
|
128
|
+
|
|
129
|
+
### Minor Changes
|
|
130
|
+
|
|
7
131
|
- 1b33456: Enable the require-await lint rule: drop the redundant `async` keyword from test callbacks that never await, and keep intentionally-async (Promise-returning) functions as-is
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
8
135
|
- Updated dependencies [1b33456]
|
|
9
136
|
- Updated dependencies [ffa3daa]
|
|
10
137
|
- Updated dependencies [f733ceb]
|
|
11
|
-
- @osdk/functions@
|
|
12
|
-
- @osdk/client@
|
|
13
|
-
- @osdk/api@
|
|
138
|
+
- @osdk/functions@1.17.0
|
|
139
|
+
- @osdk/client@2.44.0
|
|
140
|
+
- @osdk/api@2.44.0
|
|
14
141
|
|
|
15
142
|
## 0.17.0
|
|
16
143
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MockClient.js","names":[],"sources":["MockClient.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n CompileTimeMetadata,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n QueryDefinition,\n} from \"@osdk/api\";\nimport type { Client } from \"@osdk/client\";\n\nimport type { QueryStubBuilder, StubBuilderFor } from \"./StubBuilders.js\";\nimport type { StubClient } from \"./StubClient.js\";\n\ntype QueryReturnTypeFromDef<Q extends QueryDefinition> =\n ReturnType<CompileTimeMetadata<Q>[\"signature\"]> extends Promise<infer R>\n ? R\n : never;\n\ntype QueryParamsFromDef<Q extends QueryDefinition> =\n Parameters<CompileTimeMetadata<Q>[\"signature\"]> extends [infer P]\n ? P\n : undefined;\n\nexport type StubPatternCallback<T> = (client: StubClient) => T;\n\nexport type ObjectSetStubCallback<Q extends ObjectOrInterfaceDefinition, T> = (\n os: ObjectSet<Q
|
|
1
|
+
{"version":3,"file":"MockClient.js","names":[],"sources":["MockClient.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n CompileTimeMetadata,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n QueryDefinition,\n} from \"@osdk/api\";\nimport type { Client } from \"@osdk/client\";\n\nimport type { QueryStubBuilder, StubBuilderFor } from \"./StubBuilders.js\";\nimport type { StubClient } from \"./StubClient.js\";\n\ntype QueryReturnTypeFromDef<Q extends QueryDefinition> =\n ReturnType<CompileTimeMetadata<Q>[\"signature\"]> extends Promise<infer R>\n ? R\n : never;\n\ntype QueryParamsFromDef<Q extends QueryDefinition> =\n Parameters<CompileTimeMetadata<Q>[\"signature\"]> extends [infer P]\n ? P\n : undefined;\n\nexport type StubPatternCallback<T> = (client: StubClient) => T;\n\nexport type ObjectSetStubCallback<Q extends ObjectOrInterfaceDefinition, T> = (\n os: ObjectSet<Q>,\n) => T;\n\nexport interface MockClient extends Client {\n when<T>(callback: StubPatternCallback<T>): StubBuilderFor<T>;\n whenObjectSet<Q extends ObjectOrInterfaceDefinition, T>(\n objectSet: ObjectSet<Q>,\n callback: ObjectSetStubCallback<Q, T>,\n ): StubBuilderFor<T>;\n whenQuery<Q extends QueryDefinition>(\n query: Q,\n params?: QueryParamsFromDef<Q>,\n ): QueryStubBuilder<QueryReturnTypeFromDef<Q>>;\n clearStubs(): void;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockWriteableClient.js","names":[],"sources":["MockWriteableClient.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { WriteableClient } from \"@osdk/functions/experimental\";\nimport type { AnyEdit } from \"@osdk/functions/internal\";\n\nimport type { MockClient } from \"./MockClient.js\";\n\nexport interface MockWriteableClient<X extends AnyEdit = never>\n extends MockClient, WriteableClient<X> {\n getEdits(): X[];\n clearEdits(): void;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type { MockClient } from \"./MockClient.js\";\nexport type { MockOsdkObjectOptions } from \"./MockOsdkObjectOptions.js\";\nexport type {\n AggregateStubBuilder,\n FetchOneStubBuilder,\n FetchPageStubBuilder,\n QueryStubBuilder,\n StubBuilderFor,\n} from \"./StubBuilders.js\";\nexport type { StubClient } from \"./StubClient.js\";\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type { MockClient } from \"./MockClient.js\";\nexport type { MockOsdkObjectOptions } from \"./MockOsdkObjectOptions.js\";\nexport type { MockWriteableClient } from \"./MockWriteableClient.js\";\nexport type {\n AggregateStubBuilder,\n FetchOneStubBuilder,\n FetchPageStubBuilder,\n QueryStubBuilder,\n StubBuilderFor,\n} from \"./StubBuilders.js\";\nexport type { StubClient } from \"./StubClient.js\";\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basicAggregate.js","names":["Employee","basicAggregate","client","aggregation","where","employeeId","$eq","aggregate","$select","employeeLocation","exactDistinct","Error","JSON","stringify","aggregation2","$groupBy","$group","max","fullName","approximateDistinct"],"sources":["basicAggregate.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client } from \"@osdk/client\";\nimport { Employee } from \"@osdk/client.test.ontology\";\nimport type { Integer } from \"@osdk/functions\";\n\nexport async function basicAggregate(client: Client): Promise<Integer> {\n const aggregation = await client(Employee)\n .where({ employeeId: { $eq: 5 } })\n .aggregate({ $select: { \"employeeLocation:exactDistinct\": \"asc\" } });\n if (aggregation.employeeLocation.exactDistinct !== 3) {\n throw new Error(\n `Unexpected aggregation result: ${JSON.stringify(aggregation)}
|
|
1
|
+
{"version":3,"file":"basicAggregate.js","names":["Employee","basicAggregate","client","aggregation","where","employeeId","$eq","aggregate","$select","employeeLocation","exactDistinct","Error","JSON","stringify","aggregation2","$groupBy","$group","max","fullName","approximateDistinct"],"sources":["basicAggregate.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client } from \"@osdk/client\";\nimport { Employee } from \"@osdk/client.test.ontology\";\nimport type { Integer } from \"@osdk/functions\";\n\nexport async function basicAggregate(client: Client): Promise<Integer> {\n const aggregation = await client(Employee)\n .where({ employeeId: { $eq: 5 } })\n .aggregate({ $select: { \"employeeLocation:exactDistinct\": \"asc\" } });\n if (aggregation.employeeLocation.exactDistinct !== 3) {\n throw new Error(\n `Unexpected aggregation result: ${JSON.stringify(aggregation)}`,\n );\n }\n\n const aggregation2 = await client(Employee)\n .where({\n employeeId: { $eq: 5 },\n })\n .aggregate({\n $select: {\n \"employeeId:max\": \"unordered\",\n \"fullName:approximateDistinct\": \"unordered\",\n },\n $groupBy: { employeeId: \"exact\" },\n });\n\n if (\n aggregation2[0].$group.employeeId !== 5 ||\n aggregation2[0].employeeId.max !== 5 ||\n aggregation2[0].fullName.approximateDistinct !== 1\n ) {\n throw new Error(\n `Unexpected aggregation result: ${JSON.stringify(aggregation2)}`,\n );\n }\n\n return 1;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,QAAQ,4BAA4B;AAGrD,OAAO,eAAeC,cAAcA,CAACC,MAAc,EAAoB;EACrE,MAAMC,WAAW,GAAG,MAAMD,MAAM,CAACF,QAAQ,CAAC,CACvCI,KAAK,CAAC;IAAEC,UAAU,EAAE;MAAEC,GAAG,EAAE;IAAE;EAAE,CAAC,CAAC,CACjCC,SAAS,CAAC;IAAEC,OAAO,EAAE;MAAE,gCAAgC,EAAE;IAAM;EAAE,CAAC,CAAC;EACtE,IAAIL,WAAW,CAACM,gBAAgB,CAACC,aAAa,KAAK,CAAC,EAAE;IACpD,MAAM,IAAIC,KAAK,CACb,kCAAkCC,IAAI,CAACC,SAAS,CAACV,WAAW,CAAC,EAC/D,CAAC;EACH;EAEA,MAAMW,YAAY,GAAG,MAAMZ,MAAM,CAACF,QAAQ,CAAC,CACxCI,KAAK,CAAC;IACLC,UAAU,EAAE;MAAEC,GAAG,EAAE;IAAE;EACvB,CAAC,CAAC,CACDC,SAAS,CAAC;IACTC,OAAO,EAAE;MACP,gBAAgB,EAAE,WAAW;MAC7B,8BAA8B,EAAE;IAClC,CAAC;IACDO,QAAQ,EAAE;MAAEV,UAAU,EAAE;IAAQ;EAClC,CAAC,CAAC;EAEJ,IACES,YAAY,CAAC,CAAC,CAAC,CAACE,MAAM,CAACX,UAAU,KAAK,CAAC,IACvCS,YAAY,CAAC,CAAC,CAAC,CAACT,UAAU,CAACY,GAAG,KAAK,CAAC,IACpCH,YAAY,CAAC,CAAC,CAAC,CAACI,QAAQ,CAACC,mBAAmB,KAAK,CAAC,EAClD;IACA,MAAM,IAAIR,KAAK,CACb,kCAAkCC,IAAI,CAACC,SAAS,CAACC,YAAY,CAAC,EAChE,CAAC;EACH;EAEA,OAAO,CAAC;AACV","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basicFetchPage.js","names":["Employee","basicFetchPage","client","objects","fetchPage","object","data","Error","employeeId","fullName","JSON","stringify"],"sources":["basicFetchPage.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Osdk } from \"@osdk/api\";\nimport type { Client } from \"@osdk/client\";\nimport { Employee } from \"@osdk/client.test.ontology\";\n\nexport async function basicFetchPage(\n client: Client
|
|
1
|
+
{"version":3,"file":"basicFetchPage.js","names":["Employee","basicFetchPage","client","objects","fetchPage","object","data","Error","employeeId","fullName","JSON","stringify"],"sources":["basicFetchPage.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Osdk } from \"@osdk/api\";\nimport type { Client } from \"@osdk/client\";\nimport { Employee } from \"@osdk/client.test.ontology\";\n\nexport async function basicFetchPage(\n client: Client,\n): Promise<Osdk.Instance<Employee>> {\n const objects = await client(Employee).fetchPage();\n const object = objects.data[0];\n if (object == null) {\n throw new Error(\"No objects returned\");\n }\n if (object.employeeId !== 1 || object.fullName !== \"John\") {\n throw new Error(`Unexpected object returned: ${JSON.stringify(object)}`);\n }\n return object;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,QAAQ,QAAQ,4BAA4B;AAErD,OAAO,eAAeC,cAAcA,CAClCC,MAAc,EACoB;EAClC,MAAMC,OAAO,GAAG,MAAMD,MAAM,CAACF,QAAQ,CAAC,CAACI,SAAS,CAAC,CAAC;EAClD,MAAMC,MAAM,GAAGF,OAAO,CAACG,IAAI,CAAC,CAAC,CAAC;EAC9B,IAAID,MAAM,IAAI,IAAI,EAAE;IAClB,MAAM,IAAIE,KAAK,CAAC,qBAAqB,CAAC;EACxC;EACA,IAAIF,MAAM,CAACG,UAAU,KAAK,CAAC,IAAIH,MAAM,CAACI,QAAQ,KAAK,MAAM,EAAE;IACzD,MAAM,IAAIF,KAAK,CAAC,+BAA+BG,IAAI,CAACC,SAAS,CAACN,MAAM,CAAC,EAAE,CAAC;EAC1E;EACA,OAAOA,MAAM;AACf","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectAsInput.js","names":["objectAsInput","object","$apiName","Error","employeeId"],"sources":["objectAsInput.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Osdk } from \"@osdk/api\";\nimport type { Employee } from \"@osdk/client.test.ontology\";\n\nexport function objectAsInput(\n object: Osdk.Instance<Employee
|
|
1
|
+
{"version":3,"file":"objectAsInput.js","names":["objectAsInput","object","$apiName","Error","employeeId"],"sources":["objectAsInput.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Osdk } from \"@osdk/api\";\nimport type { Employee } from \"@osdk/client.test.ontology\";\n\nexport function objectAsInput(\n object: Osdk.Instance<Employee>,\n): Osdk.Instance<Employee> {\n if (object.$apiName !== \"Employee\") {\n throw new Error(\n `Expected object of type Employee, but got ${object.$apiName}`,\n );\n }\n if (object.employeeId == null) {\n throw new Error(\n `Expected object to have employeeId property, but it was missing`,\n );\n }\n return object;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,OAAO,SAASA,aAAaA,CAC3BC,MAA+B,EACN;EACzB,IAAIA,MAAM,CAACC,QAAQ,KAAK,UAAU,EAAE;IAClC,MAAM,IAAIC,KAAK,CACb,6CAA6CF,MAAM,CAACC,QAAQ,EAC9D,CAAC;EACH;EACA,IAAID,MAAM,CAACG,UAAU,IAAI,IAAI,EAAE;IAC7B,MAAM,IAAID,KAAK,CACb,iEACF,CAAC;EACH;EACA,OAAOF,MAAM;AACf","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 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
|
+
import { Employee } from "@osdk/client.test.ontology";
|
|
18
|
+
export async function objectSetArithmetic(client, employees) {
|
|
19
|
+
const employeeSet = client(Employee);
|
|
20
|
+
const [union, standaloneUnion, intersect, subtract] = await Promise.all([employeeSet.union(employees).fetchPage(), employees.union(employeeSet).fetchPage(), employeeSet.intersect(employees).fetchPage(), employeeSet.subtract(employees).fetchPage()]);
|
|
21
|
+
return {
|
|
22
|
+
union: union.data,
|
|
23
|
+
standaloneUnion: standaloneUnion.data,
|
|
24
|
+
intersect: intersect.data,
|
|
25
|
+
subtract: subtract.data
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=objectSetArithmetic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectSetArithmetic.js","names":["Employee","objectSetArithmetic","client","employees","employeeSet","union","standaloneUnion","intersect","subtract","Promise","all","fetchPage","data"],"sources":["objectSetArithmetic.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectSet, Osdk } from \"@osdk/api\";\nimport type { Client } from \"@osdk/client\";\nimport { Employee } from \"@osdk/client.test.ontology\";\n\nexport async function objectSetArithmetic(\n client: Client,\n employees: ObjectSet<Employee>,\n): Promise<{\n union: Array<Osdk.Instance<Employee>>;\n standaloneUnion: Array<Osdk.Instance<Employee>>;\n intersect: Array<Osdk.Instance<Employee>>;\n subtract: Array<Osdk.Instance<Employee>>;\n}> {\n const employeeSet = client(Employee);\n const [union, standaloneUnion, intersect, subtract] = await Promise.all([\n employeeSet.union(employees).fetchPage(),\n employees.union(employeeSet).fetchPage(),\n employeeSet.intersect(employees).fetchPage(),\n employeeSet.subtract(employees).fetchPage(),\n ]);\n\n return {\n union: union.data,\n standaloneUnion: standaloneUnion.data,\n intersect: intersect.data,\n subtract: subtract.data,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,QAAQ,QAAQ,4BAA4B;AAErD,OAAO,eAAeC,mBAAmBA,CACvCC,MAAc,EACdC,SAA8B,EAM7B;EACD,MAAMC,WAAW,GAAGF,MAAM,CAACF,QAAQ,CAAC;EACpC,MAAM,CAACK,KAAK,EAAEC,eAAe,EAAEC,SAAS,EAAEC,QAAQ,CAAC,GAAG,MAAMC,OAAO,CAACC,GAAG,CAAC,CACtEN,WAAW,CAACC,KAAK,CAACF,SAAS,CAAC,CAACQ,SAAS,CAAC,CAAC,EACxCR,SAAS,CAACE,KAAK,CAACD,WAAW,CAAC,CAACO,SAAS,CAAC,CAAC,EACxCP,WAAW,CAACG,SAAS,CAACJ,SAAS,CAAC,CAACQ,SAAS,CAAC,CAAC,EAC5CP,WAAW,CAACI,QAAQ,CAACL,SAAS,CAAC,CAACQ,SAAS,CAAC,CAAC,CAC5C,CAAC;EAEF,OAAO;IACLN,KAAK,EAAEA,KAAK,CAACO,IAAI;IACjBN,eAAe,EAAEA,eAAe,CAACM,IAAI;IACrCL,SAAS,EAAEA,SAAS,CAACK,IAAI;IACzBJ,QAAQ,EAAEA,QAAQ,CAACI;EACrB,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectSetAsInput.js","names":["getEmployeeNames","employees","page","fetchPage","data","map","emp","fullName","countEmployees","result","aggregate","$select","$count"],"sources":["objectSetAsInput.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectSet } from \"@osdk/api\";\nimport type { Employee } from \"@osdk/client.test.ontology\";\n\nexport async function getEmployeeNames(\n employees: ObjectSet<Employee
|
|
1
|
+
{"version":3,"file":"objectSetAsInput.js","names":["getEmployeeNames","employees","page","fetchPage","data","map","emp","fullName","countEmployees","result","aggregate","$select","$count"],"sources":["objectSetAsInput.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectSet } from \"@osdk/api\";\nimport type { Employee } from \"@osdk/client.test.ontology\";\n\nexport async function getEmployeeNames(\n employees: ObjectSet<Employee>,\n): Promise<string[]> {\n const page = await employees.fetchPage();\n return page.data.map((emp) => emp.fullName ?? \"Unknown\");\n}\n\nexport async function countEmployees(\n employees: ObjectSet<Employee>,\n): Promise<number> {\n const result = await employees.aggregate({\n $select: { $count: \"unordered\" },\n });\n return result.$count;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,OAAO,eAAeA,gBAAgBA,CACpCC,SAA8B,EACX;EACnB,MAAMC,IAAI,GAAG,MAAMD,SAAS,CAACE,SAAS,CAAC,CAAC;EACxC,OAAOD,IAAI,CAACE,IAAI,CAACC,GAAG,CAAEC,GAAG,IAAKA,GAAG,CAACC,QAAQ,IAAI,SAAS,CAAC;AAC1D;AAEA,OAAO,eAAeC,cAAcA,CAClCP,SAA8B,EACb;EACjB,MAAMQ,MAAM,GAAG,MAAMR,SAAS,CAACS,SAAS,CAAC;IACvCC,OAAO,EAAE;MAAEC,MAAM,EAAE;IAAY;EACjC,CAAC,CAAC;EACF,OAAOH,MAAM,CAACG,MAAM;AACtB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objectWithLinks.js","names":["getEmployeeOfficeName","employee","office","$link","officeLink","fetchOne","name","getEmployeePeepNames","page","peeps","fetchPage","data","map","peep","fullName","countEmployeePeeps","count","_peep","asyncIter","getSpecificPeep","peepId","countPeepsViaAggregate","result","aggregate","$select","$count"],"sources":["objectWithLinks.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Osdk } from \"@osdk/api\";\nimport type { Employee } from \"@osdk/client.test.ontology\";\n\nexport async function getEmployeeOfficeName(\n employee: Osdk.Instance<Employee
|
|
1
|
+
{"version":3,"file":"objectWithLinks.js","names":["getEmployeeOfficeName","employee","office","$link","officeLink","fetchOne","name","getEmployeePeepNames","page","peeps","fetchPage","data","map","peep","fullName","countEmployeePeeps","count","_peep","asyncIter","getSpecificPeep","peepId","countPeepsViaAggregate","result","aggregate","$select","$count"],"sources":["objectWithLinks.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Osdk } from \"@osdk/api\";\nimport type { Employee } from \"@osdk/client.test.ontology\";\n\nexport async function getEmployeeOfficeName(\n employee: Osdk.Instance<Employee>,\n): Promise<string | undefined> {\n const office = await employee.$link.officeLink.fetchOne();\n return office.name;\n}\n\nexport async function getEmployeePeepNames(\n employee: Osdk.Instance<Employee>,\n): Promise<string[]> {\n const page = await employee.$link.peeps.fetchPage();\n return page.data.map((peep) => peep.fullName ?? \"Unknown\");\n}\n\nexport async function countEmployeePeeps(\n employee: Osdk.Instance<Employee>,\n): Promise<number> {\n let count = 0;\n for await (const _peep of employee.$link.peeps.asyncIter()) {\n count++;\n }\n return count;\n}\n\n// TODO(oxc type-aware): the type-aware typescript/require-await rule does not flag this (it returns a Promise); remove this disable once type-aware linting is enabled.\n// oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed\nexport async function getSpecificPeep(\n employee: Osdk.Instance<Employee>,\n peepId: number,\n): Promise<Osdk.Instance<Employee>> {\n return employee.$link.peeps.fetchOne(peepId);\n}\n\nexport async function countPeepsViaAggregate(\n employee: Osdk.Instance<Employee>,\n): Promise<number> {\n const result = await employee.$link.peeps.aggregate({\n $select: { $count: \"unordered\" },\n });\n return result.$count;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,OAAO,eAAeA,qBAAqBA,CACzCC,QAAiC,EACJ;EAC7B,MAAMC,MAAM,GAAG,MAAMD,QAAQ,CAACE,KAAK,CAACC,UAAU,CAACC,QAAQ,CAAC,CAAC;EACzD,OAAOH,MAAM,CAACI,IAAI;AACpB;AAEA,OAAO,eAAeC,oBAAoBA,CACxCN,QAAiC,EACd;EACnB,MAAMO,IAAI,GAAG,MAAMP,QAAQ,CAACE,KAAK,CAACM,KAAK,CAACC,SAAS,CAAC,CAAC;EACnD,OAAOF,IAAI,CAACG,IAAI,CAACC,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,QAAQ,IAAI,SAAS,CAAC;AAC5D;AAEA,OAAO,eAAeC,kBAAkBA,CACtCd,QAAiC,EAChB;EACjB,IAAIe,KAAK,GAAG,CAAC;EACb,WAAW,MAAMC,KAAK,IAAIhB,QAAQ,CAACE,KAAK,CAACM,KAAK,CAACS,SAAS,CAAC,CAAC,EAAE;IAC1DF,KAAK,EAAE;EACT;EACA,OAAOA,KAAK;AACd;;AAEA;AACA;AACA,OAAO,eAAeG,eAAeA,CACnClB,QAAiC,EACjCmB,MAAc,EACoB;EAClC,OAAOnB,QAAQ,CAACE,KAAK,CAACM,KAAK,CAACJ,QAAQ,CAACe,MAAM,CAAC;AAC9C;AAEA,OAAO,eAAeC,sBAAsBA,CAC1CpB,QAAiC,EAChB;EACjB,MAAMqB,MAAM,GAAG,MAAMrB,QAAQ,CAACE,KAAK,CAACM,KAAK,CAACc,SAAS,CAAC;IAClDC,OAAO,EAAE;MAAEC,MAAM,EAAE;IAAY;EACjC,CAAC,CAAC;EACF,OAAOH,MAAM,CAACG,MAAM;AACtB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ontologyEdits.js","names":["Employee","FooInterface","createEditBatch","ontologyEdits","client","object","editBatch","create","employeeId","fullName","update","favoriteRestaurants","delete","link","unlink","$objectType","fooIdp","getEdits"],"sources":["ontologyEdits.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client, Osdk } from \"@osdk/client\";\nimport type { $Interfaces } from \"@osdk/client.test.ontology\";\nimport { Employee, FooInterface } from \"@osdk/client.test.ontology\";\nimport { createEditBatch, type Edits } from \"@osdk/functions\";\n\ntype edits =\n | Edits.Object<Employee>\n | Edits.Link<Employee, \"peeps\">\n | Edits.Interface<$Interfaces.FooInterface>;\nexport function ontologyEdits(\n client: Client,\n object: Osdk.Instance<Employee
|
|
1
|
+
{"version":3,"file":"ontologyEdits.js","names":["Employee","FooInterface","createEditBatch","ontologyEdits","client","object","editBatch","create","employeeId","fullName","update","favoriteRestaurants","delete","link","unlink","$objectType","fooIdp","getEdits"],"sources":["ontologyEdits.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client, Osdk } from \"@osdk/client\";\nimport type { $Interfaces } from \"@osdk/client.test.ontology\";\nimport { Employee, FooInterface } from \"@osdk/client.test.ontology\";\nimport { createEditBatch, type Edits } from \"@osdk/functions\";\n\ntype edits =\n | Edits.Object<Employee>\n | Edits.Link<Employee, \"peeps\">\n | Edits.Interface<$Interfaces.FooInterface>;\nexport function ontologyEdits(\n client: Client,\n object: Osdk.Instance<Employee>,\n): edits[] {\n const editBatch = createEditBatch<edits>(client);\n editBatch.create(Employee, { employeeId: 1, fullName: \"John Doe\" });\n\n editBatch.update(object, { favoriteRestaurants: [\"McDonald's\"] });\n\n editBatch.delete(object);\n\n editBatch.link(object, \"peeps\", object);\n editBatch.unlink(object, \"peeps\", object);\n\n editBatch.create(FooInterface, { $objectType: \"Employee\", fooIdp: \"bar\" });\n return editBatch.getEdits();\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,QAAQ,EAAEC,YAAY,QAAQ,4BAA4B;AACnE,SAASC,eAAe,QAAoB,iBAAiB;AAM7D,OAAO,SAASC,aAAaA,CAC3BC,MAAc,EACdC,MAA+B,EACtB;EACT,MAAMC,SAAS,GAAGJ,eAAe,CAAQE,MAAM,CAAC;EAChDE,SAAS,CAACC,MAAM,CAACP,QAAQ,EAAE;IAAEQ,UAAU,EAAE,CAAC;IAAEC,QAAQ,EAAE;EAAW,CAAC,CAAC;EAEnEH,SAAS,CAACI,MAAM,CAACL,MAAM,EAAE;IAAEM,mBAAmB,EAAE,CAAC,YAAY;EAAE,CAAC,CAAC;EAEjEL,SAAS,CAACM,MAAM,CAACP,MAAM,CAAC;EAExBC,SAAS,CAACO,IAAI,CAACR,MAAM,EAAE,OAAO,EAAEA,MAAM,CAAC;EACvCC,SAAS,CAACQ,MAAM,CAACT,MAAM,EAAE,OAAO,EAAEA,MAAM,CAAC;EAEzCC,SAAS,CAACC,MAAM,CAACN,YAAY,EAAE;IAAEc,WAAW,EAAE,UAAU;IAAEC,MAAM,EAAE;EAAM,CAAC,CAAC;EAC1E,OAAOV,SAAS,CAACW,QAAQ,CAAC,CAAC;AAC7B","ignoreList":[]}
|
package/build/browser/example-function-tests/queryWithArrayParams/queryWithArrayParams.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryWithArrayParams.js","names":["queryTypeReturnsArray","queryWithArrayParams","client","people","result","executeFunction","Array","isArray","Error"],"sources":["queryWithArrayParams.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client } from \"@osdk/client\";\nimport { queryTypeReturnsArray } from \"@osdk/client.test.ontology\";\n\nexport async function queryWithArrayParams(\n client: Client,\n people: readonly string[]
|
|
1
|
+
{"version":3,"file":"queryWithArrayParams.js","names":["queryTypeReturnsArray","queryWithArrayParams","client","people","result","executeFunction","Array","isArray","Error"],"sources":["queryWithArrayParams.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client } from \"@osdk/client\";\nimport { queryTypeReturnsArray } from \"@osdk/client.test.ontology\";\n\nexport async function queryWithArrayParams(\n client: Client,\n people: readonly string[],\n): Promise<string[]> {\n const result = await client(queryTypeReturnsArray).executeFunction({\n people,\n });\n\n if (!Array.isArray(result)) {\n throw new Error(\"Expected array result\");\n }\n\n return result;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,qBAAqB,QAAQ,4BAA4B;AAElE,OAAO,eAAeC,oBAAoBA,CACxCC,MAAc,EACdC,MAAyB,EACN;EACnB,MAAMC,MAAM,GAAG,MAAMF,MAAM,CAACF,qBAAqB,CAAC,CAACK,eAAe,CAAC;IACjEF;EACF,CAAC,CAAC;EAEF,IAAI,CAACG,KAAK,CAACC,OAAO,CAACH,MAAM,CAAC,EAAE;IAC1B,MAAM,IAAII,KAAK,CAAC,uBAAuB,CAAC;EAC1C;EAEA,OAAOJ,MAAM;AACf","ignoreList":[]}
|
|
@@ -14,8 +14,20 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
import { Employee } from "@osdk/client.test.ontology";
|
|
18
|
+
import { flushEdits } from "@osdk/functions/unstable-do-not-use";
|
|
19
|
+
export async function relocateOffice(client, fromOffice, toOffice) {
|
|
20
|
+
const employees = await client(Employee).where({
|
|
21
|
+
office: {
|
|
22
|
+
$eq: fromOffice
|
|
23
|
+
}
|
|
24
|
+
}).fetchPage();
|
|
25
|
+
for (const employee of employees.data) {
|
|
26
|
+
await client.update(employee, {
|
|
27
|
+
office: toOffice
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
await flushEdits(client);
|
|
31
|
+
return employees.data.length;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=writeableClientEdits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeableClientEdits.js","names":["Employee","flushEdits","relocateOffice","client","fromOffice","toOffice","employees","where","office","$eq","fetchPage","employee","data","update","length"],"sources":["writeableClientEdits.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Employee } from \"@osdk/client.test.ontology\";\nimport type { Edits } from \"@osdk/functions\";\nimport type { WriteableClient } from \"@osdk/functions/experimental\";\nimport { flushEdits } from \"@osdk/functions/unstable-do-not-use\";\n\nexport async function relocateOffice(\n client: WriteableClient<Edits.Object<Employee>>,\n fromOffice: string,\n toOffice: string,\n): Promise<number> {\n const employees = await client(Employee)\n .where({ office: { $eq: fromOffice } })\n .fetchPage();\n\n for (const employee of employees.data) {\n await client.update(employee, { office: toOffice });\n }\n\n await flushEdits(client);\n return employees.data.length;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,4BAA4B;AAGrD,SAASC,UAAU,QAAQ,qCAAqC;AAEhE,OAAO,eAAeC,cAAcA,CAClCC,MAA+C,EAC/CC,UAAkB,EAClBC,QAAgB,EACC;EACjB,MAAMC,SAAS,GAAG,MAAMH,MAAM,CAACH,QAAQ,CAAC,CACrCO,KAAK,CAAC;IAAEC,MAAM,EAAE;MAAEC,GAAG,EAAEL;IAAW;EAAE,CAAC,CAAC,CACtCM,SAAS,CAAC,CAAC;EAEd,KAAK,MAAMC,QAAQ,IAAIL,SAAS,CAACM,IAAI,EAAE;IACrC,MAAMT,MAAM,CAACU,MAAM,CAACF,QAAQ,EAAE;MAAEH,MAAM,EAAEH;IAAS,CAAC,CAAC;EACrD;EAEA,MAAMJ,UAAU,CAACE,MAAM,CAAC;EACxB,OAAOG,SAAS,CAACM,IAAI,CAACE,MAAM;AAC9B","ignoreList":[]}
|
package/build/browser/index.js
CHANGED
|
@@ -18,4 +18,5 @@ export { createMockAttachment } from "./mock/createMockAttachment.js";
|
|
|
18
18
|
export { createMockClient } from "./mock/createMockClient.js";
|
|
19
19
|
export { createMockObjectSet } from "./mock/createMockObjectSet.js";
|
|
20
20
|
export { createMockOsdkObject } from "./mock/createMockOsdkObject.js";
|
|
21
|
+
export { createMockWriteableClient } from "./mock/createMockWriteableClient.js";
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["createMockAttachment","createMockClient","createMockObjectSet","createMockOsdkObject"],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type {\n AggregateStubBuilder,\n FetchOneStubBuilder,\n FetchPageStubBuilder,\n MockClient,\n MockOsdkObjectOptions,\n QueryStubBuilder,\n StubBuilderFor,\n StubClient,\n} from \"./api/index.js\";\n\nexport { createMockAttachment } from \"./mock/createMockAttachment.js\";\nexport { createMockClient } from \"./mock/createMockClient.js\";\nexport { createMockObjectSet } from \"./mock/createMockObjectSet.js\";\nexport { createMockOsdkObject } from \"./mock/createMockOsdkObject.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;
|
|
1
|
+
{"version":3,"file":"index.js","names":["createMockAttachment","createMockClient","createMockObjectSet","createMockOsdkObject","createMockWriteableClient"],"sources":["index.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type {\n AggregateStubBuilder,\n FetchOneStubBuilder,\n FetchPageStubBuilder,\n MockClient,\n MockOsdkObjectOptions,\n MockWriteableClient,\n QueryStubBuilder,\n StubBuilderFor,\n StubClient,\n} from \"./api/index.js\";\n\nexport { createMockAttachment } from \"./mock/createMockAttachment.js\";\nexport { createMockClient } from \"./mock/createMockClient.js\";\nexport { createMockObjectSet } from \"./mock/createMockObjectSet.js\";\nexport { createMockOsdkObject } from \"./mock/createMockOsdkObject.js\";\nexport { createMockWriteableClient } from \"./mock/createMockWriteableClient.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,SAASA,oBAAoB,QAAQ,gCAAgC;AACrE,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SAASC,mBAAmB,QAAQ,+BAA+B;AACnE,SAASC,oBAAoB,QAAQ,gCAAgC;AACrE,SAASC,yBAAyB,QAAQ,qCAAqC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMockAttachment.js","names":["invariant","createMockAttachment","rid","blob","metadata","fetchContents","process","env","NODE_ENV","Promise","resolve","Response","fetchMetadata"],"sources":["createMockAttachment.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Attachment, AttachmentMetadata } from \"@osdk/api\";\nimport invariant from \"tiny-invariant\";\n\nexport function createMockAttachment(\n rid: string,\n blob?: Blob,\n metadata?: AttachmentMetadata
|
|
1
|
+
{"version":3,"file":"createMockAttachment.js","names":["invariant","createMockAttachment","rid","blob","metadata","fetchContents","process","env","NODE_ENV","Promise","resolve","Response","fetchMetadata"],"sources":["createMockAttachment.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Attachment, AttachmentMetadata } from \"@osdk/api\";\nimport invariant from \"tiny-invariant\";\n\nexport function createMockAttachment(\n rid: string,\n blob?: Blob,\n metadata?: AttachmentMetadata,\n): Attachment {\n return {\n rid,\n fetchContents() {\n invariant(\n blob != null,\n `fetchContents was called on mock attachment \"${rid}\" but no blob was provided. ` +\n `Pass a Blob as the second argument to createMockAttachment to stub fetchContents.`,\n );\n return Promise.resolve(new Response(blob));\n },\n fetchMetadata() {\n invariant(\n metadata != null,\n `fetchMetadata was called on mock attachment \"${rid}\" but no metadata was provided. ` +\n `Pass AttachmentMetadata as the third argument to createMockAttachment to stub fetchMetadata.`,\n );\n return Promise.resolve(metadata);\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,SAAS,MAAM,gBAAgB;AAEtC,OAAO,SAASC,oBAAoBA,CAClCC,GAAW,EACXC,IAAW,EACXC,QAA6B,EACjB;EACZ,OAAO;IACLF,GAAG;IACHG,aAAaA,CAAA,EAAG;MACd,EACEF,IAAI,IAAI,IAAI,IAAAG,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADdR,SAAS,QAEP,gDAAgDE,GAAG,8BAA8B,GAC/E,mFAAmF,IAHvFF,SAAS;MAKT,OAAOS,OAAO,CAACC,OAAO,CAAC,IAAIC,QAAQ,CAACR,IAAI,CAAC,CAAC;IAC5C,CAAC;IACDS,aAAaA,CAAA,EAAG;MACd,EACER,QAAQ,IAAI,IAAI,IAAAE,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBADlBR,SAAS,QAEP,gDAAgDE,GAAG,kCAAkC,GACnF,8FAA8F,IAHlGF,SAAS;MAKT,OAAOS,OAAO,CAACC,OAAO,CAACN,QAAQ,CAAC;IAClC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -26,7 +26,8 @@ export function createMockClient() {
|
|
|
26
26
|
const queryStubs = [];
|
|
27
27
|
const resolve = (objectType, calls) => resolveStub(stubs.filter(s => s.objectType === objectType), calls, `No stub for request\n`);
|
|
28
28
|
const resolveQuery = (queryApiName, params) => {
|
|
29
|
-
for (
|
|
29
|
+
for (let i = queryStubs.length - 1; i >= 0; i--) {
|
|
30
|
+
const stub = queryStubs[i];
|
|
30
31
|
if (stub.queryApiName !== queryApiName) continue;
|
|
31
32
|
if (deepEqual(stub.params, params)) {
|
|
32
33
|
if (stub.error !== undefined) {
|
|
@@ -138,9 +139,6 @@ export function createMockClient() {
|
|
|
138
139
|
async () => "mock-token"),
|
|
139
140
|
enumerable: false
|
|
140
141
|
});
|
|
141
|
-
|
|
142
|
-
// TODO: Implement WriteableClient operations
|
|
143
|
-
|
|
144
142
|
return mockClient;
|
|
145
143
|
}
|
|
146
144
|
//# sourceMappingURL=createMockClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMockClient.js","names":["createPlatformClient","invariant","createMockObjectSetWithResolver","deepEqual","resolveStub","SYMBOL_CLIENT_CONTEXT","createMockClient","stubs","queryStubs","resolve","objectType","calls","filter","s","resolveQuery","queryApiName","params","stub","error","undefined","value","Error","mockClient","def","process","env","NODE_ENV","type","executeFunction","Promise","apiName","e","reject","when","callback","captured","data","nextPageToken","register","push","thenReturnObjects","thenReturnObject","thenReturnAggregation","whenObjectSet","objectSet","capturedCalls","capturingProxy","$objectSetInternals","__registerStub","whenQuery","query","thenReturn","result","thenThrow","clearStubs","length","fetchMetadata","Object","defineProperty","enumerable"],"sources":["createMockClient.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n CompileTimeMetadata,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n QueryDefinition,\n} from \"@osdk/api\";\nimport { createPlatformClient } from \"@osdk/client\";\nimport invariant from \"tiny-invariant\";\n\nimport type {\n MockClient,\n ObjectSetStubCallback,\n StubPatternCallback,\n} from \"../api/MockClient.js\";\nimport type { QueryStubBuilder, StubBuilderFor } from \"../api/StubBuilders.js\";\nimport type { StubClient } from \"../api/StubClient.js\";\nimport { type MockObjectSetBranded } from \"./createMockObjectSet.js\";\nimport {\n type Call,\n createMockObjectSetWithResolver,\n deepEqual,\n resolveStub,\n type Stub,\n} from \"./createMockObjectSetWithResolver.js\";\n\ntype ClientStub = Stub & { objectType: string };\n\ntype QueryStub = {\n queryApiName: string;\n params: unknown;\n value?: unknown;\n error?: Error;\n};\n\ntype QueryReturnTypeFromDef<Q extends QueryDefinition> =\n ReturnType<CompileTimeMetadata<Q>[\"signature\"]> extends Promise<infer R>\n ? R\n : never;\n\ntype QueryParamsFromDef<Q extends QueryDefinition> =\n Parameters<CompileTimeMetadata<Q>[\"signature\"]> extends [infer P]\n ? P\n : undefined;\n\n// Well-known string key used by Foundry Platform APIs to pull the\n// SharedClientContext (baseUrl, tokenProvider, fetch) off a client. Matches\n// the value of `symbolClientContext` in `@osdk/shared.client2`.\nconst SYMBOL_CLIENT_CONTEXT = \"__osdkClientContext\";\n\nexport function createMockClient(): MockClient {\n const stubs: ClientStub[] = [];\n const queryStubs: QueryStub[] = [];\n\n const resolve = (objectType: string, calls: Call[]): unknown =>\n resolveStub(\n stubs.filter((s) => s.objectType === objectType),\n calls,\n `No stub for request\\n`\n );\n\n const resolveQuery = (queryApiName: string, params: unknown): unknown => {\n for (const stub of queryStubs) {\n if (stub.queryApiName !== queryApiName) continue;\n if (deepEqual(stub.params, params)) {\n if (stub.error !== undefined) {\n throw stub.error;\n }\n return stub.value;\n }\n }\n\n const msg = `No stub for query '${queryApiName}'`;\n throw new Error(msg);\n };\n\n const mockClient = ((def: ObjectOrInterfaceDefinition | QueryDefinition) => {\n invariant(\"apiName\" in def, \"Expected ObjectType, Interface, or Query\");\n\n if (def.type === \"query\") {\n return {\n executeFunction: (params?: unknown) => {\n try {\n return Promise.resolve(resolveQuery(def.apiName, params));\n } catch (e) {\n return Promise.reject(e);\n }\n },\n };\n }\n\n return createMockObjectSetWithResolver(def, (calls) =>\n resolve(def.apiName, calls)\n );\n }) as MockClient;\n\n mockClient.when = <T>(\n callback: StubPatternCallback<T>\n ): StubBuilderFor<T> => {\n let captured: { objectType: string; calls: Call[] } | undefined;\n\n const stubClient: StubClient = (def: ObjectOrInterfaceDefinition) => {\n return createMockObjectSetWithResolver(def, (calls) => {\n captured = { objectType: def.apiName, calls };\n return { data: [], nextPageToken: undefined };\n });\n };\n\n // The callback actually runs synchronously but all terminal methods are typed as async.\n void callback(stubClient);\n\n const register = (value: unknown) => {\n if (captured) stubs.push({ ...captured, value });\n };\n\n return {\n thenReturnObjects: register,\n thenReturnObject: register,\n thenReturnAggregation: register,\n } as unknown as StubBuilderFor<T>;\n };\n\n mockClient.whenObjectSet = <Q extends ObjectOrInterfaceDefinition, T>(\n objectSet: ObjectSet<Q>,\n callback: ObjectSetStubCallback<Q, T>\n ): StubBuilderFor<T> => {\n let capturedCalls: Call[] | undefined;\n\n const capturingProxy = createMockObjectSetWithResolver(\n objectSet.$objectSetInternals.def,\n (calls) => {\n capturedCalls = calls;\n return { data: [], nextPageToken: undefined };\n }\n );\n\n void callback(capturingProxy);\n\n const branded = objectSet as unknown as MockObjectSetBranded<Q>;\n\n const register = (value: unknown) => {\n if (capturedCalls) {\n branded.__registerStub(capturedCalls, value);\n }\n };\n\n return {\n thenReturnObjects: register,\n thenReturnObject: register,\n thenReturnAggregation: register,\n } as unknown as StubBuilderFor<T>;\n };\n\n mockClient.whenQuery = <Q extends QueryDefinition>(\n query: Q,\n params?: QueryParamsFromDef<Q>\n ): QueryStubBuilder<QueryReturnTypeFromDef<Q>> => {\n return {\n thenReturn: (result: QueryReturnTypeFromDef<Q>) => {\n queryStubs.push({\n queryApiName: query.apiName,\n params,\n value: result,\n });\n },\n thenThrow: (error: Error) => {\n queryStubs.push({\n queryApiName: query.apiName,\n params,\n error,\n });\n },\n };\n };\n\n mockClient.clearStubs = () => {\n stubs.length = 0;\n queryStubs.length = 0;\n };\n\n // oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed\n mockClient.fetchMetadata = async () => {\n invariant(false, \"fetchMetadata is not supported in mocks\");\n };\n\n // Attach a SharedClientContext so Foundry Platform API helpers\n // (e.g. `Users.getCurrent(client)`) don't crash inside `foundryPlatformFetch`\n // on an undefined `baseUrl` before any request is made. Callers intercept the\n // actual HTTP layer themselves (MSW, vi.spyOn(globalThis, \"fetch\"), etc.).\n Object.defineProperty(mockClient, SYMBOL_CLIENT_CONTEXT, {\n value: createPlatformClient(\n \"https://mock.invalid/\",\n // oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed\n async () => \"mock-token\"\n ),\n enumerable: false,\n });\n\n // TODO: Implement WriteableClient operations\n\n return mockClient;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAAS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MockClient.js","names":["createPlatformClient","invariant","createMockObjectSetWithResolver","deepEqual","resolveStub","SYMBOL_CLIENT_CONTEXT","createMockClient","stubs","queryStubs","resolve","objectType","calls","filter","s","resolveQuery","queryApiName","params","i","length","stub","error","undefined","value","Error","mockClient","def","process","env","NODE_ENV","type","executeFunction","Promise","apiName","e","reject","when","callback","captured","data","nextPageToken","register","push","thenReturnObjects","thenReturnObject","thenReturnAggregation","whenObjectSet","objectSet","capturedCalls","capturingProxy","$objectSetInternals","__registerStub","whenQuery","query","thenReturn","result","thenThrow","clearStubs","fetchMetadata","Object","defineProperty","enumerable"],"sources":["createMockClient.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n CompileTimeMetadata,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n QueryDefinition,\n} from \"@osdk/api\";\nimport { createPlatformClient } from \"@osdk/client\";\nimport invariant from \"tiny-invariant\";\n\nimport type {\n MockClient,\n ObjectSetStubCallback,\n StubPatternCallback,\n} from \"../api/MockClient.js\";\nimport type { QueryStubBuilder, StubBuilderFor } from \"../api/StubBuilders.js\";\nimport type { StubClient } from \"../api/StubClient.js\";\nimport { type MockObjectSetBranded } from \"./createMockObjectSet.js\";\nimport {\n type Call,\n createMockObjectSetWithResolver,\n deepEqual,\n resolveStub,\n type Stub,\n} from \"./createMockObjectSetWithResolver.js\";\n\ntype ClientStub = Stub & { objectType: string };\n\ntype QueryStub = {\n queryApiName: string;\n params: unknown;\n value?: unknown;\n error?: Error;\n};\n\ntype QueryReturnTypeFromDef<Q extends QueryDefinition> =\n ReturnType<CompileTimeMetadata<Q>[\"signature\"]> extends Promise<infer R>\n ? R\n : never;\n\ntype QueryParamsFromDef<Q extends QueryDefinition> =\n Parameters<CompileTimeMetadata<Q>[\"signature\"]> extends [infer P]\n ? P\n : undefined;\n\n// Well-known string key used by Foundry Platform APIs to pull the\n// SharedClientContext (baseUrl, tokenProvider, fetch) off a client. Matches\n// the value of `symbolClientContext` in `@osdk/shared.client2`.\nconst SYMBOL_CLIENT_CONTEXT = \"__osdkClientContext\";\n\nexport function createMockClient(): MockClient {\n const stubs: ClientStub[] = [];\n const queryStubs: QueryStub[] = [];\n\n const resolve = (objectType: string, calls: Call[]): unknown =>\n resolveStub(\n stubs.filter((s) => s.objectType === objectType),\n calls,\n `No stub for request\\n`,\n );\n\n const resolveQuery = (queryApiName: string, params: unknown): unknown => {\n for (let i = queryStubs.length - 1; i >= 0; i--) {\n const stub = queryStubs[i];\n if (stub.queryApiName !== queryApiName) continue;\n if (deepEqual(stub.params, params)) {\n if (stub.error !== undefined) {\n throw stub.error;\n }\n return stub.value;\n }\n }\n\n const msg = `No stub for query '${queryApiName}'`;\n throw new Error(msg);\n };\n\n const mockClient = ((def: ObjectOrInterfaceDefinition | QueryDefinition) => {\n invariant(\"apiName\" in def, \"Expected ObjectType, Interface, or Query\");\n\n if (def.type === \"query\") {\n return {\n executeFunction: (params?: unknown) => {\n try {\n return Promise.resolve(resolveQuery(def.apiName, params));\n } catch (e) {\n return Promise.reject(e);\n }\n },\n };\n }\n\n return createMockObjectSetWithResolver(def, (calls) =>\n resolve(def.apiName, calls),\n );\n }) as MockClient;\n\n mockClient.when = <T>(\n callback: StubPatternCallback<T>,\n ): StubBuilderFor<T> => {\n let captured: { objectType: string; calls: Call[] } | undefined;\n\n const stubClient: StubClient = (def: ObjectOrInterfaceDefinition) => {\n return createMockObjectSetWithResolver(def, (calls) => {\n captured = { objectType: def.apiName, calls };\n return { data: [], nextPageToken: undefined };\n });\n };\n\n // The callback actually runs synchronously but all terminal methods are typed as async.\n void callback(stubClient);\n\n const register = (value: unknown) => {\n if (captured) stubs.push({ ...captured, value });\n };\n\n return {\n thenReturnObjects: register,\n thenReturnObject: register,\n thenReturnAggregation: register,\n } as unknown as StubBuilderFor<T>;\n };\n\n mockClient.whenObjectSet = <Q extends ObjectOrInterfaceDefinition, T>(\n objectSet: ObjectSet<Q>,\n callback: ObjectSetStubCallback<Q, T>,\n ): StubBuilderFor<T> => {\n let capturedCalls: Call[] | undefined;\n\n const capturingProxy = createMockObjectSetWithResolver(\n objectSet.$objectSetInternals.def,\n (calls) => {\n capturedCalls = calls;\n return { data: [], nextPageToken: undefined };\n },\n );\n\n void callback(capturingProxy);\n\n const branded = objectSet as unknown as MockObjectSetBranded<Q>;\n\n const register = (value: unknown) => {\n if (capturedCalls) {\n branded.__registerStub(capturedCalls, value);\n }\n };\n\n return {\n thenReturnObjects: register,\n thenReturnObject: register,\n thenReturnAggregation: register,\n } as unknown as StubBuilderFor<T>;\n };\n\n mockClient.whenQuery = <Q extends QueryDefinition>(\n query: Q,\n params?: QueryParamsFromDef<Q>,\n ): QueryStubBuilder<QueryReturnTypeFromDef<Q>> => {\n return {\n thenReturn: (result: QueryReturnTypeFromDef<Q>) => {\n queryStubs.push({\n queryApiName: query.apiName,\n params,\n value: result,\n });\n },\n thenThrow: (error: Error) => {\n queryStubs.push({\n queryApiName: query.apiName,\n params,\n error,\n });\n },\n };\n };\n\n mockClient.clearStubs = () => {\n stubs.length = 0;\n queryStubs.length = 0;\n };\n\n // oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed\n mockClient.fetchMetadata = async () => {\n invariant(false, \"fetchMetadata is not supported in mocks\");\n };\n\n // Attach a SharedClientContext so Foundry Platform API helpers\n // (e.g. `Users.getCurrent(client)`) don't crash inside `foundryPlatformFetch`\n // on an undefined `baseUrl` before any request is made. Callers intercept the\n // actual HTTP layer themselves (MSW, vi.spyOn(globalThis, \"fetch\"), etc.).\n Object.defineProperty(mockClient, SYMBOL_CLIENT_CONTEXT, {\n value: createPlatformClient(\n \"https://mock.invalid/\",\n // oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed\n async () => \"mock-token\",\n ),\n enumerable: false,\n });\n\n return mockClient;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,oBAAoB,QAAQ,cAAc;AACnD,OAAOC,SAAS,MAAM,gBAAgB;AAUtC,SAEEC,+BAA+B,EAC/BC,SAAS,EACTC,WAAW,QAEN,sCAAsC;AAqB7C;AACA;AACA;AACA,MAAMC,qBAAqB,GAAG,qBAAqB;AAEnD,OAAO,SAASC,gBAAgBA,CAAA,EAAe;EAC7C,MAAMC,KAAmB,GAAG,EAAE;EAC9B,MAAMC,UAAuB,GAAG,EAAE;EAElC,MAAMC,OAAO,GAAGA,CAACC,UAAkB,EAAEC,KAAa,KAChDP,WAAW,CACTG,KAAK,CAACK,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACH,UAAU,KAAKA,UAAU,CAAC,EAChDC,KAAK,EACL,uBACF,CAAC;EAEH,MAAMG,YAAY,GAAGA,CAACC,YAAoB,EAAEC,MAAe,KAAc;IACvE,KAAK,IAAIC,CAAC,GAAGT,UAAU,CAACU,MAAM,GAAG,CAAC,EAAED,CAAC,IAAI,CAAC,EAAEA,CAAC,EAAE,EAAE;MAC/C,MAAME,IAAI,GAAGX,UAAU,CAACS,CAAC,CAAC;MAC1B,IAAIE,IAAI,CAACJ,YAAY,KAAKA,YAAY,EAAE;MACxC,IAAIZ,SAAS,CAACgB,IAAI,CAACH,MAAM,EAAEA,MAAM,CAAC,EAAE;QAClC,IAAIG,IAAI,CAACC,KAAK,KAAKC,SAAS,EAAE;UAC5B,MAAMF,IAAI,CAACC,KAAK;QAClB;QACA,OAAOD,IAAI,CAACG,KAAK;MACnB;IACF;IAGA,MAAM,IAA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AAU,CAACiC,aAAa,GAAG,YAAY;IACrC/B,OAAA,CAAAC,GAAA,CAAAC,QAAA,oBAAA3B,SAAS,QAAQ,yCAAyC,IAA1DA,SAAS;EACX,CAAC;;EAED;EACA;EACA;EACA;EACAyD,MAAM,CAACC,cAAc,CAACnC,UAAU,EAAEnB,qBAAqB,EAAE;IACvDiB,KAAK,EAAEtB,oBAAoB,CACzB,uBAAuB;IACvB;IACA,YAAY,YACd,CAAC;IACD4D,UAAU,EAAE;EACd,CAAC,CAAC;EAEF,OAAOpC,UAAU;AACnB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMockObjectSet.js","names":["createMockObjectSetWithResolver","resolveStub","MOCK_OBJECT_SET_BRAND","Symbol","createMockObjectSet","objectType","stubs","objectSet","calls","__registerStub","value","push","isMockObjectSet"],"sources":["createMockObjectSet.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectOrInterfaceDefinition, ObjectSet } from \"@osdk/api\";\n\nimport {\n type Call,\n createMockObjectSetWithResolver,\n resolveStub,\n type Stub,\n} from \"./createMockObjectSetWithResolver.js\";\n\nconst MOCK_OBJECT_SET_BRAND: unique symbol = Symbol(\"MOCK_OBJECT_SET_BRAND\");\n\nexport type MockObjectSetBranded<Q extends ObjectOrInterfaceDefinition> =\n ObjectSet<Q> & {\n [MOCK_OBJECT_SET_BRAND]: true;\n __registerStub(calls: Call[], value: unknown): void;\n };\n\nexport function createMockObjectSet<Q extends ObjectOrInterfaceDefinition>(\n objectType: Q
|
|
1
|
+
{"version":3,"file":"createMockObjectSet.js","names":["createMockObjectSetWithResolver","resolveStub","MOCK_OBJECT_SET_BRAND","Symbol","createMockObjectSet","objectType","stubs","objectSet","calls","__registerStub","value","push","isMockObjectSet"],"sources":["createMockObjectSet.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectOrInterfaceDefinition, ObjectSet } from \"@osdk/api\";\n\nimport {\n type Call,\n createMockObjectSetWithResolver,\n resolveStub,\n type Stub,\n} from \"./createMockObjectSetWithResolver.js\";\n\nconst MOCK_OBJECT_SET_BRAND: unique symbol = Symbol(\"MOCK_OBJECT_SET_BRAND\");\n\nexport type MockObjectSetBranded<Q extends ObjectOrInterfaceDefinition> =\n ObjectSet<Q> & {\n [MOCK_OBJECT_SET_BRAND]: true;\n __registerStub(calls: Call[], value: unknown): void;\n };\n\nexport function createMockObjectSet<Q extends ObjectOrInterfaceDefinition>(\n objectType: Q,\n): ObjectSet<Q> {\n const stubs: Stub[] = [];\n\n const resolve = (calls: Call[]): unknown =>\n resolveStub(\n stubs,\n calls,\n `No stub registered on standalone MockObjectSet\\n`,\n );\n\n const objectSet = createMockObjectSetWithResolver(\n objectType,\n resolve,\n ) as MockObjectSetBranded<Q>;\n\n objectSet[MOCK_OBJECT_SET_BRAND] = true;\n (objectSet as any).__registerStub = (calls: Call[], value: unknown) => {\n stubs.push({ calls, value });\n };\n\n return objectSet;\n}\n\n/** @internal */\nexport function isMockObjectSet(\n value: unknown,\n): value is MockObjectSetBranded<ObjectOrInterfaceDefinition> {\n return (\n value != null && typeof value === \"object\" && MOCK_OBJECT_SET_BRAND in value\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAEEA,+BAA+B,EAC/BC,WAAW,QAEN,sCAAsC;AAE7C,MAAMC,qBAAoC,GAAGC,MAAM,CAAC,uBAAuB,CAAC;AAQ5E,OAAO,SAASC,mBAAmBA,CACjCC,UAAa,EACC;EACd,MAAMC,KAAa,GAAG,EAAE;EASxB,MAAMC,SAAS,GAAGP,+BAA+B,CAC/CK,UAAU,EARKG,KAAa,IAC5BP,WAAW,CACTK,KAAK,EACLE,KAAK,EACL,kDACF,CAKF,CAA4B;EAE5BD,SAAS,CAACL,qBAAqB,CAAC,GAAG,IAAI;EACtCK,SAAS,CAASE,cAAc,GAAG,CAACD,KAAa,EAAEE,KAAc,KAAK;IACrEJ,KAAK,CAACK,IAAI,CAAC;MAAEH,KAAK;MAAEE;IAAM,CAAC,CAAC;EAC9B,CAAC;EAED,OAAOH,SAAS;AAClB;;AAEA;AACA,OAAO,SAASK,eAAeA,CAC7BF,KAAc,EAC8C;EAC5D,OACEA,KAAK,IAAI,IAAI,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIR,qBAAqB,IAAIQ,KAAK;AAEhF","ignoreList":[]}
|
|
@@ -15,16 +15,20 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import invariant from "tiny-invariant";
|
|
18
|
+
const mockObjectSetDefinitions = new WeakMap();
|
|
18
19
|
export function createMockObjectSetWithResolver(objectType, resolver, calls = []) {
|
|
19
20
|
const chain = (method, args) => createMockObjectSetWithResolver(objectType, resolver, [...calls, [method, args]]);
|
|
20
21
|
const terminal = (method, args) => resolver([...calls, [method, args]]);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const setOperation = (method, objectSets) => chain(method, objectSets.map(operand => {
|
|
23
|
+
const definition = mockObjectSetDefinitions.get(operand);
|
|
24
|
+
!definition ? process.env.NODE_ENV !== "production" ? invariant(false, `${method} only supports mock object sets`) : invariant(false) : void 0;
|
|
25
|
+
return definition;
|
|
26
|
+
}));
|
|
27
|
+
const objectSet = {
|
|
24
28
|
where: clause => chain("where", clause),
|
|
25
|
-
union: () =>
|
|
26
|
-
intersect: () =>
|
|
27
|
-
subtract: () =>
|
|
29
|
+
union: (...objectSets) => setOperation("union", objectSets),
|
|
30
|
+
intersect: (...objectSets) => setOperation("intersect", objectSets),
|
|
31
|
+
subtract: (...objectSets) => setOperation("subtract", objectSets),
|
|
28
32
|
pivotTo: link => chain("pivotTo", link),
|
|
29
33
|
narrowToType: type => chain("narrowToType", type),
|
|
30
34
|
nearestNeighbors: (query, num, prop) => chain("nearestNeighbors", {
|
|
@@ -79,9 +83,14 @@ export function createMockObjectSetWithResolver(objectType, resolver, calls = []
|
|
|
79
83
|
def: {}
|
|
80
84
|
}
|
|
81
85
|
};
|
|
86
|
+
mockObjectSetDefinitions.set(objectSet, {
|
|
87
|
+
calls
|
|
88
|
+
});
|
|
89
|
+
return objectSet;
|
|
82
90
|
}
|
|
83
91
|
export function resolveStub(stubs, calls, errorMsg) {
|
|
84
|
-
for (
|
|
92
|
+
for (let s = stubs.length - 1; s >= 0; s--) {
|
|
93
|
+
const stub = stubs[s];
|
|
85
94
|
if (stub.calls.length !== calls.length) continue;
|
|
86
95
|
if (stub.calls.every(([m, a], i) => calls[i][0] === m && deepEqual(a, calls[i][1]))) {
|
|
87
96
|
const terminal = calls[calls.length - 1][0];
|