@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
|
@@ -0,0 +1,60 @@
|
|
|
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 { createEditBatch } from "@osdk/functions";
|
|
18
|
+
import { writeableClientContext } from "@osdk/functions/internal";
|
|
19
|
+
import { createMockClient } from "./createMockClient.js";
|
|
20
|
+
const noop = () => Promise.resolve();
|
|
21
|
+
export function createMockWriteableClient() {
|
|
22
|
+
const mockClient = createMockClient();
|
|
23
|
+
let batch = createEditBatch(mockClient);
|
|
24
|
+
mockClient.link = (source, apiName, target) => {
|
|
25
|
+
batch.link(source, apiName, target);
|
|
26
|
+
return Promise.resolve();
|
|
27
|
+
};
|
|
28
|
+
mockClient.unlink = (source, apiName, target) => {
|
|
29
|
+
batch.unlink(source, apiName, target);
|
|
30
|
+
return Promise.resolve();
|
|
31
|
+
};
|
|
32
|
+
mockClient.create = (obj, properties) => {
|
|
33
|
+
batch.create(obj, properties);
|
|
34
|
+
return Promise.resolve();
|
|
35
|
+
};
|
|
36
|
+
mockClient.update = (obj, properties) => {
|
|
37
|
+
batch.update(obj, properties);
|
|
38
|
+
return Promise.resolve();
|
|
39
|
+
};
|
|
40
|
+
mockClient.delete = obj => {
|
|
41
|
+
batch.delete(obj);
|
|
42
|
+
return Promise.resolve();
|
|
43
|
+
};
|
|
44
|
+
mockClient.getEdits = () => batch.getEdits();
|
|
45
|
+
mockClient.clearEdits = () => {
|
|
46
|
+
batch = createEditBatch(mockClient);
|
|
47
|
+
};
|
|
48
|
+
Object.defineProperty(mockClient, writeableClientContext, {
|
|
49
|
+
value: {
|
|
50
|
+
ontologyRid: "ri.ontology.main.ontology.mock",
|
|
51
|
+
transactionId: "mock-transaction",
|
|
52
|
+
editRequestManager: {
|
|
53
|
+
flushPendingEdits: noop
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
enumerable: false
|
|
57
|
+
});
|
|
58
|
+
return mockClient;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=createMockWriteableClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createMockWriteableClient.js","names":["createEditBatch","writeableClientContext","createMockClient","noop","Promise","resolve","createMockWriteableClient","mockClient","batch","link","source","apiName","target","unlink","create","obj","properties","update","delete","getEdits","clearEdits","Object","defineProperty","value","ontologyRid","transactionId","editRequestManager","flushPendingEdits","enumerable"],"sources":["createMockWriteableClient.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 { createEditBatch, type EditBatch } from \"@osdk/functions\";\nimport {\n type AnyEdit,\n writeableClientContext,\n type WriteableClientContext,\n} from \"@osdk/functions/internal\";\n\nimport type { MockWriteableClient } from \"../api/MockWriteableClient.js\";\nimport { createMockClient } from \"./createMockClient.js\";\n\nconst noop = (): Promise<void> => Promise.resolve();\n\nexport function createMockWriteableClient<\n X extends AnyEdit = never,\n>(): MockWriteableClient<X> {\n const mockClient = createMockClient() as MockWriteableClient<X>;\n\n let batch: EditBatch<X> = createEditBatch<X>(mockClient);\n\n mockClient.link = (source, apiName, target) => {\n batch.link(source, apiName, target);\n return Promise.resolve();\n };\n mockClient.unlink = (source, apiName, target) => {\n batch.unlink(source, apiName, target);\n return Promise.resolve();\n };\n mockClient.create = (obj, properties) => {\n batch.create(obj, properties);\n return Promise.resolve();\n };\n mockClient.update = (obj, properties) => {\n batch.update(obj, properties);\n return Promise.resolve();\n };\n mockClient.delete = (obj) => {\n batch.delete(obj);\n return Promise.resolve();\n };\n mockClient.getEdits = () => batch.getEdits();\n mockClient.clearEdits = () => {\n batch = createEditBatch<X>(mockClient);\n };\n\n Object.defineProperty(mockClient, writeableClientContext, {\n value: {\n ontologyRid: \"ri.ontology.main.ontology.mock\",\n transactionId: \"mock-transaction\",\n editRequestManager: {\n flushPendingEdits: noop,\n } as unknown as WriteableClientContext[\"editRequestManager\"],\n } satisfies WriteableClientContext,\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;;AAEA,SAASA,eAAe,QAAwB,iBAAiB;AACjE,SAEEC,sBAAsB,QAEjB,0BAA0B;AAGjC,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,MAAMC,IAAI,GAAGA,CAAA,KAAqBC,OAAO,CAACC,OAAO,CAAC,CAAC;AAEnD,OAAO,SAASC,yBAAyBA,CAAA,EAEb;EAC1B,MAAMC,UAAU,GAAGL,gBAAgB,CAAC,CAA2B;EAE/D,IAAIM,KAAmB,GAAGR,eAAe,CAAIO,UAAU,CAAC;EAExDA,UAAU,CAACE,IAAI,GAAG,CAACC,MAAM,EAAEC,OAAO,EAAEC,MAAM,KAAK;IAC7CJ,KAAK,CAACC,IAAI,CAACC,MAAM,EAAEC,OAAO,EAAEC,MAAM,CAAC;IACnC,OAAOR,OAAO,CAACC,OAAO,CAAC,CAAC;EAC1B,CAAC;EACDE,UAAU,CAACM,MAAM,GAAG,CAACH,MAAM,EAAEC,OAAO,EAAEC,MAAM,KAAK;IAC/CJ,KAAK,CAACK,MAAM,CAACH,MAAM,EAAEC,OAAO,EAAEC,MAAM,CAAC;IACrC,OAAOR,OAAO,CAACC,OAAO,CAAC,CAAC;EAC1B,CAAC;EACDE,UAAU,CAACO,MAAM,GAAG,CAACC,GAAG,EAAEC,UAAU,KAAK;IACvCR,KAAK,CAACM,MAAM,CAACC,GAAG,EAAEC,UAAU,CAAC;IAC7B,OAAOZ,OAAO,CAACC,OAAO,CAAC,CAAC;EAC1B,CAAC;EACDE,UAAU,CAACU,MAAM,GAAG,CAACF,GAAG,EAAEC,UAAU,KAAK;IACvCR,KAAK,CAACS,MAAM,CAACF,GAAG,EAAEC,UAAU,CAAC;IAC7B,OAAOZ,OAAO,CAACC,OAAO,CAAC,CAAC;EAC1B,CAAC;EACDE,UAAU,CAACW,MAAM,GAAIH,GAAG,IAAK;IAC3BP,KAAK,CAACU,MAAM,CAACH,GAAG,CAAC;IACjB,OAAOX,OAAO,CAACC,OAAO,CAAC,CAAC;EAC1B,CAAC;EACDE,UAAU,CAACY,QAAQ,GAAG,MAAMX,KAAK,CAACW,QAAQ,CAAC,CAAC;EAC5CZ,UAAU,CAACa,UAAU,GAAG,MAAM;IAC5BZ,KAAK,GAAGR,eAAe,CAAIO,UAAU,CAAC;EACxC,CAAC;EAEDc,MAAM,CAACC,cAAc,CAACf,UAAU,EAAEN,sBAAsB,EAAE;IACxDsB,KAAK,EAAE;MACLC,WAAW,EAAE,gCAAgC;MAC7CC,aAAa,EAAE,kBAAkB;MACjCC,kBAAkB,EAAE;QAClBC,iBAAiB,EAAExB;MACrB;IACF,CAAkC;IAClCyB,UAAU,EAAE;EACd,CAAC,CAAC;EAEF,OAAOrB,UAAU;AACnB","ignoreList":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { WriteableClient } from "@osdk/functions/experimental";
|
|
2
|
+
import type { AnyEdit } from "@osdk/functions/internal";
|
|
3
|
+
import type { MockClient } from "./MockClient.js";
|
|
4
|
+
export interface MockWriteableClient<X extends AnyEdit = never> extends MockClient, WriteableClient<X> {
|
|
5
|
+
getEdits(): X[];
|
|
6
|
+
clearEdits(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,uBAAuB,8BAA+B;AACpE,cAAc,eAAe,0BAA2B;AAExD,cAAc,kBAAkB,iBAAkB;AAElD,iBAAiB,oBAAoB,UAAU,yBACrC,YAAY,gBAAgB,GAAG;CACvC,YAAY;CACZ;AACD","names":[],"sources":["../../../src/api/MockWriteableClient.ts"],"version":3,"file":"MockWriteableClient.d.ts"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type { MockClient } from "./MockClient.js";
|
|
2
2
|
export type { MockOsdkObjectOptions } from "./MockOsdkObjectOptions.js";
|
|
3
|
+
export type { MockWriteableClient } from "./MockWriteableClient.js";
|
|
3
4
|
export type { AggregateStubBuilder, FetchOneStubBuilder, FetchPageStubBuilder, QueryStubBuilder, StubBuilderFor } from "./StubBuilders.js";
|
|
4
5
|
export type { StubClient } from "./StubClient.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cAAc,kBAAkB;AAChC,cAAc,6BAA6B;AAC3C,cACE,sBACA,qBACA,sBACA,kBACA,sBACK;AACP,cAAc,kBAAkB","names":[],"sources":["../../../src/api/index.ts"],"version":3,"file":"index.d.ts"}
|
|
1
|
+
{"mappings":"AAgBA,cAAc,kBAAkB;AAChC,cAAc,6BAA6B;AAC3C,cAAc,2BAA2B;AACzC,cACE,sBACA,qBACA,sBACA,kBACA,sBACK;AACP,cAAc,kBAAkB","names":[],"sources":["../../../src/api/index.ts"],"version":3,"file":"index.d.ts"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ObjectSet, Osdk } from "@osdk/api";
|
|
2
|
+
import type { Client } from "@osdk/client";
|
|
3
|
+
import { Employee } from "@osdk/client.test.ontology";
|
|
4
|
+
export declare function objectSetArithmetic(client: Client, employees: ObjectSet<Employee>): Promise<{
|
|
5
|
+
union: Array<Osdk.Instance<Employee>>
|
|
6
|
+
standaloneUnion: Array<Osdk.Instance<Employee>>
|
|
7
|
+
intersect: Array<Osdk.Instance<Employee>>
|
|
8
|
+
subtract: Array<Osdk.Instance<Employee>>
|
|
9
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cAAc,WAAW,YAAY,WAAY;AACjD,cAAc,cAAc,cAAe;AAC3C,SAAS,gBAAgB,4BAA6B;AAEtD,OAAO,iBAAe,oBACpBA,QAAQ,QACRC,WAAW,UAAU,YACpB,QAAQ;CACT,OAAO,MAAM,KAAK,SAAS;CAC3B,iBAAiB,MAAM,KAAK,SAAS;CACrC,WAAW,MAAM,KAAK,SAAS;CAC/B,UAAU,MAAM,KAAK,SAAS;AAC/B","names":["client: Client","employees: ObjectSet<Employee>"],"sources":["../../../../src/example-function-tests/objectSetArithmetic/objectSetArithmetic.ts"],"version":3,"file":"objectSetArithmetic.d.ts"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Employee } from "@osdk/client.test.ontology";
|
|
2
|
+
import type { Edits } from "@osdk/functions";
|
|
3
|
+
import type { WriteableClient } from "@osdk/functions/experimental";
|
|
4
|
+
export declare function relocateOffice(client: WriteableClient<Edits.Object<Employee>>, fromOffice: string, toOffice: string): Promise<number>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,SAAS,gBAAgB,4BAA6B;AACtD,cAAc,aAAa,iBAAkB;AAC7C,cAAc,uBAAuB,8BAA+B;AAGpE,OAAO,iBAAe,eACpBA,QAAQ,gBAAgB,MAAM,OAAO,YACrCC,oBACAC,mBACC","names":["client: WriteableClient<Edits.Object<Employee>>","fromOffice: string","toOffice: string"],"sources":["../../../../src/example-function-tests/writeableClientEdits/writeableClientEdits.ts"],"version":3,"file":"writeableClientEdits.d.ts"}
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export type { AggregateStubBuilder, FetchOneStubBuilder, FetchPageStubBuilder, MockClient, MockOsdkObjectOptions, QueryStubBuilder, StubBuilderFor, StubClient } from "./api/index.js";
|
|
1
|
+
export type { AggregateStubBuilder, FetchOneStubBuilder, FetchPageStubBuilder, MockClient, MockOsdkObjectOptions, MockWriteableClient, QueryStubBuilder, StubBuilderFor, StubClient } from "./api/index.js";
|
|
2
2
|
export { createMockAttachment } from "./mock/createMockAttachment.js";
|
|
3
3
|
export { createMockClient } from "./mock/createMockClient.js";
|
|
4
4
|
export { createMockObjectSet } from "./mock/createMockObjectSet.js";
|
|
5
5
|
export { createMockOsdkObject } from "./mock/createMockOsdkObject.js";
|
|
6
|
+
export { createMockWriteableClient } from "./mock/createMockWriteableClient.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cACE,sBACA,qBACA,sBACA,YACA,uBACA,kBACA,gBACA,kBACK;AAEP,SAAS,4BAA4B;AACrC,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,4BAA4B","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
|
|
1
|
+
{"mappings":"AAgBA,cACE,sBACA,qBACA,sBACA,YACA,uBACA,qBACA,kBACA,gBACA,kBACK;AAEP,SAAS,4BAA4B;AACrC,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AACrC,SAAS,iCAAiC","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cAGE,6BACA,iBAIK,WAAY;AAGnB,YAAY,QAAQ,gBAAgB;AAEpC,YAAY,YAAYA,OAAO;AAE/B,YAAY,OAAO;CAAE,OAAO;CAAQ;AAAgB;
|
|
1
|
+
{"mappings":"AAgBA,cAGE,6BACA,iBAIK,WAAY;AAGnB,YAAY,QAAQ,gBAAgB;AAEpC,YAAY,YAAYA,OAAO;AAE/B,YAAY,OAAO;CAAE,OAAO;CAAQ;AAAgB;AAQpD,OAAO,iBAAS,gCACd,UAAU,6BACVC,YAAY,GAAGC,UAAU,UAAUF,QAAO,SAAc,UAAU;AAiGpE,OAAO,iBAAS,YACdG,OAAO,QACPH,OAAO,QACPI;AAoBF,OAAO,iBAAS,UAAUC,YAAYC","names":["calls: Call[]","objectType: Q","resolver: Resolver","stubs: Stub[]","errorMsg: string","a: unknown","b: unknown"],"sources":["../../../src/mock/createMockObjectSetWithResolver.ts"],"version":3,"file":"createMockObjectSetWithResolver.d.ts"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAiBA,cACO,eAGA,0BAA2B;AAElC,cAAc,2BAA2B,+BAAgC;AAKzE,OAAO,iBAAS,0BACd,UAAU,oBACP,oBAAoB","names":[],"sources":["../../../src/mock/createMockWriteableClient.ts"],"version":3,"file":"createMockWriteableClient.d.ts"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdk/unit-testing",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"access": "public",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -18,15 +18,6 @@
|
|
|
18
18
|
"require": "./build/cjs/index.cjs",
|
|
19
19
|
"default": "./build/browser/index.js"
|
|
20
20
|
},
|
|
21
|
-
"./experimental": {
|
|
22
|
-
"browser": "./build/browser/public/experimental.js",
|
|
23
|
-
"import": {
|
|
24
|
-
"types": "./build/types/public/experimental.d.ts",
|
|
25
|
-
"default": "./build/esm/public/experimental.js"
|
|
26
|
-
},
|
|
27
|
-
"require": "./build/cjs/public/experimental.cjs",
|
|
28
|
-
"default": "./build/browser/public/experimental.js"
|
|
29
|
-
},
|
|
30
21
|
"./*": {
|
|
31
22
|
"browser": "./build/browser/public/*.js",
|
|
32
23
|
"import": {
|
|
@@ -41,23 +32,23 @@
|
|
|
41
32
|
"tiny-invariant": "^1.3.3"
|
|
42
33
|
},
|
|
43
34
|
"peerDependencies": {
|
|
44
|
-
"@osdk/api": "^
|
|
45
|
-
"@osdk/
|
|
46
|
-
"@osdk/
|
|
35
|
+
"@osdk/api": "^2.84.0",
|
|
36
|
+
"@osdk/functions": "^1.30.0",
|
|
37
|
+
"@osdk/client": "^2.84.0"
|
|
47
38
|
},
|
|
48
39
|
"devDependencies": {
|
|
49
40
|
"@microsoft/api-documenter": "^7.26.32",
|
|
50
41
|
"@microsoft/api-extractor": "^7.52.11",
|
|
51
|
-
"@osdk/foundry.admin": "2.
|
|
42
|
+
"@osdk/foundry.admin": "2.83.0",
|
|
52
43
|
"msw": "^2.11.1",
|
|
53
44
|
"typescript": "~5.5.4",
|
|
54
45
|
"vitest": "^3.2.4",
|
|
55
|
-
"@osdk/api": "~
|
|
56
|
-
"@osdk/
|
|
57
|
-
"@osdk/client
|
|
58
|
-
"@osdk/
|
|
59
|
-
"@osdk/monorepo.
|
|
60
|
-
"@osdk/monorepo.
|
|
46
|
+
"@osdk/api": "~2.84.0",
|
|
47
|
+
"@osdk/functions": "~1.30.0",
|
|
48
|
+
"@osdk/client": "~2.84.0",
|
|
49
|
+
"@osdk/client.test.ontology": "~2.84.0",
|
|
50
|
+
"@osdk/monorepo.tsconfig": "~0.7.0",
|
|
51
|
+
"@osdk/monorepo.api-extractor": "~0.7.0"
|
|
61
52
|
},
|
|
62
53
|
"publishConfig": {
|
|
63
54
|
"access": "public"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"experimental.js","names":["createMockAttachment","createMockClient","createMockObjectSet","createMockOsdkObject"],"sources":["experimental.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 QueryStubBuilder,\n StubBuilderFor,\n} from \"../api/index.js\";\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;;AASA,SAASA,oBAAoB,QAAQ,iCAAiC;AACtE,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,mBAAmB,QAAQ,gCAAgC;AACpE,SAASC,oBAAoB,QAAQ,iCAAiC","ignoreList":[]}
|
|
@@ -1,453 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var invariant4 = require('tiny-invariant');
|
|
4
|
-
var client = require('@osdk/client');
|
|
5
|
-
|
|
6
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
-
|
|
8
|
-
var invariant4__default = /*#__PURE__*/_interopDefault(invariant4);
|
|
9
|
-
|
|
10
|
-
// src/mock/createMockAttachment.ts
|
|
11
|
-
function createMockAttachment(rid, blob, metadata) {
|
|
12
|
-
return {
|
|
13
|
-
rid,
|
|
14
|
-
fetchContents() {
|
|
15
|
-
!(blob != null) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, `fetchContents was called on mock attachment "${rid}" but no blob was provided. Pass a Blob as the second argument to createMockAttachment to stub fetchContents.`) : invariant4__default.default(false) : void 0;
|
|
16
|
-
return Promise.resolve(new Response(blob));
|
|
17
|
-
},
|
|
18
|
-
fetchMetadata() {
|
|
19
|
-
!(metadata != null) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, `fetchMetadata was called on mock attachment "${rid}" but no metadata was provided. Pass AttachmentMetadata as the third argument to createMockAttachment to stub fetchMetadata.`) : invariant4__default.default(false) : void 0;
|
|
20
|
-
return Promise.resolve(metadata);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
function createMockObjectSetWithResolver(objectType, resolver, calls = []) {
|
|
25
|
-
const chain = (method, args) => createMockObjectSetWithResolver(objectType, resolver, [...calls, [method, args]]);
|
|
26
|
-
const terminal = (method, args) => resolver([...calls, [method, args]]);
|
|
27
|
-
return {
|
|
28
|
-
where: (clause) => chain("where", clause),
|
|
29
|
-
union: () => void (process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "union is not supported in mocks") : invariant4__default.default(false) ),
|
|
30
|
-
intersect: () => void (process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "intersect is not supported in mocks") : invariant4__default.default(false) ),
|
|
31
|
-
subtract: () => void (process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "subtract is not supported in mocks") : invariant4__default.default(false) ),
|
|
32
|
-
pivotTo: (link) => chain("pivotTo", link),
|
|
33
|
-
narrowToType: (type) => chain("narrowToType", type),
|
|
34
|
-
nearestNeighbors: (query, num, prop) => chain("nearestNeighbors", {
|
|
35
|
-
query,
|
|
36
|
-
num,
|
|
37
|
-
prop
|
|
38
|
-
}),
|
|
39
|
-
withProperties: () => (
|
|
40
|
-
// TODO: Add with properties support
|
|
41
|
-
void (process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "withProperties is not supported in mocks") : invariant4__default.default(false) )
|
|
42
|
-
),
|
|
43
|
-
// oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed
|
|
44
|
-
fetchPage: async (args) => terminal("fetchPage", args),
|
|
45
|
-
fetchPageWithErrors: async (args) => {
|
|
46
|
-
try {
|
|
47
|
-
return {
|
|
48
|
-
type: "ok",
|
|
49
|
-
value: await terminal("fetchPage", args)
|
|
50
|
-
};
|
|
51
|
-
} catch (error) {
|
|
52
|
-
return {
|
|
53
|
-
type: "error",
|
|
54
|
-
error
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
// oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed
|
|
59
|
-
fetchOne: async (pk) => terminal("fetchOne", pk),
|
|
60
|
-
fetchOneWithErrors: async (pk) => {
|
|
61
|
-
try {
|
|
62
|
-
return {
|
|
63
|
-
type: "ok",
|
|
64
|
-
value: await terminal("fetchOne", pk)
|
|
65
|
-
};
|
|
66
|
-
} catch (error) {
|
|
67
|
-
return {
|
|
68
|
-
type: "error",
|
|
69
|
-
error
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
// oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed
|
|
74
|
-
aggregate: async (req) => terminal("aggregate", req),
|
|
75
|
-
asyncIter: (args) => {
|
|
76
|
-
const data = terminal("asyncIter", args);
|
|
77
|
-
return (async function* () {
|
|
78
|
-
for (const item of data) yield item;
|
|
79
|
-
})();
|
|
80
|
-
},
|
|
81
|
-
subscribe: () => void (process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "subscribe is not supported in mocks") : invariant4__default.default(false) ),
|
|
82
|
-
experimental_asyncIterLinks: () => void (process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "experimental_asyncIterLinks is not supported in mocks") : invariant4__default.default(false) ),
|
|
83
|
-
$objectSetInternals: {
|
|
84
|
-
def: {}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
function resolveStub(stubs, calls, errorMsg) {
|
|
89
|
-
for (const stub of stubs) {
|
|
90
|
-
if (stub.calls.length !== calls.length) continue;
|
|
91
|
-
if (stub.calls.every(([m, a], i) => calls[i][0] === m && deepEqual(a, calls[i][1]))) {
|
|
92
|
-
const terminal = calls[calls.length - 1][0];
|
|
93
|
-
if (terminal === "fetchPage") {
|
|
94
|
-
return {
|
|
95
|
-
data: stub.value,
|
|
96
|
-
nextPageToken: void 0
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
return stub.value;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
throw new Error(errorMsg);
|
|
103
|
-
}
|
|
104
|
-
function deepEqual(a, b) {
|
|
105
|
-
if (a === b) return true;
|
|
106
|
-
if (isAsymmetricMatcher(a)) return a.asymmetricMatch(b);
|
|
107
|
-
if (isAsymmetricMatcher(b)) return b.asymmetricMatch(a);
|
|
108
|
-
if (a == null || b == null) return a === b;
|
|
109
|
-
if (typeof a !== typeof b) return false;
|
|
110
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
111
|
-
if (a.length !== b.length) return false;
|
|
112
|
-
return a.every((v, i) => deepEqual(v, b[i]));
|
|
113
|
-
}
|
|
114
|
-
if (typeof a === "object") {
|
|
115
|
-
const aKeys = Object.keys(a);
|
|
116
|
-
const bKeys = Object.keys(b);
|
|
117
|
-
if (aKeys.length !== bKeys.length) return false;
|
|
118
|
-
return aKeys.every((k) => deepEqual(a[k], b[k]));
|
|
119
|
-
}
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
function isAsymmetricMatcher(x) {
|
|
123
|
-
return x != null && typeof x === "object" && typeof x.asymmetricMatch === "function";
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// src/mock/createMockClient.ts
|
|
127
|
-
var SYMBOL_CLIENT_CONTEXT = "__osdkClientContext";
|
|
128
|
-
function createMockClient() {
|
|
129
|
-
const stubs = [];
|
|
130
|
-
const queryStubs = [];
|
|
131
|
-
const resolve = (objectType, calls) => resolveStub(stubs.filter((s) => s.objectType === objectType), calls, `No stub for request
|
|
132
|
-
`);
|
|
133
|
-
const resolveQuery = (queryApiName, params) => {
|
|
134
|
-
for (const stub of queryStubs) {
|
|
135
|
-
if (stub.queryApiName !== queryApiName) continue;
|
|
136
|
-
if (deepEqual(stub.params, params)) {
|
|
137
|
-
if (stub.error !== void 0) {
|
|
138
|
-
throw stub.error;
|
|
139
|
-
}
|
|
140
|
-
return stub.value;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
const msg = `No stub for query '${queryApiName}'`;
|
|
144
|
-
throw new Error(msg);
|
|
145
|
-
};
|
|
146
|
-
const mockClient = (def) => {
|
|
147
|
-
!("apiName" in def) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "Expected ObjectType, Interface, or Query") : invariant4__default.default(false) : void 0;
|
|
148
|
-
if (def.type === "query") {
|
|
149
|
-
return {
|
|
150
|
-
executeFunction: (params) => {
|
|
151
|
-
try {
|
|
152
|
-
return Promise.resolve(resolveQuery(def.apiName, params));
|
|
153
|
-
} catch (e) {
|
|
154
|
-
return Promise.reject(e);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
return createMockObjectSetWithResolver(def, (calls) => resolve(def.apiName, calls));
|
|
160
|
-
};
|
|
161
|
-
mockClient.when = (callback) => {
|
|
162
|
-
let captured;
|
|
163
|
-
const stubClient = (def) => {
|
|
164
|
-
return createMockObjectSetWithResolver(def, (calls) => {
|
|
165
|
-
captured = {
|
|
166
|
-
objectType: def.apiName,
|
|
167
|
-
calls
|
|
168
|
-
};
|
|
169
|
-
return {
|
|
170
|
-
data: [],
|
|
171
|
-
nextPageToken: void 0
|
|
172
|
-
};
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
void callback(stubClient);
|
|
176
|
-
const register = (value) => {
|
|
177
|
-
if (captured) stubs.push({
|
|
178
|
-
...captured,
|
|
179
|
-
value
|
|
180
|
-
});
|
|
181
|
-
};
|
|
182
|
-
return {
|
|
183
|
-
thenReturnObjects: register,
|
|
184
|
-
thenReturnObject: register,
|
|
185
|
-
thenReturnAggregation: register
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
mockClient.whenObjectSet = (objectSet, callback) => {
|
|
189
|
-
let capturedCalls;
|
|
190
|
-
const capturingProxy = createMockObjectSetWithResolver(objectSet.$objectSetInternals.def, (calls) => {
|
|
191
|
-
capturedCalls = calls;
|
|
192
|
-
return {
|
|
193
|
-
data: [],
|
|
194
|
-
nextPageToken: void 0
|
|
195
|
-
};
|
|
196
|
-
});
|
|
197
|
-
void callback(capturingProxy);
|
|
198
|
-
const branded = objectSet;
|
|
199
|
-
const register = (value) => {
|
|
200
|
-
if (capturedCalls) {
|
|
201
|
-
branded.__registerStub(capturedCalls, value);
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
return {
|
|
205
|
-
thenReturnObjects: register,
|
|
206
|
-
thenReturnObject: register,
|
|
207
|
-
thenReturnAggregation: register
|
|
208
|
-
};
|
|
209
|
-
};
|
|
210
|
-
mockClient.whenQuery = (query, params) => {
|
|
211
|
-
return {
|
|
212
|
-
thenReturn: (result) => {
|
|
213
|
-
queryStubs.push({
|
|
214
|
-
queryApiName: query.apiName,
|
|
215
|
-
params,
|
|
216
|
-
value: result
|
|
217
|
-
});
|
|
218
|
-
},
|
|
219
|
-
thenThrow: (error) => {
|
|
220
|
-
queryStubs.push({
|
|
221
|
-
queryApiName: query.apiName,
|
|
222
|
-
params,
|
|
223
|
-
error
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
};
|
|
228
|
-
mockClient.clearStubs = () => {
|
|
229
|
-
stubs.length = 0;
|
|
230
|
-
queryStubs.length = 0;
|
|
231
|
-
};
|
|
232
|
-
mockClient.fetchMetadata = async () => {
|
|
233
|
-
process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "fetchMetadata is not supported in mocks") : invariant4__default.default(false) ;
|
|
234
|
-
};
|
|
235
|
-
Object.defineProperty(mockClient, SYMBOL_CLIENT_CONTEXT, {
|
|
236
|
-
value: client.createPlatformClient(
|
|
237
|
-
"https://mock.invalid/",
|
|
238
|
-
// oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed
|
|
239
|
-
async () => "mock-token"
|
|
240
|
-
),
|
|
241
|
-
enumerable: false
|
|
242
|
-
});
|
|
243
|
-
return mockClient;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// src/mock/createMockObjectSet.ts
|
|
247
|
-
var MOCK_OBJECT_SET_BRAND = Symbol("MOCK_OBJECT_SET_BRAND");
|
|
248
|
-
function createMockObjectSet(objectType) {
|
|
249
|
-
const stubs = [];
|
|
250
|
-
const resolve = (calls) => resolveStub(stubs, calls, `No stub registered on standalone MockObjectSet
|
|
251
|
-
`);
|
|
252
|
-
const objectSet = createMockObjectSetWithResolver(objectType, resolve);
|
|
253
|
-
objectSet[MOCK_OBJECT_SET_BRAND] = true;
|
|
254
|
-
objectSet.__registerStub = (calls, value) => {
|
|
255
|
-
stubs.push({
|
|
256
|
-
calls,
|
|
257
|
-
value
|
|
258
|
-
});
|
|
259
|
-
};
|
|
260
|
-
return objectSet;
|
|
261
|
-
}
|
|
262
|
-
function isMockObjectSet(value) {
|
|
263
|
-
return value != null && typeof value === "object" && MOCK_OBJECT_SET_BRAND in value;
|
|
264
|
-
}
|
|
265
|
-
function createSingleLinkStub(linked) {
|
|
266
|
-
if (linked instanceof Error) {
|
|
267
|
-
return {
|
|
268
|
-
fetchOne: () => Promise.reject(linked),
|
|
269
|
-
fetchOneWithErrors: () => Promise.resolve({
|
|
270
|
-
error: linked
|
|
271
|
-
})
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
return {
|
|
275
|
-
fetchOne: () => Promise.resolve(linked),
|
|
276
|
-
fetchOneWithErrors: () => Promise.resolve({
|
|
277
|
-
value: linked
|
|
278
|
-
})
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
function createMissingLinkStub(linkName, objectApiName, primaryKey) {
|
|
282
|
-
const makeError = () => new Error(`Link "${linkName}" was not configured on mock ${objectApiName} object with primary key ${primaryKey}. Pass it via the \`links\` option on createMockOsdkObject, or pass an Error instance to simulate a link failure.`);
|
|
283
|
-
return {
|
|
284
|
-
fetchOne: () => Promise.reject(makeError()),
|
|
285
|
-
fetchOneWithErrors: () => Promise.resolve({
|
|
286
|
-
error: makeError()
|
|
287
|
-
}),
|
|
288
|
-
fetchPage: () => Promise.reject(makeError()),
|
|
289
|
-
asyncIter: () => {
|
|
290
|
-
throw makeError();
|
|
291
|
-
},
|
|
292
|
-
aggregate: () => {
|
|
293
|
-
throw makeError();
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
function createManyLinkStub(linkedObjects) {
|
|
298
|
-
return {
|
|
299
|
-
fetchOne: (primaryKey) => {
|
|
300
|
-
if (linkedObjects.length > 0 && linkedObjects[0].$primaryKey == null) {
|
|
301
|
-
process.env.NODE_ENV !== "production" ? invariant4__default.default(false, `fetchOne requires primaryKeyApiName to be set on linked objects`) : invariant4__default.default(false) ;
|
|
302
|
-
}
|
|
303
|
-
const found = linkedObjects.find((obj) => obj.$primaryKey === primaryKey);
|
|
304
|
-
!(found != null) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, `fetchOne could not find object with primary key ${String(primaryKey)}`) : invariant4__default.default(false) : void 0;
|
|
305
|
-
return Promise.resolve(found);
|
|
306
|
-
},
|
|
307
|
-
fetchPage: () => Promise.resolve({
|
|
308
|
-
data: linkedObjects,
|
|
309
|
-
nextPageToken: void 0
|
|
310
|
-
}),
|
|
311
|
-
asyncIter: () => {
|
|
312
|
-
let index = 0;
|
|
313
|
-
return {
|
|
314
|
-
[Symbol.asyncIterator]() {
|
|
315
|
-
return this;
|
|
316
|
-
},
|
|
317
|
-
// oxlint-disable-next-line require-await -- intentionally async: returns a Promise to satisfy its declared/contract type; no await needed
|
|
318
|
-
async next() {
|
|
319
|
-
if (index < linkedObjects.length) {
|
|
320
|
-
return {
|
|
321
|
-
value: linkedObjects[index++],
|
|
322
|
-
done: false
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
return {
|
|
326
|
-
value: void 0,
|
|
327
|
-
done: true
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
},
|
|
332
|
-
aggregate: () => {
|
|
333
|
-
process.env.NODE_ENV !== "production" ? invariant4__default.default(false, `aggregate is not supported on mock link stubs.`) : invariant4__default.default(false) ;
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
function createMockOsdkObject(objectType, properties, options = {}) {
|
|
338
|
-
const {
|
|
339
|
-
links,
|
|
340
|
-
titlePropertyApiName
|
|
341
|
-
} = options;
|
|
342
|
-
const primaryKeyApiName = objectType.primaryKeyApiName;
|
|
343
|
-
!(primaryKeyApiName != null) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, `Object type "${objectType.apiName}" does not have a primaryKeyApiName defined. Ensure you are using a generated object type constant that includes primaryKeyApiName.`) : invariant4__default.default(false) : void 0;
|
|
344
|
-
if (properties == null) {
|
|
345
|
-
properties = {};
|
|
346
|
-
}
|
|
347
|
-
!(primaryKeyApiName in properties) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, `Primary key property "${primaryKeyApiName}" must be provided in properties for ${objectType.apiName}. Include "${primaryKeyApiName}" in the properties argument.`) : invariant4__default.default(false) : void 0;
|
|
348
|
-
if (titlePropertyApiName != null) {
|
|
349
|
-
!(titlePropertyApiName in properties) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, `titlePropertyApiName "${titlePropertyApiName}" was specified but not found in properties for ${objectType.apiName}`) : invariant4__default.default(false) : void 0;
|
|
350
|
-
}
|
|
351
|
-
const $primaryKey = properties[primaryKeyApiName];
|
|
352
|
-
const $title = titlePropertyApiName != null ? properties[titlePropertyApiName] : void 0;
|
|
353
|
-
const $rid = options.$rid ?? `ri.mock.main.object.${objectType.apiName}.${String($primaryKey)}`;
|
|
354
|
-
const mockObject = {
|
|
355
|
-
$apiName: objectType.apiName,
|
|
356
|
-
$objectType: objectType.apiName,
|
|
357
|
-
...properties
|
|
358
|
-
};
|
|
359
|
-
Object.defineProperty(mockObject, "$primaryKey", {
|
|
360
|
-
get() {
|
|
361
|
-
return $primaryKey;
|
|
362
|
-
},
|
|
363
|
-
enumerable: true
|
|
364
|
-
});
|
|
365
|
-
Object.defineProperty(mockObject, "$title", {
|
|
366
|
-
get() {
|
|
367
|
-
return $title;
|
|
368
|
-
},
|
|
369
|
-
enumerable: true
|
|
370
|
-
});
|
|
371
|
-
Object.defineProperty(mockObject, "$rid", {
|
|
372
|
-
get() {
|
|
373
|
-
return $rid;
|
|
374
|
-
},
|
|
375
|
-
enumerable: true
|
|
376
|
-
});
|
|
377
|
-
Object.defineProperty(mockObject, "$objectSpecifier", {
|
|
378
|
-
get() {
|
|
379
|
-
return `${objectType.apiName}:${String($primaryKey)}`;
|
|
380
|
-
},
|
|
381
|
-
enumerable: true
|
|
382
|
-
});
|
|
383
|
-
Object.defineProperty(mockObject, "$link", {
|
|
384
|
-
get() {
|
|
385
|
-
const linkAccessors = {};
|
|
386
|
-
for (const [linkName, linkValue] of Object.entries(links ?? {})) {
|
|
387
|
-
if (linkValue == null) {
|
|
388
|
-
continue;
|
|
389
|
-
}
|
|
390
|
-
if (isMockObjectSet(linkValue)) {
|
|
391
|
-
linkAccessors[linkName] = linkValue;
|
|
392
|
-
} else if (Array.isArray(linkValue)) {
|
|
393
|
-
linkAccessors[linkName] = createManyLinkStub(linkValue);
|
|
394
|
-
} else {
|
|
395
|
-
linkAccessors[linkName] = createSingleLinkStub(linkValue);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
return new Proxy(linkAccessors, {
|
|
399
|
-
get(target, prop) {
|
|
400
|
-
if (typeof prop === "symbol" || prop in target) {
|
|
401
|
-
return target[prop];
|
|
402
|
-
}
|
|
403
|
-
return createMissingLinkStub(prop, objectType.apiName, String($primaryKey));
|
|
404
|
-
}
|
|
405
|
-
});
|
|
406
|
-
},
|
|
407
|
-
enumerable: true
|
|
408
|
-
});
|
|
409
|
-
Object.defineProperty(mockObject, "$as", {
|
|
410
|
-
value: function $as() {
|
|
411
|
-
process.env.NODE_ENV !== "production" ? invariant4__default.default(false, `$as is not supported on mock objects.`) : invariant4__default.default(false) ;
|
|
412
|
-
},
|
|
413
|
-
enumerable: false
|
|
414
|
-
});
|
|
415
|
-
Object.defineProperty(mockObject, "$clone", {
|
|
416
|
-
value: function $clone(updates) {
|
|
417
|
-
if (updates == null) {
|
|
418
|
-
return createMockOsdkObject(objectType, {
|
|
419
|
-
...properties
|
|
420
|
-
}, options);
|
|
421
|
-
}
|
|
422
|
-
if (primaryKeyApiName in updates) {
|
|
423
|
-
!(updates[primaryKeyApiName] === $primaryKey) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, `Cannot update ${objectType.apiName} object with differing primary key values`) : invariant4__default.default(false) : void 0;
|
|
424
|
-
}
|
|
425
|
-
const newProperties = {
|
|
426
|
-
...properties,
|
|
427
|
-
...updates
|
|
428
|
-
};
|
|
429
|
-
return createMockOsdkObject(objectType, newProperties, options);
|
|
430
|
-
},
|
|
431
|
-
enumerable: false
|
|
432
|
-
});
|
|
433
|
-
Object.defineProperty(mockObject, "$__EXPERIMENTAL__NOT_SUPPORTED_YET__metadata", {
|
|
434
|
-
get() {
|
|
435
|
-
process.env.NODE_ENV !== "production" ? invariant4__default.default(false, `$__EXPERIMENTAL__NOT_SUPPORTED_YET__metadata is not supported on mock objects.`) : invariant4__default.default(false) ;
|
|
436
|
-
},
|
|
437
|
-
enumerable: false
|
|
438
|
-
});
|
|
439
|
-
Object.defineProperty(mockObject, "$__EXPERIMENTAL__NOT_SUPPORTED_YET__getFormattedValue", {
|
|
440
|
-
value: function $__EXPERIMENTAL__NOT_SUPPORTED_YET__getFormattedValue() {
|
|
441
|
-
process.env.NODE_ENV !== "production" ? invariant4__default.default(false, `$__EXPERIMENTAL__NOT_SUPPORTED_YET__getFormattedValue is not supported on mock objects.`) : invariant4__default.default(false) ;
|
|
442
|
-
},
|
|
443
|
-
enumerable: false
|
|
444
|
-
});
|
|
445
|
-
return Object.freeze(mockObject);
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
exports.createMockAttachment = createMockAttachment;
|
|
449
|
-
exports.createMockClient = createMockClient;
|
|
450
|
-
exports.createMockObjectSet = createMockObjectSet;
|
|
451
|
-
exports.createMockOsdkObject = createMockOsdkObject;
|
|
452
|
-
//# sourceMappingURL=chunk-DABCNUHL.cjs.map
|
|
453
|
-
//# sourceMappingURL=chunk-DABCNUHL.cjs.map
|