@ms-cloudpack/api-server 0.61.33 → 0.61.35
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/lib/trpc/common.d.ts.map +1 -1
- package/lib/trpc/httpAdapter.d.ts.map +1 -1
- package/lib/utilities/getImportsAndExports.d.ts.map +1 -1
- package/lib/utilities/getImportsAndExports.js +8 -5
- package/lib/utilities/getImportsAndExports.js.map +1 -1
- package/lib/utilities/serializeContext.d.ts.map +1 -1
- package/package.json +4 -4
package/lib/trpc/common.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/trpc/common.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;AAKnD,mCAAmC;AACnC,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/trpc/common.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;AAKnD,mCAAmC;AACnC,eAAO,MAAM,YAAY;;;;;0FAAW,CAAC;AAErC,sCAAsC;AACtC,eAAO,MAAM,eAAe,iYAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpAdapter.d.ts","sourceRoot":"","sources":["../../src/trpc/httpAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAG9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAEL,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC5B,MAAM,iCAAiC,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AC;AAEjH,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS,EACzD,OAAO,EAAE,wBAAwB,CAAC,OAAO,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,IAElD,KAAK,IAAI,CAAC,eAAe,EAAE,KAAK,IAAI,CAAC,cAAc,KAAG,OAAO,CAAC,IAAI,CAAC,CAkBlF;AAED,wBAAsB,gBAAgB,CAAC,OAAO,SAAS,SAAS,EAC9D,OAAO,EAAE,wBAAwB,CAAC,OAAO,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/D,OAAO,CAAC;IACT,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IACnC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC,CAAC;CACvF,CAAC,CA0DD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getImportsAndExports.d.ts","sourceRoot":"","sources":["../../src/utilities/getImportsAndExports.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"getImportsAndExports.d.ts","sourceRoot":"","sources":["../../src/utilities/getImportsAndExports.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAI5E;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CACN;IACE,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,4EAA4E;IAC5E,cAAc,EAAE,aAAa,EAAE,CAAC;CACjC,GACD,SAAS,CACZ,CAwIA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { parseImportString, parseNamedImports } from '@ms-cloudpack/path-string-parsing';
|
|
2
|
-
import { parse } from 'es-module-lexer';
|
|
2
|
+
import { parse, init } from 'es-module-lexer';
|
|
3
3
|
import fsPromises from 'fs/promises';
|
|
4
4
|
import { SourceMapConsumer } from 'source-map';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { normalizedPathRelativeTo } from '@ms-cloudpack/path-utilities';
|
|
7
|
+
let initialized = false;
|
|
7
8
|
/**
|
|
8
9
|
* Get info about imports and exports from a file.
|
|
9
10
|
* Returns undefined if the file doesn't exist or can't be parsed.
|
|
@@ -18,13 +19,15 @@ export async function getImportsAndExports(filePath, packagePath) {
|
|
|
18
19
|
console.warn(`Failed to read ${filePath}:`, err);
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
22
|
+
if (!initialized) {
|
|
23
|
+
// Await init once for the Web Assembly boot to call parse synchronously.
|
|
24
|
+
await init;
|
|
25
|
+
initialized = true;
|
|
26
|
+
}
|
|
21
27
|
let rawImports;
|
|
22
28
|
let rawExports;
|
|
23
29
|
try {
|
|
24
|
-
|
|
25
|
-
// https://github.com/guybedford/es-module-lexer/issues/155
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/await-thenable
|
|
27
|
-
[rawImports, rawExports] = await parse(source);
|
|
30
|
+
[rawImports, rawExports] = parse(source);
|
|
28
31
|
}
|
|
29
32
|
catch (err) {
|
|
30
33
|
// This could happen if the source file isn't valid JS
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getImportsAndExports.js","sourceRoot":"","sources":["../../src/utilities/getImportsAndExports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAE,KAAK,EAA8C,MAAM,iBAAiB,CAAC;AACpF,OA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AAG,CAAC,CAAC;QACb,CAAC;aAAM,CAAC;YACN,MAAM,EAAE,CAAC;QACX,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC","sourcesContent":["import { parseImportString, parseNamedImports } from '@ms-cloudpack/path-string-parsing';\nimport { parse, type ImportSpecifier, type ExportSpecifier } from 'es-module-lexer';\nimport fsPromises from 'fs/promises';\nimport { SourceMapConsumer, type RawSourceMap } from 'source-map';\nimport path from 'path';\nimport { normalizedPathRelativeTo } from '@ms-cloudpack/path-utilities';\nimport type { ConsumedImport, DynamicImport } from '../types/BundleInfo.js';\n\n/**\n * Get info about imports and exports from a file.\n * Returns undefined if the file doesn't exist or can't be parsed.\n */\nexport async function getImportsAndExports(\n filePath: string,\n packagePath?: string,\n): Promise<\n | {\n exportNames: Set<string>;\n imports: ConsumedImport[];\n /** Dynamic (async) imports with non-literal paths consumed by this file. */\n dynamicImports: DynamicImport[];\n }\n | undefined\n> {\n let source: string;\n try {\n source = await fsPromises.readFile(filePath, 'utf-8');\n } catch (err) {\n // This could happen if a package is missing a file.\n console.warn(`Failed to read ${filePath}:`, err);\n return;\n }\n\n let rawImports: readonly ImportSpecifier[];\n let rawExports: readonly ExportSpecifier[];\n try {\n // es-module-lexer/parse may return Promise in some conditions\n // https://github.com/guybedford/es-module-lexer/issues/155\n // eslint-disable-next-line @typescript-eslint/await-thenable\n [rawImports, rawExports] = await parse(source);\n } catch (err) {\n // This could happen if the source file isn't valid JS\n console.warn(`Failed to parse ${filePath}: ${err}\\nSource is:\\n${source}`);\n return;\n }\n\n // es-module-lexer doesn't handle export * from statements correctly as it parses them as\n // imports but not as exports. We need to handle them separately.\n // TODO: Remove when https://github.com/guybedford/es-module-lexer/issues/76 is fixed\n const exportStarPaths: string[] = [];\n\n const imports: ConsumedImport[] = [];\n const dynamicImports: DynamicImport[] = [];\n for (const imprt of new Set(rawImports)) {\n if (imprt.d === -2) {\n continue; // -2 means import.meta, which we don't care about\n }\n\n // es-module-lexer returns objects where the \"n\" property is the import source,\n // e.g. \"@fluentui/react/lib/Button\" for this import:\n // import { Button } from '@fluentui/react/lib/Button';\n // However, \"n\" will be undefined for import() if isn't a plain string literal.\n let importPath = imprt.n;\n // ss and se point to the entire import string's start/end\n const importCode = source.slice(imprt.ss, imprt.se);\n // s and e point to the specificer's start/end, including quotes -- e.g. \"@fluentui/react/lib/Button\"\n const importSpecifier = source.slice(imprt.s, imprt.e);\n\n // Currently when the import source is a backtick string, the path (\"n\" property) is undefined.\n // This is a limitation in es-module-lexer.\n if (/^`[^$`]+`$/.test(importSpecifier)) {\n // If it's a static string which happened to use backticks for some reason, we can parse that.\n importPath = importSpecifier.slice(1, -1);\n }\n\n // Handle literal paths first\n if (importPath) {\n // Handling `export * from` import statements\n if (/export\\s*\\*\\s*from/.test(importCode)) {\n exportStarPaths.push(importPath);\n }\n\n let importedNames: string[];\n if (imprt.d >= 0) {\n // This is a dynamic import. In this case we don't know which names are used, so assume all of them.\n importedNames = ['*'];\n } else {\n // Parse the import string into its component parts.\n importedNames = parseNamedImports(importCode);\n }\n\n imports.push({\n ...parseImportString(importPath),\n names: Array.from(new Set(importedNames)),\n });\n } else if (packagePath) {\n // Non-literal path.\n // Find the original source of the import.\n let rawSourceMap: RawSourceMap;\n let originalSource: string | null = null;\n try {\n rawSourceMap = JSON.parse(await fsPromises.readFile(`${filePath}.map`, 'utf-8')) as RawSourceMap;\n const consumer = await new SourceMapConsumer(rawSourceMap);\n const pos = getLineAndColumn(source, imprt.s);\n originalSource = consumer.originalPositionFor(pos).source;\n consumer.destroy(); // Clean up the consumer\n if (originalSource === null) {\n console.debug(`Failed to find original source for import:\\nFilename:${filePath}\\nImport:\\n ${importCode}`);\n }\n } catch (err) {\n console.debug(`Failed to read sourcemap for import:\\nFilename:${filePath}\\nImport:\\n ${importCode}`, err);\n }\n\n // Original source where the import was found.\n const absoluteImportSpecifier = originalSource ? path.resolve(path.dirname(filePath), originalSource) : filePath;\n\n // TODO: This will give a bad path for a lot of template or concatenated strings\n let packageName = '.'; // Default to local package\n // Remove leading quote from the import specifier if it exists.\n const cleanImportSpecifier = importSpecifier.replace(/^[\"'`]/, '');\n if (!cleanImportSpecifier.startsWith('.')) {\n packageName = parseImportString(cleanImportSpecifier).packageName;\n }\n dynamicImports.push({\n packageName,\n // Relative path from package path to file with import. Prefer original source if available.\n // or use the file path if original source is not available.\n importOrigin: normalizedPathRelativeTo(packagePath, absoluteImportSpecifier),\n importSpecifier,\n });\n } else {\n console.debug(`Found an import that didn't have a static path:\\nFilename:${filePath}\\nImport:\\n ${importCode}`);\n }\n }\n\n // Processing exports is cheap as we already have to parse the source.\n // Helps find exports uncaught by output files.\n const exportNames = new Set<string>();\n for (const exprt of rawExports) {\n if (exprt.n) {\n // Exports don't need to be parsed as it is\n // already in the format we need.\n exportNames.add(exprt.n);\n } else {\n console.debug(\n `Found an export that didn't parse correctly:\\nFilename: ${filePath}\\nExport:\\n ${source.slice(exprt.s, exprt.e)}`,\n );\n }\n }\n\n for (const exportPath of exportStarPaths) {\n // This follows the following convention: https://github.com/guybedford/es-module-lexer/issues/76#issuecomment-868561807\n exportNames.add(`*${exportPath}`);\n }\n\n return { exportNames, imports, dynamicImports };\n}\n\nfunction getLineAndColumn(source: string, position: number): { line: number; column: number } {\n let line = 1;\n let column = 1;\n\n for (let i = 0; i < position; i++) {\n if (source[i] === '\\n') {\n line++;\n column = 1;\n } else {\n column++;\n }\n }\n\n return { line, column };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"getImportsAndExports.js","sourceRoot":"","sources":["../../src/utilities/getImportsAndExports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAE,KAAK,EAA8C,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAqB,MAAM,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,IAAI,EAAE,CAAC;YACP,MAAM,GAAG,CAAC,CAAC;QACb,CAAC;aAAM,CAAC;YACN,MAAM,EAAE,CAAC;QACX,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC","sourcesContent":["import { parseImportString, parseNamedImports } from '@ms-cloudpack/path-string-parsing';\nimport { parse, type ImportSpecifier, type ExportSpecifier, init } from 'es-module-lexer';\nimport fsPromises from 'fs/promises';\nimport { SourceMapConsumer, type RawSourceMap } from 'source-map';\nimport path from 'path';\nimport { normalizedPathRelativeTo } from '@ms-cloudpack/path-utilities';\nimport type { ConsumedImport, DynamicImport } from '../types/BundleInfo.js';\n\nlet initialized = false;\n\n/**\n * Get info about imports and exports from a file.\n * Returns undefined if the file doesn't exist or can't be parsed.\n */\nexport async function getImportsAndExports(\n filePath: string,\n packagePath?: string,\n): Promise<\n | {\n exportNames: Set<string>;\n imports: ConsumedImport[];\n /** Dynamic (async) imports with non-literal paths consumed by this file. */\n dynamicImports: DynamicImport[];\n }\n | undefined\n> {\n let source: string;\n try {\n source = await fsPromises.readFile(filePath, 'utf-8');\n } catch (err) {\n // This could happen if a package is missing a file.\n console.warn(`Failed to read ${filePath}:`, err);\n return;\n }\n\n if (!initialized) {\n // Await init once for the Web Assembly boot to call parse synchronously.\n await init;\n initialized = true;\n }\n\n let rawImports: readonly ImportSpecifier[];\n let rawExports: readonly ExportSpecifier[];\n try {\n [rawImports, rawExports] = parse(source);\n } catch (err) {\n // This could happen if the source file isn't valid JS\n console.warn(`Failed to parse ${filePath}: ${err}\\nSource is:\\n${source}`);\n return;\n }\n\n // es-module-lexer doesn't handle export * from statements correctly as it parses them as\n // imports but not as exports. We need to handle them separately.\n // TODO: Remove when https://github.com/guybedford/es-module-lexer/issues/76 is fixed\n const exportStarPaths: string[] = [];\n\n const imports: ConsumedImport[] = [];\n const dynamicImports: DynamicImport[] = [];\n for (const imprt of new Set(rawImports)) {\n if (imprt.d === -2) {\n continue; // -2 means import.meta, which we don't care about\n }\n\n // es-module-lexer returns objects where the \"n\" property is the import source,\n // e.g. \"@fluentui/react/lib/Button\" for this import:\n // import { Button } from '@fluentui/react/lib/Button';\n // However, \"n\" will be undefined for import() if isn't a plain string literal.\n let importPath = imprt.n;\n // ss and se point to the entire import string's start/end\n const importCode = source.slice(imprt.ss, imprt.se);\n // s and e point to the specificer's start/end, including quotes -- e.g. \"@fluentui/react/lib/Button\"\n const importSpecifier = source.slice(imprt.s, imprt.e);\n\n // Currently when the import source is a backtick string, the path (\"n\" property) is undefined.\n // This is a limitation in es-module-lexer.\n if (/^`[^$`]+`$/.test(importSpecifier)) {\n // If it's a static string which happened to use backticks for some reason, we can parse that.\n importPath = importSpecifier.slice(1, -1);\n }\n\n // Handle literal paths first\n if (importPath) {\n // Handling `export * from` import statements\n if (/export\\s*\\*\\s*from/.test(importCode)) {\n exportStarPaths.push(importPath);\n }\n\n let importedNames: string[];\n if (imprt.d >= 0) {\n // This is a dynamic import. In this case we don't know which names are used, so assume all of them.\n importedNames = ['*'];\n } else {\n // Parse the import string into its component parts.\n importedNames = parseNamedImports(importCode);\n }\n\n imports.push({\n ...parseImportString(importPath),\n names: Array.from(new Set(importedNames)),\n });\n } else if (packagePath) {\n // Non-literal path.\n // Find the original source of the import.\n let rawSourceMap: RawSourceMap;\n let originalSource: string | null = null;\n try {\n rawSourceMap = JSON.parse(await fsPromises.readFile(`${filePath}.map`, 'utf-8')) as RawSourceMap;\n const consumer = await new SourceMapConsumer(rawSourceMap);\n const pos = getLineAndColumn(source, imprt.s);\n originalSource = consumer.originalPositionFor(pos).source;\n consumer.destroy(); // Clean up the consumer\n if (originalSource === null) {\n console.debug(`Failed to find original source for import:\\nFilename:${filePath}\\nImport:\\n ${importCode}`);\n }\n } catch (err) {\n console.debug(`Failed to read sourcemap for import:\\nFilename:${filePath}\\nImport:\\n ${importCode}`, err);\n }\n\n // Original source where the import was found.\n const absoluteImportSpecifier = originalSource ? path.resolve(path.dirname(filePath), originalSource) : filePath;\n\n // TODO: This will give a bad path for a lot of template or concatenated strings\n let packageName = '.'; // Default to local package\n // Remove leading quote from the import specifier if it exists.\n const cleanImportSpecifier = importSpecifier.replace(/^[\"'`]/, '');\n if (!cleanImportSpecifier.startsWith('.')) {\n packageName = parseImportString(cleanImportSpecifier).packageName;\n }\n dynamicImports.push({\n packageName,\n // Relative path from package path to file with import. Prefer original source if available.\n // or use the file path if original source is not available.\n importOrigin: normalizedPathRelativeTo(packagePath, absoluteImportSpecifier),\n importSpecifier,\n });\n } else {\n console.debug(`Found an import that didn't have a static path:\\nFilename:${filePath}\\nImport:\\n ${importCode}`);\n }\n }\n\n // Processing exports is cheap as we already have to parse the source.\n // Helps find exports uncaught by output files.\n const exportNames = new Set<string>();\n for (const exprt of rawExports) {\n if (exprt.n) {\n // Exports don't need to be parsed as it is\n // already in the format we need.\n exportNames.add(exprt.n);\n } else {\n console.debug(\n `Found an export that didn't parse correctly:\\nFilename: ${filePath}\\nExport:\\n ${source.slice(exprt.s, exprt.e)}`,\n );\n }\n }\n\n for (const exportPath of exportStarPaths) {\n // This follows the following convention: https://github.com/guybedford/es-module-lexer/issues/76#issuecomment-868561807\n exportNames.add(`*${exportPath}`);\n }\n\n return { exportNames, imports, dynamicImports };\n}\n\nfunction getLineAndColumn(source: string, position: number): { line: number; column: number } {\n let line = 1;\n let column = 1;\n\n for (let i = 0; i < position; i++) {\n if (source[i] === '\\n') {\n line++;\n column = 1;\n } else {\n column++;\n }\n }\n\n return { line, column };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializeContext.d.ts","sourceRoot":"","sources":["../../src/utilities/serializeContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"serializeContext.d.ts","sourceRoot":"","sources":["../../src/utilities/serializeContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,eAAO,MAAM,gBAAgB,GAC3B,UAAU,MAAM,EAChB,SAAS,cAAc,CACrB,UAAU,GAAG,eAAe,EAC5B,QAAQ,GAAG,oBAAoB,GAAG,YAAY,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,MAAM,GAAG,WAAW,CAC5G,KACA,OAAO,CAAC,IAAI,CAYd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/api-server",
|
|
3
|
-
"version": "0.61.
|
|
3
|
+
"version": "0.61.35",
|
|
4
4
|
"description": "An implementation of the API server that does interacts with a task scheduler.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@ms-cloudpack/bundler": "^0.24.
|
|
26
|
+
"@ms-cloudpack/bundler": "^0.24.30",
|
|
27
27
|
"@ms-cloudpack/common-types": "^0.24.16",
|
|
28
28
|
"@ms-cloudpack/config": "^0.35.0",
|
|
29
29
|
"@ms-cloudpack/create-express-app": "^1.10.29",
|
|
30
30
|
"@ms-cloudpack/data-bus": "^0.4.3",
|
|
31
31
|
"@ms-cloudpack/environment": "^0.1.1",
|
|
32
|
-
"@ms-cloudpack/esm-stub-utilities": "^0.14.
|
|
32
|
+
"@ms-cloudpack/esm-stub-utilities": "^0.14.27",
|
|
33
33
|
"@ms-cloudpack/file-watcher": "^0.3.0",
|
|
34
34
|
"@ms-cloudpack/import-map": "^0.10.18",
|
|
35
35
|
"@ms-cloudpack/json-utilities": "^0.1.10",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@ms-cloudpack/package-utilities": "^12.3.3",
|
|
38
38
|
"@ms-cloudpack/path-string-parsing": "^1.2.7",
|
|
39
39
|
"@ms-cloudpack/path-utilities": "^3.1.0",
|
|
40
|
-
"@ms-cloudpack/remote-cache": "^0.11.
|
|
40
|
+
"@ms-cloudpack/remote-cache": "^0.11.12",
|
|
41
41
|
"@ms-cloudpack/task-reporter": "^0.16.2",
|
|
42
42
|
"@ms-cloudpack/telemetry": "^0.11.15",
|
|
43
43
|
"@trpc/client": "^11.1.1",
|