@palantir/pack.core 0.1.0 → 0.1.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.1.0 lint /home/runner/work/pack/pack/packages/core
2
+ > @palantir/pack.core@0.1.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,5 @@
1
1
 
2
- > @palantir/pack.core@0.1.0 transpileBrowser /home/runner/work/pack/pack/packages/core
2
+ > @palantir/pack.core@0.1.1 transpileBrowser /home/runner/work/pack/pack/packages/core
3
3
  > monorepo-transpile -f esm -m bundle -t browser
4
4
 
5
5
  👍
@@ -1,5 +1,5 @@
1
1
 
2
- > @palantir/pack.core@0.1.0 transpileCjs /home/runner/work/pack/pack/packages/core
2
+ > @palantir/pack.core@0.1.1 transpileCjs /home/runner/work/pack/pack/packages/core
3
3
  > monorepo-transpile -f cjs -m bundle -t node
4
4
 
5
5
  👍
@@ -1,5 +1,5 @@
1
1
 
2
- > @palantir/pack.core@0.1.0 transpileEsm /home/runner/work/pack/pack/packages/core
2
+ > @palantir/pack.core@0.1.1 transpileEsm /home/runner/work/pack/pack/packages/core
3
3
  > monorepo-transpile -f esm -m bundle -t node
4
4
 
5
5
  👍
@@ -1,5 +1,5 @@
1
1
 
2
- > @palantir/pack.core@0.1.0 transpileTypes /home/runner/work/pack/pack/packages/core
2
+ > @palantir/pack.core@0.1.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.1.0 typecheck /home/runner/work/pack/pack/packages/core
2
+ > @palantir/pack.core@0.1.1 typecheck /home/runner/work/pack/pack/packages/core
3
3
  > tsc --noEmit --emitDeclarationOnly false
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @palantir/pack.core
2
2
 
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - eba27ae: Fix issues locating model metadata when multiple copies of the schema package are present
8
+ - 67df6e4: Documented public apis
9
+
3
10
  ## 0.1.0
4
11
 
5
12
  ### Minor Changes
@@ -24,17 +24,17 @@ function assertNever(_x) {
24
24
  }
25
25
 
26
26
  // src/utils/generateId.ts
27
+ function generateId(bytes = 12) {
28
+ const array = new Int8Array(bytes);
29
+ const r = crypto.getRandomValues(array);
30
+ return toHexString(r);
31
+ }
27
32
  function toHexString(byteArray) {
28
33
  return Array.from(byteArray, function(byte) {
29
34
  const h = (byte & 255).toString(16);
30
35
  return h.length === 1 ? `0${h}` : h;
31
36
  }).join("");
32
37
  }
33
- function generateId(bytes = 12) {
34
- const array = new Int8Array(bytes);
35
- const r = crypto.getRandomValues(array);
36
- return toHexString(r);
37
- }
38
38
 
39
39
  // src/utils/justOnce.ts
40
40
  var SEEN_KEYS = /* @__PURE__ */ new Set();
@@ -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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,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.getDocument(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};\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\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\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}\nexport function generateId(bytes = 12) {\n const array = new Int8Array(bytes);\n const r = crypto.getRandomValues(array);\n return toHexString(r);\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/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}"]}
@@ -26,17 +26,17 @@ function assertNever(_x) {
26
26
  }
27
27
 
28
28
  // src/utils/generateId.ts
29
+ function generateId(bytes = 12) {
30
+ const array = new Int8Array(bytes);
31
+ const r = crypto.getRandomValues(array);
32
+ return toHexString(r);
33
+ }
29
34
  function toHexString(byteArray) {
30
35
  return Array.from(byteArray, function(byte) {
31
36
  const h = (byte & 255).toString(16);
32
37
  return h.length === 1 ? `0${h}` : h;
33
38
  }).join("");
34
39
  }
35
- function generateId(bytes = 12) {
36
- const array = new Int8Array(bytes);
37
- const r = crypto.getRandomValues(array);
38
- return toHexString(r);
39
- }
40
40
 
41
41
  // src/utils/justOnce.ts
42
42
  var SEEN_KEYS = /* @__PURE__ */ new Set();
@@ -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;AACO,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;;;ACtCO,SAAS,YAAY,EAAA,EAAI;AAC9B,EAAA,MAAM,IAAI,MAAM,sBAAsB,CAAA;AACxC;;;ACFA,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;AACO,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;;;ACVA,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.getDocument(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};\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\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\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}\nexport function generateId(bytes = 12) {\n const array = new Int8Array(bytes);\n const r = crypto.getRandomValues(array);\n return toHexString(r);\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/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}"]}
@@ -70,7 +70,7 @@ interface ModuleKey<T, TConfig = unknown> {
70
70
  * },
71
71
  * });
72
72
  *
73
- * const docRef = app.state.getDocument(docSchema, 'your-document-id');
73
+ * const docRef = app.state.createDocRef(docSchema, 'your-document-id');
74
74
  * const doc = await docRef.getSnapshot(); // get pojo of your doc state.
75
75
  * ```
76
76
  */
@@ -93,6 +93,12 @@ interface PackAppInternal {
93
93
  */
94
94
  getModule<T, TConfig = undefined>(moduleKey: ModuleKey<T, TConfig>): T;
95
95
  }
96
+ /**
97
+ * To simplify the public type interface on methods taking a PackApp,
98
+ * this function asserts that the implementation is in fact a PackAppInternal
99
+ * implementation, which allows internal module access and perhaps other
100
+ * private functionality in the future.
101
+ */
96
102
  declare function assertIsAppInternal(app: PackApp): asserts app is PackApp & PackAppInternal;
97
103
  declare function assertIsAppInternal(app: PackAppInternal): asserts app is PackAppInternal;
98
104
 
@@ -184,8 +190,19 @@ type Flavored<Flavor extends string, T = string> = T & Readonly<{
184
190
 
185
191
  type Unsubscribe = () => void;
186
192
 
193
+ /**
194
+ * Assert that a value type is never, useful for compile time exhaustiveness checking.
195
+ *
196
+ * If it is hit at runtime, it may indicate a bug in the code, or an unhandled case
197
+ * for a new value added to a remotely loaded type.
198
+ */
187
199
  declare function assertNever(_x: never): never;
188
200
 
201
+ /**
202
+ * Generates a random ID using crypto library.
203
+ * @param bytes Generate an ID with this many random bytes (default: 12)
204
+ * @returns A hexadecimal string representation of the generated ID
205
+ */
189
206
  declare function generateId(bytes?: number): string;
190
207
 
191
208
  /**
@@ -24,17 +24,17 @@ function assertNever(_x) {
24
24
  }
25
25
 
26
26
  // src/utils/generateId.ts
27
+ function generateId(bytes = 12) {
28
+ const array = new Int8Array(bytes);
29
+ const r = crypto.getRandomValues(array);
30
+ return toHexString(r);
31
+ }
27
32
  function toHexString(byteArray) {
28
33
  return Array.from(byteArray, function(byte) {
29
34
  const h = (byte & 255).toString(16);
30
35
  return h.length === 1 ? `0${h}` : h;
31
36
  }).join("");
32
37
  }
33
- function generateId(bytes = 12) {
34
- const array = new Int8Array(bytes);
35
- const r = crypto.getRandomValues(array);
36
- return toHexString(r);
37
- }
38
38
 
39
39
  // src/utils/justOnce.ts
40
40
  var SEEN_KEYS = /* @__PURE__ */ new Set();
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant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A,EAAI,CAAC,CAAA,CAAA,GAAK,CAAA;AAAA,EACpC,CAAC,CAAA,CAAE,IAAA,CAAK,EAAE,CAAA;AACZ;AACO,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;;;ACVA,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.getDocument(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};\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\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\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}\nexport function generateId(bytes = 12) {\n const array = new Int8Array(bytes);\n const r = crypto.getRandomValues(array);\n return toHexString(r);\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/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,C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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}"]}
@@ -19,7 +19,7 @@ import type { ModuleKey } from "./ModuleKey.js";
19
19
  * },
20
20
  * });
21
21
  *
22
- * const docRef = app.state.getDocument(docSchema, 'your-document-id');
22
+ * const docRef = app.state.createDocRef(docSchema, 'your-document-id');
23
23
  * const doc = await docRef.getSnapshot(); // get pojo of your doc state.
24
24
  * ```
25
25
  */
@@ -45,5 +45,11 @@ export interface PackAppInternal {
45
45
  TConfig = undefined
46
46
  >(moduleKey: ModuleKey<T, TConfig>): T;
47
47
  }
48
+ /**
49
+ * To simplify the public type interface on methods taking a PackApp,
50
+ * this function asserts that the implementation is in fact a PackAppInternal
51
+ * implementation, which allows internal module access and perhaps other
52
+ * private functionality in the future.
53
+ */
48
54
  export declare function assertIsAppInternal(app: PackApp): asserts app is PackApp & PackAppInternal;
49
55
  export declare function assertIsAppInternal(app: PackAppInternal): asserts app is PackAppInternal;
@@ -1 +1 @@
1
- {"mappings":"AAiBA,cAAc,iBAAiB;AAC/B,cAAc,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;AAyB/B,iBAAiB,QAAQ;UACd,QAAQ;;;;;AAOnB,YAAY,kBAAkB,yBAAyB,UAAU;AACjE,YAAY,aAAa,eAAe,kBAAkB,KAAK,UAAU;;;;AAKzE,OAAO,cAAM,sBACX,QAAQ,iBACP,oBAAoB;AAIvB,iBAAiB,gBAAgB;UACtB,QAAQ;;;;CAMjB;EAAU;EAAG;GAAqB,WAAW,UAAU,GAAG,WAAW;;AAGvE,OAAO,iBAAS,oBAAoB,KAAK,kBAAkB,OAAO,UAAU;AAC5E,OAAO,iBAAS,oBACd,KAAK,0BACI,OAAO","names":[],"sources":["../../../src/types/PackApp.ts"],"version":3,"file":"PackApp.d.ts"}
1
+ {"mappings":"AAiBA,cAAc,iBAAiB;AAC/B,cAAc,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;AAyB/B,iBAAiB,QAAQ;UACd,QAAQ;;;;;AAOnB,YAAY,kBAAkB,yBAAyB,UAAU;AACjE,YAAY,aAAa,eAAe,kBAAkB,KAAK,UAAU;;;;AAKzE,OAAO,cAAM,sBACX,QAAQ,iBACP,oBAAoB;AAIvB,iBAAiB,gBAAgB;UACtB,QAAQ;;;;CAMjB;EAAU;EAAG;GAAqB,WAAW,UAAU,GAAG,WAAW;;;;;;;;AASvE,OAAO,iBAAS,oBAAoB,KAAK,kBAAkB,OAAO,UAAU;AAC5E,OAAO,iBAAS,oBACd,KAAK,0BACI,OAAO","names":[],"sources":["../../../src/types/PackApp.ts"],"version":3,"file":"PackApp.d.ts"}
@@ -1 +1,7 @@
1
+ /**
2
+ * Assert that a value type is never, useful for compile time exhaustiveness checking.
3
+ *
4
+ * If it is hit at runtime, it may indicate a bug in the code, or an unhandled case
5
+ * for a new value added to a remotely loaded type.
6
+ */
1
7
  export declare function assertNever(_x: never): never;
@@ -1 +1 @@
1
- {"mappings":"AAgBA,OAAO,iBAAS,YAAY","names":[],"sources":["../../../src/utils/assertNever.ts"],"version":3,"file":"assertNever.d.ts"}
1
+ {"mappings":";;;;;;AAsBA,OAAO,iBAAS,YAAY","names":[],"sources":["../../../src/utils/assertNever.ts"],"version":3,"file":"assertNever.d.ts"}
@@ -1 +1,6 @@
1
+ /**
2
+ * Generates a random ID using crypto library.
3
+ * @param bytes Generate an ID with this many random bytes (default: 12)
4
+ * @returns A hexadecimal string representation of the generated ID
5
+ */
1
6
  export declare function generateId(bytes?: number): string;
@@ -1 +1 @@
1
- {"mappings":"AAuBA,OAAO,iBAAS,WAAW","names":[],"sources":["../../../src/utils/generateId.ts"],"version":3,"file":"generateId.d.ts"}
1
+ {"mappings":";;;;;AAqBA,OAAO,iBAAS,WAAW","names":[],"sources":["../../../src/utils/generateId.ts"],"version":3,"file":"generateId.d.ts"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@palantir/pack.core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "PACK Core functionality and utilities",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -39,7 +39,7 @@
39
39
  "tiny-invariant": "^1.3.3",
40
40
  "tslib": "^2.8.1",
41
41
  "typescript": "^5.9.2",
42
- "@palantir/pack.monorepo.tsconfig": "~0.4.0"
42
+ "@palantir/pack.monorepo.tsconfig": "~0.4.3"
43
43
  },
44
44
  "publishConfig": {
45
45
  "access": "public"
@@ -37,7 +37,7 @@ import type { ModuleKey } from "./ModuleKey.js";
37
37
  * },
38
38
  * });
39
39
  *
40
- * const docRef = app.state.getDocument(docSchema, 'your-document-id');
40
+ * const docRef = app.state.createDocRef(docSchema, 'your-document-id');
41
41
  * const doc = await docRef.getSnapshot(); // get pojo of your doc state.
42
42
  * ```
43
43
  */
@@ -71,6 +71,12 @@ export interface PackAppInternal {
71
71
  getModule<T, TConfig = undefined>(moduleKey: ModuleKey<T, TConfig>): T;
72
72
  }
73
73
 
74
+ /**
75
+ * To simplify the public type interface on methods taking a PackApp,
76
+ * this function asserts that the implementation is in fact a PackAppInternal
77
+ * implementation, which allows internal module access and perhaps other
78
+ * private functionality in the future.
79
+ */
74
80
  export function assertIsAppInternal(app: PackApp): asserts app is PackApp & PackAppInternal;
75
81
  export function assertIsAppInternal(
76
82
  app: PackAppInternal,
@@ -14,6 +14,12 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ /**
18
+ * Assert that a value type is never, useful for compile time exhaustiveness checking.
19
+ *
20
+ * If it is hit at runtime, it may indicate a bug in the code, or an unhandled case
21
+ * for a new value added to a remotely loaded type.
22
+ */
17
23
  export function assertNever(_x: never): never {
18
24
  throw new Error("Hit unreachable code");
19
25
  }
@@ -14,15 +14,20 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ /**
18
+ * Generates a random ID using crypto library.
19
+ * @param bytes Generate an ID with this many random bytes (default: 12)
20
+ * @returns A hexadecimal string representation of the generated ID
21
+ */
22
+ export function generateId(bytes = 12): string {
23
+ const array = new Int8Array(bytes);
24
+ const r = crypto.getRandomValues(array);
25
+ return toHexString(r);
26
+ }
27
+
17
28
  function toHexString(byteArray: Int8Array) {
18
29
  return Array.from(byteArray, function(byte) {
19
30
  const h = (byte & 0xff).toString(16);
20
31
  return h.length === 1 ? `0${h}` : h;
21
32
  }).join("");
22
33
  }
23
-
24
- export function generateId(bytes = 12): string {
25
- const array = new Int8Array(bytes);
26
- const r = crypto.getRandomValues(array);
27
- return toHexString(r);
28
- }