@palantir/pack.core 0.2.0 → 0.2.1

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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @palantir/pack.core@0.2.0 lint /home/runner/work/pack/pack/packages/core
2
+ > @palantir/pack.core@0.2.1 lint /home/runner/work/pack/pack/packages/core
3
3
  > eslint ./src && dprint check --config $(find-up dprint.json) --allow-no-files
4
4
 
@@ -1,5 +1,6 @@
1
1
 
2
- > @palantir/pack.core@0.2.0 transpileBrowser /home/runner/work/pack/pack/packages/core
2
+ > @palantir/pack.core@0.2.1 transpileBrowser /home/runner/work/pack/pack/packages/core
3
3
  > monorepo-transpile -f esm -m bundle -t browser
4
4
 
5
+ [baseline-browser-mapping] The data in this module is over two months old. To ensure accurate Baseline data, please update: `npm i baseline-browser-mapping@latest -D`
5
6
  👍
@@ -1,5 +1,6 @@
1
1
 
2
- > @palantir/pack.core@0.2.0 transpileCjs /home/runner/work/pack/pack/packages/core
2
+ > @palantir/pack.core@0.2.1 transpileCjs /home/runner/work/pack/pack/packages/core
3
3
  > monorepo-transpile -f cjs -m bundle -t node
4
4
 
5
+ [baseline-browser-mapping] The data in this module is over two months old. To ensure accurate Baseline data, please update: `npm i baseline-browser-mapping@latest -D`
5
6
  👍
@@ -1,5 +1,6 @@
1
1
 
2
- > @palantir/pack.core@0.2.0 transpileEsm /home/runner/work/pack/pack/packages/core
2
+ > @palantir/pack.core@0.2.1 transpileEsm /home/runner/work/pack/pack/packages/core
3
3
  > monorepo-transpile -f esm -m bundle -t node
4
4
 
5
+ [baseline-browser-mapping] The data in this module is over two months old. To ensure accurate Baseline data, please update: `npm i baseline-browser-mapping@latest -D`
5
6
  👍
@@ -1,5 +1,5 @@
1
1
 
2
- > @palantir/pack.core@0.2.0 transpileTypes /home/runner/work/pack/pack/packages/core
2
+ > @palantir/pack.core@0.2.1 transpileTypes /home/runner/work/pack/pack/packages/core
3
3
  > monorepo-transpile -f esm -m types -t node
4
4
 
5
5
  👍
@@ -1,4 +1,4 @@
1
1
 
2
- > @palantir/pack.core@0.2.0 typecheck /home/runner/work/pack/pack/packages/core
2
+ > @palantir/pack.core@0.2.1 typecheck /home/runner/work/pack/pack/packages/core
3
3
  > tsc --noEmit --emitDeclarationOnly false
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @palantir/pack.core
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 9f45b8e: Improve document creation API to separate create request from raw API types
8
+ - 571578c: Add Booleans to pack.schema
9
+ - e6e40f7: Improve demo mode services and add offline demo oauth implementation
10
+ - 7ee55de: Bump dependencies
11
+ - 4a44875: Remove bun-specific scripts and dependency
12
+
3
13
  ## 0.2.0
4
14
 
5
15
  ### Minor Changes
@@ -36,6 +36,11 @@ function toHexString(byteArray) {
36
36
  }).join("");
37
37
  }
38
38
 
39
+ // src/utils/getOntologyRid.ts
40
+ async function getOntologyRid(app) {
41
+ return app.config.ontologyRid;
42
+ }
43
+
39
44
  // src/utils/justOnce.ts
40
45
  var SEEN_KEYS = /* @__PURE__ */ new Set();
41
46
  function justOnce(key, fn) {
@@ -45,6 +50,15 @@ function justOnce(key, fn) {
45
50
  }
46
51
  }
47
52
 
48
- export { assertIsAppInternal, assertNever, generateId, isModuleConfigTuple, justOnce };
53
+ // src/utils/parseJwtPayload.ts
54
+ function parseJwtPayload(token) {
55
+ const parts = token.split(".");
56
+ if (parts.length !== 3 || !parts[1]) {
57
+ throw new Error("Invalid JWT token format");
58
+ }
59
+ return JSON.parse(atob(parts[1]));
60
+ }
61
+
62
+ export { assertIsAppInternal, assertNever, generateId, getOntologyRid, isModuleConfigTuple, justOnce, parseJwtPayload };
49
63
  //# sourceMappingURL=index.js.map
50
64
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","../../src/types/PackApp.ts","../../src/utils/assertNever.ts","../../src/utils/generateId.ts","../../src/utils/justOnce.ts"],"names":[],"mappings":";AAAA,IAAI,YAAA,GAAe,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA;AAC5C,IAAI,MAAA,GAAS,kBAAA;AACb,SAAS,SAAA,CAAU,WAAW,OAAA,EAAS;AAIrC,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,MAAM,IAAI,MAAM,MAAM,CAAA;AAAA,EACxB;AACA,EAAA,IAAI,QAAA,GAAW,OAAO,OAAA,KAAY,UAAA,GAAa,SAAQ,GAAI,OAAA;AAC3D,EAAA,IAAI,KAAA,GAAQ,WAAW,EAAA,CAAG,MAAA,CAAO,QAAQ,IAAI,CAAA,CAAE,MAAA,CAAO,QAAQ,CAAA,GAAI,MAAA;AAClE,EAAA,MAAM,IAAI,MAAM,KAAK,CAAA;AACvB;;;ACqCO,IAAM,sBAAsB,CAAA,MAAA,KAAU;AAC3C,EAAA,OAAO,KAAA,CAAM,QAAQ,MAAM,CAAA;AAC7B;AASO,SAAS,oBAAoB,GAAA,EAAK;AACvC,EAAA,EAAE,WAAA,IAAe,GAAA,CAAA,GAAO,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA,GAAe,SAAA,CAAU,KAAA,EAAO,+BAA+B,CAAA,GAAI,SAAA,CAAe,CAAA,GAAI,MAAA;AACzI;;;ACxCO,SAAS,YAAY,EAAA,EAAI;AAC9B,EAAA,MAAM,IAAI,MAAM,sBAAsB,CAAA;AACxC;;;ACHO,SAAS,UAAA,CAAW,QAAQ,EAAA,EAAI;AACrC,EAAA,MAAM,KAAA,GAAQ,IAAI,SAAA,CAAU,KAAK,CAAA;AACjC,EAAA,MAAM,CAAA,GAAI,MAAA,CAAO,eAAA,CAAgB,KAAK,CAAA;AACtC,EAAA,OAAO,YAAY,CAAC,CAAA;AACtB;AACA,SAAS,YAAY,SAAA,EAAW;AAC9B,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,SAAU,IAAA,EAAM;AAC3C,IAAA,MAAM,CAAA,GAAA,CAAK,IAAA,GAAO,GAAA,EAAM,QAAA,CAAS,EAAE,CAAA;AACnC,IAAA,OAAO,CAAA,CAAE,MAAA,KAAW,CAAA,GAAI,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,GAAK,CAAA;AAAA,EACpC,CAAC,CAAA,CAAE,IAAA,CAAK,EAAE,CAAA;AACZ;;;ACfA,IAAM,SAAA,uBAAgB,GAAA,EAAI;AAWnB,SAAS,QAAA,CAAS,KAAK,EAAA,EAAI;AAChC,EAAA,IAAI,CAAC,SAAA,CAAU,GAAA,CAAI,GAAG,CAAA,EAAG;AACvB,IAAA,SAAA,CAAU,IAAI,GAAG,CAAA;AACjB,IAAA,EAAA,EAAG;AAAA,EACL;AACF","file":"index.js","sourcesContent":["var isProduction = process.env.NODE_ENV === 'production';\nvar prefix = 'Invariant failed';\nfunction invariant(condition, message) {\n if (condition) {\n return;\n }\n if (isProduction) {\n throw new Error(prefix);\n }\n var provided = typeof message === 'function' ? message() : message;\n var value = provided ? \"\".concat(prefix, \": \").concat(provided) : prefix;\n throw new Error(value);\n}\nexport { invariant as default };","/*\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 invariant from \"tiny-invariant\";\n\n/**\n * PackApp provides access to various pack subsystems.\n *\n * Specific modules are available after configuration and through declarations mixed in by import.\n * Eg for state system, if you import @palantir/pack.state.core you will have access to `app.state` accessor.\n * Similarly, auth is added automatically by initPackApp.\n *\n * @example\n * ```typescript\n * import { DocumentRef } from '@palantir/pack.state.core';\n * import { DocSchema } from '@my-app/schema';\n *\n * const app = initPackApp({\n * tokenProvider: () => 'your-token',\n * moduleConfigs: {\n * ...createPackDocumentServiceConfig({appId: 'your-app-id', documentType: 'your-document-type'})\n * },\n * });\n *\n * const docRef = app.state.createDocRef(docSchema, 'your-document-id');\n * const doc = await docRef.getSnapshot(); // get pojo of your doc state.\n * ```\n */\n\n/**\n * Module configuration - either a tuple of [ModuleKey, config] or just a ModuleKey (for modules with no config)\n */\n\n/**\n * Type guard to check if a ModuleConfig is a tuple configuration\n */\nexport const isModuleConfigTuple = config => {\n return Array.isArray(config);\n};\n\n/**\n * To simplify the public type interface on methods taking a PackApp,\n * this function asserts that the implementation is in fact a PackAppInternal\n * implementation, which allows internal module access and perhaps other\n * private functionality in the future.\n */\n\nexport function assertIsAppInternal(app) {\n !(\"getModule\" in app) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"App is not an PackAppInternal\") : invariant(false) : void 0;\n}","/*\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\n/**\n * Assert that a value type is never, useful for compile time exhaustiveness checking.\n *\n * If it is hit at runtime, it may indicate a bug in the code, or an unhandled case\n * for a new value added to a remotely loaded type.\n */\nexport function assertNever(_x) {\n throw new Error(\"Hit unreachable code\");\n}","/*\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\n/**\n * Generates a random ID using crypto library.\n * @param bytes Generate an ID with this many random bytes (default: 12)\n * @returns A hexadecimal string representation of the generated ID\n */\nexport function generateId(bytes = 12) {\n const array = new Int8Array(bytes);\n const r = crypto.getRandomValues(array);\n return toHexString(r);\n}\nfunction toHexString(byteArray) {\n return Array.from(byteArray, function (byte) {\n const h = (byte & 0xff).toString(16);\n return h.length === 1 ? `0${h}` : h;\n }).join(\"\");\n}","/*\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\nconst SEEN_KEYS = new Set();\n\n/**\n * Used to call fn only once between app reloads.\n * eg: Useful for logging warnings that should only be logged once.\n *\n * @example\n * ```ts\n * justOnce(\"unexpected-value\", () => console.warn(\"There was an unexpected value returned\", {value}));\n * ```\n */\nexport function justOnce(key, fn) {\n if (!SEEN_KEYS.has(key)) {\n SEEN_KEYS.add(key);\n fn();\n }\n}"]}
1
+ {"version":3,"sources":["../../../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","../../src/types/PackApp.ts","../../src/utils/assertNever.ts","../../src/utils/generateId.ts","../../src/utils/getOntologyRid.ts","../../src/utils/justOnce.ts","../../src/utils/parseJwtPayload.ts"],"names":[],"mappings":";AAAA,IAAI,YAAA,GAAe,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA;AAC5C,IAAI,MAAA,GAAS,kBAAA;AACb,SAAS,SAAA,CAAU,WAAW,OAAA,EAAS;AAIrC,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,MAAM,IAAI,MAAM,MAAM,CAAA;AAAA,EACxB;AACA,EAAA,IAAI,QAAA,GAAW,OAAO,OAAA,KAAY,UAAA,GAAa,SAAQ,GAAI,OAAA;AAC3D,EAAA,IAAI,KAAA,GAAQ,WAAW,EAAA,CAAG,MAAA,CAAO,QAAQ,IAAI,CAAA,CAAE,MAAA,CAAO,QAAQ,CAAA,GAAI,MAAA;AAClE,EAAA,MAAM,IAAI,MAAM,KAAK,CAAA;AACvB;;;ACqCO,IAAM,sBAAsB,CAAA,MAAA,KAAU;AAC3C,EAAA,OAAO,KAAA,CAAM,QAAQ,MAAM,CAAA;AAC7B;AASO,SAAS,oBAAoB,GAAA,EAAK;AACvC,EAAA,EAAE,WAAA,IAAe,GAAA,CAAA,GAAO,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA,GAAe,SAAA,CAAU,KAAA,EAAO,+BAA+B,CAAA,GAAI,SAAA,CAAe,CAAA,GAAI,MAAA;AACzI;;;ACxCO,SAAS,YAAY,EAAA,EAAI;AAC9B,EAAA,MAAM,IAAI,MAAM,sBAAsB,CAAA;AACxC;;;ACHO,SAAS,UAAA,CAAW,QAAQ,EAAA,EAAI;AACrC,EAAA,MAAM,KAAA,GAAQ,IAAI,SAAA,CAAU,KAAK,CAAA;AACjC,EAAA,MAAM,CAAA,GAAI,MAAA,CAAO,eAAA,CAAgB,KAAK,CAAA;AACtC,EAAA,OAAO,YAAY,CAAC,CAAA;AACtB;AACA,SAAS,YAAY,SAAA,EAAW;AAC9B,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,SAAU,IAAA,EAAM;AAC3C,IAAA,MAAM,CAAA,GAAA,CAAK,IAAA,GAAO,GAAA,EAAM,QAAA,CAAS,EAAE,CAAA;AACnC,IAAA,OAAO,CAAA,CAAE,MAAA,KAAW,CAAA,GAAI,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,GAAK,CAAA;AAAA,EACpC,CAAC,CAAA,CAAE,IAAA,CAAK,EAAE,CAAA;AACZ;;;ACfA,eAAsB,eAAe,GAAA,EAAK;AACxC,EAAA,OAAO,IAAI,MAAA,CAAO,WAAA;AACpB;;;ACFA,IAAM,SAAA,uBAAgB,GAAA,EAAI;AAWnB,SAAS,QAAA,CAAS,KAAK,EAAA,EAAI;AAChC,EAAA,IAAI,CAAC,SAAA,CAAU,GAAA,CAAI,GAAG,CAAA,EAAG;AACvB,IAAA,SAAA,CAAU,IAAI,GAAG,CAAA;AACjB,IAAA,EAAA,EAAG;AAAA,EACL;AACF;;;ACPO,SAAS,gBAAgB,KAAA,EAAO;AACrC,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,KAAA,CAAM,GAAG,CAAA;AAC7B,EAAA,IAAI,MAAM,MAAA,KAAW,CAAA,IAAK,CAAC,KAAA,CAAM,CAAC,CAAA,EAAG;AACnC,IAAA,MAAM,IAAI,MAAM,0BAA0B,CAAA;AAAA,EAC5C;AACA,EAAA,OAAO,KAAK,KAAA,CAAM,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,CAAC,CAAA;AAClC","file":"index.js","sourcesContent":["var isProduction = process.env.NODE_ENV === 'production';\nvar prefix = 'Invariant failed';\nfunction invariant(condition, message) {\n if (condition) {\n return;\n }\n if (isProduction) {\n throw new Error(prefix);\n }\n var provided = typeof message === 'function' ? message() : message;\n var value = provided ? \"\".concat(prefix, \": \").concat(provided) : prefix;\n throw new Error(value);\n}\nexport { invariant as default };","/*\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 invariant from \"tiny-invariant\";\n\n/**\n * PackApp provides access to various pack subsystems.\n *\n * Specific modules are available after configuration and through declarations mixed in by import.\n * Eg for state system, if you import @palantir/pack.state.core you will have access to `app.state` accessor.\n * Similarly, auth is added automatically by initPackApp.\n *\n * @example\n * ```typescript\n * import { DocumentRef } from '@palantir/pack.state.core';\n * import { DocSchema } from '@my-app/schema';\n *\n * const app = initPackApp({\n * tokenProvider: () => 'your-token',\n * moduleConfigs: {\n * ...createPackDocumentServiceConfig({appId: 'your-app-id', documentType: 'your-document-type'})\n * },\n * });\n *\n * const docRef = app.state.createDocRef(docSchema, 'your-document-id');\n * const doc = await docRef.getSnapshot(); // get pojo of your doc state.\n * ```\n */\n\n/**\n * Module configuration - either a tuple of [ModuleKey, config] or just a ModuleKey (for modules with no config)\n */\n\n/**\n * Type guard to check if a ModuleConfig is a tuple configuration\n */\nexport const isModuleConfigTuple = config => {\n return Array.isArray(config);\n};\n\n/**\n * To simplify the public type interface on methods taking a PackApp,\n * this function asserts that the implementation is in fact a PackAppInternal\n * implementation, which allows internal module access and perhaps other\n * private functionality in the future.\n */\n\nexport function assertIsAppInternal(app) {\n !(\"getModule\" in app) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"App is not an PackAppInternal\") : invariant(false) : void 0;\n}","/*\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\n/**\n * Assert that a value type is never, useful for compile time exhaustiveness checking.\n *\n * If it is hit at runtime, it may indicate a bug in the code, or an unhandled case\n * for a new value added to a remotely loaded type.\n */\nexport function assertNever(_x) {\n throw new Error(\"Hit unreachable code\");\n}","/*\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\n/**\n * Generates a random ID using crypto library.\n * @param bytes Generate an ID with this many random bytes (default: 12)\n * @returns A hexadecimal string representation of the generated ID\n */\nexport function generateId(bytes = 12) {\n const array = new Int8Array(bytes);\n const r = crypto.getRandomValues(array);\n return toHexString(r);\n}\nfunction toHexString(byteArray) {\n return Array.from(byteArray, function (byte) {\n const h = (byte & 0xff).toString(16);\n return h.length === 1 ? `0${h}` : h;\n }).join(\"\");\n}","/*\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\nexport async function getOntologyRid(app) {\n return app.config.ontologyRid;\n}","/*\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\nconst SEEN_KEYS = new Set();\n\n/**\n * Used to call fn only once between app reloads.\n * eg: Useful for logging warnings that should only be logged once.\n *\n * @example\n * ```ts\n * justOnce(\"unexpected-value\", () => console.warn(\"There was an unexpected value returned\", {value}));\n * ```\n */\nexport function justOnce(key, fn) {\n if (!SEEN_KEYS.has(key)) {\n SEEN_KEYS.add(key);\n fn();\n }\n}","/*\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\n/**\n * Parse JWT token payload without verification.\n * This does NOT verify the token signature - it only extracts payload data.\n * Use only for non-security-critical operations like testing or logging.\n *\n * @param token - JWT token string\n * @returns Parsed payload object\n * @throws Error if token format is invalid\n */\nexport function parseJwtPayload(token) {\n const parts = token.split(\".\");\n if (parts.length !== 3 || !parts[1]) {\n throw new Error(\"Invalid JWT token format\");\n }\n return JSON.parse(atob(parts[1]));\n}"]}
@@ -38,6 +38,11 @@ function toHexString(byteArray) {
38
38
  }).join("");
39
39
  }
40
40
 
41
+ // src/utils/getOntologyRid.ts
42
+ async function getOntologyRid(app) {
43
+ return app.config.ontologyRid;
44
+ }
45
+
41
46
  // src/utils/justOnce.ts
42
47
  var SEEN_KEYS = /* @__PURE__ */ new Set();
43
48
  function justOnce(key, fn) {
@@ -47,10 +52,21 @@ function justOnce(key, fn) {
47
52
  }
48
53
  }
49
54
 
55
+ // src/utils/parseJwtPayload.ts
56
+ function parseJwtPayload(token) {
57
+ const parts = token.split(".");
58
+ if (parts.length !== 3 || !parts[1]) {
59
+ throw new Error("Invalid JWT token format");
60
+ }
61
+ return JSON.parse(atob(parts[1]));
62
+ }
63
+
50
64
  exports.assertIsAppInternal = assertIsAppInternal;
51
65
  exports.assertNever = assertNever;
52
66
  exports.generateId = generateId;
67
+ exports.getOntologyRid = getOntologyRid;
53
68
  exports.isModuleConfigTuple = isModuleConfigTuple;
54
69
  exports.justOnce = justOnce;
70
+ exports.parseJwtPayload = parseJwtPayload;
55
71
  //# sourceMappingURL=index.cjs.map
56
72
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","../../src/types/PackApp.ts","../../src/utils/assertNever.ts","../../src/utils/generateId.ts","../../src/utils/justOnce.ts"],"names":[],"mappings":";;;AAAA,IAAI,YAAA,GAAe,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA;AAC5C,IAAI,MAAA,GAAS,kBAAA;AACb,SAAS,SAAA,CAAU,WAAW,OAAA,EAAS;AAIrC,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,MAAM,IAAI,MAAM,MAAM,CAAA;AAAA,EACxB;AACA,EAAA,IAAI,QAAA,GAAW,OAAO,OAAA,KAAY,UAAA,GAAa,SAAQ,GAAI,OAAA;AAC3D,EAAA,IAAI,KAAA,GAAQ,WAAW,EAAA,CAAG,MAAA,CAAO,QAAQ,IAAI,CAAA,CAAE,MAAA,CAAO,QAAQ,CAAA,GAAI,MAAA;AAClE,EAAA,MAAM,IAAI,MAAM,KAAK,CAAA;AACvB;;;ACqCO,IAAM,sBAAsB,CAAA,MAAA,KAAU;AAC3C,EAAA,OAAO,KAAA,CAAM,QAAQ,MAAM,CAAA;AAC7B;AASO,SAAS,oBAAoB,GAAA,EAAK;AACvC,EAAA,EAAE,WAAA,IAAe,GAAA,CAAA,GAAO,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA,GAAe,SAAA,CAAU,KAAA,EAAO,+BAA+B,CAAA,GAAI,SAAA,CAAe,CAAA,GAAI,MAAA;AACzI;;;ACxCO,SAAS,YAAY,EAAA,EAAI;AAC9B,EAAA,MAAM,IAAI,MAAM,sBAAsB,CAAA;AACxC;;;ACHO,SAAS,UAAA,CAAW,QAAQ,EAAA,EAAI;AACrC,EAAA,MAAM,KAAA,GAAQ,IAAI,SAAA,CAAU,KAAK,CAAA;AACjC,EAAA,MAAM,CAAA,GAAI,MAAA,CAAO,eAAA,CAAgB,KAAK,CAAA;AACtC,EAAA,OAAO,YAAY,CAAC,CAAA;AACtB;AACA,SAAS,YAAY,SAAA,EAAW;AAC9B,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,SAAU,IAAA,EAAM;AAC3C,IAAA,MAAM,CAAA,GAAA,CAAK,IAAA,GAAO,GAAA,EAAM,QAAA,CAAS,EAAE,CAAA;AACnC,IAAA,OAAO,CAAA,CAAE,MAAA,KAAW,CAAA,GAAI,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,GAAK,CAAA;AAAA,EACpC,CAAC,CAAA,CAAE,IAAA,CAAK,EAAE,CAAA;AACZ;;;ACfA,IAAM,SAAA,uBAAgB,GAAA,EAAI;AAWnB,SAAS,QAAA,CAAS,KAAK,EAAA,EAAI;AAChC,EAAA,IAAI,CAAC,SAAA,CAAU,GAAA,CAAI,GAAG,CAAA,EAAG;AACvB,IAAA,SAAA,CAAU,IAAI,GAAG,CAAA;AACjB,IAAA,EAAA,EAAG;AAAA,EACL;AACF","file":"index.cjs","sourcesContent":["var isProduction = process.env.NODE_ENV === 'production';\nvar prefix = 'Invariant failed';\nfunction invariant(condition, message) {\n if (condition) {\n return;\n }\n if (isProduction) {\n throw new Error(prefix);\n }\n var provided = typeof message === 'function' ? message() : message;\n var value = provided ? \"\".concat(prefix, \": \").concat(provided) : prefix;\n throw new Error(value);\n}\nexport { invariant as default };","/*\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 invariant from \"tiny-invariant\";\n\n/**\n * PackApp provides access to various pack subsystems.\n *\n * Specific modules are available after configuration and through declarations mixed in by import.\n * Eg for state system, if you import @palantir/pack.state.core you will have access to `app.state` accessor.\n * Similarly, auth is added automatically by initPackApp.\n *\n * @example\n * ```typescript\n * import { DocumentRef } from '@palantir/pack.state.core';\n * import { DocSchema } from '@my-app/schema';\n *\n * const app = initPackApp({\n * tokenProvider: () => 'your-token',\n * moduleConfigs: {\n * ...createPackDocumentServiceConfig({appId: 'your-app-id', documentType: 'your-document-type'})\n * },\n * });\n *\n * const docRef = app.state.createDocRef(docSchema, 'your-document-id');\n * const doc = await docRef.getSnapshot(); // get pojo of your doc state.\n * ```\n */\n\n/**\n * Module configuration - either a tuple of [ModuleKey, config] or just a ModuleKey (for modules with no config)\n */\n\n/**\n * Type guard to check if a ModuleConfig is a tuple configuration\n */\nexport const isModuleConfigTuple = config => {\n return Array.isArray(config);\n};\n\n/**\n * To simplify the public type interface on methods taking a PackApp,\n * this function asserts that the implementation is in fact a PackAppInternal\n * implementation, which allows internal module access and perhaps other\n * private functionality in the future.\n */\n\nexport function assertIsAppInternal(app) {\n !(\"getModule\" in app) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"App is not an PackAppInternal\") : invariant(false) : void 0;\n}","/*\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\n/**\n * Assert that a value type is never, useful for compile time exhaustiveness checking.\n *\n * If it is hit at runtime, it may indicate a bug in the code, or an unhandled case\n * for a new value added to a remotely loaded type.\n */\nexport function assertNever(_x) {\n throw new Error(\"Hit unreachable code\");\n}","/*\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\n/**\n * Generates a random ID using crypto library.\n * @param bytes Generate an ID with this many random bytes (default: 12)\n * @returns A hexadecimal string representation of the generated ID\n */\nexport function generateId(bytes = 12) {\n const array = new Int8Array(bytes);\n const r = crypto.getRandomValues(array);\n return toHexString(r);\n}\nfunction toHexString(byteArray) {\n return Array.from(byteArray, function (byte) {\n const h = (byte & 0xff).toString(16);\n return h.length === 1 ? `0${h}` : h;\n }).join(\"\");\n}","/*\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\nconst SEEN_KEYS = new Set();\n\n/**\n * Used to call fn only once between app reloads.\n * eg: Useful for logging warnings that should only be logged once.\n *\n * @example\n * ```ts\n * justOnce(\"unexpected-value\", () => console.warn(\"There was an unexpected value returned\", {value}));\n * ```\n */\nexport function justOnce(key, fn) {\n if (!SEEN_KEYS.has(key)) {\n SEEN_KEYS.add(key);\n fn();\n }\n}"]}
1
+ {"version":3,"sources":["../../../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","../../src/types/PackApp.ts","../../src/utils/assertNever.ts","../../src/utils/generateId.ts","../../src/utils/getOntologyRid.ts","../../src/utils/justOnce.ts","../../src/utils/parseJwtPayload.ts"],"names":[],"mappings":";;;AAAA,IAAI,YAAA,GAAe,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA;AAC5C,IAAI,MAAA,GAAS,kBAAA;AACb,SAAS,SAAA,CAAU,WAAW,OAAA,EAAS;AAIrC,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,MAAM,IAAI,MAAM,MAAM,CAAA;AAAA,EACxB;AACA,EAAA,IAAI,QAAA,GAAW,OAAO,OAAA,KAAY,UAAA,GAAa,SAAQ,GAAI,OAAA;AAC3D,EAAA,IAAI,KAAA,GAAQ,WAAW,EAAA,CAAG,MAAA,CAAO,QAAQ,IAAI,CAAA,CAAE,MAAA,CAAO,QAAQ,CAAA,GAAI,MAAA;AAClE,EAAA,MAAM,IAAI,MAAM,KAAK,CAAA;AACvB;;;ACqCO,IAAM,sBAAsB,CAAA,MAAA,KAAU;AAC3C,EAAA,OAAO,KAAA,CAAM,QAAQ,MAAM,CAAA;AAC7B;AASO,SAAS,oBAAoB,GAAA,EAAK;AACvC,EAAA,EAAE,WAAA,IAAe,GAAA,CAAA,GAAO,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA,GAAe,SAAA,CAAU,KAAA,EAAO,+BAA+B,CAAA,GAAI,SAAA,CAAe,CAAA,GAAI,MAAA;AACzI;;;ACxCO,SAAS,YAAY,EAAA,EAAI;AAC9B,EAAA,MAAM,IAAI,MAAM,sBAAsB,CAAA;AACxC;;;ACHO,SAAS,UAAA,CAAW,QAAQ,EAAA,EAAI;AACrC,EAAA,MAAM,KAAA,GAAQ,IAAI,SAAA,CAAU,KAAK,CAAA;AACjC,EAAA,MAAM,CAAA,GAAI,MAAA,CAAO,eAAA,CAAgB,KAAK,CAAA;AACtC,EAAA,OAAO,YAAY,CAAC,CAAA;AACtB;AACA,SAAS,YAAY,SAAA,EAAW;AAC9B,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,SAAU,IAAA,EAAM;AAC3C,IAAA,MAAM,CAAA,GAAA,CAAK,IAAA,GAAO,GAAA,EAAM,QAAA,CAAS,EAAE,CAAA;AACnC,IAAA,OAAO,CAAA,CAAE,MAAA,KAAW,CAAA,GAAI,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,GAAK,CAAA;AAAA,EACpC,CAAC,CAAA,CAAE,IAAA,CAAK,EAAE,CAAA;AACZ;;;ACfA,eAAsB,eAAe,GAAA,EAAK;AACxC,EAAA,OAAO,IAAI,MAAA,CAAO,WAAA;AACpB;;;ACFA,IAAM,SAAA,uBAAgB,GAAA,EAAI;AAWnB,SAAS,QAAA,CAAS,KAAK,EAAA,EAAI;AAChC,EAAA,IAAI,CAAC,SAAA,CAAU,GAAA,CAAI,GAAG,CAAA,EAAG;AACvB,IAAA,SAAA,CAAU,IAAI,GAAG,CAAA;AACjB,IAAA,EAAA,EAAG;AAAA,EACL;AACF;;;ACPO,SAAS,gBAAgB,KAAA,EAAO;AACrC,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,KAAA,CAAM,GAAG,CAAA;AAC7B,EAAA,IAAI,MAAM,MAAA,KAAW,CAAA,IAAK,CAAC,KAAA,CAAM,CAAC,CAAA,EAAG;AACnC,IAAA,MAAM,IAAI,MAAM,0BAA0B,CAAA;AAAA,EAC5C;AACA,EAAA,OAAO,KAAK,KAAA,CAAM,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,CAAC,CAAA;AAClC","file":"index.cjs","sourcesContent":["var isProduction = process.env.NODE_ENV === 'production';\nvar prefix = 'Invariant failed';\nfunction invariant(condition, message) {\n if (condition) {\n return;\n }\n if (isProduction) {\n throw new Error(prefix);\n }\n var provided = typeof message === 'function' ? message() : message;\n var value = provided ? \"\".concat(prefix, \": \").concat(provided) : prefix;\n throw new Error(value);\n}\nexport { invariant as default };","/*\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 invariant from \"tiny-invariant\";\n\n/**\n * PackApp provides access to various pack subsystems.\n *\n * Specific modules are available after configuration and through declarations mixed in by import.\n * Eg for state system, if you import @palantir/pack.state.core you will have access to `app.state` accessor.\n * Similarly, auth is added automatically by initPackApp.\n *\n * @example\n * ```typescript\n * import { DocumentRef } from '@palantir/pack.state.core';\n * import { DocSchema } from '@my-app/schema';\n *\n * const app = initPackApp({\n * tokenProvider: () => 'your-token',\n * moduleConfigs: {\n * ...createPackDocumentServiceConfig({appId: 'your-app-id', documentType: 'your-document-type'})\n * },\n * });\n *\n * const docRef = app.state.createDocRef(docSchema, 'your-document-id');\n * const doc = await docRef.getSnapshot(); // get pojo of your doc state.\n * ```\n */\n\n/**\n * Module configuration - either a tuple of [ModuleKey, config] or just a ModuleKey (for modules with no config)\n */\n\n/**\n * Type guard to check if a ModuleConfig is a tuple configuration\n */\nexport const isModuleConfigTuple = config => {\n return Array.isArray(config);\n};\n\n/**\n * To simplify the public type interface on methods taking a PackApp,\n * this function asserts that the implementation is in fact a PackAppInternal\n * implementation, which allows internal module access and perhaps other\n * private functionality in the future.\n */\n\nexport function assertIsAppInternal(app) {\n !(\"getModule\" in app) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"App is not an PackAppInternal\") : invariant(false) : void 0;\n}","/*\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\n/**\n * Assert that a value type is never, useful for compile time exhaustiveness checking.\n *\n * If it is hit at runtime, it may indicate a bug in the code, or an unhandled case\n * for a new value added to a remotely loaded type.\n */\nexport function assertNever(_x) {\n throw new Error(\"Hit unreachable code\");\n}","/*\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\n/**\n * Generates a random ID using crypto library.\n * @param bytes Generate an ID with this many random bytes (default: 12)\n * @returns A hexadecimal string representation of the generated ID\n */\nexport function generateId(bytes = 12) {\n const array = new Int8Array(bytes);\n const r = crypto.getRandomValues(array);\n return toHexString(r);\n}\nfunction toHexString(byteArray) {\n return Array.from(byteArray, function (byte) {\n const h = (byte & 0xff).toString(16);\n return h.length === 1 ? `0${h}` : h;\n }).join(\"\");\n}","/*\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\nexport async function getOntologyRid(app) {\n return app.config.ontologyRid;\n}","/*\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\nconst SEEN_KEYS = new Set();\n\n/**\n * Used to call fn only once between app reloads.\n * eg: Useful for logging warnings that should only be logged once.\n *\n * @example\n * ```ts\n * justOnce(\"unexpected-value\", () => console.warn(\"There was an unexpected value returned\", {value}));\n * ```\n */\nexport function justOnce(key, fn) {\n if (!SEEN_KEYS.has(key)) {\n SEEN_KEYS.add(key);\n fn();\n }\n}","/*\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\n/**\n * Parse JWT token payload without verification.\n * This does NOT verify the token signature - it only extracts payload data.\n * Use only for non-security-critical operations like testing or logging.\n *\n * @param token - JWT token string\n * @returns Parsed payload object\n * @throws Error if token format is invalid\n */\nexport function parseJwtPayload(token) {\n const parts = token.split(\".\");\n if (parts.length !== 3 || !parts[1]) {\n throw new Error(\"Invalid JWT token format\");\n }\n return JSON.parse(atob(parts[1]));\n}"]}
@@ -109,8 +109,16 @@ interface AppConfig {
109
109
  readonly appId: string;
110
110
  readonly appVersion?: string;
111
111
  };
112
- readonly isTestMode: boolean;
112
+ /**
113
+ * Test/demo mode configuration:
114
+ * - `true`: Is in demo mode (always use demo services, ignore real Foundry config)
115
+ * - `false`: Production only (never use demo services)
116
+ *
117
+ * @default false (production mode)
118
+ */
119
+ readonly isDemoMode?: boolean;
113
120
  readonly logger: Logger;
121
+ readonly ontologyRid: Promise<string>;
114
122
  readonly osdkClient: Client;
115
123
  readonly remote: {
116
124
  readonly packWsPath: string;
@@ -133,6 +141,17 @@ interface AppOptions {
133
141
  readonly appId: string;
134
142
  readonly appVersion?: string;
135
143
  };
144
+ /**
145
+ * Test/demo mode configuration:
146
+ * - `true`: Force demo mode (always use demo services)
147
+ * - `"auto"`: Auto-detect - use demo mode when no real Foundry config in environment, otherwise production
148
+ * - `false`: Production only
149
+ *
150
+ * When `"auto"`, checks for non-localhost FOUNDRY_URL in environment variables.
151
+ *
152
+ * @default Auto-detected: true if no baseUrl, otherwise false
153
+ */
154
+ readonly demoMode?: boolean | "auto";
136
155
  /**
137
156
  * Logger configuration.
138
157
  * @see {@link @osdk/client/internal.BrowserLogger} for a richer console logger.
@@ -144,6 +163,7 @@ interface AppOptions {
144
163
  * Internal testing overrides.
145
164
  */
146
165
  readonly moduleOverrides?: readonly ModuleConfigTuple[];
166
+ readonly ontologyRid?: string | Promise<string>;
147
167
  readonly remote?: {
148
168
  /**
149
169
  * @default "/api/v2/packSubscriptions"
@@ -205,6 +225,8 @@ declare function assertNever(_x: never): never;
205
225
  */
206
226
  declare function generateId(bytes?: number): string;
207
227
 
228
+ declare function getOntologyRid(app: PackApp | PackAppInternal): Promise<string>;
229
+
208
230
  /**
209
231
  * Used to call fn only once between app reloads.
210
232
  * eg: Useful for logging warnings that should only be logged once.
@@ -216,4 +238,15 @@ declare function generateId(bytes?: number): string;
216
238
  */
217
239
  declare function justOnce(key: string, fn: () => void): void;
218
240
 
219
- export { type AppConfig, type AppOptions, type Branded, type Flavored, type ModuleConfig, type ModuleConfigTuple, type ModuleKey, type PackApp, type PackAppInternal, type TokenProvider, type Unsubscribe, assertIsAppInternal, assertNever, generateId, isModuleConfigTuple, justOnce };
241
+ /**
242
+ * Parse JWT token payload without verification.
243
+ * This does NOT verify the token signature - it only extracts payload data.
244
+ * Use only for non-security-critical operations like testing or logging.
245
+ *
246
+ * @param token - JWT token string
247
+ * @returns Parsed payload object
248
+ * @throws Error if token format is invalid
249
+ */
250
+ declare function parseJwtPayload(token: string): Record<string, unknown>;
251
+
252
+ export { type AppConfig, type AppOptions, type Branded, type Flavored, type ModuleConfig, type ModuleConfigTuple, type ModuleKey, type PackApp, type PackAppInternal, type TokenProvider, type Unsubscribe, assertIsAppInternal, assertNever, generateId, getOntologyRid, isModuleConfigTuple, justOnce, parseJwtPayload };
@@ -36,6 +36,11 @@ function toHexString(byteArray) {
36
36
  }).join("");
37
37
  }
38
38
 
39
+ // src/utils/getOntologyRid.ts
40
+ async function getOntologyRid(app) {
41
+ return app.config.ontologyRid;
42
+ }
43
+
39
44
  // src/utils/justOnce.ts
40
45
  var SEEN_KEYS = /* @__PURE__ */ new Set();
41
46
  function justOnce(key, fn) {
@@ -45,6 +50,15 @@ function justOnce(key, fn) {
45
50
  }
46
51
  }
47
52
 
48
- export { assertIsAppInternal, assertNever, generateId, isModuleConfigTuple, justOnce };
53
+ // src/utils/parseJwtPayload.ts
54
+ function parseJwtPayload(token) {
55
+ const parts = token.split(".");
56
+ if (parts.length !== 3 || !parts[1]) {
57
+ throw new Error("Invalid JWT token format");
58
+ }
59
+ return JSON.parse(atob(parts[1]));
60
+ }
61
+
62
+ export { assertIsAppInternal, assertNever, generateId, getOntologyRid, isModuleConfigTuple, justOnce, parseJwtPayload };
49
63
  //# sourceMappingURL=index.js.map
50
64
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","../../src/types/PackApp.ts","../../src/utils/assertNever.ts","../../src/utils/generateId.ts","../../src/utils/justOnce.ts"],"names":[],"mappings":";AAAA,IAAI,YAAA,GAAe,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA;AAC5C,IAAI,MAAA,GAAS,kBAAA;AACb,SAAS,SAAA,CAAU,WAAW,OAAA,EAAS;AAIrC,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,MAAM,IAAI,MAAM,MAAM,CAAA;AAAA,EACxB;AACA,EAAA,IAAI,QAAA,GAAW,OAAO,OAAA,KAAY,UAAA,GAAa,SAAQ,GAAI,OAAA;AAC3D,EAAA,IAAI,KAAA,GAAQ,WAAW,EAAA,CAAG,MAAA,CAAO,QAAQ,IAAI,CAAA,CAAE,MAAA,CAAO,QAAQ,CAAA,GAAI,MAAA;AAClE,EAAA,MAAM,IAAI,MAAM,KAAK,CAAA;AACvB;;;ACqCO,IAAM,sBAAsB,CAAA,MAAA,KAAU;AAC3C,EAAA,OAAO,KAAA,CAAM,QAAQ,MAAM,CAAA;AAC7B;AASO,SAAS,oBAAoB,GAAA,EAAK;AACvC,EAAA,EAAE,WAAA,IAAe,GAAA,CAAA,GAAO,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA,GAAe,SAAA,CAAU,KAAA,EAAO,+BAA+B,CAAA,GAAI,SAAA,CAAe,CAAA,GAAI,MAAA;AACzI;;;ACxCO,SAAS,YAAY,EAAA,EAAI;AAC9B,EAAA,MAAM,IAAI,MAAM,sBAAsB,CAAA;AACxC;;;ACHO,SAAS,UAAA,CAAW,QAAQ,EAAA,EAAI;AACrC,EAAA,MAAM,KAAA,GAAQ,IAAI,SAAA,CAAU,KAAK,CAAA;AACjC,EAAA,MAAM,CAAA,GAAI,MAAA,CAAO,eAAA,CAAgB,KAAK,CAAA;AACtC,EAAA,OAAO,YAAY,CAAC,CAAA;AACtB;AACA,SAAS,YAAY,SAAA,EAAW;AAC9B,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,SAAU,IAAA,EAAM;AAC3C,IAAA,MAAM,CAAA,GAAA,CAAK,IAAA,GAAO,GAAA,EAAM,QAAA,CAAS,EAAE,CAAA;AACnC,IAAA,OAAO,CAAA,CAAE,MAAA,KAAW,CAAA,GAAI,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,GAAK,CAAA;AAAA,EACpC,CAAC,CAAA,CAAE,IAAA,CAAK,EAAE,CAAA;AACZ;;;ACfA,IAAM,SAAA,uBAAgB,GAAA,EAAI;AAWnB,SAAS,QAAA,CAAS,KAAK,EAAA,EAAI;AAChC,EAAA,IAAI,CAAC,SAAA,CAAU,GAAA,CAAI,GAAG,CAAA,EAAG;AACvB,IAAA,SAAA,CAAU,IAAI,GAAG,CAAA;AACjB,IAAA,EAAA,EAAG;AAAA,EACL;AACF","file":"index.js","sourcesContent":["var isProduction = process.env.NODE_ENV === 'production';\nvar prefix = 'Invariant failed';\nfunction invariant(condition, message) {\n if (condition) {\n return;\n }\n if (isProduction) {\n throw new Error(prefix);\n }\n var provided = typeof message === 'function' ? message() : message;\n var value = provided ? \"\".concat(prefix, \": \").concat(provided) : prefix;\n throw new Error(value);\n}\nexport { invariant as default };","/*\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 invariant from \"tiny-invariant\";\n\n/**\n * PackApp provides access to various pack subsystems.\n *\n * Specific modules are available after configuration and through declarations mixed in by import.\n * Eg for state system, if you import @palantir/pack.state.core you will have access to `app.state` accessor.\n * Similarly, auth is added automatically by initPackApp.\n *\n * @example\n * ```typescript\n * import { DocumentRef } from '@palantir/pack.state.core';\n * import { DocSchema } from '@my-app/schema';\n *\n * const app = initPackApp({\n * tokenProvider: () => 'your-token',\n * moduleConfigs: {\n * ...createPackDocumentServiceConfig({appId: 'your-app-id', documentType: 'your-document-type'})\n * },\n * });\n *\n * const docRef = app.state.createDocRef(docSchema, 'your-document-id');\n * const doc = await docRef.getSnapshot(); // get pojo of your doc state.\n * ```\n */\n\n/**\n * Module configuration - either a tuple of [ModuleKey, config] or just a ModuleKey (for modules with no config)\n */\n\n/**\n * Type guard to check if a ModuleConfig is a tuple configuration\n */\nexport const isModuleConfigTuple = config => {\n return Array.isArray(config);\n};\n\n/**\n * To simplify the public type interface on methods taking a PackApp,\n * this function asserts that the implementation is in fact a PackAppInternal\n * implementation, which allows internal module access and perhaps other\n * private functionality in the future.\n */\n\nexport function assertIsAppInternal(app) {\n !(\"getModule\" in app) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"App is not an PackAppInternal\") : invariant(false) : void 0;\n}","/*\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\n/**\n * Assert that a value type is never, useful for compile time exhaustiveness checking.\n *\n * If it is hit at runtime, it may indicate a bug in the code, or an unhandled case\n * for a new value added to a remotely loaded type.\n */\nexport function assertNever(_x) {\n throw new Error(\"Hit unreachable code\");\n}","/*\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\n/**\n * Generates a random ID using crypto library.\n * @param bytes Generate an ID with this many random bytes (default: 12)\n * @returns A hexadecimal string representation of the generated ID\n */\nexport function generateId(bytes = 12) {\n const array = new Int8Array(bytes);\n const r = crypto.getRandomValues(array);\n return toHexString(r);\n}\nfunction toHexString(byteArray) {\n return Array.from(byteArray, function (byte) {\n const h = (byte & 0xff).toString(16);\n return h.length === 1 ? `0${h}` : h;\n }).join(\"\");\n}","/*\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\nconst SEEN_KEYS = new Set();\n\n/**\n * Used to call fn only once between app reloads.\n * eg: Useful for logging warnings that should only be logged once.\n *\n * @example\n * ```ts\n * justOnce(\"unexpected-value\", () => console.warn(\"There was an unexpected value returned\", {value}));\n * ```\n */\nexport function justOnce(key, fn) {\n if (!SEEN_KEYS.has(key)) {\n SEEN_KEYS.add(key);\n fn();\n }\n}"]}
1
+ {"version":3,"sources":["../../../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","../../src/types/PackApp.ts","../../src/utils/assertNever.ts","../../src/utils/generateId.ts","../../src/utils/getOntologyRid.ts","../../src/utils/justOnce.ts","../../src/utils/parseJwtPayload.ts"],"names":[],"mappings":";AAAA,IAAI,YAAA,GAAe,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA;AAC5C,IAAI,MAAA,GAAS,kBAAA;AACb,SAAS,SAAA,CAAU,WAAW,OAAA,EAAS;AAIrC,EAAA,IAAI,YAAA,EAAc;AAChB,IAAA,MAAM,IAAI,MAAM,MAAM,CAAA;AAAA,EACxB;AACA,EAAA,IAAI,QAAA,GAAW,OAAO,OAAA,KAAY,UAAA,GAAa,SAAQ,GAAI,OAAA;AAC3D,EAAA,IAAI,KAAA,GAAQ,WAAW,EAAA,CAAG,MAAA,CAAO,QAAQ,IAAI,CAAA,CAAE,MAAA,CAAO,QAAQ,CAAA,GAAI,MAAA;AAClE,EAAA,MAAM,IAAI,MAAM,KAAK,CAAA;AACvB;;;ACqCO,IAAM,sBAAsB,CAAA,MAAA,KAAU;AAC3C,EAAA,OAAO,KAAA,CAAM,QAAQ,MAAM,CAAA;AAC7B;AASO,SAAS,oBAAoB,GAAA,EAAK;AACvC,EAAA,EAAE,WAAA,IAAe,GAAA,CAAA,GAAO,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA,GAAe,SAAA,CAAU,KAAA,EAAO,+BAA+B,CAAA,GAAI,SAAA,CAAe,CAAA,GAAI,MAAA;AACzI;;;ACxCO,SAAS,YAAY,EAAA,EAAI;AAC9B,EAAA,MAAM,IAAI,MAAM,sBAAsB,CAAA;AACxC;;;ACHO,SAAS,UAAA,CAAW,QAAQ,EAAA,EAAI;AACrC,EAAA,MAAM,KAAA,GAAQ,IAAI,SAAA,CAAU,KAAK,CAAA;AACjC,EAAA,MAAM,CAAA,GAAI,MAAA,CAAO,eAAA,CAAgB,KAAK,CAAA;AACtC,EAAA,OAAO,YAAY,CAAC,CAAA;AACtB;AACA,SAAS,YAAY,SAAA,EAAW;AAC9B,EAAA,OAAO,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,SAAU,IAAA,EAAM;AAC3C,IAAA,MAAM,CAAA,GAAA,CAAK,IAAA,GAAO,GAAA,EAAM,QAAA,CAAS,EAAE,CAAA;AACnC,IAAA,OAAO,CAAA,CAAE,MAAA,KAAW,CAAA,GAAI,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,GAAK,CAAA;AAAA,EACpC,CAAC,CAAA,CAAE,IAAA,CAAK,EAAE,CAAA;AACZ;;;ACfA,eAAsB,eAAe,GAAA,EAAK;AACxC,EAAA,OAAO,IAAI,MAAA,CAAO,WAAA;AACpB;;;ACFA,IAAM,SAAA,uBAAgB,GAAA,EAAI;AAWnB,SAAS,QAAA,CAAS,KAAK,EAAA,EAAI;AAChC,EAAA,IAAI,CAAC,SAAA,CAAU,GAAA,CAAI,GAAG,CAAA,EAAG;AACvB,IAAA,SAAA,CAAU,IAAI,GAAG,CAAA;AACjB,IAAA,EAAA,EAAG;AAAA,EACL;AACF;;;ACPO,SAAS,gBAAgB,KAAA,EAAO;AACrC,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,KAAA,CAAM,GAAG,CAAA;AAC7B,EAAA,IAAI,MAAM,MAAA,KAAW,CAAA,IAAK,CAAC,KAAA,CAAM,CAAC,CAAA,EAAG;AACnC,IAAA,MAAM,IAAI,MAAM,0BAA0B,CAAA;AAAA,EAC5C;AACA,EAAA,OAAO,KAAK,KAAA,CAAM,IAAA,CAAK,KAAA,CAAM,CAAC,CAAC,CAAC,CAAA;AAClC","file":"index.js","sourcesContent":["var isProduction = process.env.NODE_ENV === 'production';\nvar prefix = 'Invariant failed';\nfunction invariant(condition, message) {\n if (condition) {\n return;\n }\n if (isProduction) {\n throw new Error(prefix);\n }\n var provided = typeof message === 'function' ? message() : message;\n var value = provided ? \"\".concat(prefix, \": \").concat(provided) : prefix;\n throw new Error(value);\n}\nexport { invariant as default };","/*\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 invariant from \"tiny-invariant\";\n\n/**\n * PackApp provides access to various pack subsystems.\n *\n * Specific modules are available after configuration and through declarations mixed in by import.\n * Eg for state system, if you import @palantir/pack.state.core you will have access to `app.state` accessor.\n * Similarly, auth is added automatically by initPackApp.\n *\n * @example\n * ```typescript\n * import { DocumentRef } from '@palantir/pack.state.core';\n * import { DocSchema } from '@my-app/schema';\n *\n * const app = initPackApp({\n * tokenProvider: () => 'your-token',\n * moduleConfigs: {\n * ...createPackDocumentServiceConfig({appId: 'your-app-id', documentType: 'your-document-type'})\n * },\n * });\n *\n * const docRef = app.state.createDocRef(docSchema, 'your-document-id');\n * const doc = await docRef.getSnapshot(); // get pojo of your doc state.\n * ```\n */\n\n/**\n * Module configuration - either a tuple of [ModuleKey, config] or just a ModuleKey (for modules with no config)\n */\n\n/**\n * Type guard to check if a ModuleConfig is a tuple configuration\n */\nexport const isModuleConfigTuple = config => {\n return Array.isArray(config);\n};\n\n/**\n * To simplify the public type interface on methods taking a PackApp,\n * this function asserts that the implementation is in fact a PackAppInternal\n * implementation, which allows internal module access and perhaps other\n * private functionality in the future.\n */\n\nexport function assertIsAppInternal(app) {\n !(\"getModule\" in app) ? process.env.NODE_ENV !== \"production\" ? invariant(false, \"App is not an PackAppInternal\") : invariant(false) : void 0;\n}","/*\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\n/**\n * Assert that a value type is never, useful for compile time exhaustiveness checking.\n *\n * If it is hit at runtime, it may indicate a bug in the code, or an unhandled case\n * for a new value added to a remotely loaded type.\n */\nexport function assertNever(_x) {\n throw new Error(\"Hit unreachable code\");\n}","/*\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\n/**\n * Generates a random ID using crypto library.\n * @param bytes Generate an ID with this many random bytes (default: 12)\n * @returns A hexadecimal string representation of the generated ID\n */\nexport function generateId(bytes = 12) {\n const array = new Int8Array(bytes);\n const r = crypto.getRandomValues(array);\n return toHexString(r);\n}\nfunction toHexString(byteArray) {\n return Array.from(byteArray, function (byte) {\n const h = (byte & 0xff).toString(16);\n return h.length === 1 ? `0${h}` : h;\n }).join(\"\");\n}","/*\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\nexport async function getOntologyRid(app) {\n return app.config.ontologyRid;\n}","/*\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\nconst SEEN_KEYS = new Set();\n\n/**\n * Used to call fn only once between app reloads.\n * eg: Useful for logging warnings that should only be logged once.\n *\n * @example\n * ```ts\n * justOnce(\"unexpected-value\", () => console.warn(\"There was an unexpected value returned\", {value}));\n * ```\n */\nexport function justOnce(key, fn) {\n if (!SEEN_KEYS.has(key)) {\n SEEN_KEYS.add(key);\n fn();\n }\n}","/*\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\n/**\n * Parse JWT token payload without verification.\n * This does NOT verify the token signature - it only extracts payload data.\n * Use only for non-security-critical operations like testing or logging.\n *\n * @param token - JWT token string\n * @returns Parsed payload object\n * @throws Error if token format is invalid\n */\nexport function parseJwtPayload(token) {\n const parts = token.split(\".\");\n if (parts.length !== 3 || !parts[1]) {\n throw new Error(\"Invalid JWT token format\");\n }\n return JSON.parse(atob(parts[1]));\n}"]}
@@ -7,4 +7,6 @@ export type { TokenProvider } from "./types/TokenProvider.js";
7
7
  export type { Unsubscribe } from "./types/Unsubscribe.js";
8
8
  export { assertNever } from "./utils/assertNever.js";
9
9
  export { generateId } from "./utils/generateId.js";
10
+ export { getOntologyRid } from "./utils/getOntologyRid.js";
10
11
  export { justOnce } from "./utils/justOnce.js";
12
+ export { parseJwtPayload } from "./utils/parseJwtPayload.js";
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,WAAW,kBAAkB;AAC3C,cAAc,SAAS,gBAAgB;AACvC,cAAc,iBAAiB;AAC/B,SAAS,qBAAqB,2BAA2B;AACzD,cAAc,cAAc,mBAAmB,SAAS,uBAAuB;AAC/E,cAAc,qBAAqB;AACnC,cAAc,mBAAmB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,WAAW,kBAAkB;AAC3C,cAAc,SAAS,gBAAgB;AACvC,cAAc,iBAAiB;AAC/B,SAAS,qBAAqB,2BAA2B;AACzD,cAAc,cAAc,mBAAmB,SAAS,uBAAuB;AAC/E,cAAc,qBAAqB;AACnC,cAAc,mBAAmB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AACzB,SAAS,uBAAuB","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
@@ -7,8 +7,16 @@ export interface AppConfig {
7
7
  readonly appId: string;
8
8
  readonly appVersion?: string;
9
9
  };
10
- readonly isTestMode: boolean;
10
+ /**
11
+ * Test/demo mode configuration:
12
+ * - `true`: Is in demo mode (always use demo services, ignore real Foundry config)
13
+ * - `false`: Production only (never use demo services)
14
+ *
15
+ * @default false (production mode)
16
+ */
17
+ readonly isDemoMode?: boolean;
11
18
  readonly logger: Logger;
19
+ readonly ontologyRid: Promise<string>;
12
20
  readonly osdkClient: Client;
13
21
  readonly remote: {
14
22
  readonly packWsPath: string;
@@ -32,6 +40,17 @@ export interface AppOptions {
32
40
  readonly appVersion?: string;
33
41
  };
34
42
  /**
43
+ * Test/demo mode configuration:
44
+ * - `true`: Force demo mode (always use demo services)
45
+ * - `"auto"`: Auto-detect - use demo mode when no real Foundry config in environment, otherwise production
46
+ * - `false`: Production only
47
+ *
48
+ * When `"auto"`, checks for non-localhost FOUNDRY_URL in environment variables.
49
+ *
50
+ * @default Auto-detected: true if no baseUrl, otherwise false
51
+ */
52
+ readonly demoMode?: boolean | "auto";
53
+ /**
35
54
  * Logger configuration.
36
55
  * @see {@link @osdk/client/internal.BrowserLogger} for a richer console logger.
37
56
  * @default Log warnings & errors only.
@@ -42,6 +61,7 @@ export interface AppOptions {
42
61
  * Internal testing overrides.
43
62
  */
44
63
  readonly moduleOverrides?: readonly ModuleConfigTuple[];
64
+ readonly ontologyRid?: string | Promise<string>;
45
65
  readonly remote?: {
46
66
  /**
47
67
  * @default "/api/v2/packSubscriptions"
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,cAAc;AAC5B,cAAc,cAAc;AAC5B,cAAc,yBAAyB;AACvC,cAAc,qBAAqB;AAEnC,iBAAiB,UAAU;UAChB,KAAK;WACH;WACA;;UAGF;UAEA,QAAQ;UAER,YAAY;UAEZ,QAAQ;WACN;WACA;WACA,gBAAgB,WAAW;;;AAIxC,iBAAiB,WAAW;;;;;;UAMjB,OAAO;;;;;UAMP,MAAM;WACJ;WACA;;;;;;;UAQF,SAAS;UACT,WAAW,UAAU,UAAU,SAAS;;;;UAKxC,2BAA2B;UAE3B,SAAS;;;;WAIP;;;;;;;;WASA;;;;WAKA,iBAAiB,WAAW","names":[],"sources":["../../../src/types/AppConfig.ts"],"version":3,"file":"AppConfig.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,cAAc;AAC5B,cAAc,cAAc;AAC5B,cAAc,yBAAyB;AACvC,cAAc,qBAAqB;AAEnC,iBAAiB,UAAU;UAChB,KAAK;WACH;WACA;;;;;;;;;UAUF;UAEA,QAAQ;UAER,aAAa;UACb,YAAY;UAEZ,QAAQ;WACN;WACA;WACA,gBAAgB,WAAW;;;AAIxC,iBAAiB,WAAW;;;;;;UAMjB,OAAO;;;;;UAMP,MAAM;WACJ;WACA;;;;;;;;;;;;UAaF,qBAAqB;;;;;;UAOrB,SAAS;UACT,WAAW,UAAU,UAAU,SAAS;;;;UAKxC,2BAA2B;UAG3B,uBAAuB;UAEvB,SAAS;;;;WAIP;;;;;;;;WASA;;;;WAKA,iBAAiB,WAAW","names":[],"sources":["../../../src/types/AppConfig.ts"],"version":3,"file":"AppConfig.d.ts"}
@@ -0,0 +1,2 @@
1
+ import type { PackApp, PackAppInternal } from "../types/PackApp.js";
2
+ export declare function getOntologyRid(app: PackApp | PackAppInternal): Promise<string>;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAAc,SAAS,uBAAuB;AAE9C,OAAO,iBAAe,eAAe,KAAK,UAAU,kBAAkB","names":[],"sources":["../../../src/utils/getOntologyRid.ts"],"version":3,"file":"getOntologyRid.d.ts"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Parse JWT token payload without verification.
3
+ * This does NOT verify the token signature - it only extracts payload data.
4
+ * Use only for non-security-critical operations like testing or logging.
5
+ *
6
+ * @param token - JWT token string
7
+ * @returns Parsed payload object
8
+ * @throws Error if token format is invalid
9
+ */
10
+ export declare function parseJwtPayload(token: string): Record<string, unknown>;
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;AAyBA,OAAO,iBAAS,gBAAgB,gBAAgB","names":[],"sources":["../../../src/utils/parseJwtPayload.ts"],"version":3,"file":"parseJwtPayload.d.ts"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@palantir/pack.core",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "PACK Core functionality and utilities",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -28,17 +28,17 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@osdk/client": "~2.4.2",
31
+ "@osdk/client": "~2.5.2",
32
32
  "remeda": "^2.32.0"
33
33
  },
34
34
  "peerDependencies": {
35
- "@osdk/api": "~2.4.2"
35
+ "@osdk/api": "~2.5.2"
36
36
  },
37
37
  "devDependencies": {
38
- "rimraf": "^6.0.1",
38
+ "rimraf": "^6.1.2",
39
39
  "tiny-invariant": "^1.3.3",
40
40
  "tslib": "^2.8.1",
41
- "typescript": "^5.9.2",
41
+ "typescript": "^5.9.3",
42
42
  "@palantir/pack.monorepo.tsconfig": "~0.4.3"
43
43
  },
44
44
  "publishConfig": {
package/src/index.ts CHANGED
@@ -23,4 +23,6 @@ export type { TokenProvider } from "./types/TokenProvider.js";
23
23
  export type { Unsubscribe } from "./types/Unsubscribe.js";
24
24
  export { assertNever } from "./utils/assertNever.js";
25
25
  export { generateId } from "./utils/generateId.js";
26
+ export { getOntologyRid } from "./utils/getOntologyRid.js";
26
27
  export { justOnce } from "./utils/justOnce.js";
28
+ export { parseJwtPayload } from "./utils/parseJwtPayload.js";
@@ -25,10 +25,18 @@ export interface AppConfig {
25
25
  readonly appVersion?: string;
26
26
  };
27
27
 
28
- readonly isTestMode: boolean;
28
+ /**
29
+ * Test/demo mode configuration:
30
+ * - `true`: Is in demo mode (always use demo services, ignore real Foundry config)
31
+ * - `false`: Production only (never use demo services)
32
+ *
33
+ * @default false (production mode)
34
+ */
35
+ readonly isDemoMode?: boolean;
29
36
 
30
37
  readonly logger: Logger;
31
38
 
39
+ readonly ontologyRid: Promise<string>;
32
40
  readonly osdkClient: Client;
33
41
 
34
42
  readonly remote: {
@@ -55,6 +63,18 @@ export interface AppOptions {
55
63
  readonly appVersion?: string;
56
64
  };
57
65
 
66
+ /**
67
+ * Test/demo mode configuration:
68
+ * - `true`: Force demo mode (always use demo services)
69
+ * - `"auto"`: Auto-detect - use demo mode when no real Foundry config in environment, otherwise production
70
+ * - `false`: Production only
71
+ *
72
+ * When `"auto"`, checks for non-localhost FOUNDRY_URL in environment variables.
73
+ *
74
+ * @default Auto-detected: true if no baseUrl, otherwise false
75
+ */
76
+ readonly demoMode?: boolean | "auto";
77
+
58
78
  /**
59
79
  * Logger configuration.
60
80
  * @see {@link @osdk/client/internal.BrowserLogger} for a richer console logger.
@@ -68,6 +88,9 @@ export interface AppOptions {
68
88
  */
69
89
  readonly moduleOverrides?: readonly ModuleConfigTuple[];
70
90
 
91
+ // TODO: ideally we can extract this from the osdkClient but it hides everything and provides no util.
92
+ readonly ontologyRid?: string | Promise<string>;
93
+
71
94
  readonly remote?: {
72
95
  /**
73
96
  * @default "/api/v2/packSubscriptions"
@@ -0,0 +1,21 @@
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 type { PackApp, PackAppInternal } from "../types/PackApp.js";
18
+
19
+ export async function getOntologyRid(app: PackApp | PackAppInternal): Promise<string> {
20
+ return app.config.ontologyRid;
21
+ }
@@ -0,0 +1,32 @@
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
+ * Parse JWT token payload without verification.
19
+ * This does NOT verify the token signature - it only extracts payload data.
20
+ * Use only for non-security-critical operations like testing or logging.
21
+ *
22
+ * @param token - JWT token string
23
+ * @returns Parsed payload object
24
+ * @throws Error if token format is invalid
25
+ */
26
+ export function parseJwtPayload(token: string): Record<string, unknown> {
27
+ const parts = token.split(".");
28
+ if (parts.length !== 3 || !parts[1]) {
29
+ throw new Error("Invalid JWT token format");
30
+ }
31
+ return JSON.parse(atob(parts[1]));
32
+ }