@palantir/pack.core 0.1.0-beta.2 → 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.
- package/.turbo/turbo-lint.log +2 -2
- package/.turbo/turbo-transpileBrowser.log +1 -1
- package/.turbo/turbo-transpileCjs.log +1 -1
- package/.turbo/turbo-transpileEsm.log +1 -1
- package/.turbo/turbo-transpileTypes.log +1 -1
- package/.turbo/turbo-typecheck.log +1 -1
- package/CHANGELOG.md +18 -0
- package/build/browser/index.js +5 -5
- package/build/browser/index.js.map +1 -1
- package/build/cjs/index.cjs +5 -5
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/index.d.cts +19 -7
- package/build/esm/index.js +5 -5
- package/build/esm/index.js.map +1 -1
- package/build/types/types/AppConfig.d.ts +1 -6
- package/build/types/types/AppConfig.d.ts.map +1 -1
- package/build/types/types/PackApp.d.ts +7 -1
- package/build/types/types/PackApp.d.ts.map +1 -1
- package/build/types/utils/assertNever.d.ts +6 -0
- package/build/types/utils/assertNever.d.ts.map +1 -1
- package/build/types/utils/generateId.d.ts +5 -0
- package/build/types/utils/generateId.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/types/AppConfig.ts +1 -7
- package/src/types/PackApp.ts +7 -1
- package/src/utils/assertNever.ts +6 -0
- package/src/utils/generateId.ts +11 -6
package/.turbo/turbo-lint.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @palantir/pack.core@0.1.
|
|
3
|
-
> eslint ./src
|
|
2
|
+
> @palantir/pack.core@0.1.1 lint /home/runner/work/pack/pack/packages/core
|
|
3
|
+
> eslint ./src && dprint check --config $(find-up dprint.json) --allow-no-files
|
|
4
4
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
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
|
+
|
|
10
|
+
## 0.1.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 77c07c4: Add Core and State Core packages, add Refs to core model types
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 8698373: Updated websocket path
|
|
19
|
+
- 3ebc927: Drop packApiPath
|
|
20
|
+
|
|
3
21
|
## 0.1.0-beta.2
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/build/browser/index.js
CHANGED
|
@@ -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,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;
|
|
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,sBAAs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ant 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}"]}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -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();
|
package/build/cjs/index.cjs.map
CHANGED
|
@@ -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;
|
|
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;;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V === '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}"]}
|
package/build/cjs/index.d.cts
CHANGED
|
@@ -70,7 +70,7 @@ interface ModuleKey<T, TConfig = unknown> {
|
|
|
70
70
|
* },
|
|
71
71
|
* });
|
|
72
72
|
*
|
|
73
|
-
* const docRef = app.state.
|
|
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
|
|
|
@@ -107,7 +113,6 @@ interface AppConfig {
|
|
|
107
113
|
readonly logger: Logger;
|
|
108
114
|
readonly osdkClient: Client;
|
|
109
115
|
readonly remote: {
|
|
110
|
-
readonly packApiPath: string;
|
|
111
116
|
readonly packWsPath: string;
|
|
112
117
|
readonly baseUrl: string;
|
|
113
118
|
readonly fetchFn: typeof globalThis.fetch;
|
|
@@ -141,11 +146,7 @@ interface AppOptions {
|
|
|
141
146
|
readonly moduleOverrides?: readonly ModuleConfigTuple[];
|
|
142
147
|
readonly remote?: {
|
|
143
148
|
/**
|
|
144
|
-
* @default "/
|
|
145
|
-
*/
|
|
146
|
-
readonly packApiPath?: string;
|
|
147
|
-
/**
|
|
148
|
-
* @default "/pack/ws"
|
|
149
|
+
* @default "/api/v2/packSubscriptions"
|
|
149
150
|
*/
|
|
150
151
|
readonly packWsPath?: string;
|
|
151
152
|
/**
|
|
@@ -189,8 +190,19 @@ type Flavored<Flavor extends string, T = string> = T & Readonly<{
|
|
|
189
190
|
|
|
190
191
|
type Unsubscribe = () => void;
|
|
191
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
|
+
*/
|
|
192
199
|
declare function assertNever(_x: never): never;
|
|
193
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
|
+
*/
|
|
194
206
|
declare function generateId(bytes?: number): string;
|
|
195
207
|
|
|
196
208
|
/**
|
package/build/esm/index.js
CHANGED
|
@@ -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();
|
package/build/esm/index.js.map
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"sources":["../../../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.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AM,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}"]}
|
|
@@ -11,7 +11,6 @@ export interface AppConfig {
|
|
|
11
11
|
readonly logger: Logger;
|
|
12
12
|
readonly osdkClient: Client;
|
|
13
13
|
readonly remote: {
|
|
14
|
-
readonly packApiPath: string;
|
|
15
14
|
readonly packWsPath: string;
|
|
16
15
|
readonly baseUrl: string;
|
|
17
16
|
readonly fetchFn: typeof globalThis.fetch;
|
|
@@ -45,11 +44,7 @@ export interface AppOptions {
|
|
|
45
44
|
readonly moduleOverrides?: readonly ModuleConfigTuple[];
|
|
46
45
|
readonly remote?: {
|
|
47
46
|
/**
|
|
48
|
-
* @default "/
|
|
49
|
-
*/
|
|
50
|
-
readonly packApiPath?: string;
|
|
51
|
-
/**
|
|
52
|
-
* @default "/pack/ws"
|
|
47
|
+
* @default "/api/v2/packSubscriptions"
|
|
53
48
|
*/
|
|
54
49
|
readonly packWsPath?: string;
|
|
55
50
|
/**
|
|
@@ -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
|
|
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"}
|
|
@@ -19,7 +19,7 @@ import type { ModuleKey } from "./ModuleKey.js";
|
|
|
19
19
|
* },
|
|
20
20
|
* });
|
|
21
21
|
*
|
|
22
|
-
* const docRef = app.state.
|
|
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
|
|
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":"
|
|
1
|
+
{"mappings":";;;;;;AAsBA,OAAO,iBAAS,YAAY","names":[],"sources":["../../../src/utils/assertNever.ts"],"version":3,"file":"assertNever.d.ts"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
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.
|
|
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.
|
|
42
|
+
"@palantir/pack.monorepo.tsconfig": "~0.4.3"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"type": "module",
|
|
55
55
|
"scripts": {
|
|
56
56
|
"clean": "rimraf .turbo build dist lib test-output *.tgz tsconfig.tsbuildinfo",
|
|
57
|
-
"lint": "eslint ./src
|
|
58
|
-
"lint:fix": "eslint ./src --fix
|
|
57
|
+
"lint": "eslint ./src && dprint check --config $(find-up dprint.json) --allow-no-files",
|
|
58
|
+
"lint:fix": "eslint ./src --fix && dprint fmt --config $(find-up dprint.json) --allow-no-files",
|
|
59
59
|
"test": "vitest run --passWithNoTests -u",
|
|
60
60
|
"test:watch": "vitest --passWithNoTests",
|
|
61
61
|
"transpileBrowser": "monorepo-transpile -f esm -m bundle -t browser",
|
package/src/types/AppConfig.ts
CHANGED
|
@@ -32,7 +32,6 @@ export interface AppConfig {
|
|
|
32
32
|
readonly osdkClient: Client;
|
|
33
33
|
|
|
34
34
|
readonly remote: {
|
|
35
|
-
readonly packApiPath: string;
|
|
36
35
|
readonly packWsPath: string;
|
|
37
36
|
readonly baseUrl: string;
|
|
38
37
|
readonly fetchFn: typeof globalThis.fetch;
|
|
@@ -71,12 +70,7 @@ export interface AppOptions {
|
|
|
71
70
|
|
|
72
71
|
readonly remote?: {
|
|
73
72
|
/**
|
|
74
|
-
* @default "/
|
|
75
|
-
*/
|
|
76
|
-
readonly packApiPath?: string;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* @default "/pack/ws"
|
|
73
|
+
* @default "/api/v2/packSubscriptions"
|
|
80
74
|
*/
|
|
81
75
|
readonly packWsPath?: string;
|
|
82
76
|
|
package/src/types/PackApp.ts
CHANGED
|
@@ -37,7 +37,7 @@ import type { ModuleKey } from "./ModuleKey.js";
|
|
|
37
37
|
* },
|
|
38
38
|
* });
|
|
39
39
|
*
|
|
40
|
-
* const docRef = app.state.
|
|
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,
|
package/src/utils/assertNever.ts
CHANGED
|
@@ -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
|
}
|
package/src/utils/generateId.ts
CHANGED
|
@@ -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
|
-
}
|