@osdk/client 2.1.0-beta.2 → 2.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -0
- package/build/browser/Client.d.ts +8 -21
- package/build/browser/Client.d.ts.map +1 -1
- package/build/browser/Client.js +2 -1
- package/build/browser/Client.js.map +1 -1
- package/build/browser/MinimalClientContext.d.ts +1 -1
- package/build/browser/MinimalClientContext.d.ts.map +1 -1
- package/build/browser/__unstable/ConjureSupport.js +4 -4
- package/build/browser/__unstable/ConjureSupport.js.map +1 -1
- package/build/browser/__unstable/createBulkLinksAsyncIterFactory.d.ts +1 -6
- package/build/browser/__unstable/createBulkLinksAsyncIterFactory.d.ts.map +1 -1
- package/build/browser/__unstable/createBulkLinksAsyncIterFactory.js +1 -1
- package/build/browser/__unstable/createBulkLinksAsyncIterFactory.js.map +1 -1
- package/build/browser/actions/applyAction.js +1 -1
- package/build/browser/actions/applyAction.js.map +1 -1
- package/build/browser/createClient.d.ts +1 -1
- package/build/browser/createClient.d.ts.map +1 -1
- package/build/browser/createClient.js +41 -19
- package/build/browser/createClient.js.map +1 -1
- package/build/browser/createGeotimeSeriesProperty.d.ts +1 -1
- package/build/browser/createGeotimeSeriesProperty.d.ts.map +1 -1
- package/build/browser/createGeotimeSeriesProperty.js +4 -1
- package/build/browser/createGeotimeSeriesProperty.js.map +1 -1
- package/build/browser/createMinimalClient.js +3 -3
- package/build/browser/createMinimalClient.js.map +1 -1
- package/build/browser/createPlatformClient.d.ts +1 -1
- package/build/browser/createPlatformClient.d.ts.map +1 -1
- package/build/browser/index.d.ts +0 -1
- package/build/browser/index.d.ts.map +1 -1
- package/build/browser/index.js +0 -1
- package/build/browser/index.js.map +1 -1
- package/build/browser/intellisense.test.js +1 -1
- package/build/browser/intellisense.test.js.map +1 -1
- package/build/browser/internal/conversions/legacyToModernSingleAggregationResult.js +1 -1
- package/build/browser/internal/conversions/legacyToModernSingleAggregationResult.js.map +1 -1
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js +3 -3
- package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/browser/object/aggregate.js +1 -1
- package/build/browser/object/aggregate.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/InterfaceHolder.d.ts +1 -10
- package/build/browser/object/convertWireToOsdkObjects/InterfaceHolder.d.ts.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.d.ts +0 -7
- package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.d.ts.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.js +6 -0
- package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +7 -1
- package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.js +2 -2
- package/build/browser/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/browser/object/convertWireToOsdkObjects.test.js +10 -10
- package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/browser/object/fetchPage.js +1 -1
- package/build/browser/object/fetchPage.js.map +1 -1
- package/build/browser/objectSet/ObjectSet.test.js +43 -47
- package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js +62 -57
- package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +109 -21
- package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/browser/objectSet/createObjectSet.js +2 -5
- package/build/browser/objectSet/createObjectSet.js.map +1 -1
- package/build/browser/ontology/makeConjureContext.d.ts +1 -1
- package/build/browser/ontology/makeConjureContext.d.ts.map +1 -1
- package/build/browser/queries/applyQuery.js +1 -1
- package/build/browser/queries/applyQuery.js.map +1 -1
- package/build/browser/queries/queries.test.js +30 -2
- package/build/browser/queries/queries.test.js.map +1 -1
- package/build/browser/tsserver.js +1 -1
- package/build/browser/tsserver.js.map +1 -1
- package/build/browser/util/UserAgent.js +1 -1
- package/build/esm/Client.d.ts +8 -21
- package/build/esm/Client.d.ts.map +1 -1
- package/build/esm/Client.js +2 -1
- package/build/esm/Client.js.map +1 -1
- package/build/esm/MinimalClientContext.d.ts +1 -1
- package/build/esm/MinimalClientContext.d.ts.map +1 -1
- package/build/esm/__unstable/ConjureSupport.js +4 -4
- package/build/esm/__unstable/ConjureSupport.js.map +1 -1
- package/build/esm/__unstable/createBulkLinksAsyncIterFactory.d.ts +1 -6
- package/build/esm/__unstable/createBulkLinksAsyncIterFactory.d.ts.map +1 -1
- package/build/esm/__unstable/createBulkLinksAsyncIterFactory.js +1 -1
- package/build/esm/__unstable/createBulkLinksAsyncIterFactory.js.map +1 -1
- package/build/esm/actions/applyAction.js +1 -1
- package/build/esm/actions/applyAction.js.map +1 -1
- package/build/esm/createClient.d.ts +1 -1
- package/build/esm/createClient.d.ts.map +1 -1
- package/build/esm/createClient.js +41 -19
- package/build/esm/createClient.js.map +1 -1
- package/build/esm/createGeotimeSeriesProperty.d.ts +1 -1
- package/build/esm/createGeotimeSeriesProperty.d.ts.map +1 -1
- package/build/esm/createGeotimeSeriesProperty.js +4 -1
- package/build/esm/createGeotimeSeriesProperty.js.map +1 -1
- package/build/esm/createMinimalClient.js +3 -3
- package/build/esm/createMinimalClient.js.map +1 -1
- package/build/esm/createPlatformClient.d.ts +1 -1
- package/build/esm/createPlatformClient.d.ts.map +1 -1
- package/build/esm/index.d.ts +0 -1
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +0 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/intellisense.test.js +1 -1
- package/build/esm/intellisense.test.js.map +1 -1
- package/build/esm/internal/conversions/legacyToModernSingleAggregationResult.js +1 -1
- package/build/esm/internal/conversions/legacyToModernSingleAggregationResult.js.map +1 -1
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js +3 -3
- package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
- package/build/esm/object/aggregate.js +1 -1
- package/build/esm/object/aggregate.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/InterfaceHolder.d.ts +1 -10
- package/build/esm/object/convertWireToOsdkObjects/InterfaceHolder.d.ts.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.d.ts +0 -7
- package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.d.ts.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.js +6 -0
- package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +7 -1
- package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.js +2 -2
- package/build/esm/object/convertWireToOsdkObjects.js.map +1 -1
- package/build/esm/object/convertWireToOsdkObjects.test.js +10 -10
- package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
- package/build/esm/object/fetchPage.js +1 -1
- package/build/esm/object/fetchPage.js.map +1 -1
- package/build/esm/objectSet/ObjectSet.test.js +43 -47
- package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js +62 -57
- package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +109 -21
- package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
- package/build/esm/objectSet/createObjectSet.js +2 -5
- package/build/esm/objectSet/createObjectSet.js.map +1 -1
- package/build/esm/ontology/makeConjureContext.d.ts +1 -1
- package/build/esm/ontology/makeConjureContext.d.ts.map +1 -1
- package/build/esm/queries/applyQuery.js +1 -1
- package/build/esm/queries/applyQuery.js.map +1 -1
- package/build/esm/queries/queries.test.js +30 -2
- package/build/esm/queries/queries.test.js.map +1 -1
- package/build/esm/tsserver.js +1 -1
- package/build/esm/tsserver.js.map +1 -1
- package/build/esm/util/UserAgent.js +1 -1
- package/package.json +14 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectSet.test.js","names":["isOk","$ontologyRid","Employee","FooInterface","Office","apiServer","stubData","afterAll","beforeAll","describe","expect","expectTypeOf","it","createClient","client","listen","close","employeeObjectSet","officeObjectSet","union","subtract","intersect","objectSet","unionedObjectSet","iter","data","employees","fetchPage","emp","employeeId","toEqual","objectSet2","where","subtractedObjectSet","intersectedObjectSet","$orderBy","toMatchObject","$apiName","$objectType","$primaryKey","class","employeeStatus","anything","fullName","office","startDate","employeeLocation","$title","employee","fetchOne","employee1","toMatchTypeOf","toBe","employeeResult","fetchOneWithErrors","value","$select","branded","toEqualTypeOf","rejects","toThrow","employee2","pivotTo","result","fetchPageWithErrors","each","k","opts","$__EXPERIMENTAL_strictNonNull","$includeRid","toHaveLength","includeRid","toThrowErrorMatchingInlineSnapshot","not","toBeUndefined","empNotStrict","cheesedFooNotStrict","$as","fooSpt"],"sources":["ObjectSet.test.js"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport { isOk } from \"@osdk/api\";\nimport { $ontologyRid, Employee, FooInterface, Office, } from \"@osdk/client.test.ontology\";\nimport { apiServer, stubData } from \"@osdk/shared.test\";\nimport { afterAll, beforeAll, describe, expect, expectTypeOf, it, } from \"vitest\";\nimport { createClient } from \"../createClient.js\";\ndescribe(\"ObjectSet\", () => {\n let client;\n beforeAll(async () => {\n apiServer.listen();\n client = createClient(\"https://stack.palantir.com\", $ontologyRid, async () => \"myAccessToken\");\n });\n afterAll(() => {\n apiServer.close();\n });\n it(\"does not allow intersect/union/subtract with different object types\", () => {\n const employeeObjectSet = client(Employee);\n const officeObjectSet = client(Office);\n // @ts-expect-error\n employeeObjectSet.union(officeObjectSet);\n // @ts-expect-error\n employeeObjectSet.subtract(officeObjectSet);\n // @ts-expect-error\n employeeObjectSet.intersect(officeObjectSet);\n });\n it(\"can be cast bidirectionally\", () => {\n function takesOldStyleObjectSet(os) {\n return os;\n }\n function takesNewStyleObjectSet(os) {\n return os;\n }\n function maybe() {\n const newStyleObjectSet = client(Employee);\n const oldStyleObjectSet = newStyleObjectSet;\n takesOldStyleObjectSet(newStyleObjectSet);\n takesNewStyleObjectSet(newStyleObjectSet);\n takesOldStyleObjectSet(oldStyleObjectSet);\n takesNewStyleObjectSet(oldStyleObjectSet);\n }\n if (false) {\n // here for a simple type check\n maybe();\n }\n });\n it(\"objects set union\", async () => {\n const objectSet = client(Employee);\n const unionedObjectSet = objectSet.union(objectSet);\n let iter = 0;\n const { data: employees } = await unionedObjectSet.fetchPage();\n for (const emp of employees) {\n expect(emp.employeeId).toEqual(50030 + iter);\n iter += 1;\n }\n expect(iter).toEqual(2);\n });\n it(\"objects set subtract\", async () => {\n const objectSet = client(Employee);\n const objectSet2 = client(Employee).where({\n employeeId: 50030,\n });\n const subtractedObjectSet = objectSet.subtract(objectSet2);\n let iter = 0;\n const { data: employees } = await subtractedObjectSet.fetchPage();\n for (const emp of employees) {\n expect(emp.employeeId).toEqual(50031 + iter);\n iter += 1;\n }\n expect(iter).toEqual(2);\n });\n it(\"objects set intersect\", async () => {\n const objectSet = client(Employee);\n const intersectedObjectSet = objectSet.intersect(objectSet);\n let iter = 0;\n const { data: employees } = await intersectedObjectSet.fetchPage();\n for (const emp of employees) {\n expect(emp.employeeId).toEqual(50032);\n iter += 1;\n }\n expect(iter).toEqual(1);\n });\n it(\"orders objects in ascending order without a filter, and returns all results\", async () => {\n const { data: employees } = await client(Employee)\n .fetchPage({\n $orderBy: { \"employeeId\": \"asc\" },\n });\n expect(employees).toMatchObject([\n {\n $apiName: \"Employee\",\n $objectType: \"Employee\",\n $primaryKey: 50030,\n class: \"Red\",\n employeeId: 50030,\n employeeStatus: expect.anything(),\n fullName: \"John Doe\",\n office: \"NYC\",\n startDate: \"2019-01-01\",\n employeeLocation: expect.anything(),\n },\n {\n $apiName: \"Employee\",\n $objectType: \"Employee\",\n $primaryKey: 50031,\n $title: \"Jane Doe\",\n class: \"Blue\",\n employeeId: 50031,\n employeeStatus: expect.anything(),\n fullName: \"Jane Doe\",\n office: \"SEA\",\n startDate: \"2012-02-12\",\n employeeLocation: expect.anything(),\n },\n {\n $apiName: \"Employee\",\n $objectType: \"Employee\",\n $primaryKey: 50032,\n $title: \"Jack Smith\",\n class: \"Red\",\n employeeId: 50032,\n employeeStatus: expect.anything(),\n fullName: \"Jack Smith\",\n office: \"LON\",\n startDate: \"2015-05-15\",\n employeeLocation: expect.anything(),\n },\n ]);\n });\n it(\"allows fetching by PK from a base object set - fetchOne\", async () => {\n const employee = await client(Employee).fetchOne(stubData.employee1.employeeId);\n expectTypeOf().toMatchTypeOf;\n expect(employee.$primaryKey).toBe(stubData.employee1.employeeId);\n });\n it(\"allows fetching by PK from a base object set - fetchOneWithErrors\", async () => {\n const employeeResult = await client(Employee)\n .fetchOneWithErrors(stubData.employee1.employeeId);\n expectTypeOf().toMatchTypeOf;\n if (isOk(employeeResult)) {\n const employee = employeeResult.value;\n expect(employee.$primaryKey).toBe(stubData.employee1.employeeId);\n }\n });\n it(\"allows fetching by PK from a base object set with selected properties - fetchOne\", async () => {\n const employee = await client(Employee).fetchOne(stubData.employee1.employeeId, { $select: [\"fullName\"] });\n expectTypeOf().branded.toEqualTypeOf;\n expect(employee.$primaryKey).toBe(stubData.employee1.employeeId);\n });\n it(\"allows fetching by PK from a base object set with selected properties - fetchOneWithErrors\", async () => {\n const employeeResult = await client(Employee)\n .fetchOneWithErrors(stubData.employee1.employeeId, { $select: [\"fullName\"] });\n expectTypeOf().branded.toEqualTypeOf;\n if (isOk(employeeResult)) {\n const employee = employeeResult.value;\n expect(employee.$primaryKey).toBe(stubData.employee1.employeeId);\n }\n });\n it(\"throws when fetching by PK with an object that does not exist - fetchOne\", async () => {\n await expect(client(Employee).fetchOne(-1)).rejects\n .toThrow();\n });\n it(\"throws when fetching by PK with an object that does not exist - fetchOneWithErrors\", async () => {\n const employeeResult = await client(Employee)\n .fetchOneWithErrors(-1);\n expectTypeOf().branded.toEqualTypeOf;\n expect(\"error\" in employeeResult);\n });\n it(\"allows fetching by PK from a pivoted object set - fetchOne\", async () => {\n const employee = await client(Employee).where({\n employeeId: stubData.employee2.employeeId,\n })\n .pivotTo(\"peeps\").fetchOne(stubData.employee1.employeeId);\n expect(employee.$primaryKey).toBe(stubData.employee1.employeeId);\n });\n it(\"allows fetching by PK from a pivoted object set - fetchOneWithErrors\", async () => {\n const employeeResult = await client(Employee).where({\n employeeId: stubData.employee2.employeeId,\n })\n .pivotTo(\"peeps\").fetchOneWithErrors(stubData.employee1.employeeId);\n if (isOk(employeeResult)) {\n const employee = employeeResult.value;\n expect(employee.$primaryKey).toBe(stubData.employee1.employeeId);\n }\n });\n it(\" object set union works with fetchPageWithErrors\", async () => {\n const objectSet = client(Employee);\n const unionedObjectSet = objectSet.union(objectSet);\n let iter = 0;\n const result = await unionedObjectSet.fetchPageWithErrors();\n if (isOk(result)) {\n const employees = result.value.data;\n for (const emp of employees) {\n expect(emp.employeeId).toEqual(50030 + iter);\n iter += 1;\n }\n expect(iter).toEqual(2);\n }\n });\n describe.each([\"fetchPage\", \"fetchPageWithErrors\"])(\"%s\", (k) => {\n describe(\"strictNonNull: \\\"drop\\\"\", () => {\n describe(\"includeRid: true\", () => {\n it(\"drops bad data\", async () => {\n const opts = {\n $__EXPERIMENTAL_strictNonNull: \"drop\",\n $includeRid: true,\n };\n const result = k === \"fetchPage\"\n ? await client(Employee).fetchPage(opts)\n : (await client(Employee).fetchPageWithErrors(opts)).value;\n expect(result.data).toHaveLength(3);\n expectTypeOf(result.data[0]).branded.toEqualTypeOf();\n expectTypeOf(result.data[0]).branded.toEqualTypeOf();\n });\n });\n describe(\"includeRid: false\", () => {\n it(\"drops bad data\", async () => {\n const opts = {\n $__EXPERIMENTAL_strictNonNull: \"drop\",\n $includeRid: false,\n };\n const result = k === \"fetchPage\"\n ? await client(Employee).fetchPage(opts)\n : (await client(Employee).fetchPageWithErrors(opts)).value;\n expect(result.data).toHaveLength(3);\n expectTypeOf(result.data[0]).branded.toEqualTypeOf();\n expectTypeOf(result.data[0]).branded.toEqualTypeOf();\n expectTypeOf(result.data[0]).branded.toEqualTypeOf();\n });\n });\n });\n describe(\"strictNonNull: false\", () => {\n describe(\"includeRid: true\", () => {\n it(\"returns bad data\", async () => {\n const opts = {\n $__EXPERIMENTAL_strictNonNull: false,\n $includeRid: true,\n };\n const result = k === \"fetchPage\"\n ? await client(Employee).fetchPage(opts)\n : (await client(Employee).fetchPageWithErrors(opts)).value;\n expect(result.data).toHaveLength(4);\n expectTypeOf(result.data[0]).branded.toEqualTypeOf();\n });\n });\n describe(\"includeRid: false\", () => {\n it(\"returns bad data\", async () => {\n const opts = {\n $__EXPERIMENTAL_strictNonNull: false,\n includeRid: false,\n };\n const result = k === \"fetchPage\"\n ? await client(Employee).fetchPage(opts)\n : (await client(Employee).fetchPageWithErrors(opts)).value;\n expect(result.data).toHaveLength(4);\n expectTypeOf(result.data[0]).branded.toEqualTypeOf();\n });\n });\n });\n });\n describe(\"strictNonNull: \\\"throw\\\"\", () => {\n it(\"throws when getting bad data\", () => {\n expect(() => client(Employee).fetchPage({\n $__EXPERIMENTAL_strictNonNull: \"throw\",\n })).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: Unable to safely convert objects as some non nullable properties are null]`);\n });\n });\n describe.each([\"fetchOne\", \"fetchOneWithErrors\"])(\"%s\", (k) => {\n describe(\"strictNonNull: false\", () => {\n describe(\"includeRid: true\", () => {\n it(\"returns bad data\", async () => {\n const opts = {\n $__EXPERIMENTAL_strictNonNull: false,\n $includeRid: true,\n };\n const result = k === \"fetchOne\"\n ? await client(Employee).fetchOne(50033, opts)\n : (await client(Employee).fetchOneWithErrors(50033, opts)).value;\n expect(result).not.toBeUndefined();\n expectTypeOf(result).branded.toEqualTypeOf();\n });\n });\n describe(\"includeRid: false\", () => {\n it(\"returns bad data\", async () => {\n const opts = {\n $__EXPERIMENTAL_strictNonNull: false,\n includeRid: false,\n };\n const result = k === \"fetchOne\"\n ? await client(Employee).fetchOne(50033, opts)\n : (await client(Employee).fetchOneWithErrors(50033, opts)).value;\n expect(result).not.toBeUndefined();\n expectTypeOf(result).branded.toEqualTypeOf();\n });\n });\n });\n });\n describe(\"strictNonNull: \\\"throw\\\"\", () => {\n it(\"throws when getting bad data\", () => {\n expect(() => client(Employee).fetchPage({\n $__EXPERIMENTAL_strictNonNull: \"throw\",\n })).rejects.toThrowErrorMatchingInlineSnapshot(`[Error: Unable to safely convert objects as some non nullable properties are null]`);\n });\n });\n describe(\"conversions\", () => {\n describe(\"strictNonNull: false\", () => {\n it(\"returns bad data\", async () => {\n const result = await client(Employee).fetchPage({\n $__EXPERIMENTAL_strictNonNull: false,\n });\n const empNotStrict = result.data[0];\n const empNotStrict2 = empNotStrict;\n expectTypeOf(empNotStrict).branded.toEqualTypeOf();\n expectTypeOf(empNotStrict).branded.toEqualTypeOf();\n expectTypeOf(empNotStrict).branded.toEqualTypeOf();\n expectTypeOf(empNotStrict.employeeId).toEqualTypeOf();\n expectTypeOf(empNotStrict2.employeeId).toEqualTypeOf();\n expectTypeOf()\n .toEqualTypeOf();\n expectTypeOf()\n .toEqualTypeOf();\n expectTypeOf()\n .toEqualTypeOf();\n expectTypeOf()\n .toEqualTypeOf();\n expectTypeOf()\n .toEqualTypeOf();\n expectTypeOf()\n .toEqualTypeOf();\n expectTypeOf()\n .toEqualTypeOf();\n expectTypeOf()\n .toEqualTypeOf();\n const CheesedFoo = FooInterface;\n const cheesedFooNotStrict = result.data[0].$as(CheesedFoo);\n expectTypeOf(cheesedFooNotStrict).branded.toEqualTypeOf();\n cheesedFooNotStrict.fooSpt;\n });\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,IAAI,QAAQ,WAAW;AAChC,SAASC,YAAY,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,MAAM,QAAS,4BAA4B;AAC1F,SAASC,SAAS,EAAEC,QAAQ,QAAQ,mBAAmB;AACvD,SAASC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,YAAY,EAAEC,EAAE,QAAS,QAAQ;AACjF,SAASC,YAAY,QAAQ,oBAAoB;AACjDJ,QAAQ,CAAC,WAAW,EAAE,MAAM;EACxB,IAAIK,MAAM;EACVN,SAAS,CAAC,YAAY;IAClBH,SAAS,CAACU,MAAM,CAAC,CAAC;IAClBD,MAAM,GAAGD,YAAY,CAAC,4BAA4B,EAAEZ,YAAY,EAAE,YAAY,eAAe,CAAC;EAClG,CAAC,CAAC;EACFM,QAAQ,CAAC,MAAM;IACXF,SAAS,CAACW,KAAK,CAAC,CAAC;EACrB,CAAC,CAAC;EACFJ,EAAE,CAAC,qEAAqE,EAAE,MAAM;IAC5E,MAAMK,iBAAiB,GAAGH,MAAM,CAACZ,QAAQ,CAAC;IAC1C,MAAMgB,eAAe,GAAGJ,MAAM,CAACV,MAAM,CAAC;IACtC;IACAa,iBAAiB,CAACE,KAAK,CAACD,eAAe,CAAC;IACxC;IACAD,iBAAiB,CAACG,QAAQ,CAACF,eAAe,CAAC;IAC3C;IACAD,iBAAiB,CAACI,SAAS,CAACH,eAAe,CAAC;EAChD,CAAC,CAAC;EACFN,EAAE,CAAC,6BAA6B,EAAE,MAAM,CAmBxC,CAAC,CAAC;EACFA,EAAE,CAAC,mBAA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aAAa,CAAC,CAAC;QACpB/C,YAAY,CAAC,CAAC,CACT+C,aAAa,CAAC,CAAC;QACpB/C,YAAY,CAAC,CAAC,CACT+C,aAAa,CAAC,CAAC;QACpB/C,YAAY,CAAC,CAAC,CACT+C,aAAa,CAAC,CAAC;QACpB/C,YAAY,CAAC,CAAC,CACT+C,aAAa,CAAC,CAAC;QAEpB,MAAMkB,mBAAmB,GAAGb,MAAM,CAACtC,IAAI,CAAC,CAAC,CAAC,CAACoD,GAAG,CAD3B1E,YACsC,CAAC;QAC1DQ,YAAY,CAACiE,mBAAmB,CAAC,CAACnB,OAAO,CAACC,aAAa,CAAC,CAAC;QACzDkB,mBAAmB,CAACE,MAAM;MAC9B,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ObjectSet.test.js","names":["isOk","$ontologyRid","Employee","FooInterface","Office","apiServer","stubData","afterAll","beforeAll","describe","expect","expectTypeOf","it","createClient","client","listen","close","employeeObjectSet","officeObjectSet","union","subtract","intersect","objectSet","unionedObjectSet","iter","data","employees","fetchPage","emp","employeeId","toEqual","objectSet2","where","subtractedObjectSet","intersectedObjectSet","$orderBy","toMatchObject","$apiName","$objectType","$primaryKey","class","employeeStatus","anything","fullName","office","startDate","employeeLocation","$title","employee","fetchOne","employee1","toMatchTypeOf","toBe","employeeResult","fetchOneWithErrors","value","$select","branded","toEqualTypeOf","rejects","toThrow","employee2","pivotTo","result","fetchPageWithErrors","each","k","opts","$__EXPERIMENTAL_strictNonNull","$includeRid","toHaveLength","not","toBeUndefined","empNotStrict","cheesedFooNotStrict","$as","fooSpt"],"sources":["ObjectSet.test.js"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport { isOk } from \"@osdk/api\";\nimport { $ontologyRid, Employee, FooInterface, Office, } from \"@osdk/client.test.ontology\";\nimport { apiServer, stubData } from \"@osdk/shared.test\";\nimport { afterAll, beforeAll, describe, expect, expectTypeOf, it, } from \"vitest\";\nimport { createClient } from \"../createClient.js\";\ndescribe(\"ObjectSet\", () => {\n let client;\n beforeAll(async () => {\n apiServer.listen();\n client = createClient(\"https://stack.palantir.com\", $ontologyRid, async () => \"myAccessToken\");\n });\n afterAll(() => {\n apiServer.close();\n });\n it(\"does not allow intersect/union/subtract with different object types\", () => {\n const employeeObjectSet = client(Employee);\n const officeObjectSet = client(Office);\n // @ts-expect-error\n employeeObjectSet.union(officeObjectSet);\n // @ts-expect-error\n employeeObjectSet.subtract(officeObjectSet);\n // @ts-expect-error\n employeeObjectSet.intersect(officeObjectSet);\n });\n it(\"can be cast bidirectionally\", () => {\n function takesOldStyleObjectSet(os) {\n return os;\n }\n function takesNewStyleObjectSet(os) {\n return os;\n }\n function maybe() {\n const newStyleObjectSet = client(Employee);\n const oldStyleObjectSet = newStyleObjectSet;\n takesOldStyleObjectSet(newStyleObjectSet);\n takesNewStyleObjectSet(newStyleObjectSet);\n takesOldStyleObjectSet(oldStyleObjectSet);\n takesNewStyleObjectSet(oldStyleObjectSet);\n }\n if (false) {\n // here for a simple type check\n maybe();\n }\n });\n it(\"objects set union\", async () => {\n const objectSet = client(Employee);\n const unionedObjectSet = objectSet.union(objectSet);\n let iter = 0;\n const { data: employees } = await unionedObjectSet.fetchPage();\n for (const emp of employees) {\n expect(emp.employeeId).toEqual(50030 + iter);\n iter += 1;\n }\n expect(iter).toEqual(2);\n });\n it(\"objects set subtract\", async () => {\n const objectSet = client(Employee);\n const objectSet2 = client(Employee).where({\n employeeId: 50030,\n });\n const subtractedObjectSet = objectSet.subtract(objectSet2);\n let iter = 0;\n const { data: employees } = await subtractedObjectSet.fetchPage();\n for (const emp of employees) {\n expect(emp.employeeId).toEqual(50031 + iter);\n iter += 1;\n }\n expect(iter).toEqual(2);\n });\n it(\"objects set intersect\", async () => {\n const objectSet = client(Employee);\n const intersectedObjectSet = objectSet.intersect(objectSet);\n let iter = 0;\n const { data: employees } = await intersectedObjectSet.fetchPage();\n for (const emp of employees) {\n expect(emp.employeeId).toEqual(50032);\n iter += 1;\n }\n expect(iter).toEqual(1);\n });\n it(\"orders objects in ascending order without a filter, and returns all results\", async () => {\n const { data: employees } = await client(Employee)\n .fetchPage({\n $orderBy: { \"employeeId\": \"asc\" },\n });\n expect(employees).toMatchObject([\n {\n $apiName: \"Employee\",\n $objectType: \"Employee\",\n $primaryKey: 50030,\n class: \"Red\",\n employeeId: 50030,\n employeeStatus: expect.anything(),\n fullName: \"John Doe\",\n office: \"NYC\",\n startDate: \"2019-01-01\",\n employeeLocation: expect.anything(),\n },\n {\n $apiName: \"Employee\",\n $objectType: \"Employee\",\n $primaryKey: 50031,\n $title: \"Jane Doe\",\n class: \"Blue\",\n employeeId: 50031,\n employeeStatus: expect.anything(),\n fullName: \"Jane Doe\",\n office: \"SEA\",\n startDate: \"2012-02-12\",\n employeeLocation: expect.anything(),\n },\n {\n $apiName: \"Employee\",\n $objectType: \"Employee\",\n $primaryKey: 50032,\n $title: \"Jack Smith\",\n class: \"Red\",\n employeeId: 50032,\n employeeStatus: expect.anything(),\n fullName: \"Jack Smith\",\n office: \"LON\",\n startDate: \"2015-05-15\",\n employeeLocation: expect.anything(),\n },\n ]);\n });\n it(\"allows fetching by PK from a base object set - fetchOne\", async () => {\n const employee = await client(Employee).fetchOne(stubData.employee1.employeeId);\n expectTypeOf().toMatchTypeOf;\n expect(employee.$primaryKey).toBe(stubData.employee1.employeeId);\n });\n it(\"allows fetching by PK from a base object set - fetchOneWithErrors\", async () => {\n const employeeResult = await client(Employee)\n .fetchOneWithErrors(stubData.employee1.employeeId);\n expectTypeOf().toMatchTypeOf;\n if (isOk(employeeResult)) {\n const employee = employeeResult.value;\n expect(employee.$primaryKey).toBe(stubData.employee1.employeeId);\n }\n });\n it(\"allows fetching by PK from a base object set with selected properties - fetchOne\", async () => {\n const employee = await client(Employee).fetchOne(stubData.employee1.employeeId, { $select: [\"fullName\"] });\n expectTypeOf().branded.toEqualTypeOf;\n expect(employee.$primaryKey).toBe(stubData.employee1.employeeId);\n });\n it(\"allows fetching by PK from a base object set with selected properties - fetchOneWithErrors\", async () => {\n const employeeResult = await client(Employee)\n .fetchOneWithErrors(stubData.employee1.employeeId, { $select: [\"fullName\"] });\n expectTypeOf().branded.toEqualTypeOf;\n if (isOk(employeeResult)) {\n const employee = employeeResult.value;\n expect(employee.$primaryKey).toBe(stubData.employee1.employeeId);\n }\n });\n it(\"throws when fetching by PK with an object that does not exist - fetchOne\", async () => {\n await expect(client(Employee).fetchOne(-1)).rejects\n .toThrow();\n });\n it(\"throws when fetching by PK with an object that does not exist - fetchOneWithErrors\", async () => {\n const employeeResult = await client(Employee)\n .fetchOneWithErrors(-1);\n expectTypeOf().branded.toEqualTypeOf;\n expect(\"error\" in employeeResult);\n });\n it(\"allows fetching by PK from a pivoted object set - fetchOne\", async () => {\n const employee = await client(Employee).where({\n employeeId: stubData.employee2.employeeId,\n })\n .pivotTo(\"peeps\").fetchOne(stubData.employee1.employeeId);\n expect(employee.$primaryKey).toBe(stubData.employee1.employeeId);\n });\n it(\"allows fetching by PK from a pivoted object set - fetchOneWithErrors\", async () => {\n const employeeResult = await client(Employee).where({\n employeeId: stubData.employee2.employeeId,\n })\n .pivotTo(\"peeps\").fetchOneWithErrors(stubData.employee1.employeeId);\n if (isOk(employeeResult)) {\n const employee = employeeResult.value;\n expect(employee.$primaryKey).toBe(stubData.employee1.employeeId);\n }\n });\n it(\" object set union works with fetchPageWithErrors\", async () => {\n const objectSet = client(Employee);\n const unionedObjectSet = objectSet.union(objectSet);\n let iter = 0;\n const result = await unionedObjectSet.fetchPageWithErrors();\n if (isOk(result)) {\n const employees = result.value.data;\n for (const emp of employees) {\n expect(emp.employeeId).toEqual(50030 + iter);\n iter += 1;\n }\n expect(iter).toEqual(2);\n }\n });\n describe.each([\"fetchPage\", \"fetchPageWithErrors\"])(\"%s\", (k) => {\n // describe(\"strictNonNull: \\\"drop\\\"\", () => {\n // describe(\"includeRid: true\", () => {\n // it(\"drops bad data\", async () => {\n // const opts = {\n // $__EXPERIMENTAL_strictNonNull: \"drop\",\n // $includeRid: true,\n // } as const;\n // const result = k === \"fetchPage\"\n // ? await client(Employee).fetchPage(opts)\n // : (await client(Employee).fetchPageWithErrors(opts)).value!;\n // expect(result.data).toHaveLength(3);\n // expectTypeOf(result.data[0]).branded.toEqualTypeOf<\n // Osdk<Employee, \"$rid\" | \"$all\">\n // >();\n // expectTypeOf(result.data[0]).branded.toEqualTypeOf<\n // Employee.OsdkObject<\"$rid\">\n // >();\n // });\n // });\n // describe(\"includeRid: false\", () => {\n // it(\"drops bad data\", async () => {\n // const opts = {\n // $__EXPERIMENTAL_strictNonNull: \"drop\",\n // $includeRid: false,\n // } as const;\n // const result = k === \"fetchPage\"\n // ? await client(Employee).fetchPage(opts)\n // : (await client(Employee).fetchPageWithErrors(opts)).value!;\n // expect(result.data).toHaveLength(3);\n // expectTypeOf(result.data[0]).branded.toEqualTypeOf<Osdk<Employee>>();\n // expectTypeOf(result.data[0]).branded.toEqualTypeOf<\n // Employee.OsdkObject\n // >();\n // expectTypeOf(result.data[0]).branded.toEqualTypeOf<\n // Employee.OsdkObject<never>\n // >();\n // });\n // });\n // });\n describe(\"strictNonNull: false\", () => {\n describe(\"includeRid: true\", () => {\n it(\"returns bad data\", async () => {\n const opts = {\n $__EXPERIMENTAL_strictNonNull: false,\n $includeRid: true,\n };\n const result = k === \"fetchPage\"\n ? await client(Employee).fetchPage(opts)\n : (await client(Employee).fetchPageWithErrors(opts)).value;\n expect(result.data).toHaveLength(4);\n expectTypeOf(result.data[0]).branded.toEqualTypeOf();\n });\n });\n describe(\"includeRid: false\", () => {\n it(\"returns bad data\", async () => {\n const opts = {\n $includeRid: false,\n };\n const result = k === \"fetchPage\"\n ? await client(Employee).fetchPage(opts)\n : (await client(Employee).fetchPageWithErrors(opts)).value;\n expect(result.data).toHaveLength(4);\n expectTypeOf(result.data[0]).branded.toEqualTypeOf();\n });\n });\n });\n });\n describe.each([\"fetchOne\", \"fetchOneWithErrors\"])(\"%s\", (k) => {\n describe(\"strictNonNull: false\", () => {\n describe(\"includeRid: true\", () => {\n it(\"returns bad data\", async () => {\n // Look at this\n const opts = {\n $__EXPERIMENTAL_strictNonNull: false,\n $includeRid: true,\n };\n const result = k === \"fetchOne\"\n ? await client(Employee).fetchOne(50033, opts)\n : (await client(Employee).fetchOneWithErrors(50033, opts)).value;\n expect(result).not.toBeUndefined();\n expectTypeOf(result).branded.toEqualTypeOf();\n });\n });\n describe(\"includeRid: false\", () => {\n it(\"returns bad data\", async () => {\n const opts = {\n $__EXPERIMENTAL_strictNonNull: false,\n $includeRid: false,\n };\n const result = k === \"fetchOne\"\n ? await client(Employee).fetchOne(50033, opts)\n : (await client(Employee).fetchOneWithErrors(50033, opts)).value;\n expect(result).not.toBeUndefined();\n expectTypeOf(result).branded.toEqualTypeOf();\n });\n });\n });\n });\n describe(\"conversions\", () => {\n describe(\"strictNonNull: false\", () => {\n it(\"returns bad data\", async () => {\n const result = await client(Employee).fetchPage({});\n const empNotStrict = result.data[0];\n const empNotStrict2 = empNotStrict;\n expectTypeOf(empNotStrict).branded.toEqualTypeOf();\n expectTypeOf(empNotStrict).branded.toEqualTypeOf();\n expectTypeOf(empNotStrict).branded.toEqualTypeOf();\n expectTypeOf(empNotStrict.employeeId).toEqualTypeOf();\n expectTypeOf(empNotStrict2.employeeId).toEqualTypeOf();\n expectTypeOf()\n .toEqualTypeOf();\n expectTypeOf()\n .toEqualTypeOf();\n expectTypeOf()\n .toEqualTypeOf();\n expectTypeOf()\n .toEqualTypeOf();\n expectTypeOf()\n .toEqualTypeOf();\n expectTypeOf()\n .toEqualTypeOf();\n expectTypeOf()\n .toEqualTypeOf();\n expectTypeOf()\n .toEqualTypeOf();\n const CheesedFoo = FooInterface;\n const cheesedFooNotStrict = result.data[0].$as(CheesedFoo);\n expectTypeOf(cheesedFooNotStrict).branded.toEqualTypeOf();\n cheesedFooNotStrict.fooSpt;\n });\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,IAAI,QAAQ,WAAW;AAChC,SAASC,YAAY,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,MAAM,QAAS,4BAA4B;AAC1F,SAASC,SAAS,EAAEC,QAAQ,QAAQ,mBAAmB;AACvD,SAASC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,YAAY,EAAEC,EAAE,QAAS,QAAQ;AACjF,SAASC,YAAY,QAAQ,oBAAoB;AACjDJ,QAAQ,CAAC,WAAW,EAAE,MAAM;EACxB,IAAIK,MAAM;EACVN,SAAS,CAAC,YAAY;IAClBH,SAAS,CAACU,MAAM,CAAC,CAAC;IAClBD,MAAM,GAAGD,YAAY,CAAC,4BAA4B,EAAEZ,YAAY,EAAE,YAAY,eAAe,CAAC;EAClG,CAAC,CAAC;EACFM,QAAQ,CAAC,MAAM;IACXF,SAAS,CAACW,KAAK,CAAC,CAAC;EACrB,CAAC,CAAC;EACFJ,EAAE,CAAC,qEAAqE,EAAE,MAAM;IAC5E,MAAMK,iBAAiB,GAAGH,MAAM,CAACZ,QAAQ,CAAC;IAC1C,MAAMgB,eAAe,GAAGJ,MAAM,CAACV,MAAM,CAAC;IACtC;IACAa,iBAAiB,CAACE,KAAK,CAACD,eAAe,CAAC;IACxC;IACAD,iBAAiB,CAACG,QAAQ,CAACF,eAAe,CAAC;IAC3C;IACAD,iBAAiB,CAACI,SAAS,CAACH,eAAe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V,MAAM,CAACtC,IAAI,CAAC,CAAC,CAAC;QAEnCd,YAAY,CAAC8D,YAAY,CAAC,CAAChB,OAAO,CAACC,aAAa,CAAC,CAAC;QAClD/C,YAAY,CAAC8D,YAAY,CAAC,CAAChB,OAAO,CAACC,aAAa,CAAC,CAAC;QAClD/C,YAAY,CAAC8D,YAAY,CAAC,CAAChB,OAAO,CAACC,aAAa,CAAC,CAAC;QAClD/C,YAAY,CAAC8D,YAAY,CAAC5C,UAAU,CAAC,CAAC6B,aAAa,CAAC,CAAC;QACrD/C,YAAY,CALU8D,YAAY,CAKP5C,UAAU,CAAC,CAAC6B,aAAa,CAAC,CAAC;QACtD/C,YAAY,CAAC,CAAC,CACT+C,aAAa,CAAC,CAAC;QACpB/C,YAAY,CAAC,CAAC,CACT+C,aAAa,CAAC,CAAC;QACpB/C,YAAY,CAAC,CAAC,CACT+C,aAAa,CAAC,CAAC;QACpB/C,YAAY,CAAC,CAAC,CACT+C,aAAa,CAAC,CAAC;QACpB/C,YAAY,CAAC,CAAC,CACT+C,aAAa,CAAC,CAAC;QACpB/C,YAAY,CAAC,CAAC,CACT+C,aAAa,CAAC,CAAC;QACpB/C,YAAY,CAAC,CAAC,CACT+C,aAAa,CAAC,CAAC;QACpB/C,YAAY,CAAC,CAAC,CACT+C,aAAa,CAAC,CAAC;QAEpB,MAAMgB,mBAAmB,GAAGX,MAAM,CAACtC,IAAI,CAAC,CAAC,CAAC,CAACkD,GAAG,CAD3BxE,YACsC,CAAC;QAC1DQ,YAAY,CAAC+D,mBAAmB,CAAC,CAACjB,OAAO,CAACC,aAAa,CAAC,CAAC;QACzDgB,mBAAmB,CAACE,MAAM;MAC9B,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
import WebSocket from "isomorphic-ws";
|
|
17
17
|
import invariant from "tiny-invariant";
|
|
18
18
|
import { convertWireToOsdkObjects } from "../object/convertWireToOsdkObjects.js";
|
|
19
|
-
const ONE_DAY_MS = 24 * 60 * 60 * 1000;
|
|
20
19
|
const MINIMUM_RECONNECT_DELAY_MS = 5 * 1000;
|
|
21
20
|
/** Noop function to reduce conditional checks */
|
|
22
21
|
function doNothing() {}
|
|
@@ -26,12 +25,14 @@ function doNothing() {}
|
|
|
26
25
|
function fillOutListener({
|
|
27
26
|
onChange = doNothing,
|
|
28
27
|
onError = doNothing,
|
|
29
|
-
onOutOfDate = doNothing
|
|
28
|
+
onOutOfDate = doNothing,
|
|
29
|
+
onSuccessfulSubscription = doNothing
|
|
30
30
|
}) {
|
|
31
31
|
return {
|
|
32
32
|
onChange,
|
|
33
33
|
onError,
|
|
34
|
-
onOutOfDate
|
|
34
|
+
onOutOfDate,
|
|
35
|
+
onSuccessfulSubscription
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
function isReady(sub) {
|
|
@@ -43,7 +44,6 @@ function subscriptionIsDone(sub) {
|
|
|
43
44
|
/** @internal */
|
|
44
45
|
export class ObjectSetListenerWebsocket {
|
|
45
46
|
static #instances = new WeakMap();
|
|
46
|
-
OBJECT_SET_EXPIRY_MS;
|
|
47
47
|
MINIMUM_RECONNECT_DELAY_MS;
|
|
48
48
|
// FIXME
|
|
49
49
|
static getInstance(client) {
|
|
@@ -70,25 +70,28 @@ export class ObjectSetListenerWebsocket {
|
|
|
70
70
|
#maybeDisconnectTimeout;
|
|
71
71
|
// DO NOT CONSTRUCT DIRECTLY. ONLY EXPOSED AS A TESTING SEAM
|
|
72
72
|
constructor(client, {
|
|
73
|
-
objectSetExpiryMs = ONE_DAY_MS,
|
|
74
73
|
minimumReconnectDelayMs = MINIMUM_RECONNECT_DELAY_MS
|
|
75
74
|
} = {}) {
|
|
76
|
-
this.OBJECT_SET_EXPIRY_MS = objectSetExpiryMs;
|
|
77
75
|
this.MINIMUM_RECONNECT_DELAY_MS = minimumReconnectDelayMs;
|
|
78
76
|
this.#client = client;
|
|
79
77
|
this.#logger = client.logger?.child({}, {
|
|
80
78
|
msgPrefix: "<OSW> "
|
|
81
79
|
});
|
|
82
|
-
!(client.baseUrl.startsWith("https://") || client.baseUrl.startsWith("http://")) ? invariant(false, "Stack must be a URL") : void 0;
|
|
80
|
+
!(client.baseUrl.startsWith("https://") || client.baseUrl.startsWith("http://")) ? process.env.NODE_ENV !== "production" ? invariant(false, "Stack must be a URL") : invariant(false) : void 0;
|
|
83
81
|
}
|
|
84
|
-
async subscribe(objectSet, listener, properties) {
|
|
82
|
+
async subscribe(objectType, objectSet, listener, properties) {
|
|
85
83
|
// Node 18 does not expose 'crypto' on globalThis, so we need to do it ourselves. This
|
|
86
84
|
// will not be needed after our minimum version is 19 or greater.
|
|
87
85
|
globalThis.crypto ??= (await import("node:crypto")).webcrypto;
|
|
86
|
+
const objDef = await this.#client.ontologyProvider.getObjectDefinition(objectType.apiName);
|
|
87
|
+
const objectProperties = properties.filter(p => objDef.properties[p].type !== "geotimeSeriesReference");
|
|
88
|
+
const referenceProperties = properties.filter(p => objDef.properties[p].type === "geotimeSeriesReference");
|
|
88
89
|
const sub = {
|
|
89
90
|
listener: fillOutListener(listener),
|
|
90
91
|
objectSet,
|
|
91
|
-
|
|
92
|
+
primaryKeyPropertyName: objDef.primaryKeyApiName,
|
|
93
|
+
requestedProperties: objectProperties,
|
|
94
|
+
requestedReferenceProperties: referenceProperties,
|
|
92
95
|
status: "preparing",
|
|
93
96
|
// Since we don't have a real subscription id yet but we need to keep
|
|
94
97
|
// track of this reference, we can just use a random uuid.
|
|
@@ -112,16 +115,9 @@ export class ObjectSetListenerWebsocket {
|
|
|
112
115
|
* @returns
|
|
113
116
|
*/
|
|
114
117
|
async #initiateSubscribe(sub) {
|
|
115
|
-
if (process
|
|
118
|
+
if (process.env.NODE_ENV !== "production") {
|
|
116
119
|
this.#logger?.trace("#initiateSubscribe()");
|
|
117
120
|
}
|
|
118
|
-
if (sub.expiry) {
|
|
119
|
-
clearTimeout(sub.expiry);
|
|
120
|
-
}
|
|
121
|
-
// expiry is tied to the temporary object set, which is set to `timeToLive: "ONE_DAY"`
|
|
122
|
-
// in `#createTemporaryObjectSet`. They should be in sync
|
|
123
|
-
sub.expiry = setTimeout(() => this.#expire(sub), this.OBJECT_SET_EXPIRY_MS);
|
|
124
|
-
await this.#client.ontologyRid;
|
|
125
121
|
try {
|
|
126
122
|
await this.#ensureWebsocket();
|
|
127
123
|
// the consumer may have already unsubscribed before we are ready to request a subscription
|
|
@@ -140,7 +136,7 @@ export class ObjectSetListenerWebsocket {
|
|
|
140
136
|
}
|
|
141
137
|
}
|
|
142
138
|
#sendSubscribeMessage() {
|
|
143
|
-
if (process
|
|
139
|
+
if (process.env.NODE_ENV !== "production") {
|
|
144
140
|
this.#logger?.trace("#sendSubscribeMessage()");
|
|
145
141
|
}
|
|
146
142
|
// If two calls to `.subscribe()` happen at once (or if the connection is reset),
|
|
@@ -148,7 +144,7 @@ export class ObjectSetListenerWebsocket {
|
|
|
148
144
|
// so we filter those out.
|
|
149
145
|
const readySubs = [...this.#subscriptions.values()].filter(isReady);
|
|
150
146
|
if (readySubs.length === 0) {
|
|
151
|
-
if (process
|
|
147
|
+
if (process.env.NODE_ENV !== "production") {
|
|
152
148
|
this.#logger?.trace("#sendSubscribeMessage(): aborting due to no ready subscriptions");
|
|
153
149
|
}
|
|
154
150
|
return;
|
|
@@ -163,31 +159,23 @@ export class ObjectSetListenerWebsocket {
|
|
|
163
159
|
id,
|
|
164
160
|
requests: readySubs.map(({
|
|
165
161
|
objectSet,
|
|
166
|
-
requestedProperties
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
162
|
+
requestedProperties,
|
|
163
|
+
requestedReferenceProperties
|
|
164
|
+
}) => {
|
|
165
|
+
return {
|
|
166
|
+
objectSet: objectSet,
|
|
167
|
+
propertySet: requestedProperties,
|
|
168
|
+
referenceSet: requestedReferenceProperties
|
|
169
|
+
};
|
|
170
|
+
})
|
|
172
171
|
};
|
|
173
|
-
if (process
|
|
172
|
+
if (process.env.NODE_ENV !== "production") {
|
|
174
173
|
this.#logger?.trace({
|
|
175
174
|
payload: subscribe
|
|
176
175
|
}, "sending subscribe message");
|
|
177
176
|
}
|
|
178
177
|
this.#ws?.send(JSON.stringify(subscribe));
|
|
179
178
|
}
|
|
180
|
-
#expire(sub) {
|
|
181
|
-
if (process?.env?.NODE_ENV !== "production") {
|
|
182
|
-
this.#logger?.trace({
|
|
183
|
-
subscription: sub
|
|
184
|
-
}, "#expire()");
|
|
185
|
-
}
|
|
186
|
-
// the temporary ObjectSet has expired, we should re-subscribe which will cause the
|
|
187
|
-
// listener to get an onOutOfDate message when it becomes subscribed again
|
|
188
|
-
sub.status = "expired";
|
|
189
|
-
this.#initiateSubscribe(sub);
|
|
190
|
-
}
|
|
191
179
|
#unsubscribe(sub, newStatus = "done") {
|
|
192
180
|
if (subscriptionIsDone(sub)) {
|
|
193
181
|
// if we are already done, we don't need to do anything
|
|
@@ -196,11 +184,8 @@ export class ObjectSetListenerWebsocket {
|
|
|
196
184
|
sub.status = newStatus;
|
|
197
185
|
// make sure listeners do nothing now
|
|
198
186
|
sub.listener = fillOutListener({});
|
|
199
|
-
if (sub.expiry) {
|
|
200
|
-
clearTimeout(sub.expiry);
|
|
201
|
-
sub.expiry = undefined;
|
|
202
|
-
}
|
|
203
187
|
this.#subscriptions.delete(sub.subscriptionId);
|
|
188
|
+
this.#sendSubscribeMessage();
|
|
204
189
|
// If we have no more subscriptions, we can disconnect the websocket
|
|
205
190
|
// however we should wait a bit to see if we get any more subscriptions.
|
|
206
191
|
// For example, when switching between react views, you may unsubscribe
|
|
@@ -247,7 +232,7 @@ export class ObjectSetListenerWebsocket {
|
|
|
247
232
|
this.#lastWsConnect = Date.now();
|
|
248
233
|
// we again may have lost the race after our minimum backoff time
|
|
249
234
|
if (this.#ws == null) {
|
|
250
|
-
if (process
|
|
235
|
+
if (process.env.NODE_ENV !== "production") {
|
|
251
236
|
this.#logger?.trace("Creating websocket");
|
|
252
237
|
}
|
|
253
238
|
this.#ws = new WebSocket(url, [`Bearer-${token}`]);
|
|
@@ -287,7 +272,7 @@ export class ObjectSetListenerWebsocket {
|
|
|
287
272
|
};
|
|
288
273
|
#onMessage = async message => {
|
|
289
274
|
const data = JSON.parse(message.data.toString());
|
|
290
|
-
if (process
|
|
275
|
+
if (process.env.NODE_ENV !== "production") {
|
|
291
276
|
this.#logger?.trace({
|
|
292
277
|
payload: data
|
|
293
278
|
}, "received message from ws");
|
|
@@ -304,15 +289,37 @@ export class ObjectSetListenerWebsocket {
|
|
|
304
289
|
return this.#handleMessage_subscriptionClosed(data);
|
|
305
290
|
}
|
|
306
291
|
default:
|
|
307
|
-
invariant(false, "Unexpected message type");
|
|
292
|
+
process.env.NODE_ENV !== "production" ? invariant(false, "Unexpected message type") : invariant(false);
|
|
308
293
|
}
|
|
309
294
|
};
|
|
310
295
|
#handleMessage_objectSetChanged = async payload => {
|
|
311
296
|
const sub = this.#subscriptions.get(payload.id);
|
|
312
|
-
|
|
297
|
+
if (sub == null) return;
|
|
313
298
|
const objectUpdates = payload.updates.filter(update => update.type === "object");
|
|
314
|
-
payload.updates.filter(update => update.type === "reference");
|
|
299
|
+
const referenceUpdates = payload.updates.filter(update => update.type === "reference");
|
|
300
|
+
const osdkObjectsWithReferenceUpdates = await Promise.all(referenceUpdates.map(async o => {
|
|
301
|
+
const osdkObjectArray = await convertWireToOsdkObjects(this.#client, [{
|
|
302
|
+
__apiName: o.objectType,
|
|
303
|
+
__primaryKey: o.primaryKey[sub.primaryKeyPropertyName],
|
|
304
|
+
...o.primaryKey,
|
|
305
|
+
[o.property]: o.value
|
|
306
|
+
}], undefined);
|
|
307
|
+
const singleOsdkObject = osdkObjectArray[0] ?? undefined;
|
|
308
|
+
return singleOsdkObject != null ? {
|
|
309
|
+
object: singleOsdkObject,
|
|
310
|
+
state: "ADDED_OR_UPDATED"
|
|
311
|
+
} : undefined;
|
|
312
|
+
}));
|
|
313
|
+
for (const osdkObject of osdkObjectsWithReferenceUpdates) {
|
|
314
|
+
if (osdkObject != null) {
|
|
315
|
+
sub.listener.onChange?.(osdkObject);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
315
318
|
const osdkObjects = await Promise.all(objectUpdates.map(async o => {
|
|
319
|
+
const keysToDelete = Object.keys(o.object).filter(key => sub.requestedReferenceProperties.includes(key));
|
|
320
|
+
for (const key of keysToDelete) {
|
|
321
|
+
delete o.object[key];
|
|
322
|
+
}
|
|
316
323
|
const osdkObjectArray = await convertWireToOsdkObjects(this.#client, [o.object], undefined);
|
|
317
324
|
const singleOsdkObject = osdkObjectArray[0] ?? undefined;
|
|
318
325
|
return singleOsdkObject != null ? {
|
|
@@ -322,13 +329,13 @@ export class ObjectSetListenerWebsocket {
|
|
|
322
329
|
}));
|
|
323
330
|
for (const osdkObject of osdkObjects) {
|
|
324
331
|
if (osdkObject != null) {
|
|
325
|
-
|
|
332
|
+
sub.listener.onChange?.(osdkObject);
|
|
326
333
|
}
|
|
327
334
|
}
|
|
328
335
|
};
|
|
329
336
|
#handleMessage_refreshObjectSet = payload => {
|
|
330
337
|
const sub = this.#subscriptions.get(payload.id);
|
|
331
|
-
!sub ? invariant(false, `Expected subscription id ${payload.id}`) : void 0;
|
|
338
|
+
!sub ? process.env.NODE_ENV !== "production" ? invariant(false, `Expected subscription id ${payload.id}`) : invariant(false) : void 0;
|
|
332
339
|
sub.listener.onOutOfDate();
|
|
333
340
|
};
|
|
334
341
|
#handleMessage_subscribeResponses = payload => {
|
|
@@ -337,7 +344,7 @@ export class ObjectSetListenerWebsocket {
|
|
|
337
344
|
responses
|
|
338
345
|
} = payload;
|
|
339
346
|
const subs = this.#pendingSubscriptions.get(id);
|
|
340
|
-
!subs ? invariant(false, `should have a pending subscription for ${id}`) : void 0;
|
|
347
|
+
!subs ? process.env.NODE_ENV !== "production" ? invariant(false, `should have a pending subscription for ${id}`) : invariant(false) : void 0;
|
|
341
348
|
this.#pendingSubscriptions.delete(id);
|
|
342
349
|
for (let i = 0; i < responses.length; i++) {
|
|
343
350
|
const sub = subs[i];
|
|
@@ -354,7 +361,7 @@ export class ObjectSetListenerWebsocket {
|
|
|
354
361
|
case "success":
|
|
355
362
|
// `"preparing"` should only be the status on an initial subscribe.
|
|
356
363
|
const shouldFireOutOfDate = sub.status === "expired" || sub.status === "reconnecting";
|
|
357
|
-
if (process
|
|
364
|
+
if (process.env.NODE_ENV !== "production") {
|
|
358
365
|
this.#logger?.trace({
|
|
359
366
|
shouldFireOutOfDate
|
|
360
367
|
}, "success");
|
|
@@ -366,7 +373,7 @@ export class ObjectSetListenerWebsocket {
|
|
|
366
373
|
sub.subscriptionId = response.id;
|
|
367
374
|
this.#subscriptions.set(sub.subscriptionId, sub); // future messages come by this subId
|
|
368
375
|
}
|
|
369
|
-
if (shouldFireOutOfDate) sub.listener.onOutOfDate();
|
|
376
|
+
if (shouldFireOutOfDate) sub.listener.onOutOfDate();else sub.listener.onSuccessfulSubscription();
|
|
370
377
|
break;
|
|
371
378
|
default:
|
|
372
379
|
sub.listener.onError(response);
|
|
@@ -375,12 +382,12 @@ export class ObjectSetListenerWebsocket {
|
|
|
375
382
|
};
|
|
376
383
|
#handleMessage_subscriptionClosed(payload) {
|
|
377
384
|
const sub = this.#subscriptions.get(payload.id);
|
|
378
|
-
!sub ? invariant(false, `Expected subscription id ${payload.id}`) : void 0;
|
|
385
|
+
!sub ? process.env.NODE_ENV !== "production" ? invariant(false, `Expected subscription id ${payload.id}`) : invariant(false) : void 0;
|
|
379
386
|
sub.listener.onError([payload.cause]);
|
|
380
387
|
this.#unsubscribe(sub, "error");
|
|
381
388
|
}
|
|
382
389
|
#onClose = event => {
|
|
383
|
-
if (process
|
|
390
|
+
if (process.env.NODE_ENV !== "production") {
|
|
384
391
|
this.#logger?.trace({
|
|
385
392
|
event
|
|
386
393
|
}, "Received close event from ws", event);
|
|
@@ -388,8 +395,6 @@ export class ObjectSetListenerWebsocket {
|
|
|
388
395
|
// TODO we should probably throttle this so we don't abuse the backend
|
|
389
396
|
this.#cycleWebsocket();
|
|
390
397
|
};
|
|
391
|
-
// TODO: Validate if this is needed
|
|
392
|
-
async #enableObjectSetsWatcher() {}
|
|
393
398
|
#cycleWebsocket = () => {
|
|
394
399
|
if (this.#ws) {
|
|
395
400
|
this.#ws.removeEventListener("open", this.#onOpen);
|
|
@@ -402,9 +407,9 @@ export class ObjectSetListenerWebsocket {
|
|
|
402
407
|
}
|
|
403
408
|
// if we have any listeners that are still depending on us, go ahead and reopen the websocket
|
|
404
409
|
if (this.#subscriptions.size > 0) {
|
|
405
|
-
if (process
|
|
410
|
+
if (process.env.NODE_ENV !== "production") {
|
|
406
411
|
for (const s of this.#subscriptions.values()) {
|
|
407
|
-
!(s.status !== "done" && s.status !== "error") ? invariant(false, "should not have done/error subscriptions still") : void 0;
|
|
412
|
+
!(s.status !== "done" && s.status !== "error") ? process.env.NODE_ENV !== "production" ? invariant(false, "should not have done/error subscriptions still") : invariant(false) : void 0;
|
|
408
413
|
}
|
|
409
414
|
}
|
|
410
415
|
for (const s of this.#subscriptions.values()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectSetListenerWebsocket.js","names":["WebSocket","invariant","convertWireToOsdkObjects","ONE_DAY_MS","MINIMUM_RECONNECT_DELAY_MS","doNothing","fillOutListener","onChange","onError","onOutOfDate","isReady","sub","subscriptionIsDone","status","ObjectSetListenerWebsocket","instances","WeakMap","OBJECT_SET_EXPIRY_MS","getInstance","client","instance","get","clientCacheKey","set","ws","lastWsConnect","logger","pendingSubscriptions","Map","subscriptions","maybeDisconnectTimeout","constructor","objectSetExpiryMs","minimumReconnectDelayMs","child","msgPrefix","baseUrl","startsWith","subscribe","objectSet","listener","properties","globalThis","crypto","webcrypto","requestedProperties","subscriptionId","randomUUID","initiateSubscribe","unsubscribe","#initiateSubscribe","process","env","NODE_ENV","trace","expiry","clearTimeout","setTimeout","expire","ontologyRid","ensureWebsocket","readyState","OPEN","sendSubscribeMessage","error","#sendSubscribeMessage","readySubs","values","filter","length","id","requests","map","propertySet","referenceSet","payload","send","JSON","stringify","#expire","subscription","#unsubscribe","newStatus","undefined","delete","size","cycleWebsocket","#ensureWebsocket","tokenProvider","base","URL","url","host","token","nextConnectTime","Date","now","Promise","resolve","addEventListener","onClose","onMessage","onOpen","CONNECTING","reject","cleanup","removeEventListener","open","evt","#onOpen","message","data","parse","toString","type","handleMessage_objectSetChanged","handleMessage_refreshObjectSet","handleMessage_subscribeResponses","handleMessage_subscriptionClosed","objectUpdates","updates","update","osdkObjects","all","o","osdkObjectArray","object","singleOsdkObject","state","osdkObject","responses","subs","i","response","errors","shouldFireOutOfDate","#handleMessage_subscriptionClosed","cause","event","enableObjectSetsWatcher","#enableObjectSetsWatcher","#cycleWebsocket","CLOSING","CLOSED","close","s"],"sources":["ObjectSetListenerWebsocket.js"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport WebSocket from \"isomorphic-ws\";\nimport invariant from \"tiny-invariant\";\nimport { convertWireToOsdkObjects } from \"../object/convertWireToOsdkObjects.js\";\nconst ONE_DAY_MS = 24 * 60 * 60 * 1000;\nconst MINIMUM_RECONNECT_DELAY_MS = 5 * 1000;\n/** Noop function to reduce conditional checks */\nfunction doNothing() { }\n/**\n * Converts an ObjectSetListener to one where all the functions are defined.\n */\nfunction fillOutListener({ onChange = doNothing, onError = doNothing, onOutOfDate = doNothing, }) {\n return { onChange, onError, onOutOfDate };\n}\nfunction isReady(sub) {\n return sub.isReady != null;\n}\nfunction subscriptionIsDone(sub) {\n return sub.status === \"done\" || sub.status === \"error\";\n}\n/** @internal */\nexport class ObjectSetListenerWebsocket {\n static #instances = new WeakMap();\n OBJECT_SET_EXPIRY_MS;\n MINIMUM_RECONNECT_DELAY_MS;\n // FIXME\n static getInstance(client) {\n let instance = ObjectSetListenerWebsocket.#instances.get(client.clientCacheKey);\n if (instance == null) {\n instance = new ObjectSetListenerWebsocket(client);\n ObjectSetListenerWebsocket.#instances.set(client.clientCacheKey, instance);\n }\n return instance;\n }\n #ws;\n #lastWsConnect = 0;\n #client;\n #logger;\n /**\n * map of requestId to all active subscriptions at the time of the request\n */\n #pendingSubscriptions = new Map();\n /**\n * Map of subscriptionId to Subscription. Note: the subscriptionId may be\n * temporary and not the actual subscriptionId from the server.\n */\n #subscriptions = new Map();\n #maybeDisconnectTimeout;\n // DO NOT CONSTRUCT DIRECTLY. ONLY EXPOSED AS A TESTING SEAM\n constructor(client, { objectSetExpiryMs = ONE_DAY_MS, minimumReconnectDelayMs = MINIMUM_RECONNECT_DELAY_MS, } = {}) {\n this.OBJECT_SET_EXPIRY_MS = objectSetExpiryMs;\n this.MINIMUM_RECONNECT_DELAY_MS = minimumReconnectDelayMs;\n this.#client = client;\n this.#logger = client.logger?.child({}, {\n msgPrefix: \"<OSW> \",\n });\n invariant(client.baseUrl.startsWith(\"https://\")\n || client.baseUrl.startsWith(\"http://\"), \"Stack must be a URL\");\n }\n async subscribe(objectSet, listener, properties) {\n if (process.env.TARGET !== \"browser\") {\n // Node 18 does not expose 'crypto' on globalThis, so we need to do it ourselves. This\n // will not be needed after our minimum version is 19 or greater.\n globalThis.crypto ??= (await import(\"node:crypto\")).webcrypto;\n }\n const sub = {\n listener: fillOutListener(listener),\n objectSet,\n requestedProperties: properties,\n status: \"preparing\",\n // Since we don't have a real subscription id yet but we need to keep\n // track of this reference, we can just use a random uuid.\n subscriptionId: `TMP-${crypto.randomUUID()}`,\n };\n this.#subscriptions.set(sub.subscriptionId, sub);\n // actually prepares the subscription, ensures the ws is ready, and sends\n // a subscribe message. We don't want to block on this.\n this.#initiateSubscribe(sub);\n return () => {\n this.#unsubscribe(sub);\n };\n }\n /**\n * Called at least once for every subscription.\n *\n * - Resets pending expiry\n * - Recreates temporary object set\n * - Triggers a full subscribe message\n *\n * @returns\n */\n async #initiateSubscribe(sub) {\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace(\"#initiateSubscribe()\");\n }\n if (sub.expiry) {\n clearTimeout(sub.expiry);\n }\n // expiry is tied to the temporary object set, which is set to `timeToLive: \"ONE_DAY\"`\n // in `#createTemporaryObjectSet`. They should be in sync\n sub.expiry = setTimeout(() => this.#expire(sub), this.OBJECT_SET_EXPIRY_MS);\n const ontologyRid = await this.#client.ontologyRid;\n try {\n await this.#ensureWebsocket();\n // the consumer may have already unsubscribed before we are ready to request a subscription\n // so we have to acquire the pendingSubscription after the await.\n if (subscriptionIsDone(sub)) {\n return;\n }\n sub.isReady = true;\n // if we aren't open, then this happens after we #onConnect\n if (this.#ws?.readyState === WebSocket.OPEN) {\n this.#sendSubscribeMessage();\n }\n }\n catch (error) {\n this.#logger?.error(error, \"Error in #initiateSubscribe\");\n sub.listener.onError([error]);\n }\n }\n #sendSubscribeMessage() {\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace(\"#sendSubscribeMessage()\");\n }\n // If two calls to `.subscribe()` happen at once (or if the connection is reset),\n // we may have multiple subscriptions that don't have a subscriptionId yet,\n // so we filter those out.\n const readySubs = [...this.#subscriptions.values()].filter(isReady);\n if (readySubs.length === 0) {\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace(\"#sendSubscribeMessage(): aborting due to no ready subscriptions\");\n }\n return;\n }\n // Assumes the node 18 crypto fallback to globalThis in `subscribe` has happened.\n const id = crypto.randomUUID();\n // responses come back as an array of subIds, so we need to know the sources\n this.#pendingSubscriptions.set(id, readySubs);\n // every subscribe message \"overwrites\" the previous ones that are not\n // re-included, so we have to reconstitute the entire list of subscriptions\n const subscribe = {\n id,\n requests: readySubs.map(({ objectSet, requestedProperties }) => ({\n objectSet: objectSet,\n propertySet: requestedProperties,\n referenceSet: [],\n })),\n };\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace({ payload: subscribe }, \"sending subscribe message\");\n }\n this.#ws?.send(JSON.stringify(subscribe));\n }\n #expire(sub) {\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace({ subscription: sub }, \"#expire()\");\n }\n // the temporary ObjectSet has expired, we should re-subscribe which will cause the\n // listener to get an onOutOfDate message when it becomes subscribed again\n sub.status = \"expired\";\n this.#initiateSubscribe(sub);\n }\n #unsubscribe(sub, newStatus = \"done\") {\n if (subscriptionIsDone(sub)) {\n // if we are already done, we don't need to do anything\n return;\n }\n sub.status = newStatus;\n // make sure listeners do nothing now\n sub.listener = fillOutListener({});\n if (sub.expiry) {\n clearTimeout(sub.expiry);\n sub.expiry = undefined;\n }\n this.#subscriptions.delete(sub.subscriptionId);\n // If we have no more subscriptions, we can disconnect the websocket\n // however we should wait a bit to see if we get any more subscriptions.\n // For example, when switching between react views, you may unsubscribe\n // in the old view and subscribe in the new view. We don't need to re-establish\n // the websocket connection in that case.\n if (this.#maybeDisconnectTimeout) {\n // We reset the timeout on every unsubscribe so its always at least 15s from\n // the last time we are empty. E.g.:\n // - 0s: Subscribe(A)\n // - 10s: Unsubscribe(A)\n // - 11s: Subscribe(B)\n // - 20s: Unsubscribe(B)\n // If we do not clear out the timeout we would disconnect at 25s but that would only be\n // 5s after the last subscription was removed instead of at 35s for the desired 15s.\n clearTimeout(this.#maybeDisconnectTimeout);\n }\n this.#maybeDisconnectTimeout = setTimeout(() => {\n this.#maybeDisconnectTimeout = undefined;\n if (this.#subscriptions.size === 0) {\n this.#cycleWebsocket();\n }\n }, 15_000 /* ms */);\n }\n async #ensureWebsocket() {\n if (this.#ws == null) {\n const { baseUrl, tokenProvider } = this.#client;\n const base = new URL(baseUrl);\n const url = `wss://${base.host}/api/v2/ontologySubscriptions/ontologies/${this.#client.ontologyRid}/streamSubscriptions`;\n const token = await tokenProvider();\n // tokenProvider is async, there could potentially be a race to create the websocket.\n // Only the first call to reach here will find a null this.#ws, the rest will bail out\n if (this.#ws == null) {\n // TODO this can probably be exponential backoff with jitter\n // don't reconnect more quickly than MINIMUM_RECONNECT_DELAY\n const nextConnectTime = (this.#lastWsConnect ?? 0)\n + this.MINIMUM_RECONNECT_DELAY_MS;\n if (nextConnectTime > Date.now()) {\n await new Promise((resolve) => {\n setTimeout(resolve, nextConnectTime - Date.now());\n });\n }\n this.#lastWsConnect = Date.now();\n // we again may have lost the race after our minimum backoff time\n if (this.#ws == null) {\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace(\"Creating websocket\");\n }\n this.#ws = new WebSocket(url, [`Bearer-${token}`]);\n this.#ws.addEventListener(\"close\", this.#onClose);\n this.#ws.addEventListener(\"message\", this.#onMessage);\n this.#ws.addEventListener(\"open\", this.#onOpen);\n }\n }\n // Allow await-ing the websocket open event if it isn't open already.\n // This needs to happen even for callers that didn't just create this.#ws\n if (this.#ws.readyState === WebSocket.CONNECTING) {\n const ws = this.#ws;\n return new Promise((resolve, reject) => {\n function cleanup() {\n ws.removeEventListener(\"open\", open);\n ws.removeEventListener(\"error\", error);\n ws.removeEventListener(\"close\", cleanup);\n }\n function open() {\n cleanup();\n resolve();\n }\n function error(evt) {\n cleanup();\n reject(evt);\n }\n ws.addEventListener(\"open\", open);\n ws.addEventListener(\"error\", error);\n ws.addEventListener(\"close\", cleanup);\n });\n }\n }\n }\n #onOpen = () => {\n // resubscribe all of the listeners\n this.#sendSubscribeMessage();\n };\n #onMessage = async (message) => {\n const data = JSON.parse(message.data.toString());\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace({ payload: data }, \"received message from ws\");\n }\n switch (data.type) {\n case \"objectSetChanged\":\n return this.#handleMessage_objectSetChanged(data);\n case \"refreshObjectSet\":\n return this.#handleMessage_refreshObjectSet(data);\n case \"subscribeResponses\":\n return this.#handleMessage_subscribeResponses(data);\n case \"subscriptionClosed\": {\n return this.#handleMessage_subscriptionClosed(data);\n }\n default:\n const _ = data;\n invariant(false, \"Unexpected message type\");\n }\n };\n #handleMessage_objectSetChanged = async (payload) => {\n const sub = this.#subscriptions.get(payload.id);\n invariant(sub, `Expected subscription id ${payload.id}`);\n const objectUpdates = payload.updates.filter((update) => update.type === \"object\");\n const referenceUpdates = payload.updates.filter((update) => update.type === \"reference\");\n const osdkObjects = await Promise.all(objectUpdates.map(async (o) => {\n const osdkObjectArray = await convertWireToOsdkObjects(this.#client, [o.object], undefined);\n const singleOsdkObject = osdkObjectArray[0] ?? undefined;\n return singleOsdkObject != null\n ? {\n object: singleOsdkObject,\n state: o.state,\n }\n : undefined;\n }));\n for (const osdkObject of osdkObjects) {\n if (osdkObject != null) {\n return sub.listener.onChange?.(osdkObject);\n }\n }\n };\n #handleMessage_refreshObjectSet = (payload) => {\n const sub = this.#subscriptions.get(payload.id);\n invariant(sub, `Expected subscription id ${payload.id}`);\n sub.listener.onOutOfDate();\n };\n #handleMessage_subscribeResponses = (payload) => {\n const { id, responses } = payload;\n const subs = this.#pendingSubscriptions.get(id);\n invariant(subs, `should have a pending subscription for ${id}`);\n this.#pendingSubscriptions.delete(id);\n for (let i = 0; i < responses.length; i++) {\n const sub = subs[i];\n const response = responses[i];\n switch (response.type) {\n case \"error\":\n sub.listener.onError(response.errors);\n this.#unsubscribe(sub, \"error\");\n break;\n case \"qos\":\n // the server has requested that we tear down our websocket and reconnect to help load balance\n this.#cycleWebsocket();\n break;\n case \"success\":\n // `\"preparing\"` should only be the status on an initial subscribe.\n const shouldFireOutOfDate = sub.status === \"expired\"\n || sub.status === \"reconnecting\";\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace({ shouldFireOutOfDate }, \"success\");\n }\n sub.status = \"subscribed\";\n if (sub.subscriptionId !== response.id) {\n // might be the temporary one\n this.#subscriptions.delete(sub.subscriptionId);\n sub.subscriptionId = response.id;\n this.#subscriptions.set(sub.subscriptionId, sub); // future messages come by this subId\n }\n if (shouldFireOutOfDate)\n sub.listener.onOutOfDate();\n break;\n default:\n const _ = response;\n sub.listener.onError(response);\n }\n }\n };\n #handleMessage_subscriptionClosed(payload) {\n const sub = this.#subscriptions.get(payload.id);\n invariant(sub, `Expected subscription id ${payload.id}`);\n sub.listener.onError([payload.cause]);\n this.#unsubscribe(sub, \"error\");\n }\n #onClose = (event) => {\n if (process?.env?.NODE_ENV !== \"production\") {\n this.#logger?.trace({ event }, \"Received close event from ws\", event);\n }\n // TODO we should probably throttle this so we don't abuse the backend\n this.#cycleWebsocket();\n };\n // TODO: Validate if this is needed\n async #enableObjectSetsWatcher(objectTypeRids) {\n // return batchEnableWatcher(this.#oswContext, {\n // requests: objectTypeRids,\n // });\n return;\n }\n #cycleWebsocket = () => {\n if (this.#ws) {\n this.#ws.removeEventListener(\"open\", this.#onOpen);\n this.#ws.removeEventListener(\"message\", this.#onMessage);\n this.#ws.removeEventListener(\"close\", this.#onClose);\n if (this.#ws.readyState !== WebSocket.CLOSING\n && this.#ws.readyState !== WebSocket.CLOSED) {\n this.#ws.close();\n }\n this.#ws = undefined;\n }\n // if we have any listeners that are still depending on us, go ahead and reopen the websocket\n if (this.#subscriptions.size > 0) {\n if (process?.env?.NODE_ENV !== \"production\") {\n for (const s of this.#subscriptions.values()) {\n invariant(s.status !== \"done\" && s.status !== \"error\", \"should not have done/error subscriptions still\");\n }\n }\n for (const s of this.#subscriptions.values()) {\n if (s.status === \"subscribed\")\n s.status = \"reconnecting\";\n }\n this.#ensureWebsocket();\n }\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,eAAe;AACrC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,wBAAwB,QAAQ,uCAAuC;AAChF,MAAMC,UAAU,GAAG,EAAE,GAAG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C,EAAU8E,CAAC,CAACpI,MAAM,KAAK,MAAM,IAAIoI,CAAC,CAACpI,MAAM,KAAK,OAAO,IAArDZ,SAAS,QAA8C,gDAAgD;QAC3G;MACJ;MACA,KAAK,MAAMgJ,CAAC,IAAI,IAAI,CAAC,CAACpH,aAAa,CAACsC,MAAM,CAAC,CAAC,EAAE;QAC1C,IAAI8E,CAAC,CAACpI,MAAM,KAAK,YAAY,EACzBoI,CAAC,CAACpI,MAAM,GAAG,cAAc;MACjC;MACA,IAAI,CAAC,CAAC+C,eAAe,CAAC,CAAC;IAC3B;EACJ,CAAC;AACL","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ObjectSetListenerWebsocket.js","names":["WebSocket","invariant","convertWireToOsdkObjects","MINIMUM_RECONNECT_DELAY_MS","doNothing","fillOutListener","onChange","onError","onOutOfDate","onSuccessfulSubscription","isReady","sub","subscriptionIsDone","status","ObjectSetListenerWebsocket","instances","WeakMap","getInstance","client","instance","get","clientCacheKey","set","ws","lastWsConnect","logger","pendingSubscriptions","Map","subscriptions","maybeDisconnectTimeout","constructor","minimumReconnectDelayMs","child","msgPrefix","baseUrl","startsWith","process","env","NODE_ENV","subscribe","objectType","objectSet","listener","properties","globalThis","crypto","webcrypto","objDef","ontologyProvider","getObjectDefinition","apiName","objectProperties","filter","p","type","referenceProperties","primaryKeyPropertyName","primaryKeyApiName","requestedProperties","requestedReferenceProperties","subscriptionId","randomUUID","initiateSubscribe","unsubscribe","#initiateSubscribe","trace","ensureWebsocket","readyState","OPEN","sendSubscribeMessage","error","#sendSubscribeMessage","readySubs","values","length","id","requests","map","propertySet","referenceSet","payload","send","JSON","stringify","#unsubscribe","newStatus","delete","clearTimeout","setTimeout","undefined","size","cycleWebsocket","#ensureWebsocket","tokenProvider","base","URL","url","host","ontologyRid","token","nextConnectTime","Date","now","Promise","resolve","addEventListener","onClose","onMessage","onOpen","CONNECTING","reject","cleanup","removeEventListener","open","evt","#onOpen","message","data","parse","toString","handleMessage_objectSetChanged","handleMessage_refreshObjectSet","handleMessage_subscribeResponses","handleMessage_subscriptionClosed","objectUpdates","updates","update","referenceUpdates","osdkObjectsWithReferenceUpdates","all","o","osdkObjectArray","__apiName","__primaryKey","primaryKey","property","value","singleOsdkObject","object","state","osdkObject","osdkObjects","keysToDelete","Object","keys","key","includes","responses","subs","i","response","errors","shouldFireOutOfDate","#handleMessage_subscriptionClosed","cause","event","#cycleWebsocket","CLOSING","CLOSED","close","s"],"sources":["ObjectSetListenerWebsocket.js"],"sourcesContent":["/*\n * Copyright 2023 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 */\nimport WebSocket from \"isomorphic-ws\";\nimport invariant from \"tiny-invariant\";\nimport { convertWireToOsdkObjects } from \"../object/convertWireToOsdkObjects.js\";\nconst MINIMUM_RECONNECT_DELAY_MS = 5 * 1000;\n/** Noop function to reduce conditional checks */\nfunction doNothing() { }\n/**\n * Converts an ObjectSetListener to one where all the functions are defined.\n */\nfunction fillOutListener({ onChange = doNothing, onError = doNothing, onOutOfDate = doNothing, onSuccessfulSubscription = doNothing, }) {\n return { onChange, onError, onOutOfDate, onSuccessfulSubscription };\n}\nfunction isReady(sub) {\n return sub.isReady != null;\n}\nfunction subscriptionIsDone(sub) {\n return sub.status === \"done\" || sub.status === \"error\";\n}\n/** @internal */\nexport class ObjectSetListenerWebsocket {\n static #instances = new WeakMap();\n MINIMUM_RECONNECT_DELAY_MS;\n // FIXME\n static getInstance(client) {\n let instance = ObjectSetListenerWebsocket.#instances.get(client.clientCacheKey);\n if (instance == null) {\n instance = new ObjectSetListenerWebsocket(client);\n ObjectSetListenerWebsocket.#instances.set(client.clientCacheKey, instance);\n }\n return instance;\n }\n #ws;\n #lastWsConnect = 0;\n #client;\n #logger;\n /**\n * map of requestId to all active subscriptions at the time of the request\n */\n #pendingSubscriptions = new Map();\n /**\n * Map of subscriptionId to Subscription. Note: the subscriptionId may be\n * temporary and not the actual subscriptionId from the server.\n */\n #subscriptions = new Map();\n #maybeDisconnectTimeout;\n // DO NOT CONSTRUCT DIRECTLY. ONLY EXPOSED AS A TESTING SEAM\n constructor(client, { minimumReconnectDelayMs = MINIMUM_RECONNECT_DELAY_MS, } = {}) {\n this.MINIMUM_RECONNECT_DELAY_MS = minimumReconnectDelayMs;\n this.#client = client;\n this.#logger = client.logger?.child({}, {\n msgPrefix: \"<OSW> \",\n });\n invariant(client.baseUrl.startsWith(\"https://\")\n || client.baseUrl.startsWith(\"http://\"), \"Stack must be a URL\");\n }\n async subscribe(objectType, objectSet, listener, properties) {\n if (process.env.TARGET !== \"browser\") {\n // Node 18 does not expose 'crypto' on globalThis, so we need to do it ourselves. This\n // will not be needed after our minimum version is 19 or greater.\n globalThis.crypto ??= (await import(\"node:crypto\")).webcrypto;\n }\n const objDef = await this.#client.ontologyProvider.getObjectDefinition(objectType.apiName);\n const objectProperties = properties.filter((p) => objDef.properties[p].type !== \"geotimeSeriesReference\");\n const referenceProperties = properties.filter((p) => objDef.properties[p].type === \"geotimeSeriesReference\");\n const sub = {\n listener: fillOutListener(listener),\n objectSet,\n primaryKeyPropertyName: objDef.primaryKeyApiName,\n requestedProperties: objectProperties,\n requestedReferenceProperties: referenceProperties,\n status: \"preparing\",\n // Since we don't have a real subscription id yet but we need to keep\n // track of this reference, we can just use a random uuid.\n subscriptionId: `TMP-${crypto.randomUUID()}`,\n };\n this.#subscriptions.set(sub.subscriptionId, sub);\n // actually prepares the subscription, ensures the ws is ready, and sends\n // a subscribe message. We don't want to block on this.\n this.#initiateSubscribe(sub);\n return () => {\n this.#unsubscribe(sub);\n };\n }\n /**\n * Called at least once for every subscription.\n *\n * - Resets pending expiry\n * - Recreates temporary object set\n * - Triggers a full subscribe message\n *\n * @returns\n */\n async #initiateSubscribe(sub) {\n if (process.env.NODE_ENV !== \"production\") {\n this.#logger?.trace(\"#initiateSubscribe()\");\n }\n try {\n await this.#ensureWebsocket();\n // the consumer may have already unsubscribed before we are ready to request a subscription\n // so we have to acquire the pendingSubscription after the await.\n if (subscriptionIsDone(sub)) {\n return;\n }\n sub.isReady = true;\n // if we aren't open, then this happens after we #onConnect\n if (this.#ws?.readyState === WebSocket.OPEN) {\n this.#sendSubscribeMessage();\n }\n }\n catch (error) {\n this.#logger?.error(error, \"Error in #initiateSubscribe\");\n sub.listener.onError([error]);\n }\n }\n #sendSubscribeMessage() {\n if (process.env.NODE_ENV !== \"production\") {\n this.#logger?.trace(\"#sendSubscribeMessage()\");\n }\n // If two calls to `.subscribe()` happen at once (or if the connection is reset),\n // we may have multiple subscriptions that don't have a subscriptionId yet,\n // so we filter those out.\n const readySubs = [...this.#subscriptions.values()].filter(isReady);\n if (readySubs.length === 0) {\n if (process.env.NODE_ENV !== \"production\") {\n this.#logger?.trace(\"#sendSubscribeMessage(): aborting due to no ready subscriptions\");\n }\n return;\n }\n // Assumes the node 18 crypto fallback to globalThis in `subscribe` has happened.\n const id = crypto.randomUUID();\n // responses come back as an array of subIds, so we need to know the sources\n this.#pendingSubscriptions.set(id, readySubs);\n // every subscribe message \"overwrites\" the previous ones that are not\n // re-included, so we have to reconstitute the entire list of subscriptions\n const subscribe = {\n id,\n requests: readySubs.map(({ objectSet, requestedProperties, requestedReferenceProperties }) => {\n return {\n objectSet: objectSet,\n propertySet: requestedProperties,\n referenceSet: requestedReferenceProperties,\n };\n }),\n };\n if (process.env.NODE_ENV !== \"production\") {\n this.#logger?.trace({ payload: subscribe }, \"sending subscribe message\");\n }\n this.#ws?.send(JSON.stringify(subscribe));\n }\n #unsubscribe(sub, newStatus = \"done\") {\n if (subscriptionIsDone(sub)) {\n // if we are already done, we don't need to do anything\n return;\n }\n sub.status = newStatus;\n // make sure listeners do nothing now\n sub.listener = fillOutListener({});\n this.#subscriptions.delete(sub.subscriptionId);\n this.#sendSubscribeMessage();\n // If we have no more subscriptions, we can disconnect the websocket\n // however we should wait a bit to see if we get any more subscriptions.\n // For example, when switching between react views, you may unsubscribe\n // in the old view and subscribe in the new view. We don't need to re-establish\n // the websocket connection in that case.\n if (this.#maybeDisconnectTimeout) {\n // We reset the timeout on every unsubscribe so its always at least 15s from\n // the last time we are empty. E.g.:\n // - 0s: Subscribe(A)\n // - 10s: Unsubscribe(A)\n // - 11s: Subscribe(B)\n // - 20s: Unsubscribe(B)\n // If we do not clear out the timeout we would disconnect at 25s but that would only be\n // 5s after the last subscription was removed instead of at 35s for the desired 15s.\n clearTimeout(this.#maybeDisconnectTimeout);\n }\n this.#maybeDisconnectTimeout = setTimeout(() => {\n this.#maybeDisconnectTimeout = undefined;\n if (this.#subscriptions.size === 0) {\n this.#cycleWebsocket();\n }\n }, 15_000 /* ms */);\n }\n async #ensureWebsocket() {\n if (this.#ws == null) {\n const { baseUrl, tokenProvider } = this.#client;\n const base = new URL(baseUrl);\n const url = `wss://${base.host}/api/v2/ontologySubscriptions/ontologies/${this.#client.ontologyRid}/streamSubscriptions`;\n const token = await tokenProvider();\n // tokenProvider is async, there could potentially be a race to create the websocket.\n // Only the first call to reach here will find a null this.#ws, the rest will bail out\n if (this.#ws == null) {\n // TODO this can probably be exponential backoff with jitter\n // don't reconnect more quickly than MINIMUM_RECONNECT_DELAY\n const nextConnectTime = (this.#lastWsConnect ?? 0)\n + this.MINIMUM_RECONNECT_DELAY_MS;\n if (nextConnectTime > Date.now()) {\n await new Promise((resolve) => {\n setTimeout(resolve, nextConnectTime - Date.now());\n });\n }\n this.#lastWsConnect = Date.now();\n // we again may have lost the race after our minimum backoff time\n if (this.#ws == null) {\n if (process.env.NODE_ENV !== \"production\") {\n this.#logger?.trace(\"Creating websocket\");\n }\n this.#ws = new WebSocket(url, [`Bearer-${token}`]);\n this.#ws.addEventListener(\"close\", this.#onClose);\n this.#ws.addEventListener(\"message\", this.#onMessage);\n this.#ws.addEventListener(\"open\", this.#onOpen);\n }\n }\n // Allow await-ing the websocket open event if it isn't open already.\n // This needs to happen even for callers that didn't just create this.#ws\n if (this.#ws.readyState === WebSocket.CONNECTING) {\n const ws = this.#ws;\n return new Promise((resolve, reject) => {\n function cleanup() {\n ws.removeEventListener(\"open\", open);\n ws.removeEventListener(\"error\", error);\n ws.removeEventListener(\"close\", cleanup);\n }\n function open() {\n cleanup();\n resolve();\n }\n function error(evt) {\n cleanup();\n reject(evt);\n }\n ws.addEventListener(\"open\", open);\n ws.addEventListener(\"error\", error);\n ws.addEventListener(\"close\", cleanup);\n });\n }\n }\n }\n #onOpen = () => {\n // resubscribe all of the listeners\n this.#sendSubscribeMessage();\n };\n #onMessage = async (message) => {\n const data = JSON.parse(message.data.toString());\n if (process.env.NODE_ENV !== \"production\") {\n this.#logger?.trace({ payload: data }, \"received message from ws\");\n }\n switch (data.type) {\n case \"objectSetChanged\":\n return this.#handleMessage_objectSetChanged(data);\n case \"refreshObjectSet\":\n return this.#handleMessage_refreshObjectSet(data);\n case \"subscribeResponses\":\n return this.#handleMessage_subscribeResponses(data);\n case \"subscriptionClosed\": {\n return this.#handleMessage_subscriptionClosed(data);\n }\n default:\n const _ = data;\n invariant(false, \"Unexpected message type\");\n }\n };\n #handleMessage_objectSetChanged = async (payload) => {\n const sub = this.#subscriptions.get(payload.id);\n if (sub == null)\n return;\n const objectUpdates = payload.updates.filter((update) => update.type === \"object\");\n const referenceUpdates = payload.updates.filter((update) => update.type === \"reference\");\n const osdkObjectsWithReferenceUpdates = await Promise.all(referenceUpdates.map(async (o) => {\n const osdkObjectArray = await convertWireToOsdkObjects(this.#client, [{\n __apiName: o.objectType,\n __primaryKey: o.primaryKey[sub.primaryKeyPropertyName],\n ...o.primaryKey,\n [o.property]: o.value,\n }], undefined);\n const singleOsdkObject = osdkObjectArray[0] ?? undefined;\n return singleOsdkObject != null\n ? {\n object: singleOsdkObject,\n state: \"ADDED_OR_UPDATED\",\n }\n : undefined;\n }));\n for (const osdkObject of osdkObjectsWithReferenceUpdates) {\n if (osdkObject != null) {\n sub.listener.onChange?.(osdkObject);\n }\n }\n const osdkObjects = await Promise.all(objectUpdates.map(async (o) => {\n const keysToDelete = Object.keys(o.object).filter((key) => sub.requestedReferenceProperties.includes(key));\n for (const key of keysToDelete) {\n delete o.object[key];\n }\n const osdkObjectArray = await convertWireToOsdkObjects(this.#client, [o.object], undefined);\n const singleOsdkObject = osdkObjectArray[0] ?? undefined;\n return singleOsdkObject != null\n ? {\n object: singleOsdkObject,\n state: o.state,\n }\n : undefined;\n }));\n for (const osdkObject of osdkObjects) {\n if (osdkObject != null) {\n sub.listener.onChange?.(osdkObject);\n }\n }\n };\n #handleMessage_refreshObjectSet = (payload) => {\n const sub = this.#subscriptions.get(payload.id);\n invariant(sub, `Expected subscription id ${payload.id}`);\n sub.listener.onOutOfDate();\n };\n #handleMessage_subscribeResponses = (payload) => {\n const { id, responses } = payload;\n const subs = this.#pendingSubscriptions.get(id);\n invariant(subs, `should have a pending subscription for ${id}`);\n this.#pendingSubscriptions.delete(id);\n for (let i = 0; i < responses.length; i++) {\n const sub = subs[i];\n const response = responses[i];\n switch (response.type) {\n case \"error\":\n sub.listener.onError(response.errors);\n this.#unsubscribe(sub, \"error\");\n break;\n case \"qos\":\n // the server has requested that we tear down our websocket and reconnect to help load balance\n this.#cycleWebsocket();\n break;\n case \"success\":\n // `\"preparing\"` should only be the status on an initial subscribe.\n const shouldFireOutOfDate = sub.status === \"expired\"\n || sub.status === \"reconnecting\";\n if (process.env.NODE_ENV !== \"production\") {\n this.#logger?.trace({ shouldFireOutOfDate }, \"success\");\n }\n sub.status = \"subscribed\";\n if (sub.subscriptionId !== response.id) {\n // might be the temporary one\n this.#subscriptions.delete(sub.subscriptionId);\n sub.subscriptionId = response.id;\n this.#subscriptions.set(sub.subscriptionId, sub); // future messages come by this subId\n }\n if (shouldFireOutOfDate)\n sub.listener.onOutOfDate();\n else\n sub.listener.onSuccessfulSubscription();\n break;\n default:\n const _ = response;\n sub.listener.onError(response);\n }\n }\n };\n #handleMessage_subscriptionClosed(payload) {\n const sub = this.#subscriptions.get(payload.id);\n invariant(sub, `Expected subscription id ${payload.id}`);\n sub.listener.onError([payload.cause]);\n this.#unsubscribe(sub, \"error\");\n }\n #onClose = (event) => {\n if (process.env.NODE_ENV !== \"production\") {\n this.#logger?.trace({ event }, \"Received close event from ws\", event);\n }\n // TODO we should probably throttle this so we don't abuse the backend\n this.#cycleWebsocket();\n };\n #cycleWebsocket = () => {\n if (this.#ws) {\n this.#ws.removeEventListener(\"open\", this.#onOpen);\n this.#ws.removeEventListener(\"message\", this.#onMessage);\n this.#ws.removeEventListener(\"close\", this.#onClose);\n if (this.#ws.readyState !== WebSocket.CLOSING\n && this.#ws.readyState !== WebSocket.CLOSED) {\n this.#ws.close();\n }\n this.#ws = undefined;\n }\n // if we have any listeners that are still depending on us, go ahead and reopen the websocket\n if (this.#subscriptions.size > 0) {\n if (process.env.NODE_ENV !== \"production\") {\n for (const s of this.#subscriptions.values()) {\n invariant(s.status !== \"done\" && s.status !== \"error\", \"should not have done/error subscriptions still\");\n }\n }\n for (const s of this.#subscriptions.values()) {\n if (s.status === \"subscribed\")\n s.status = \"reconnecting\";\n }\n this.#ensureWebsocket();\n }\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,eAAe;AACrC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,wBAAwB,QAAQ,uCAAuC;AAChF,MAAMC,0BAA0B,GAAG,CAAC,GAAG,IAAI;AAC3C;AACA,SAASC,SAASA,CAAA,EAAG,CAAE;AACvB;AACA;AACA;AACA,SAASC,eAAeA,CAAC;EAAEC,QAAQ,GAAGF,SAAS;EAAEG,OAAO,GAAGH,SAAS;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