@osdk/client 2.2.0-beta.2 → 2.2.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 +25 -0
- package/build/browser/Logger.js.map +1 -1
- package/build/browser/createClient.js +3 -3
- package/build/browser/createClient.js.map +1 -1
- package/build/browser/observable/ObservableClient.js.map +1 -1
- package/build/browser/observable/internal/ActionApplication.js +102 -0
- package/build/browser/observable/internal/ActionApplication.js.map +1 -0
- package/build/browser/observable/internal/CacheKey.js +38 -1
- package/build/browser/observable/internal/CacheKey.js.map +1 -1
- package/build/browser/observable/internal/CacheKeys.js +4 -4
- package/build/browser/observable/internal/CacheKeys.js.map +1 -1
- package/build/browser/observable/internal/ChangedObjects.js +24 -1
- package/build/browser/observable/internal/ChangedObjects.js.map +1 -1
- package/build/browser/observable/internal/Layer.js +3 -3
- package/build/browser/observable/internal/Layer.js.map +1 -1
- package/build/browser/observable/internal/ListQuery.js +188 -66
- package/build/browser/observable/internal/ListQuery.js.map +1 -1
- package/build/browser/observable/internal/ObjectQuery.js +16 -3
- package/build/browser/observable/internal/ObjectQuery.js.map +1 -1
- package/build/browser/observable/internal/ObservableClientImpl.js +2 -2
- package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/browser/observable/internal/OptimisticJob.js +30 -29
- package/build/browser/observable/internal/OptimisticJob.js.map +1 -1
- package/build/browser/observable/internal/Query.js +42 -2
- package/build/browser/observable/internal/Query.js.map +1 -1
- package/build/browser/observable/internal/Store.js +259 -126
- package/build/browser/observable/internal/Store.js.map +1 -1
- package/build/browser/observable/internal/Store.test.js +416 -76
- package/build/browser/observable/internal/Store.test.js.map +1 -1
- package/build/browser/observable/internal/testUtils.js +142 -6
- package/build/browser/observable/internal/testUtils.js.map +1 -1
- package/build/browser/util/UserAgent.js +1 -1
- package/build/cjs/index.cjs +4 -4
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.cjs +657 -268
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +13 -4
- package/build/esm/Logger.js.map +1 -1
- package/build/esm/createClient.js +3 -3
- package/build/esm/createClient.js.map +1 -1
- package/build/esm/observable/ObservableClient.js.map +1 -1
- package/build/esm/observable/internal/ActionApplication.js +102 -0
- package/build/esm/observable/internal/ActionApplication.js.map +1 -0
- package/build/esm/observable/internal/CacheKey.js +38 -1
- package/build/esm/observable/internal/CacheKey.js.map +1 -1
- package/build/esm/observable/internal/CacheKeys.js +4 -4
- package/build/esm/observable/internal/CacheKeys.js.map +1 -1
- package/build/esm/observable/internal/ChangedObjects.js +24 -1
- package/build/esm/observable/internal/ChangedObjects.js.map +1 -1
- package/build/esm/observable/internal/Layer.js +3 -3
- package/build/esm/observable/internal/Layer.js.map +1 -1
- package/build/esm/observable/internal/ListQuery.js +188 -66
- package/build/esm/observable/internal/ListQuery.js.map +1 -1
- package/build/esm/observable/internal/ObjectQuery.js +16 -3
- package/build/esm/observable/internal/ObjectQuery.js.map +1 -1
- package/build/esm/observable/internal/ObservableClientImpl.js +2 -2
- package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
- package/build/esm/observable/internal/OptimisticJob.js +30 -29
- package/build/esm/observable/internal/OptimisticJob.js.map +1 -1
- package/build/esm/observable/internal/Query.js +42 -2
- package/build/esm/observable/internal/Query.js.map +1 -1
- package/build/esm/observable/internal/Store.js +259 -126
- package/build/esm/observable/internal/Store.js.map +1 -1
- package/build/esm/observable/internal/Store.test.js +416 -76
- package/build/esm/observable/internal/Store.test.js.map +1 -1
- package/build/esm/observable/internal/testUtils.js +142 -6
- package/build/esm/observable/internal/testUtils.js.map +1 -1
- package/build/esm/util/UserAgent.js +1 -1
- package/build/types/Logger.d.ts +1 -2
- package/build/types/Logger.d.ts.map +1 -1
- package/build/types/createClient.d.ts.map +1 -1
- package/build/types/observable/ObservableClient.d.ts +10 -3
- package/build/types/observable/ObservableClient.d.ts.map +1 -1
- package/build/types/observable/internal/ActionApplication.d.ts +9 -0
- package/build/types/observable/internal/ActionApplication.d.ts.map +1 -0
- package/build/types/observable/internal/CacheKeys.d.ts +2 -1
- package/build/types/observable/internal/CacheKeys.d.ts.map +1 -1
- package/build/types/observable/internal/ChangedObjects.d.ts +6 -2
- package/build/types/observable/internal/ChangedObjects.d.ts.map +1 -1
- package/build/types/observable/internal/Layer.d.ts +1 -1
- package/build/types/observable/internal/Layer.d.ts.map +1 -1
- package/build/types/observable/internal/ListQuery.d.ts +18 -17
- package/build/types/observable/internal/ListQuery.d.ts.map +1 -1
- package/build/types/observable/internal/ObjectQuery.d.ts +3 -3
- package/build/types/observable/internal/ObjectQuery.d.ts.map +1 -1
- package/build/types/observable/internal/OptimisticJob.d.ts +2 -2
- package/build/types/observable/internal/OptimisticJob.d.ts.map +1 -1
- package/build/types/observable/internal/Query.d.ts +6 -5
- package/build/types/observable/internal/Query.d.ts.map +1 -1
- package/build/types/observable/internal/Store.d.ts +47 -19
- package/build/types/observable/internal/Store.d.ts.map +1 -1
- package/build/types/observable/internal/testUtils.d.ts +13 -3
- package/build/types/observable/internal/testUtils.d.ts.map +1 -1
- package/package.json +7 -6
package/build/esm/Logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.js","names":[],"sources":["Logger.ts"],"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 */\n\nexport interface Logger {\n trace: LogFn;\n debug: LogFn;\n fatal: LogFn;\n error: LogFn;\n warn: LogFn;\n info: LogFn;\n\n isLevelEnabled(level: string): boolean;\n\n child(\n bindings: Record<string, any>,\n options?: { level?: string; msgPrefix?: string },\n ): Logger;\n}\n\
|
|
1
|
+
{"version":3,"file":"Logger.js","names":[],"sources":["Logger.ts"],"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 */\n\nexport interface Logger {\n trace: LogFn;\n debug: LogFn;\n fatal: LogFn;\n error: LogFn;\n warn: LogFn;\n info: LogFn;\n\n isLevelEnabled(level: string): boolean;\n\n child(\n bindings: Record<string, any>,\n options?: { level?: string; msgPrefix?: string },\n ): Logger;\n}\n\nexport interface LogFn {\n (obj: unknown, msg?: string, ...args: any[]): void;\n (msg: string, ...args: any[]): void;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -94,10 +94,10 @@ baseUrl, ontologyRid, tokenProvider, options = undefined, fetchFn = fetch) {
|
|
|
94
94
|
const {
|
|
95
95
|
data,
|
|
96
96
|
fileName,
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
objectType,
|
|
98
|
+
propertyType
|
|
99
99
|
} = args;
|
|
100
|
-
return await OntologiesV2.MediaReferenceProperties.upload(clientCtx, await clientCtx.ontologyRid,
|
|
100
|
+
return await OntologiesV2.MediaReferenceProperties.upload(clientCtx, await clientCtx.ontologyRid, objectType.apiName, propertyType, data, {
|
|
101
101
|
mediaItemPath: fileName,
|
|
102
102
|
preview: true
|
|
103
103
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks","OntologiesV2","symbolClientContext","oldSymbolClientContext","createBulkLinksAsyncIterFactory","applyAction","additionalContext","createMinimalClient","fetchMetadataInternal","fetchSingle","createObjectSet","applyQuery","ActionInvoker","constructor","clientCtx","actionDef","bind","undefined","batchApplyAction","QueryInvoker","queryDef","executeFunction","createClientInternal","objectSetFactory","baseUrl","ontologyRid","tokenProvider","options","fetchFn","fetch","startsWith","Error","then","fetchMetadata","client","Object","defineProperties","o","type","name","getBulkLinks","fetchOneByRid","objectType","rid","createWithRid","createMediaReference","args","data","fileName","objectTypeApi","propertyTypeApi","MediaReferenceProperties","upload","mediaItemPath","preview","value","createClient"],"sources":["createClient.ts"],"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 */\n\nimport type {\n ActionDefinition,\n InterfaceDefinition,\n NullabilityAdherence,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SelectArg,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport {\n __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks,\n} from \"@osdk/api/unstable\";\nimport type { ObjectSet as WireObjectSet } from \"@osdk/foundry.ontologies\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport { symbolClientContext as oldSymbolClientContext } from \"@osdk/shared.client\";\nimport { createBulkLinksAsyncIterFactory } from \"./__unstable/createBulkLinksAsyncIterFactory.js\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport { applyAction } from \"./actions/applyAction.js\";\nimport { additionalContext, type Client } from \"./Client.js\";\nimport { createMinimalClient } from \"./createMinimalClient.js\";\nimport { fetchMetadataInternal } from \"./fetchMetadata.js\";\nimport type { Logger } from \"./Logger.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport { fetchSingle } from \"./object/fetchSingle.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nimport type { ObjectSetFactory } from \"./objectSet/ObjectSetFactory.js\";\nimport { applyQuery } from \"./queries/applyQuery.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\n\n// We import it this way to keep compatible with CJS. If we referenced the\n// value of `symbolClientContext` directly, then we would have to a dynamic import\n// in `createClientInternal` which would make it async and a break.\n// Since this is just a string in `@osdk/shared.client2` instead of a symbol,\n// we can safely perform this trick.\ntype newSymbolClientContext =\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n typeof import(\"@osdk/shared.client2\").symbolClientContext;\n\nclass ActionInvoker<Q extends ActionDefinition<any>>\n implements ActionSignatureFromDef<Q>\n{\n constructor(\n clientCtx: MinimalClient,\n actionDef: ActionDefinition<any>,\n ) {\n // We type the property as a generic function as binding `applyAction`\n // doesn't return a type thats all that useful anyway\n // The implements covers us for the most part here as this exact type doesn't\n // escape this file\n this.applyAction = applyAction.bind(undefined, clientCtx, actionDef);\n this.batchApplyAction = applyAction.bind(undefined, clientCtx, actionDef);\n }\n\n applyAction: (...args: any[]) => any;\n batchApplyAction: (...args: any[]) => any;\n}\n\nclass QueryInvoker<Q extends QueryDefinition<any>>\n implements QuerySignatureFromDef<Q>\n{\n constructor(\n clientCtx: MinimalClient,\n queryDef: QueryDefinition<any>,\n ) {\n this.executeFunction = applyQuery.bind(undefined, clientCtx, queryDef);\n }\n\n executeFunction: (...args: any[]) => any;\n}\n\n/** @internal */\nexport function createClientInternal(\n objectSetFactory: ObjectSetFactory<any, any>, // first so i can bind\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options: { logger?: Logger } | undefined = undefined,\n fetchFn: typeof globalThis.fetch = fetch,\n): Client {\n if (typeof ontologyRid === \"string\") {\n if (!ontologyRid.startsWith(\"ri.\")) {\n throw new Error(\"Invalid ontology RID\");\n }\n } else {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n ontologyRid.then((ontologyRid) => {\n if (!ontologyRid.startsWith(\"ri.\")) {\n // FIXME this promise is not await so this just shows up as an unhandled promise rejection\n throw new Error(\"Invalid ontology RID\");\n }\n });\n }\n\n const clientCtx: MinimalClient = createMinimalClient(\n { ontologyRid },\n baseUrl,\n tokenProvider,\n options,\n fetchFn,\n objectSetFactory,\n );\n\n function clientFn<\n T extends\n | ObjectOrInterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n | Experiment<\"2.0.8\">\n | Experiment<\"2.1.0\">,\n >(o: T): T extends ObjectTypeDefinition ? ObjectSet<T>\n : T extends InterfaceDefinition ? MinimalObjectSet<T>\n : T extends ActionDefinition<any> ? ActionSignatureFromDef<T>\n : T extends QueryDefinition<any> ? QuerySignatureFromDef<T>\n : T extends Experiment<\"2.0.8\"> | Experiment<\"2.1.0\">\n ? { invoke: ExperimentFns<T> }\n : never\n {\n if (o.type === \"object\" || o.type === \"interface\") {\n return objectSetFactory(o, clientCtx) as any;\n } else if (o.type === \"action\") {\n return new ActionInvoker(\n clientCtx,\n o,\n ) as (T extends ActionDefinition<any>\n // first `as` to the action definition for our \"real\" typecheck\n ? ActionSignatureFromDef<T>\n : never) as any; // then as any for dealing with the conditional return value\n } else if (o.type === \"query\") {\n return new QueryInvoker(\n clientCtx,\n o,\n ) as (T extends QueryDefinition<any> ? QuerySignatureFromDef<T>\n : never) as any;\n } else if (o.type === \"experiment\") {\n switch (o.name) {\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks.name:\n return {\n getBulkLinks: createBulkLinksAsyncIterFactory(\n clientCtx,\n ),\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid.name:\n return {\n fetchOneByRid: async <\n Q extends ObjectTypeDefinition,\n const L extends PropertyKeys<Q>,\n const R extends boolean,\n const S extends false | \"throw\" = NullabilityAdherence.Default,\n >(\n objectType: Q,\n rid: string,\n options: SelectArg<Q, L, R, S>,\n ) => {\n return await fetchSingle(\n clientCtx,\n objectType,\n options,\n createWithRid(\n rid,\n ),\n ) as Osdk<Q>;\n },\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference.name:\n return {\n createMediaReference: async (args: {\n data: Blob;\n fileName: string;\n objectTypeApi: string;\n propertyTypeApi: string;\n }) => {\n const { data, fileName, objectTypeApi, propertyTypeApi } = args;\n return await OntologiesV2.MediaReferenceProperties.upload(\n clientCtx,\n await clientCtx.ontologyRid,\n objectTypeApi,\n propertyTypeApi,\n data,\n {\n mediaItemPath: fileName,\n preview: true,\n },\n );\n },\n } as any;\n }\n\n throw new Error(\"not implemented\");\n } else {\n throw new Error(\"not implemented\");\n }\n }\n\n const fetchMetadata = fetchMetadataInternal.bind(\n undefined,\n clientCtx,\n );\n\n const symbolClientContext: newSymbolClientContext = \"__osdkClientContext\";\n\n const client: Client = Object.defineProperties<Client>(\n clientFn as Client,\n {\n [oldSymbolClientContext]: {\n value: clientCtx,\n },\n [symbolClientContext]: {\n value: clientCtx,\n },\n [additionalContext]: {\n value: clientCtx,\n },\n fetchMetadata: {\n value: fetchMetadata,\n },\n } satisfies Record<keyof Client, PropertyDescriptor>,\n );\n\n return client;\n}\n\nexport const createClient: (\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options?: {\n logger?: Logger;\n } | undefined,\n fetchFn?: typeof fetch | undefined,\n) => Client = createClientInternal.bind(\n undefined,\n createObjectSet,\n);\n\nfunction createWithRid(\n rid: string,\n) {\n const withRid: WireObjectSet = {\n type: \"static\",\n \"objects\": [rid],\n };\n\n return withRid;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA,SACEA,uDAAuD,EACvDC,gDAAgD,EAChDC,+CAA+C,QAC1C,oBAAoB;AAE3B,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AACxD,SAASC,mBAAmB,IAAIC,sBAAsB,QAAQ,qBAAqB;AACnF,SAASC,+BAA+B,QAAQ,iDAAiD;AAEjG,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,iBAAiB,QAAqB,aAAa;AAC5D,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,qBAAqB,QAAQ,oBAAoB;AAG1D,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,eAAe,QAAQ,gCAAgC;AAEhE,SAASC,UAAU,QAAQ,yBAAyB;;AAGpD;AACA;AACA;AACA;AACA;;AAKA,MAAMC,aAAa,CAEnB;EACEC,WAAWA,CACTC,SAAwB,EACxBC,SAAgC,EAChC;IACA;IACA;IACA;IACA;IACA,IAAI,CAACV,WAAW,GAAGA,WAAW,CAACW,IAAI,CAACC,SAAS,EAAEH,SAAS,EAAEC,SAAS,CAAC;IACpE,IAAI,CAACG,gBAAgB,GAAGb,WAAW,CAACW,IAAI,CAACC,SAAS,EAAEH,SAAS,EAAEC,SAAS,CAAC;EAC3E;AAIF;AAEA,MAAMI,YAAY,CAElB;EACEN,WAAWA,CACTC,SAAwB,EACxBM,QAA8B,EAC9B;IACA,IAAI,CAACC,eAAe,GAAGV,UAAU,CAACK,IAAI,CAACC,SAAS,EAAEH,SAAS,EAAEM,QAAQ,CAAC;EACxE;AAGF;;AAEA;AACA,OAAO,SAASE,oB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ACrCC,SAAS,EACTP,eACF,CAAC;AAED,SAASkC,aAAaA,CACpBD,GAAW,EACX;EAMA,OAL+B;IAC7BL,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,CAACK,GAAG;EACjB,CAAC;AAGH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"createClient.js","names":["__EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference","__EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid","__EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks","OntologiesV2","symbolClientContext","oldSymbolClientContext","createBulkLinksAsyncIterFactory","applyAction","additionalContext","createMinimalClient","fetchMetadataInternal","fetchSingle","createObjectSet","applyQuery","ActionInvoker","constructor","clientCtx","actionDef","bind","undefined","batchApplyAction","QueryInvoker","queryDef","executeFunction","createClientInternal","objectSetFactory","baseUrl","ontologyRid","tokenProvider","options","fetchFn","fetch","startsWith","Error","then","fetchMetadata","client","Object","defineProperties","o","type","name","getBulkLinks","fetchOneByRid","objectType","rid","createWithRid","createMediaReference","args","data","fileName","propertyType","MediaReferenceProperties","upload","apiName","mediaItemPath","preview","value","createClient"],"sources":["createClient.ts"],"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 */\n\nimport type {\n ActionDefinition,\n FilteredPropertyKeys,\n InterfaceDefinition,\n NullabilityAdherence,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SelectArg,\n} from \"@osdk/api\";\nimport type {\n Experiment,\n ExperimentFns,\n MinimalObjectSet,\n} from \"@osdk/api/unstable\";\nimport {\n __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid,\n __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks,\n} from \"@osdk/api/unstable\";\nimport type { ObjectSet as WireObjectSet } from \"@osdk/foundry.ontologies\";\nimport * as OntologiesV2 from \"@osdk/foundry.ontologies\";\nimport { symbolClientContext as oldSymbolClientContext } from \"@osdk/shared.client\";\nimport { createBulkLinksAsyncIterFactory } from \"./__unstable/createBulkLinksAsyncIterFactory.js\";\nimport type { ActionSignatureFromDef } from \"./actions/applyAction.js\";\nimport { applyAction } from \"./actions/applyAction.js\";\nimport { additionalContext, type Client } from \"./Client.js\";\nimport { createMinimalClient } from \"./createMinimalClient.js\";\nimport { fetchMetadataInternal } from \"./fetchMetadata.js\";\nimport type { Logger } from \"./Logger.js\";\nimport type { MinimalClient } from \"./MinimalClientContext.js\";\nimport { fetchSingle } from \"./object/fetchSingle.js\";\nimport { createObjectSet } from \"./objectSet/createObjectSet.js\";\nimport type { ObjectSetFactory } from \"./objectSet/ObjectSetFactory.js\";\nimport { applyQuery } from \"./queries/applyQuery.js\";\nimport type { QuerySignatureFromDef } from \"./queries/types.js\";\n\n// We import it this way to keep compatible with CJS. If we referenced the\n// value of `symbolClientContext` directly, then we would have to a dynamic import\n// in `createClientInternal` which would make it async and a break.\n// Since this is just a string in `@osdk/shared.client2` instead of a symbol,\n// we can safely perform this trick.\ntype newSymbolClientContext =\n // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n typeof import(\"@osdk/shared.client2\").symbolClientContext;\n\nclass ActionInvoker<Q extends ActionDefinition<any>>\n implements ActionSignatureFromDef<Q>\n{\n constructor(\n clientCtx: MinimalClient,\n actionDef: ActionDefinition<any>,\n ) {\n // We type the property as a generic function as binding `applyAction`\n // doesn't return a type thats all that useful anyway\n // The implements covers us for the most part here as this exact type doesn't\n // escape this file\n this.applyAction = applyAction.bind(undefined, clientCtx, actionDef);\n this.batchApplyAction = applyAction.bind(undefined, clientCtx, actionDef);\n }\n\n applyAction: (...args: any[]) => any;\n batchApplyAction: (...args: any[]) => any;\n}\n\nclass QueryInvoker<Q extends QueryDefinition<any>>\n implements QuerySignatureFromDef<Q>\n{\n constructor(\n clientCtx: MinimalClient,\n queryDef: QueryDefinition<any>,\n ) {\n this.executeFunction = applyQuery.bind(undefined, clientCtx, queryDef);\n }\n\n executeFunction: (...args: any[]) => any;\n}\n\n/** @internal */\nexport function createClientInternal(\n objectSetFactory: ObjectSetFactory<any, any>, // first so i can bind\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options: { logger?: Logger } | undefined = undefined,\n fetchFn: typeof globalThis.fetch = fetch,\n): Client {\n if (typeof ontologyRid === \"string\") {\n if (!ontologyRid.startsWith(\"ri.\")) {\n throw new Error(\"Invalid ontology RID\");\n }\n } else {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n ontologyRid.then((ontologyRid) => {\n if (!ontologyRid.startsWith(\"ri.\")) {\n // FIXME this promise is not await so this just shows up as an unhandled promise rejection\n throw new Error(\"Invalid ontology RID\");\n }\n });\n }\n\n const clientCtx: MinimalClient = createMinimalClient(\n { ontologyRid },\n baseUrl,\n tokenProvider,\n options,\n fetchFn,\n objectSetFactory,\n );\n\n function clientFn<\n T extends\n | ObjectOrInterfaceDefinition\n | ActionDefinition<any>\n | QueryDefinition<any>\n | Experiment<\"2.0.8\">\n | Experiment<\"2.1.0\">,\n >(o: T): T extends ObjectTypeDefinition ? ObjectSet<T>\n : T extends InterfaceDefinition ? MinimalObjectSet<T>\n : T extends ActionDefinition<any> ? ActionSignatureFromDef<T>\n : T extends QueryDefinition<any> ? QuerySignatureFromDef<T>\n : T extends Experiment<\"2.0.8\"> | Experiment<\"2.1.0\">\n ? { invoke: ExperimentFns<T> }\n : never\n {\n if (o.type === \"object\" || o.type === \"interface\") {\n return objectSetFactory(o, clientCtx) as any;\n } else if (o.type === \"action\") {\n return new ActionInvoker(\n clientCtx,\n o,\n ) as (T extends ActionDefinition<any>\n // first `as` to the action definition for our \"real\" typecheck\n ? ActionSignatureFromDef<T>\n : never) as any; // then as any for dealing with the conditional return value\n } else if (o.type === \"query\") {\n return new QueryInvoker(\n clientCtx,\n o,\n ) as (T extends QueryDefinition<any> ? QuerySignatureFromDef<T>\n : never) as any;\n } else if (o.type === \"experiment\") {\n switch (o.name) {\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__getBulkLinks.name:\n return {\n getBulkLinks: createBulkLinksAsyncIterFactory(\n clientCtx,\n ),\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__fetchOneByRid.name:\n return {\n fetchOneByRid: async <\n Q extends ObjectTypeDefinition,\n const L extends PropertyKeys<Q>,\n const R extends boolean,\n const S extends false | \"throw\" = NullabilityAdherence.Default,\n >(\n objectType: Q,\n rid: string,\n options: SelectArg<Q, L, R, S>,\n ) => {\n return await fetchSingle(\n clientCtx,\n objectType,\n options,\n createWithRid(\n rid,\n ),\n ) as Osdk<Q>;\n },\n } as any;\n case __EXPERIMENTAL__NOT_SUPPORTED_YET__createMediaReference.name:\n return {\n createMediaReference: async <\n Q extends ObjectTypeDefinition,\n const L extends FilteredPropertyKeys<Q, \"mediaReference\">,\n >(args: {\n data: Blob;\n fileName: string;\n objectType: Q;\n propertyType: L;\n }) => {\n const { data, fileName, objectType, propertyType } = args;\n return await OntologiesV2.MediaReferenceProperties.upload(\n clientCtx,\n await clientCtx.ontologyRid,\n objectType.apiName,\n propertyType as string,\n data,\n {\n mediaItemPath: fileName,\n preview: true,\n },\n );\n },\n } as any;\n }\n\n throw new Error(\"not implemented\");\n } else {\n throw new Error(\"not implemented\");\n }\n }\n\n const fetchMetadata = fetchMetadataInternal.bind(\n undefined,\n clientCtx,\n );\n\n const symbolClientContext: newSymbolClientContext = \"__osdkClientContext\";\n\n const client: Client = Object.defineProperties<Client>(\n clientFn as Client,\n {\n [oldSymbolClientContext]: {\n value: clientCtx,\n },\n [symbolClientContext]: {\n value: clientCtx,\n },\n [additionalContext]: {\n value: clientCtx,\n },\n fetchMetadata: {\n value: fetchMetadata,\n },\n } satisfies Record<keyof Client, PropertyDescriptor>,\n );\n\n return client;\n}\n\nexport const createClient: (\n baseUrl: string,\n ontologyRid: string | Promise<string>,\n tokenProvider: () => Promise<string>,\n options?: {\n logger?: Logger;\n } | undefined,\n fetchFn?: typeof fetch | undefined,\n) => Client = createClientInternal.bind(\n undefined,\n createObjectSet,\n);\n\nfunction createWithRid(\n rid: string,\n) {\n const withRid: WireObjectSet = {\n type: \"static\",\n \"objects\": [rid],\n };\n\n return withRid;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoBA,SACEA,uDAAuD,EACvDC,gDAAgD,EAChDC,+CAA+C,QAC1C,oBAAoB;AAE3B,OAAO,KAAKC,YAAY,MAAM,0BAA0B;AACxD,SAASC,mBAAmB,IAAIC,sBAAsB,QAAQ,qBAAqB;AACnF,SAASC,+BAA+B,QAAQ,iDAAiD;AAEjG,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,iBAAiB,QAAqB,aAAa;AAC5D,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,qBAAqB,QAAQ,oBAAoB;AAG1D,SAASC,WAAW,QAAQ,yBAAyB;AACrD,SAASC,eAAe,QAAQ,gCAAgC;AAEhE,SAASC,UAAU,QAAQ,yBAAyB;;AAGpD;AACA;AACA;AACA;AACA;;AAKA,MAAMC,aAAa,CAEnB;EACEC,WAAWA,CACTC,SAAwB,EACxBC,SAAgC,EAChC;IACA;IACA;IACA;IACA;IACA,IAAI,CAACV,WAAW,GAAGA,WAAW,CAACW,IAAI,CAACC,SAAS,EAAEH,SAAS,EAAEC,SAAS,CAAC;IACpE,IAAI,CAACG,gBAAgB,GAAGb,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BoD,KAAK,EAAEzC;IACT,CAAC;IACD,CARgD,qBAAqB,GAQ9C;MACrByC,KAAK,EAAEzC;IACT,CAAC;IACD,CAACR,iBAAiB,GAAG;MACnBiD,KAAK,EAAEzC;IACT,CAAC;IACDmB,aAAa,EAAE;MACbsB,KAAK,EAAEtB;IACT;EACF,CACF,CAAC;EAED,OAAOC,MAAM;AACf;AAEA,OAAO,MAAMsB,YAQF,GAAGlC,oBAAoB,CAACN,IAAI,CACrCC,SAAS,EACTP,eACF,CAAC;AAED,SAASkC,aAAaA,CACpBD,GAAW,EACX;EAMA,OAL+B;IAC7BL,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,CAACK,GAAG;EACjB,CAAC;AAGH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableClient.js","names":["ObservableClientImpl","Store","ObservableClient","createObservableClient","client"],"sources":["ObservableClient.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ObjectTypeDefinition,\n PrimaryKeyType,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/api\";\nimport type { ActionSignatureFromDef } from \"../actions/applyAction.js\";\nimport type { Client } from \"../Client.js\";\nimport type { Canonical } from \"./internal/Canonical.js\";\nimport { ObservableClientImpl } from \"./internal/ObservableClientImpl.js\";\nimport { Store } from \"./internal/Store.js\";\nimport type { ListPayload } from \"./ListPayload.js\";\nimport type { ObjectPayload } from \"./ObjectPayload.js\";\nimport type { OptimisticBuilder } from \"./OptimisticBuilder.js\";\nimport type { SubFn } from \"./types.js\";\n\nexport type Status = \"init\" | \"loading\" | \"loaded\" | \"error\";\n\nexport namespace ObservableClient {\n export interface ApplyActionOptions {\n optimisticUpdate?: (ctx: OptimisticBuilder) => void;\n }\n}\nexport interface
|
|
1
|
+
{"version":3,"file":"ObservableClient.js","names":["ObservableClientImpl","Store","ObservableClient","createObservableClient","client"],"sources":["ObservableClient.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ObjectTypeDefinition,\n PrimaryKeyType,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/api\";\nimport type { ActionSignatureFromDef } from \"../actions/applyAction.js\";\nimport type { Client } from \"../Client.js\";\nimport type { Canonical } from \"./internal/Canonical.js\";\nimport { ObservableClientImpl } from \"./internal/ObservableClientImpl.js\";\nimport { Store } from \"./internal/Store.js\";\nimport type { ListPayload } from \"./ListPayload.js\";\nimport type { ObjectPayload } from \"./ObjectPayload.js\";\nimport type { OptimisticBuilder } from \"./OptimisticBuilder.js\";\nimport type { SubFn } from \"./types.js\";\n\nexport type Status = \"init\" | \"loading\" | \"loaded\" | \"error\";\n\nexport namespace ObservableClient {\n export interface ApplyActionOptions {\n optimisticUpdate?: (ctx: OptimisticBuilder) => void;\n }\n}\n\nexport interface CommonObserveOptions {\n dedupeInterval?: number;\n}\n\nexport interface ObserveOptions {\n mode?: \"offline\" | \"force\";\n}\n\nexport interface ObserveObjectOptions<T extends ObjectTypeDefinition>\n extends ObserveOptions\n{\n select?: PropertyKeys<T>[];\n}\n\nexport type OrderBy<Q extends ObjectTypeDefinition> = {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\" | undefined;\n};\n\nexport interface ObserveListOptions<Q extends ObjectTypeDefinition>\n extends CommonObserveOptions, ObserveOptions\n{\n objectType: Q[\"apiName\"] | Q;\n where?: WhereClause<Q>;\n pageSize?: number;\n orderBy?: OrderBy<Q>;\n invalidationMode?: \"in-place\" | \"wait\" | \"reset\";\n expectedLength?: number;\n streamUpdates?: boolean;\n}\n\nexport interface ObservableClient {\n observeObject<T extends ObjectTypeDefinition>(\n apiName: T[\"apiName\"] | T,\n pk: PrimaryKeyType<T>,\n options: ObserveOptions,\n subFn: SubFn<ObjectPayload>,\n ): Unsubscribable;\n\n observeList<T extends ObjectTypeDefinition>(\n options: ObserveListOptions<T>,\n subFn: SubFn<ListPayload>,\n ): Unsubscribable;\n\n applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n opts?: ObservableClient.ApplyActionOptions,\n ) => Promise<unknown>;\n\n canonicalizeWhereClause: <T extends ObjectTypeDefinition>(\n where: WhereClause<T>,\n ) => Canonical<WhereClause<T>>;\n}\n\nexport function createObservableClient(client: Client): ObservableClient {\n return new ObservableClientImpl(new Store(client));\n}\n\nexport interface Unsubscribable {\n unsubscribe: () => void;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,SAASA,oBAAoB,QAAQ,oCAAoC;AACzE,SAASC,KAAK,QAAQ,qBAAqB;AAAC,WAQ3BC,gBAAgB;AA4DjC,OAAO,SAASC,sBAAsBA,CAACC,MAAc,EAAoB;EACvE,OAAO,IAAIJ,oBAAoB,CAAC,IAAIC,KAAK,CAACG,MAAM,CAAC,CAAC;AACpD","ignoreList":[]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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 { delay } from "msw";
|
|
18
|
+
import { createChangedObjects } from "./ChangedObjects.js";
|
|
19
|
+
import { runOptimisticJob } from "./OptimisticJob.js";
|
|
20
|
+
const ACTION_DELAY = process.env.NODE_ENV === "production" ? 0 : 1000;
|
|
21
|
+
export class ActionApplication {
|
|
22
|
+
constructor(store) {
|
|
23
|
+
this.store = store;
|
|
24
|
+
}
|
|
25
|
+
applyAction = (action, args, {
|
|
26
|
+
optimisticUpdate
|
|
27
|
+
} = {}) => {
|
|
28
|
+
const removeOptimisticResult = runOptimisticJob(this.store, optimisticUpdate);
|
|
29
|
+
return (async () => {
|
|
30
|
+
try {
|
|
31
|
+
// The types for client get confused when we dynamically applyAction so we
|
|
32
|
+
// have to deal with the `any` here and force cast it to what it should be.
|
|
33
|
+
// TODO: Update the types so this doesn't happen!
|
|
34
|
+
|
|
35
|
+
const actionResults = await this.store.client(action).applyAction(args, {
|
|
36
|
+
$returnEdits: true
|
|
37
|
+
});
|
|
38
|
+
if (ACTION_DELAY > 0) {
|
|
39
|
+
// eslint-disable-next-line no-console
|
|
40
|
+
console.log("action done, pausing");
|
|
41
|
+
await delay(ACTION_DELAY);
|
|
42
|
+
// eslint-disable-next-line no-console
|
|
43
|
+
console.log("action done, pausing done");
|
|
44
|
+
}
|
|
45
|
+
await this.#invalidateActionEditResponse(actionResults);
|
|
46
|
+
return actionResults;
|
|
47
|
+
} finally {
|
|
48
|
+
if (process.env.NODE_ENV !== "production") {
|
|
49
|
+
this.store.logger?.debug("optimistic action complete; remove the results");
|
|
50
|
+
}
|
|
51
|
+
// make sure this happens even if the action fails
|
|
52
|
+
await removeOptimisticResult();
|
|
53
|
+
}
|
|
54
|
+
})();
|
|
55
|
+
};
|
|
56
|
+
#invalidateActionEditResponse = async value => {
|
|
57
|
+
const typesToInvalidate = new Set();
|
|
58
|
+
let changes;
|
|
59
|
+
if (value.type === "edits") {
|
|
60
|
+
const promisesToWait = [];
|
|
61
|
+
// TODO we need an backend update for deletes
|
|
62
|
+
for (const obj of value.modifiedObjects) {
|
|
63
|
+
promisesToWait.push(this.store.invalidateObject(obj.objectType, obj.primaryKey));
|
|
64
|
+
}
|
|
65
|
+
for (const obj of value.addedObjects) {
|
|
66
|
+
promisesToWait.push(this.store.invalidateObject(obj.objectType, obj.primaryKey));
|
|
67
|
+
typesToInvalidate.add(obj.objectType);
|
|
68
|
+
}
|
|
69
|
+
await Promise.all(promisesToWait);
|
|
70
|
+
|
|
71
|
+
// the action invocation just gives back object ids,
|
|
72
|
+
// so we don't want to build the changes object
|
|
73
|
+
// until we have up to date values.
|
|
74
|
+
changes = this.#changesFromActionEditResponse(value);
|
|
75
|
+
|
|
76
|
+
// updates `changes` in place
|
|
77
|
+
await this.store.maybeRevalidateLists(changes);
|
|
78
|
+
} else {
|
|
79
|
+
for (const apiName of value.editedObjectTypes) {
|
|
80
|
+
typesToInvalidate.add(apiName.toString());
|
|
81
|
+
await this.store.invalidateObjectType(apiName, changes);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return value;
|
|
85
|
+
};
|
|
86
|
+
#changesFromActionEditResponse = value => {
|
|
87
|
+
const changes = createChangedObjects();
|
|
88
|
+
for (const changeType of ["addedObjects", "modifiedObjects"]) {
|
|
89
|
+
for (const {
|
|
90
|
+
objectType,
|
|
91
|
+
primaryKey
|
|
92
|
+
} of value[changeType] ?? []) {
|
|
93
|
+
const obj = this.store.getObject(objectType, primaryKey);
|
|
94
|
+
if (obj) {
|
|
95
|
+
changes[changeType].set(objectType, obj);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return changes;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=ActionApplication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionApplication.js","names":["delay","createChangedObjects","runOptimisticJob","ACTION_DELAY","process","env","NODE_ENV","ActionApplication","constructor","store","applyAction","action","args","optimisticUpdate","removeOptimisticResult","actionResults","client","$returnEdits","console","log","invalidateActionEditResponse","logger","debug","value","typesToInvalidate","Set","changes","type","promisesToWait","obj","modifiedObjects","push","invalidateObject","objectType","primaryKey","addedObjects","add","Promise","all","changesFromActionEditResponse","maybeRevalidateLists","apiName","editedObjectTypes","toString","invalidateObjectType","changeType","getObject","set"],"sources":["ActionApplication.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ActionDefinition, ActionEditResponse } from \"@osdk/api\";\nimport { delay } from \"msw\";\nimport type { ActionSignatureFromDef } from \"../../actions/applyAction.js\";\n\nimport { type Changes, createChangedObjects } from \"./ChangedObjects.js\";\nimport { runOptimisticJob } from \"./OptimisticJob.js\";\nimport type { Store } from \"./Store.js\";\n\nconst ACTION_DELAY = process.env.NODE_ENV === \"production\" ? 0 : 1000;\n\nexport class ActionApplication {\n constructor(private store: Store) {}\n\n applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n opts?: Store.ApplyActionOptions,\n ) => Promise<unknown> = (action, args, { optimisticUpdate } = {}) => {\n const removeOptimisticResult = runOptimisticJob(\n this.store,\n optimisticUpdate,\n );\n return (async () => {\n try {\n // The types for client get confused when we dynamically applyAction so we\n // have to deal with the `any` here and force cast it to what it should be.\n // TODO: Update the types so this doesn't happen!\n\n const actionResults: ActionEditResponse = await this.store.client(\n action,\n ).applyAction(args as any, { $returnEdits: true });\n\n if (ACTION_DELAY > 0) {\n // eslint-disable-next-line no-console\n console.log(\"action done, pausing\");\n await delay(ACTION_DELAY);\n // eslint-disable-next-line no-console\n console.log(\"action done, pausing done\");\n }\n await this.#invalidateActionEditResponse(actionResults);\n return actionResults;\n } finally {\n if (process.env.NODE_ENV !== \"production\") {\n this.store.logger?.debug(\n \"optimistic action complete; remove the results\",\n );\n }\n // make sure this happens even if the action fails\n await removeOptimisticResult();\n }\n })();\n };\n\n #invalidateActionEditResponse = async (\n value: ActionEditResponse,\n ): Promise<ActionEditResponse> => {\n const typesToInvalidate = new Set<string>();\n\n let changes: Changes | undefined;\n if (value.type === \"edits\") {\n const promisesToWait: Promise<any>[] = [];\n // TODO we need an backend update for deletes\n for (const obj of value.modifiedObjects) {\n promisesToWait.push(\n this.store.invalidateObject(obj.objectType, obj.primaryKey),\n );\n }\n\n for (const obj of value.addedObjects) {\n promisesToWait.push(\n this.store.invalidateObject(obj.objectType, obj.primaryKey),\n );\n\n typesToInvalidate.add(obj.objectType);\n }\n\n await Promise.all(promisesToWait);\n\n // the action invocation just gives back object ids,\n // so we don't want to build the changes object\n // until we have up to date values.\n changes = this.#changesFromActionEditResponse(value);\n\n // updates `changes` in place\n await this.store.maybeRevalidateLists(changes);\n } else {\n for (const apiName of value.editedObjectTypes) {\n typesToInvalidate.add(apiName.toString());\n await this.store.invalidateObjectType(apiName as string, changes);\n }\n }\n\n return value;\n };\n\n #changesFromActionEditResponse = (value: ActionEditResponse) => {\n const changes = createChangedObjects();\n for (const changeType of [\"addedObjects\", \"modifiedObjects\"] as const) {\n for (const { objectType, primaryKey } of (value[changeType] ?? [])) {\n const obj = this.store.getObject(objectType, primaryKey);\n if (obj) {\n changes[changeType].set(objectType, obj);\n }\n }\n }\n return changes;\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,KAAK,QAAQ,KAAK;AAG3B,SAAuBC,oBAAoB,QAAQ,qBAAqB;AACxE,SAASC,gBAAgB,QAAQ,oBAAoB;AAGrD,MAAMC,YAAY,GAAGC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GAAG,CAAC,GAAG,IAAI;AAErE,OAAO,MAAMC,iBAAiB,CAAC;EAC7BC,WAAWA,CAASC,KAAY,EAAE;IAAA,KAAdA,KAAY,GAAZA,KAAY;EAAG;EAEnCC,WAAW,GAIaA,CAACC,MAAM,EAAEC,IAAI,EAAE;IAAEC;EAAiB,CAAC,GAAG,CAAC,CAAC,KAAK;IACnE,MAAMC,sBAAsB,GAAGZ,gBAAgB,CAC7C,IAAI,CAACO,KAAK,EACVI,gBACF,CAAC;IACD,OAAO,CAAC,YAAY;MAClB,IAAI;QACF;QACA;QACA;;QAEA,MAAME,aAAiC,GAAG,MAAM,IAAI,CAACN,KAAK,CAACO,MAAM,CAC/DL,MACF,CAAC,CAACD,WAAW,CAACE,IAAI,EAAS;UAAEK,YAAY,EAAE;QAAK,CAAC,CAAC;QAElD,IAAId,YAAY,GAAG,CAAC,EAAE;UACpB;UACAe,OAAO,CAACC,GAAG,CAAC,sBAAsB,CAAC;UACnC,MAAMnB,KAAK,CAACG,YAAY,CAAC;UACzB;UACAe,OAAO,CAACC,GAAG,CAAC,2BAA2B,CAAC;QAC1C;QACA,MAAM,IAAI,CAAC,CAACC,4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,CAACK,OAAO,CAACE,QAAQ,CAAC,CAAC,CAAC;QACzC,MAAM,IAAI,CAAClC,KAAK,CAACmC,oBAAoB,CAACH,OAAO,EAAYf,OAAO,CAAC;MACnE;IACF;IAEA,OAAOH,KAAK;EACd,CAAC;EAED,CAACgB,6BAA6B,GAAIhB,KAAyB,IAAK;IAC9D,MAAMG,OAAO,GAAGzB,oBAAoB,CAAC,CAAC;IACtC,KAAK,MAAM4C,UAAU,IAAI,CAAC,cAAc,EAAE,iBAAiB,CAAC,EAAW;MACrE,KAAK,MAAM;QAAEZ,UAAU;QAAEC;MAAW,CAAC,IAAKX,KAAK,CAACsB,UAAU,CAAC,IAAI,EAAE,EAAG;QAClE,MAAMhB,GAAG,GAAG,IAAI,CAACpB,KAAK,CAACqC,SAAS,CAACb,UAAU,EAAEC,UAAU,CAAC;QACxD,IAAIL,GAAG,EAAE;UACPH,OAAO,CAACmB,UAAU,CAAC,CAACE,GAAG,CAACd,UAAU,EAAEJ,GAAG,CAAC;QAC1C;MACF;IACF;IACA,OAAOH,OAAO;EAChB,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,2 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
/**
|
|
18
|
+
* This isn't performant and should only be used for debug logging!
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export function DEBUG_ONLY__cacheKeyToString(x) {
|
|
22
|
+
if (process.env.NODE_ENV !== "production") {
|
|
23
|
+
return `${x.type}CacheKey<${x.otherKeys.map(xx => JSON.stringify(xx)).join(", ")}>`.replaceAll("\"", "'");
|
|
24
|
+
} else {
|
|
25
|
+
throw new Error("not implemented");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* This isn't performant and should only be used for debug logging!
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export function DEBUG_ONLY__cacheKeysToString(x) {
|
|
33
|
+
if (process.env.NODE_ENV !== "production") {
|
|
34
|
+
return JSON.stringify(x.map(DEBUG_ONLY__cacheKeyToString), null, 2);
|
|
35
|
+
} else {
|
|
36
|
+
throw new Error("not implemented");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
2
39
|
//# sourceMappingURL=CacheKey.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CacheKey.js","names":[],"sources":["CacheKey.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Query } from \"./Query.js\";\n\nexport type CacheKey<\n X extends string = string,\n T_StoreValue = unknown,\n T_Query extends Query<any, any, any> = Query<any, any, any>,\n T_KeyFactoryArgs extends any[] = any[],\n> = {\n type: X;\n otherKeys: T_KeyFactoryArgs;\n __cacheKey: {\n value: T_StoreValue;\n query: T_Query;\n args: T_KeyFactoryArgs;\n };\n};\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"CacheKey.js","names":["DEBUG_ONLY__cacheKeyToString","x","process","env","NODE_ENV","type","otherKeys","map","xx","JSON","stringify","join","replaceAll","Error","DEBUG_ONLY__cacheKeysToString"],"sources":["CacheKey.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Query } from \"./Query.js\";\n\nexport type CacheKey<\n X extends string = string,\n T_StoreValue = unknown,\n T_Query extends Query<any, any, any> = Query<any, any, any>,\n T_KeyFactoryArgs extends any[] = any[],\n> = {\n type: X;\n otherKeys: T_KeyFactoryArgs;\n __cacheKey: {\n value: T_StoreValue;\n query: T_Query;\n args: T_KeyFactoryArgs;\n };\n};\n\n/**\n * This isn't performant and should only be used for debug logging!\n * @internal\n */\nexport function DEBUG_ONLY__cacheKeyToString(x: CacheKey) {\n if (process.env.NODE_ENV !== \"production\") {\n return `${x.type}CacheKey<${\n x.otherKeys.map(xx => JSON.stringify(xx)).join(\", \")\n }>`.replaceAll(\"\\\"\", \"'\");\n } else {\n throw new Error(\"not implemented\");\n }\n}\n/**\n * This isn't performant and should only be used for debug logging!\n * @internal\n */\nexport function DEBUG_ONLY__cacheKeysToString(x: CacheKey[]) {\n if (process.env.NODE_ENV !== \"production\") {\n return JSON.stringify(x.map(DEBUG_ONLY__cacheKeyToString), null, 2);\n } else {\n throw new Error(\"not implemented\");\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmBA;AACA;AACA;AACA;AACA,OAAO,SAASA,4BAA4BA,CAACC,CAAW,EAAE;EACxD,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC,OAAO,GAAGH,CAAC,CAACI,IAAI,YACdJ,CAAC,CAACK,SAAS,CAACC,GAAG,CAACC,EAAE,IAAIC,IAAI,CAACC,SAAS,CAACF,EAAE,CAAC,CAAC,CAACG,IAAI,CAAC,IAAI,CAAC,GACnD,CAACC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC;EAC3B,CAAC,MAAM;IACL,MAAM,IAAIC,KAAK,CAAC,iBAAiB,CAAC;EACpC;AACF;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,6BAA6BA,CAACb,CAAa,EAAE;EAC3D,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC,OAAOK,IAAI,CAACC,SAAS,CAACT,CAAC,CAACM,GAAG,CAACP,4BAA4B,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;EACrE,CAAC,MAAM;IACL,MAAM,IAAIa,KAAK,CAAC,iBAAiB,CAAC;EACpC;AACF","ignoreList":[]}
|
|
@@ -28,7 +28,7 @@ export class CacheKeys {
|
|
|
28
28
|
});
|
|
29
29
|
#cacheKeyFactories = new Map();
|
|
30
30
|
#onCreate;
|
|
31
|
-
constructor(whereCanonicalizer, onCreate) {
|
|
31
|
+
constructor(whereCanonicalizer, orderByCanonicalizer, onCreate) {
|
|
32
32
|
this.#onCreate = onCreate;
|
|
33
33
|
this.#registerCacheKeyFactory("object", (apiName, pk) => {
|
|
34
34
|
if (process.env.NODE_ENV !== "production" && DEBUG_CACHE_KEYS) {
|
|
@@ -37,12 +37,12 @@ export class CacheKeys {
|
|
|
37
37
|
}
|
|
38
38
|
return this.#cacheKeys.lookupArray(["object", apiName, pk]);
|
|
39
39
|
});
|
|
40
|
-
this.#registerCacheKeyFactory("list", (apiName, where) => {
|
|
40
|
+
this.#registerCacheKeyFactory("list", (apiName, where, orderBy) => {
|
|
41
41
|
if (process.env.NODE_ENV !== "production" && DEBUG_CACHE_KEYS) {
|
|
42
42
|
// eslint-disable-next-line no-console
|
|
43
|
-
console.debug(`CacheKeys.get([list, ${apiName}, ${JSON.stringify(where)}]) -- already exists? `, this.#cacheKeys.peekArray(["list", apiName, whereCanonicalizer.canonicalize(where)]) != null);
|
|
43
|
+
console.debug(`CacheKeys.get([list, ${apiName}, ${JSON.stringify(where)}, ${JSON.stringify(orderBy)}]) -- already exists? `, this.#cacheKeys.peekArray(["list", apiName, whereCanonicalizer.canonicalize(where), orderByCanonicalizer.canonicalize(orderBy)]) != null);
|
|
44
44
|
}
|
|
45
|
-
return this.#cacheKeys.lookupArray(["list", apiName, whereCanonicalizer.canonicalize(where)]);
|
|
45
|
+
return this.#cacheKeys.lookupArray(["list", apiName, whereCanonicalizer.canonicalize(where), orderByCanonicalizer.canonicalize(orderBy)]);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
#registerCacheKeyFactory(type, factory) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CacheKeys.js","names":["Trie","invariant","DEBUG_CACHE_KEYS","CacheKeys","cacheKeys","keys","ret","type","otherKeys","slice","onCreate","cacheKeyFactories","Map","constructor","whereCanonicalizer","registerCacheKeyFactory","apiName","pk","process","env","NODE_ENV","console","debug","peekArray","lookupArray","where","JSON","stringify","canonicalize","#registerCacheKeyFactory","factory","set","get","args","remove","cacheKey"],"sources":["CacheKeys.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { Trie } from \"@wry/trie\";\nimport invariant from \"tiny-invariant\";\nimport { DEBUG_CACHE_KEYS } from \"../DebugFlags.js\";\nimport type { CacheKey } from \"./CacheKey.js\";\nimport type { ListCacheKey } from \"./ListQuery.js\";\nimport type { ObjectCacheKey } from \"./ObjectQuery.js\";\nimport type { WhereClauseCanonicalizer } from \"./WhereClauseCanonicalizer.js\";\n\nexport class CacheKeys {\n #cacheKeys = new Trie<CacheKey<string, any, any>>(false, (keys) => {\n const ret = {\n type: keys[0],\n otherKeys: keys.slice(1),\n } as unknown as CacheKey<\n string,\n any,\n any\n >;\n this.#onCreate(ret);\n return ret;\n });\n #cacheKeyFactories = new Map<string, (...args: any[]) => CacheKey>();\n #onCreate: (cacheKey: CacheKey) => void;\n\n constructor(\n whereCanonicalizer: WhereClauseCanonicalizer,\n onCreate: (cacheKey: CacheKey) => void,\n ) {\n this.#onCreate = onCreate;\n this.#registerCacheKeyFactory<ObjectCacheKey>(\n \"object\",\n (apiName, pk) => {\n if (process.env.NODE_ENV !== \"production\" && DEBUG_CACHE_KEYS) {\n // eslint-disable-next-line no-console\n console.debug(\n `CacheKeys.get([object, ${apiName}, ${pk}]) -- already exists? `,\n this.#cacheKeys.peekArray([\n \"object\",\n apiName,\n pk,\n ]) != null,\n );\n }\n return this.#cacheKeys.lookupArray([\n \"object\",\n apiName,\n pk,\n ]) as ObjectCacheKey;\n },\n );\n this.#registerCacheKeyFactory<ListCacheKey>(\n \"list\",\n (apiName, where) => {\n if (process.env.NODE_ENV !== \"production\" && DEBUG_CACHE_KEYS) {\n // eslint-disable-next-line no-console\n console.debug(\n `CacheKeys.get([list, ${apiName}, ${\n JSON.stringify(
|
|
1
|
+
{"version":3,"file":"CacheKeys.js","names":["Trie","invariant","DEBUG_CACHE_KEYS","CacheKeys","cacheKeys","keys","ret","type","otherKeys","slice","onCreate","cacheKeyFactories","Map","constructor","whereCanonicalizer","orderByCanonicalizer","registerCacheKeyFactory","apiName","pk","process","env","NODE_ENV","console","debug","peekArray","lookupArray","where","orderBy","JSON","stringify","canonicalize","#registerCacheKeyFactory","factory","set","get","args","remove","cacheKey"],"sources":["CacheKeys.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { Trie } from \"@wry/trie\";\nimport invariant from \"tiny-invariant\";\nimport { DEBUG_CACHE_KEYS } from \"../DebugFlags.js\";\nimport type { CacheKey } from \"./CacheKey.js\";\nimport type { ListCacheKey } from \"./ListQuery.js\";\nimport type { ObjectCacheKey } from \"./ObjectQuery.js\";\nimport type { OrderByCanonicalizer } from \"./Store.js\";\nimport type { WhereClauseCanonicalizer } from \"./WhereClauseCanonicalizer.js\";\n\ntype CacheKeyArgs<K extends CacheKey> = [K[\"type\"], ...K[\"otherKeys\"]];\n\nexport class CacheKeys {\n #cacheKeys = new Trie<CacheKey<string, any, any>>(false, (keys) => {\n const ret = {\n type: keys[0],\n otherKeys: keys.slice(1),\n } as unknown as CacheKey<\n string,\n any,\n any\n >;\n this.#onCreate(ret);\n return ret;\n });\n #cacheKeyFactories = new Map<string, (...args: any[]) => CacheKey>();\n #onCreate: (cacheKey: CacheKey) => void;\n\n constructor(\n whereCanonicalizer: WhereClauseCanonicalizer,\n orderByCanonicalizer: OrderByCanonicalizer,\n onCreate: (cacheKey: CacheKey) => void,\n ) {\n this.#onCreate = onCreate;\n this.#registerCacheKeyFactory<ObjectCacheKey>(\n \"object\",\n (apiName, pk) => {\n if (process.env.NODE_ENV !== \"production\" && DEBUG_CACHE_KEYS) {\n // eslint-disable-next-line no-console\n console.debug(\n `CacheKeys.get([object, ${apiName}, ${pk}]) -- already exists? `,\n this.#cacheKeys.peekArray([\n \"object\",\n apiName,\n pk,\n ]) != null,\n );\n }\n return this.#cacheKeys.lookupArray([\n \"object\",\n apiName,\n pk,\n ]) as ObjectCacheKey;\n },\n );\n this.#registerCacheKeyFactory<ListCacheKey>(\n \"list\",\n (apiName, where, orderBy) => {\n if (process.env.NODE_ENV !== \"production\" && DEBUG_CACHE_KEYS) {\n // eslint-disable-next-line no-console\n console.debug(\n `CacheKeys.get([list, ${apiName}, ${JSON.stringify(where)}, ${\n JSON.stringify(orderBy)\n }]) -- already exists? `,\n this.#cacheKeys.peekArray([\n \"list\",\n apiName,\n whereCanonicalizer.canonicalize(where),\n orderByCanonicalizer.canonicalize(orderBy),\n ]) != null,\n );\n }\n return this.#cacheKeys.lookupArray<\n CacheKeyArgs<ListCacheKey>\n >([\n \"list\",\n apiName,\n whereCanonicalizer.canonicalize(where),\n orderByCanonicalizer.canonicalize(orderBy),\n ]) as ListCacheKey;\n },\n );\n }\n\n #registerCacheKeyFactory<K extends CacheKey>(\n type: K[\"type\"],\n factory: (...args: K[\"__cacheKey\"][\"args\"]) => K,\n ): void {\n this.#cacheKeyFactories.set(type, factory);\n }\n\n get<K extends CacheKey<string, any, any>>(\n type: K[\"type\"],\n ...args: K[\"__cacheKey\"][\"args\"]\n ): K {\n const factory = this.#cacheKeyFactories.get(type);\n invariant(factory, `no cache key factory for type \"${type}\"`);\n return factory(...args) as K;\n }\n\n remove<K extends CacheKey<string, any, any>>(\n cacheKey: K,\n ): void {\n this.#cacheKeys.remove(cacheKey.type, ...cacheKey.otherKeys);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,IAAI,QAAQ,WAAW;AAChC,OAAOC,SAAS,MAAM,gBAAgB;AACtC,SAASC,gB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KeyToString } from "./CacheKey.js";
|
|
18
19
|
export function createChangedObjects() {
|
|
19
20
|
return {
|
|
20
21
|
modifiedObjects: new MultiMap(),
|
|
21
|
-
addedObjects: new MultiMap()
|
|
22
|
+
addedObjects: new MultiMap(),
|
|
23
|
+
addedLists: new Set(),
|
|
24
|
+
modifiedLists: new Set()
|
|
22
25
|
};
|
|
23
26
|
}
|
|
27
|
+
export function DEBUG_ONLY__changesToString(changes) {
|
|
28
|
+
if (process.env.NODE_ENV !== "production") {
|
|
29
|
+
return JSON.stringify({
|
|
30
|
+
modifiedObjects: multimapHelper(changes.modifiedObjects),
|
|
31
|
+
addedObjects: multimapHelper(changes.addedObjects),
|
|
32
|
+
addedLists: listHelper(changes.addedLists),
|
|
33
|
+
modifiedLists: listHelper(changes.modifiedLists)
|
|
34
|
+
}, null, 2);
|
|
35
|
+
} else {
|
|
36
|
+
throw new Error("not implemented");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function listHelper(set) {
|
|
40
|
+
return Array.from(set).map(DEBUG_ONLY__cacheKeyToString);
|
|
41
|
+
}
|
|
42
|
+
function multimapHelper(multimap) {
|
|
43
|
+
return Object.fromEntries(Array.from(multimap.associations()).map(([type, objects]) => {
|
|
44
|
+
return [type, objects.map(o => o.$primaryKey)];
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
24
47
|
//# sourceMappingURL=ChangedObjects.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChangedObjects.js","names":["MultiMap","createChangedObjects","modifiedObjects","addedObjects"],"sources":["ChangedObjects.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectTypeDefinition, Osdk } from \"@osdk/api\";\nimport { MultiMap } from \"mnemonist\";\n\nexport interface
|
|
1
|
+
{"version":3,"file":"ChangedObjects.js","names":["MultiMap","DEBUG_ONLY__cacheKeyToString","createChangedObjects","modifiedObjects","addedObjects","addedLists","Set","modifiedLists","DEBUG_ONLY__changesToString","changes","process","env","NODE_ENV","JSON","stringify","multimapHelper","listHelper","Error","set","Array","from","map","multimap","Object","fromEntries","associations","type","objects","o","$primaryKey"],"sources":["ChangedObjects.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectTypeDefinition, Osdk } from \"@osdk/api\";\nimport { MultiMap } from \"mnemonist\";\nimport { DEBUG_ONLY__cacheKeyToString } from \"./CacheKey.js\";\nimport type { ListCacheKey } from \"./ListQuery.js\";\n\nexport interface Changes {\n modifiedObjects: MultiMap<string, Osdk.Instance<ObjectTypeDefinition>>;\n addedObjects: MultiMap<string, Osdk.Instance<ObjectTypeDefinition>>;\n addedLists: Set<ListCacheKey>;\n modifiedLists: Set<ListCacheKey>;\n}\n\nexport function createChangedObjects(): Changes {\n return {\n modifiedObjects: new MultiMap<\n string,\n Osdk.Instance<ObjectTypeDefinition>\n >(),\n addedObjects: new MultiMap<string, Osdk.Instance<ObjectTypeDefinition>>(),\n addedLists: new Set<ListCacheKey>(),\n modifiedLists: new Set<ListCacheKey>(),\n };\n}\n\nexport function DEBUG_ONLY__changesToString(changes: Changes): string {\n if (process.env.NODE_ENV !== \"production\") {\n return JSON.stringify(\n {\n modifiedObjects: multimapHelper(changes.modifiedObjects),\n addedObjects: multimapHelper(changes.addedObjects),\n addedLists: listHelper(changes.addedLists),\n modifiedLists: listHelper(changes.modifiedLists),\n },\n null,\n 2,\n );\n } else {\n throw new Error(\"not implemented\");\n }\n}\n\nfunction listHelper(set: Set<ListCacheKey>) {\n return Array.from(set).map(DEBUG_ONLY__cacheKeyToString);\n}\n\nfunction multimapHelper(\n multimap: MultiMap<string, Osdk.Instance<ObjectTypeDefinition>>,\n) {\n return Object.fromEntries(\n Array.from(multimap.associations()).map(\n ([type, objects]) => {\n return [type, objects.map(o => o.$primaryKey)];\n },\n ),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,QAAQ,WAAW;AACpC,SAASC,4BAA4B,QAAQ,eAAe;AAU5D,OAAO,SAASC,oBAAoBA,CAAA,EAAY;EAC9C,OAAO;IACLC,eAAe,EAAE,IAAIH,QAAQ,CAG3B,CAAC;IACHI,YAAY,EAAE,IAAIJ,QAAQ,CAA8C,CAAC;IACzEK,UAAU,EAAE,IAAIC,GAAG,CAAe,CAAC;IACnCC,aAAa,EAAE,IAAID,GAAG,CAAe;EACvC,CAAC;AACH;AAEA,OAAO,SAASE,2BAA2BA,CAACC,OAAgB,EAAU;EACpE,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC,OAAOC,IAAI,CAACC,SAAS,CACnB;MACEX,eAAe,EAAEY,cAAc,CAACN,OAAO,CAACN,eAAe,CAAC;MACxDC,YAAY,EAAEW,cAAc,CAACN,OAAO,CAACL,YAAY,CAAC;MAClDC,UAAU,EAAEW,UAAU,CAACP,OAAO,CAACJ,UAAU,CAAC;MAC1CE,aAAa,EAAES,UAAU,CAACP,OAAO,CAACF,aAAa;IACjD,CAAC,EACD,IAAI,EACJ,CACF,CAAC;EACH,CAAC,MAAM;IACL,MAAM,IAAIU,KAAK,CAAC,iBAAiB,CAAC;EACpC;AACF;AAEA,SAASD,UAAUA,CAACE,GAAsB,EAAE;EAC1C,OAAOC,KAAK,CAACC,IAAI,CAACF,GAAG,CAAC,CAACG,GAAG,CAACpB,4BAA4B,CAAC;AAC1D;AAEA,SAASc,cAAcA,CACrBO,QAA+D,EAC/D;EACA,OAAOC,MAAM,CAACC,WAAW,CACvBL,KAAK,CAACC,IAAI,CAACE,QAAQ,CAACG,YAAY,CAAC,CAAC,CAAC,CAACJ,GAAG,CACrC,CAAC,CAACK,IAAI,EAAEC,OAAO,CAAC,KAAK;IACnB,OAAO,CAACD,IAAI,EAAEC,OAAO,CAACN,GAAG,CAACO,CAAC,IAAIA,CAAC,CAACC,WAAW,CAAC,CAAC;EAChD,CACF,CACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -53,7 +53,7 @@ export class Layer {
|
|
|
53
53
|
this.#parent = this.#parent.removeLayer(layerId);
|
|
54
54
|
return this;
|
|
55
55
|
}
|
|
56
|
-
return this.#parent
|
|
56
|
+
return this.#parent.removeLayer(layerId);
|
|
57
57
|
}
|
|
58
58
|
entries() {
|
|
59
59
|
return this.#cache.entries();
|
|
@@ -66,11 +66,11 @@ export class Layer {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
export class Entry {
|
|
69
|
-
constructor(cacheKey, value, lastUpdated) {
|
|
69
|
+
constructor(cacheKey, value, lastUpdated, status = "init") {
|
|
70
70
|
this.cacheKey = cacheKey;
|
|
71
71
|
this.value = value;
|
|
72
72
|
this.lastUpdated = lastUpdated;
|
|
73
|
-
this.status =
|
|
73
|
+
this.status = status;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
//# sourceMappingURL=Layer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layer.js","names":["WeakMapWithEntries","Layer","parent","cache","layerId","constructor","parentLayer","addLayer","removeLayer","entries","get","cacheKey","set","value","Entry","lastUpdated","status"],"sources":["Layer.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { CacheKey } from \"./CacheKey.js\";\nimport { WeakMapWithEntries } from \"./WeakMapWithEntries.js\";\n\n/*\n Image some layers\n\n [\n { cache: { obj1: { a: 1 } }, layerId: undefined },\n { cache: { obj1: { a: 1, b: 2 } }, layerId: \"layer1\" },\n { cache: { obj1: { a: undefined, b: 2 } }, layerId: \"layer2\" },\n { cache: { obj1: { a: 1, b: 2 } }, layerId: \"layer3\" },\n ]\n*/\n\nexport class Layer {\n #parent: Layer | undefined;\n #cache = new WeakMapWithEntries<CacheKey<string, any, any>, Entry<any>>();\n #layerId: unknown;\n\n constructor(parent: Layer | undefined, layerId: unknown) {\n this.#parent = parent;\n this.#layerId = layerId;\n }\n\n get parentLayer(): Layer | undefined {\n return this.#parent;\n }\n\n get layerId(): unknown {\n return this.#layerId;\n }\n\n addLayer(layerId: unknown): Layer {\n return new Layer(this, layerId);\n }\n\n removeLayer(layerId: unknown): Layer {\n if (layerId == null || this.#parent == null) {\n // we are the root, so we can't remove anything\n return this;\n }\n if (this.#layerId !== layerId) {\n this.#parent = this.#parent.removeLayer(layerId);\n return this;\n }\n\n return this.#parent
|
|
1
|
+
{"version":3,"file":"Layer.js","names":["WeakMapWithEntries","Layer","parent","cache","layerId","constructor","parentLayer","addLayer","removeLayer","entries","get","cacheKey","set","value","Entry","lastUpdated","status"],"sources":["Layer.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { CacheKey } from \"./CacheKey.js\";\nimport { WeakMapWithEntries } from \"./WeakMapWithEntries.js\";\n\n/*\n Image some layers\n\n [\n { cache: { obj1: { a: 1 } }, layerId: undefined },\n { cache: { obj1: { a: 1, b: 2 } }, layerId: \"layer1\" },\n { cache: { obj1: { a: undefined, b: 2 } }, layerId: \"layer2\" },\n { cache: { obj1: { a: 1, b: 2 } }, layerId: \"layer3\" },\n ]\n*/\n\nexport class Layer {\n #parent: Layer | undefined;\n #cache = new WeakMapWithEntries<CacheKey<string, any, any>, Entry<any>>();\n #layerId: unknown;\n\n constructor(parent: Layer | undefined, layerId: unknown) {\n this.#parent = parent;\n this.#layerId = layerId;\n }\n\n get parentLayer(): Layer | undefined {\n return this.#parent;\n }\n\n get layerId(): unknown {\n return this.#layerId;\n }\n\n addLayer(layerId: unknown): Layer {\n return new Layer(this, layerId);\n }\n\n removeLayer(layerId: unknown): Layer {\n if (layerId == null || this.#parent == null) {\n // we are the root, so we can't remove anything\n return this;\n }\n\n if (this.#layerId !== layerId) {\n this.#parent = this.#parent.removeLayer(layerId);\n return this;\n }\n\n return this.#parent.removeLayer(layerId);\n }\n\n entries(): IterableIterator<[CacheKey<string, any, any>, Entry<any>]> {\n return this.#cache.entries();\n }\n\n public get<K extends CacheKey<string, unknown, any>>(\n cacheKey: K,\n ): Entry<K> | undefined {\n return this.#cache.get(cacheKey) as Entry<K> | undefined\n ?? this.#parent?.get(cacheKey) as Entry<K> | undefined;\n }\n\n public set<K extends CacheKey<string, unknown, any>>(\n cacheKey: K,\n value: Entry<K>,\n ): void {\n this.#cache.set(cacheKey, value);\n }\n}\n\nexport class Entry<K extends CacheKey<any, any, any>> {\n readonly cacheKey: K;\n value: K[\"__cacheKey\"][\"value\"] | undefined;\n lastUpdated: number;\n status: \"init\" | \"loading\" | \"loaded\" | \"error\";\n\n constructor(\n cacheKey: K,\n value: K[\"__cacheKey\"][\"value\"],\n lastUpdated: number,\n status: \"init\" | \"loading\" | \"loaded\" | \"error\" = \"init\",\n ) {\n this.cacheKey = cacheKey;\n this.value = value;\n this.lastUpdated = lastUpdated;\n this.status = status;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,kBAAkB,QAAQ,yBAAyB;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,KAAK,CAAC;EACjB,CAACC,MAAM;EACP,CAACC,KAAK,GAAG,IAAIH,kBAAkB,CAAyC,CAAC;EACzE,CAACI,OAAO;EAERC,WAAWA,CAACH,MAAyB,EAAEE,OAAgB,EAAE;IACvD,IAAI,CAAC,CAACF,MAAM,GAAGA,MAAM;IACrB,IAAI,CAAC,CAACE,OAAO,GAAGA,OAAO;EACzB;EAEA,IAAIE,WAAWA,CAAA,EAAsB;IACnC,OAAO,IAAI,CAAC,CAACJ,MAAM;EACrB;EAEA,IAAIE,OAAOA,CAAA,EAAY;IACrB,OAAO,IAAI,CAAC,CAACA,OAAO;EACtB;EAEAG,QAAQA,CAACH,OAAgB,EAAS;IAChC,OAAO,IAAIH,KAAK,CAAC,IAAI,EAAEG,OAAO,CAAC;EACjC;EAEAI,WAAWA,CAACJ,OAAgB,EAAS;IACnC,IAAIA,OAAO,IAAI,IAAI,IAAI,IAAI,CAAC,CAACF,MAAM,IAAI,IAAI,EAAE;MAC3C;MACA,OAAO,IAAI;IACb;IAEA,IAAI,IAAI,CAAC,CA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