@shopify/cli-kit 3.91.1 → 3.92.0
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/dist/private/node/analytics/bounded-collections.d.ts +1 -3
- package/dist/private/node/analytics/bounded-collections.js.map +1 -1
- package/dist/private/node/analytics/error-categorizer.js.map +1 -1
- package/dist/private/node/analytics.js.map +1 -1
- package/dist/private/node/api/graphql.d.ts +1 -3
- package/dist/private/node/api/graphql.js.map +1 -1
- package/dist/private/node/api/headers.d.ts +2 -6
- package/dist/private/node/api/headers.js +0 -1
- package/dist/private/node/api/headers.js.map +1 -1
- package/dist/private/node/api/rest.d.ts +2 -6
- package/dist/private/node/api/rest.js.map +1 -1
- package/dist/private/node/api.js.map +1 -1
- package/dist/private/node/conf-store.d.ts +6 -6
- package/dist/private/node/conf-store.js +13 -6
- package/dist/private/node/conf-store.js.map +1 -1
- package/dist/private/node/session/device-authorization.js.map +1 -1
- package/dist/private/node/session/exchange.d.ts +1 -19
- package/dist/private/node/session/exchange.js +13 -30
- package/dist/private/node/session/exchange.js.map +1 -1
- package/dist/private/node/session/schema.d.ts +62 -62
- package/dist/private/node/session/store.js +1 -1
- package/dist/private/node/session/store.js.map +1 -1
- package/dist/private/node/session/validate.d.ts +4 -5
- package/dist/private/node/session/validate.js +7 -35
- package/dist/private/node/session/validate.js.map +1 -1
- package/dist/private/node/session.js +18 -65
- package/dist/private/node/session.js.map +1 -1
- package/dist/private/node/testing/ui.d.ts +2 -1
- package/dist/private/node/testing/ui.js +22 -24
- package/dist/private/node/testing/ui.js.map +1 -1
- package/dist/private/node/themes/generate-theme-name.js +0 -1
- package/dist/private/node/themes/generate-theme-name.js.map +1 -1
- package/dist/private/node/ui/alert.js.map +1 -1
- package/dist/private/node/ui/components/Alert.test.js +2 -4
- package/dist/private/node/ui/components/Alert.test.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.js +6 -1
- package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -1
- package/dist/private/node/ui/components/AutocompletePrompt.test.js +2 -3
- package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/Banner.js +0 -1
- package/dist/private/node/ui/components/Banner.js.map +1 -1
- package/dist/private/node/ui/components/Banner.test.js +2 -2
- package/dist/private/node/ui/components/Banner.test.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.js +4 -2
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.test.js +9 -3
- package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.js.map +1 -1
- package/dist/private/node/ui/components/DangerousConfirmationPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.js +0 -1
- package/dist/private/node/ui/components/FatalError.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
- package/dist/private/node/ui/components/List.test.js.map +1 -1
- package/dist/private/node/ui/components/LoadingBar.js.map +1 -1
- package/dist/private/node/ui/components/LoadingBar.test.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/InfoTable.d.ts +1 -3
- package/dist/private/node/ui/components/Prompts/InfoTable.js +0 -1
- package/dist/private/node/ui/components/Prompts/InfoTable.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/InfoTable.test.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/PromptLayout.d.ts +1 -1
- package/dist/private/node/ui/components/Prompts/PromptLayout.js +1 -1
- package/dist/private/node/ui/components/Prompts/PromptLayout.js.map +1 -1
- package/dist/private/node/ui/components/Prompts/PromptLayout.test.js +1 -1
- package/dist/private/node/ui/components/Prompts/PromptLayout.test.js.map +1 -1
- package/dist/private/node/ui/components/SelectInput.d.ts +4 -5
- package/dist/private/node/ui/components/SelectInput.js +5 -7
- package/dist/private/node/ui/components/SelectInput.js.map +1 -1
- package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.js +0 -1
- package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.test.js +0 -1
- package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/SingleTask.js.map +1 -1
- package/dist/private/node/ui/components/SingleTask.test.js.map +1 -1
- package/dist/private/node/ui/components/Table/ScalarDict.d.ts +2 -4
- package/dist/private/node/ui/components/Table/ScalarDict.js.map +1 -1
- package/dist/private/node/ui/components/Table/Table.js +0 -1
- package/dist/private/node/ui/components/Table/Table.js.map +1 -1
- package/dist/private/node/ui/components/Table/Table.test.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.js +0 -2
- package/dist/private/node/ui/components/Tasks.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.test.js +2 -6
- package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
- package/dist/private/node/ui/components/TextAnimation.test.js +1 -1
- package/dist/private/node/ui/components/TextAnimation.test.js.map +1 -1
- package/dist/private/node/ui/components/TextInput.js +19 -19
- package/dist/private/node/ui/components/TextInput.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.js +1 -1
- package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.test.js +0 -1
- package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.js +1 -2
- package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
- package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
- package/dist/private/node/ui/contexts/LinksContext.d.ts +1 -3
- package/dist/private/node/ui/contexts/LinksContext.js.map +1 -1
- package/dist/private/node/ui/hooks/use-abort-signal.js +9 -1
- package/dist/private/node/ui/hooks/use-abort-signal.js.map +1 -1
- package/dist/private/node/ui.js +8 -1
- package/dist/private/node/ui.js.map +1 -1
- package/dist/public/common/array.js +0 -1
- package/dist/public/common/array.js.map +1 -1
- package/dist/public/common/collection.d.ts +1 -3
- package/dist/public/common/collection.js.map +1 -1
- package/dist/public/common/string.js +1 -4
- package/dist/public/common/string.js.map +1 -1
- package/dist/public/common/ts/json-narrowing.d.ts +1 -3
- package/dist/public/common/ts/json-narrowing.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/analytics.js +1 -1
- package/dist/public/node/analytics.js.map +1 -1
- package/dist/public/node/api/admin.d.ts +2 -6
- package/dist/public/node/api/admin.js +1 -2
- package/dist/public/node/api/admin.js.map +1 -1
- package/dist/public/node/api/app-dev.d.ts +1 -1
- package/dist/public/node/api/app-dev.js +1 -1
- package/dist/public/node/api/app-dev.js.map +1 -1
- package/dist/public/node/api/app-management.d.ts +1 -3
- package/dist/public/node/api/app-management.js +1 -1
- package/dist/public/node/api/app-management.js.map +1 -1
- package/dist/public/node/api/business-platform.js.map +1 -1
- package/dist/public/node/api/functions.js +1 -1
- package/dist/public/node/api/functions.js.map +1 -1
- package/dist/public/node/api/graphql.d.ts +4 -12
- package/dist/public/node/api/graphql.js.map +1 -1
- package/dist/public/node/api/partners.js +1 -1
- package/dist/public/node/api/partners.js.map +1 -1
- package/dist/public/node/api/rest-api-throttler.js +0 -1
- package/dist/public/node/api/rest-api-throttler.js.map +1 -1
- package/dist/public/node/archiver.js +2 -2
- package/dist/public/node/archiver.js.map +1 -1
- package/dist/public/node/base-command.js +0 -2
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/cli.js.map +1 -1
- package/dist/public/node/context/local.js.map +1 -1
- package/dist/public/node/custom-oclif-loader.js +0 -1
- package/dist/public/node/custom-oclif-loader.js.map +1 -1
- package/dist/public/node/doctor/framework.d.ts +14 -9
- package/dist/public/node/doctor/framework.js +10 -3
- package/dist/public/node/doctor/framework.js.map +1 -1
- package/dist/public/node/doctor/reporter.d.ts +23 -0
- package/dist/public/node/doctor/reporter.js +33 -1
- package/dist/public/node/doctor/reporter.js.map +1 -1
- package/dist/public/node/dot-env.d.ts +2 -6
- package/dist/public/node/dot-env.js +1 -2
- package/dist/public/node/dot-env.js.map +1 -1
- package/dist/public/node/environments.d.ts +1 -3
- package/dist/public/node/environments.js.map +1 -1
- package/dist/public/node/error-handler.js +3 -3
- package/dist/public/node/error-handler.js.map +1 -1
- package/dist/public/node/error.d.ts +1 -1
- package/dist/public/node/error.js +2 -2
- package/dist/public/node/error.js.map +1 -1
- package/dist/public/node/framework.js +0 -1
- package/dist/public/node/framework.js.map +1 -1
- package/dist/public/node/fs.d.ts +1 -1
- package/dist/public/node/fs.js +1 -1
- package/dist/public/node/fs.js.map +1 -1
- package/dist/public/node/git.d.ts +1 -3
- package/dist/public/node/git.js +1 -3
- package/dist/public/node/git.js.map +1 -1
- package/dist/public/node/github.js +14 -8
- package/dist/public/node/github.js.map +1 -1
- package/dist/public/node/hooks/postrun.js +2 -2
- package/dist/public/node/hooks/postrun.js.map +1 -1
- package/dist/public/node/hooks/prerun.js +2 -2
- package/dist/public/node/hooks/prerun.js.map +1 -1
- package/dist/public/node/http.js +2 -3
- package/dist/public/node/http.js.map +1 -1
- package/dist/public/node/json-schema.d.ts +1 -3
- package/dist/public/node/json-schema.js +0 -1
- package/dist/public/node/json-schema.js.map +1 -1
- package/dist/public/node/liquid.js +1 -1
- package/dist/public/node/liquid.js.map +1 -1
- package/dist/public/node/local-storage.d.ts +1 -3
- package/dist/public/node/local-storage.js.map +1 -1
- package/dist/public/node/metadata.d.ts +1 -3
- package/dist/public/node/metadata.js +0 -1
- package/dist/public/node/metadata.js.map +1 -1
- package/dist/public/node/mimes.d.ts +1 -3
- package/dist/public/node/mimes.js.map +1 -1
- package/dist/public/node/monorail.js +1 -1
- package/dist/public/node/monorail.js.map +1 -1
- package/dist/public/node/multiple-installation-warning.d.ts +1 -3
- package/dist/public/node/multiple-installation-warning.js.map +1 -1
- package/dist/public/node/node-package-manager.d.ts +9 -27
- package/dist/public/node/node-package-manager.js +1 -1
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/os.js +1 -1
- package/dist/public/node/os.js.map +1 -1
- package/dist/public/node/output.d.ts +1 -3
- package/dist/public/node/output.js +1 -2
- package/dist/public/node/output.js.map +1 -1
- package/dist/public/node/path.d.ts +13 -0
- package/dist/public/node/path.js +10 -1
- package/dist/public/node/path.js.map +1 -1
- package/dist/public/node/plugins/tunnel.d.ts +5 -11
- package/dist/public/node/plugins/tunnel.js.map +1 -1
- package/dist/public/node/plugins.d.ts +4 -12
- package/dist/public/node/plugins.js.map +1 -1
- package/dist/public/node/result.js +1 -1
- package/dist/public/node/result.js.map +1 -1
- package/dist/public/node/session.js +15 -7
- package/dist/public/node/session.js.map +1 -1
- package/dist/public/node/system.d.ts +1 -3
- package/dist/public/node/system.js +1 -1
- package/dist/public/node/system.js.map +1 -1
- package/dist/public/node/tcp.js +1 -1
- package/dist/public/node/tcp.js.map +1 -1
- package/dist/public/node/testing/output.js +1 -1
- package/dist/public/node/testing/output.js.map +1 -1
- package/dist/public/node/themes/api.js +2 -2
- package/dist/public/node/themes/api.js.map +1 -1
- package/dist/public/node/themes/conf.d.ts +1 -3
- package/dist/public/node/themes/conf.js.map +1 -1
- package/dist/public/node/tree-kill.js +0 -1
- package/dist/public/node/tree-kill.js.map +1 -1
- package/dist/public/node/ui.js +0 -12
- package/dist/public/node/ui.js.map +1 -1
- package/dist/public/node/vendor/dev_server/dev-server-2016.d.ts +8 -0
- package/dist/public/node/vendor/dev_server/dev-server-2016.js +10 -2
- package/dist/public/node/vendor/dev_server/dev-server-2016.js.map +1 -1
- package/dist/public/node/vendor/dev_server/dev-server-2024.d.ts +8 -0
- package/dist/public/node/vendor/dev_server/dev-server-2024.js +10 -2
- package/dist/public/node/vendor/dev_server/dev-server-2024.js.map +1 -1
- package/dist/public/node/vendor/dev_server/dev-server.js +1 -1
- package/dist/public/node/vendor/dev_server/dev-server.js.map +1 -1
- package/dist/public/node/vendor/dev_server/env.d.ts +3 -0
- package/dist/public/node/vendor/dev_server/env.js +3 -0
- package/dist/public/node/vendor/dev_server/env.js.map +1 -1
- package/dist/public/node/vendor/dev_server/network/host.d.ts +7 -0
- package/dist/public/node/vendor/dev_server/network/host.js +7 -1
- package/dist/public/node/vendor/dev_server/network/host.js.map +1 -1
- package/dist/public/node/vendor/dev_server/network/index.d.ts +7 -0
- package/dist/public/node/vendor/dev_server/network/index.js +7 -2
- package/dist/public/node/vendor/dev_server/network/index.js.map +1 -1
- package/dist/public/node/vendor/otel-js/export/InstantaneousMetricReader.d.ts +1 -1
- package/dist/public/node/vendor/otel-js/export/InstantaneousMetricReader.js +2 -4
- package/dist/public/node/vendor/otel-js/export/InstantaneousMetricReader.js.map +1 -1
- package/dist/public/node/vendor/otel-js/service/BaseOtelService/BaseOtelService.d.ts +7 -0
- package/dist/public/node/vendor/otel-js/service/BaseOtelService/BaseOtelService.js +9 -1
- package/dist/public/node/vendor/otel-js/service/BaseOtelService/BaseOtelService.js.map +1 -1
- package/dist/public/node/vendor/otel-js/service/DefaultOtelService/DefaultOtelService.d.ts +12 -1
- package/dist/public/node/vendor/otel-js/service/DefaultOtelService/DefaultOtelService.js +11 -0
- package/dist/public/node/vendor/otel-js/service/DefaultOtelService/DefaultOtelService.js.map +1 -1
- package/dist/public/node/vendor/otel-js/service/types.d.ts +6 -10
- package/dist/public/node/vendor/otel-js/service/types.js.map +1 -1
- package/dist/public/node/vendor/otel-js/utils/throttle.d.ts +10 -2
- package/dist/public/node/vendor/otel-js/utils/throttle.js +9 -0
- package/dist/public/node/vendor/otel-js/utils/throttle.js.map +1 -1
- package/dist/public/node/vendor/otel-js/utils/validators.d.ts +4 -0
- package/dist/public/node/vendor/otel-js/utils/validators.js +4 -0
- package/dist/public/node/vendor/otel-js/utils/validators.js.map +1 -1
- package/dist/public/node/version.js +1 -1
- package/dist/public/node/version.js.map +1 -1
- package/dist/public/node/vscode.js +1 -1
- package/dist/public/node/vscode.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import * as ni from 'network-interfaces';
|
|
3
1
|
import { assertConnectable, getIpFromHosts } from './network/index.js';
|
|
4
2
|
import { assertCompatibleEnvironment } from './env.js';
|
|
3
|
+
import * as ni from 'network-interfaces';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
5
|
const NON_SHOP_PREFIXES = ['app', 'dev', 'shopify'];
|
|
6
6
|
const BACKEND_PORT = 8080;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param projectName
|
|
10
|
+
*/
|
|
7
11
|
export function createServer(projectName) {
|
|
8
12
|
return {
|
|
9
13
|
host: (options = {}) => host(projectName, options),
|
|
@@ -62,6 +66,10 @@ function resolveBackendHost(name) {
|
|
|
62
66
|
}
|
|
63
67
|
// Allow overrides for more concise test setup. Meh.
|
|
64
68
|
let assertRunningOverride;
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* @param override
|
|
72
|
+
*/
|
|
65
73
|
export function setAssertRunning(override) {
|
|
66
74
|
assertRunningOverride = override;
|
|
67
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server-2024.js","sourceRoot":"","sources":["../../../../../src/public/node/vendor/dev_server/dev-server-2024.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"dev-server-2024.js","sourceRoot":"","sources":["../../../../../src/public/node/vendor/dev_server/dev-server-2024.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAA;AACpE,OAAO,EAAC,2BAA2B,EAAC,MAAM,UAAU,CAAA;AACpD,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACxC,OAAO,EAAE,MAAM,SAAS,CAAA;AAIxB,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,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AC;QAC/B,IAAI,EAAE,YAAY;KACnB,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,WAAmB;IACvC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAA;QACjD,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAC,CAAC,CAAA;QAEpD,OAAO,SAAS,CAAA;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,kBAAkB,WAAW,8BAA8B,WAAW,iBAAiB,CAAC,CAAA;IAC1G,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAY;IACtC,IAAI,IAAY,CAAA;IAChB,IAAI,CAAC;QACH,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,2BAA2B,IAAI,UAAU,CAAC,CAAA;IACnE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,GAAG,GAAG,IAAI,4BAA4B,CAAA;IAC5C,CAAC;IAED,IAAI,CAAC;QACH,OAAO,cAAc,CAAC,IAAI,CAAC,CAAA;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC;AAED,oDAAoD;AACpD,IAAI,qBAA2D,CAAA;AAE/D;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAsC;IACrE,qBAAqB,GAAG,QAAQ,CAAA;AAClC,CAAC","sourcesContent":["import {assertConnectable, getIpFromHosts} from './network/index.js'\nimport {assertCompatibleEnvironment} from './env.js'\nimport * as ni from 'network-interfaces'\nimport fs from 'node:fs'\n\nimport type {HostOptions} from './types.js'\n\nconst NON_SHOP_PREFIXES = ['app', 'dev', 'shopify']\nconst BACKEND_PORT = 8080\n\n/**\n *\n * @param projectName\n */\nexport function createServer(projectName: string) {\n return {\n host: (options: HostOptions = {}) => host(projectName, options),\n url: (options: HostOptions = {}) => url(projectName, options),\n }\n}\n\nfunction host(projectName: string, options: HostOptions = {}): string {\n assertCompatibleEnvironment()\n ;(assertRunningOverride || assertRunning2024)(projectName)\n\n const prefix = (options.nonstandardHostPrefix || projectName).replace(/_/g, '-')\n\n if (projectName === 'shopify') {\n if (prefix.endsWith('-dev-api')) {\n const shopName = prefix.replace('-dev-api', '')\n return `${shopName}.dev-api.shop.dev`\n }\n if (!NON_SHOP_PREFIXES.includes(prefix)) {\n return `${prefix}.my.shop.dev`\n }\n }\n return `${prefix}.shop.dev`\n}\n\nfunction url(projectName: string, options: HostOptions = {}): string {\n return `https://${host(projectName, options)}`\n}\n\nfunction assertRunning2024(projectName: string): void {\n assertConnectable({\n projectName,\n addr: getBackendIp(projectName),\n port: BACKEND_PORT,\n })\n}\n\nfunction getBackendIp(projectName: string): string {\n try {\n const backendIp = resolveBackendHost(projectName)\n ni.fromIp(backendIp, {internal: true, ipVersion: 4})\n\n return backendIp\n } catch (error) {\n throw new Error(`DevServer for '${projectName}' is not running: \\`dev up ${projectName}\\` to start it.`)\n }\n}\n\nfunction resolveBackendHost(name: string): string {\n let host: string\n try {\n host = fs.readlinkSync(`/opt/nginx/etc/manifest/${name}/current`)\n } catch (error) {\n host = `${name}.root.shopify.dev.internal`\n }\n\n try {\n return getIpFromHosts(host)\n } catch {\n return host\n }\n}\n\n// Allow overrides for more concise test setup. Meh.\nlet assertRunningOverride: typeof assertRunning2024 | undefined\n\n/**\n *\n * @param override\n */\nexport function setAssertRunning(override: typeof assertRunningOverride) {\n assertRunningOverride = override\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
1
|
import { createServer as createServer2024 } from './dev-server-2024.js';
|
|
3
2
|
import { createServer as createServer2016 } from './dev-server-2016.js';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
4
|
export { isDevServerEnvironment } from './env.js';
|
|
5
5
|
export class DevServer {
|
|
6
6
|
constructor(projectName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server.js","sourceRoot":"","sources":["../../../../../src/public/node/vendor/dev_server/dev-server.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"dev-server.js","sourceRoot":"","sources":["../../../../../src/public/node/vendor/dev_server/dev-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,IAAI,gBAAgB,EAAC,MAAM,sBAAsB,CAAA;AACrE,OAAO,EAAC,YAAY,IAAI,gBAAgB,EAAC,MAAM,sBAAsB,CAAA;AACrE,OAAO,EAAE,MAAM,SAAS,CAAA;AAIxB,OAAO,EAAC,sBAAsB,EAAC,MAAM,UAAU,CAAA;AAE/C,MAAM,OAAO,SAAS;IAGpB,YAA6B,WAAmB;QAAnB,gBAAW,GAAX,WAAW,CAAQ;QAC9C,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAA;QAC3E,CAAC;QACD,IAAI,CAAC,UAAU,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAA;IACnD,CAAC;IAED,IAAI,CAAC,OAAqB;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACtC,CAAC;IAED,GAAG,CAAC,OAAqB;QACvB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACrC,CAAC;CACF;AAED,MAAM,OAAO,aAAa;IAGxB;QACE,IAAI,CAAC,UAAU,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAA;IACjD,CAAC;IAED,IAAI,CAAC,MAAc;QACjB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAC,qBAAqB,EAAE,MAAM,EAAC,CAAC,CAAA;IAC9D,CAAC;IAED,GAAG,CAAC,MAAc;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAC,qBAAqB,EAAE,MAAM,EAAC,CAAC,CAAA;IAC7D,CAAC;CACF;AAED,MAAM,uBAAuB,GAAG,yCAAyC,CAAA;AAEzE,SAAS,kBAAkB,CAAC,WAAmB;IAC7C,IAAI,oCAAoC,CAAC,WAAW,CAAC,EAAE,CAAC;QACtD,OAAO,gBAAgB,CAAC,WAAW,CAAC,CAAA;IACtC,CAAC;SAAM,CAAC;QACN,OAAO,gBAAgB,CAAC,WAAW,CAAC,CAAA;IACtC,CAAC;AACH,CAAC;AAED,SAAS,oCAAoC,CAAC,WAAmB;IAC/D,IAAI,CAAC;QACH,EAAE,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAA;QAEtC,IAAI,CAAC;YACH,EAAE,CAAC,UAAU,CAAC,2BAA2B,WAAW,uBAAuB,CAAC,CAAA;YAC5E,OAAO,KAAK,CAAA;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC","sourcesContent":["import {createServer as createServer2024} from './dev-server-2024.js'\nimport {createServer as createServer2016} from './dev-server-2016.js'\nimport fs from 'node:fs'\n\nimport type {DevServer as DevServerType, DevServerCore as DevServerCoreType, HostOptions} from './types.js'\n\nexport {isDevServerEnvironment} from './env.js'\n\nexport class DevServer implements DevServerType {\n private readonly serverImpl: DevServerType\n\n constructor(private readonly projectName: string) {\n if (projectName === 'shopify') {\n throw new Error(\"Use `import {DevServerCore}` for the 'shopify' project\")\n }\n this.serverImpl = inferProjectServer(projectName)\n }\n\n host(options?: HostOptions) {\n return this.serverImpl.host(options)\n }\n\n url(options?: HostOptions) {\n return this.serverImpl.url(options)\n }\n}\n\nexport class DevServerCore implements DevServerCoreType {\n private readonly serverImpl: DevServerType\n\n constructor() {\n this.serverImpl = inferProjectServer('shopify')\n }\n\n host(prefix: string) {\n return this.serverImpl.host({nonstandardHostPrefix: prefix})\n }\n\n url(prefix: string) {\n return this.serverImpl.url({nonstandardHostPrefix: prefix})\n }\n}\n\nconst INFERENCE_MODE_SENTINEL = '/opt/dev/misc/dev-server-inference-mode'\n\nfunction inferProjectServer(projectName: string) {\n if (inferenceModeAndProjectIsEdition2016(projectName)) {\n return createServer2016(projectName)\n } else {\n return createServer2024(projectName)\n }\n}\n\nfunction inferenceModeAndProjectIsEdition2016(projectName: string): boolean {\n try {\n fs.accessSync(INFERENCE_MODE_SENTINEL)\n\n try {\n fs.accessSync(`/opt/nginx/etc/manifest/${projectName}/current/edition-2024`)\n return false\n } catch {\n return true\n }\n } catch {\n return false\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../../../src/public/node/vendor/dev_server/env.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,GAAG,CAAA;AAEnE,MAAM,UAAU,2BAA2B;IACzC,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAA;IACnE,CAAC;AACH,CAAC","sourcesContent":["export const isDevServerEnvironment = process.env.USING_DEV === '1'\n\nexport function assertCompatibleEnvironment() {\n if (!isDevServerEnvironment) {\n throw new Error('DevServer is not supported in this environment')\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../../../../src/public/node/vendor/dev_server/env.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,GAAG,CAAA;AAEnE;;GAEG;AACH,MAAM,UAAU,2BAA2B;IACzC,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAA;IACnE,CAAC;AACH,CAAC","sourcesContent":["export const isDevServerEnvironment = process.env.USING_DEV === '1'\n\n/**\n *\n */\nexport function assertCompatibleEnvironment() {\n if (!isDevServerEnvironment) {\n throw new Error('DevServer is not supported in this environment')\n }\n}\n"]}
|
|
@@ -29,6 +29,10 @@ function loadHostsFile() {
|
|
|
29
29
|
console.log('Error reading hosts file:', error);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param hostname
|
|
35
|
+
*/
|
|
32
36
|
export function getIpFromHosts(hostname) {
|
|
33
37
|
loadHostsFile();
|
|
34
38
|
const ipAddress = hostToIpCache[hostname];
|
|
@@ -37,7 +41,9 @@ export function getIpFromHosts(hostname) {
|
|
|
37
41
|
}
|
|
38
42
|
throw new Error(`No IP found for hostname: ${hostname}`);
|
|
39
43
|
}
|
|
40
|
-
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
41
47
|
export function TEST_ClearCache() {
|
|
42
48
|
hostToIpCache = {};
|
|
43
49
|
lastModifiedTime = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../../../../../src/public/node/vendor/dev_server/network/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../../../../../src/public/node/vendor/dev_server/network/host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AAExB,MAAM,UAAU,GAAG,YAAY,CAAA;AAE/B,IAAI,aAAa,GAA2B,EAAE,CAAA;AAC9C,IAAI,gBAAgB,GAAG,CAAC,CAAA;AAExB,SAAS,aAAa;IACpB,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;QACrC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAA;QAElC,IAAI,YAAY,KAAK,gBAAgB;YAAE,OAAM;QAE7C,MAAM,YAAY,GAAG,EA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n\nconst HOSTS_FILE = '/etc/hosts'\n\nlet hostToIpCache: Record<string, string> = {}\nlet lastModifiedTime = 0\n\nfunction loadHostsFile() {\n try {\n const stats = fs.statSync(HOSTS_FILE)\n const modifiedTime = stats.mtimeMs\n\n if (modifiedTime === lastModifiedTime) return\n\n const hostsContent = fs.readFileSync(HOSTS_FILE, 'utf8')\n const lines = hostsContent.split(/\\r?\\n/)\n\n hostToIpCache = {}\n\n for (const line of lines) {\n if (line.trim().startsWith('#') || line.trim() === '') {\n continue\n }\n\n const matches = /^\\s*(?<ipAddress>[^\\s#]+)\\s+(?<matchedHostName>[^\\s#]+)\\s*(#.*)?$/.exec(line)\n if (matches && matches.groups) {\n const {ipAddress, matchedHostName} = matches.groups\n if (matchedHostName && ipAddress) {\n hostToIpCache[matchedHostName] = ipAddress\n }\n }\n }\n\n lastModifiedTime = modifiedTime\n } catch (error) {\n console.log('Error reading hosts file:', error)\n }\n}\n\n/**\n *\n * @param hostname\n */\nexport function getIpFromHosts(hostname: string) {\n loadHostsFile()\n\n const ipAddress = hostToIpCache[hostname]\n if (ipAddress) {\n return ipAddress\n }\n\n throw new Error(`No IP found for hostname: ${hostname}`)\n}\n\n/**\n *\n */\nexport function TEST_ClearCache() {\n hostToIpCache = {}\n lastModifiedTime = 0\n}\n"]}
|
|
@@ -5,5 +5,12 @@ export interface ConnectionArguments {
|
|
|
5
5
|
port: number;
|
|
6
6
|
timeout?: number;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param options
|
|
11
|
+
*/
|
|
8
12
|
export declare function assertConnectable(options: ConnectionArguments): void;
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
9
16
|
export declare function TEST_testResetCheckPort(): void;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { spawnSync } from 'node:child_process';
|
|
2
2
|
export { getIpFromHosts } from './host.js';
|
|
3
|
-
// eslint-disable-next-line prettier/prettier
|
|
4
3
|
const DEFAULT_CONNECT_TIMEOUT = 1000;
|
|
5
4
|
// Skip initialization on module load to prevent Spin trying to load a macOS dylib
|
|
6
5
|
// (port checks should never run on Spin anyway)
|
|
7
6
|
let checkPort;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param options
|
|
10
|
+
*/
|
|
8
11
|
export function assertConnectable(options) {
|
|
9
12
|
checkPort || (checkPort = getCheckPortHelper());
|
|
10
13
|
const { port, addr, timeout = DEFAULT_CONNECT_TIMEOUT } = options;
|
|
@@ -19,7 +22,9 @@ export function assertConnectable(options) {
|
|
|
19
22
|
throw new Error(`DevServer check for '${options.projectName}' on ${port} / ${addr} failed (${err})`);
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
|
-
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
23
28
|
export function TEST_testResetCheckPort() {
|
|
24
29
|
checkPort = getCheckPortHelper();
|
|
25
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/public/node/vendor/dev_server/network/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/public/node/vendor/dev_server/network/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAA;AAE5C,OAAO,EAAC,cAAc,EAAC,MAAM,WAAW,CAAA;AASxC,MAAM,uBAAuB,GAAG,IAAI,CAAA;AACpC,kFAAkF;AAClF,gDAAgD;AAChD,IAAI,SAAgD,CAAA;AAEpD;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAA4B;IAC5D,SAAS,KAAT,SAAS,GAAK,kBAAkB,EAAE,EAAA;IAElC,MAAM,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAG,uBAAuB,EAAC,GAAG,OAAO,CAAA;IAC/D,IAAI,CAAC;QACH,MAAM,cAAc,GAAG,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAA;QAChE,MAAM,OAAO,GAAG,SAAS,CAAC,cAAc,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;QACxD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACb,kBAAkB,OAAO,CAAC,WAAW,uBAAuB,IAAI,MAAM,IAAI,cAAc,OAAO,CAAC,WAAW,iBAAiB,CAC7H,CAAA;QACH,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,wBAAwB,OAAO,CAAC,WAAW,QAAQ,IAAI,MAAM,IAAI,YAAY,GAAG,GAAG,CAAC,CAAA;IACtG,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,SAAS,GAAG,kBAAkB,EAAE,CAAA;AAClC,CAAC;AAED,SAAS,kBAAkB;IACzB,OAAO,iBAAiB,CAAA;AAC1B,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAe,EAAE,IAAY,EAAE,OAAe;IACvE,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE;QAC1E,OAAO;QACP,KAAK,EAAE,QAAQ;KAChB,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAA;AAC5B,CAAC","sourcesContent":["import {spawnSync} from 'node:child_process'\n\nexport {getIpFromHosts} from './host.js'\n\nexport interface ConnectionArguments {\n projectName: string\n addr: string\n port: number\n timeout?: number\n}\n\nconst DEFAULT_CONNECT_TIMEOUT = 1000\n// Skip initialization on module load to prevent Spin trying to load a macOS dylib\n// (port checks should never run on Spin anyway)\nlet checkPort: ReturnType<typeof getCheckPortHelper>\n\n/**\n *\n * @param options\n */\nexport function assertConnectable(options: ConnectionArguments): void {\n checkPort ||= getCheckPortHelper()\n\n const {port, addr, timeout = DEFAULT_CONNECT_TIMEOUT} = options\n try {\n const normalizedAddr = addr === 'localhost' ? '127.0.0.1' : addr\n const running = checkPort(normalizedAddr, port, timeout)\n if (!running) {\n throw new Error(\n `DevServer for '${options.projectName}' is not running on ${port} / ${addr}: \\`dev up ${options.projectName}\\` to start it.`,\n )\n }\n } catch (err) {\n throw new Error(`DevServer check for '${options.projectName}' on ${port} / ${addr} failed (${err})`)\n }\n}\n\n/**\n *\n */\nexport function TEST_testResetCheckPort(): void {\n checkPort = getCheckPortHelper()\n}\n\nfunction getCheckPortHelper(): (addr: string, port: number, timeout: number) => boolean {\n return fallbackCheckPort\n}\n\nfunction fallbackCheckPort(address: string, port: number, timeout: number): boolean {\n const result = spawnSync('nc', ['-z', '-w', '1', address, port.toString()], {\n timeout,\n stdio: 'ignore',\n })\n\n return result.status === 0\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PushMetricExporter } from '@opentelemetry/sdk-metrics';
|
|
2
1
|
import { MetricReader } from '@opentelemetry/sdk-metrics';
|
|
2
|
+
import type { PushMetricExporter } from '@opentelemetry/sdk-metrics';
|
|
3
3
|
export interface InstantaneousMetricReaderOptions {
|
|
4
4
|
/**
|
|
5
5
|
* The backing exporter for the metric reader.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { throttle } from '../utils/throttle.js';
|
|
1
2
|
import { MetricReader } from '@opentelemetry/sdk-metrics';
|
|
2
3
|
import { ExportResultCode } from '@opentelemetry/core';
|
|
3
4
|
import { diag } from '@opentelemetry/api';
|
|
4
|
-
import { throttle } from '../utils/throttle.js';
|
|
5
5
|
export class InstantaneousMetricReader extends MetricReader {
|
|
6
6
|
constructor({ exporter, throttleLimit }) {
|
|
7
7
|
super({
|
|
@@ -9,9 +9,7 @@ export class InstantaneousMetricReader extends MetricReader {
|
|
|
9
9
|
aggregationTemporalitySelector: exporter.selectAggregationTemporality?.bind(exporter),
|
|
10
10
|
});
|
|
11
11
|
this._exporter = exporter;
|
|
12
|
-
this.onForceFlush = throttle(
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
14
|
-
this.onForceFlush, throttleLimit);
|
|
12
|
+
this.onForceFlush = throttle(this.onForceFlush, throttleLimit);
|
|
15
13
|
}
|
|
16
14
|
async onForceFlush() {
|
|
17
15
|
const { resourceMetrics, errors } = await this.collect({});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstantaneousMetricReader.js","sourceRoot":"","sources":["../../../../../../src/public/node/vendor/otel-js/export/InstantaneousMetricReader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InstantaneousMetricReader.js","sourceRoot":"","sources":["../../../../../../src/public/node/vendor/otel-js/export/InstantaneousMetricReader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAC,YAAY,EAAC,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAA;AAevC,MAAM,OAAO,yBAA0B,SAAQ,YAAY;IAGzD,YAAY,EAAC,QAAQ,EAAE,aAAa,EAAmC;QACrE,KAAK,CAAC;YACJ,mBAAmB,EAAE,QAAQ,CAAC,iBAAiB,EAAE,IAAI,CAAC,QAAQ,CAAC;YAC/D,8BAA8B,EAAE,QAAQ,CAAC,4BAA4B,EAAE,IAAI,CAAC,QAAQ,CAAC;SACtF,CAAC,CAAA;QACF,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QAEzB,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC,CAAA;IAChE,CAAC;IAES,KAAK,CAAC,YAAY;QAC1B,MAAM,EAAC,eAAe,EAAE,MAAM,EAAC,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAExD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,KAAK,CAAC,sDAAsD,EAAE,GAAG,MAAM,CAAC,CAAA;QAC/E,CAAC;QAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,EAAE;gBAChD,IAAI,MAAM,CAAC,IAAI,KAAK,gBAAgB,CAAC,OAAO,EAAE,CAAC;oBAC7C,IAAI,CAAC,KAAK,CAAC,kDAAkD,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;gBAC9E,CAAC;gBACD,OAAO,EAAE,CAAA;YACX,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;IAES,KAAK,CAAC,UAAU;QACxB,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAA;IACjC,CAAC;CACF","sourcesContent":["import {throttle} from '../utils/throttle.js'\nimport {MetricReader} from '@opentelemetry/sdk-metrics'\nimport {ExportResultCode} from '@opentelemetry/core'\nimport {diag} from '@opentelemetry/api'\nimport type {PushMetricExporter} from '@opentelemetry/sdk-metrics'\n\nexport interface InstantaneousMetricReaderOptions {\n /**\n * The backing exporter for the metric reader.\n */\n exporter: PushMetricExporter\n\n /**\n * How much the export should be throttled in milliseconds.\n */\n throttleLimit: number\n}\n\nexport class InstantaneousMetricReader extends MetricReader {\n private readonly _exporter: PushMetricExporter\n\n constructor({exporter, throttleLimit}: InstantaneousMetricReaderOptions) {\n super({\n aggregationSelector: exporter.selectAggregation?.bind(exporter),\n aggregationTemporalitySelector: exporter.selectAggregationTemporality?.bind(exporter),\n })\n this._exporter = exporter\n\n this.onForceFlush = throttle(this.onForceFlush, throttleLimit)\n }\n\n protected async onForceFlush(): Promise<void> {\n const {resourceMetrics, errors} = await this.collect({})\n\n if (errors.length > 0) {\n diag.error('InstantaneousMetricReader: metrics collection errors', ...errors)\n }\n\n return new Promise((resolve) => {\n this._exporter.export(resourceMetrics, (result) => {\n if (result.code !== ExportResultCode.SUCCESS) {\n diag.error('InstantaneousMetricReader: metrics export failed', result.error)\n }\n resolve()\n })\n })\n }\n\n protected async onShutdown(): Promise<void> {\n await this._exporter.shutdown()\n }\n}\n"]}
|
|
@@ -32,6 +32,13 @@ export declare class BaseOtelService implements OtelService {
|
|
|
32
32
|
protected readonly recordListeners: Set<OnRecordCallback>;
|
|
33
33
|
/**
|
|
34
34
|
* Bootstraps an Otel exporter which can send Otel metrics to a dedicated Shopify supported collector endpoint.
|
|
35
|
+
*
|
|
36
|
+
* @param root0
|
|
37
|
+
* @param root0.serviceName
|
|
38
|
+
* @param root0.prefixMetric
|
|
39
|
+
* @param root0.metrics
|
|
40
|
+
* @param root0.onRecord
|
|
41
|
+
* @param root0.meterProvider
|
|
35
42
|
*/
|
|
36
43
|
constructor({ serviceName, prefixMetric, metrics, onRecord, meterProvider }: BaseOtelServiceOptions);
|
|
37
44
|
getMeterProvider(): MeterProvider;
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { ExplicitBucketHistogramAggregation, View } from '@opentelemetry/sdk-metrics';
|
|
2
1
|
import { MetricInstrumentType } from '../types.js';
|
|
3
2
|
import { isValidMetricName } from '../../utils/validators.js';
|
|
3
|
+
import { ExplicitBucketHistogramAggregation, View } from '@opentelemetry/sdk-metrics';
|
|
4
4
|
const instrumentationScope = 'opentelemetry-js-shopify-web';
|
|
5
5
|
export class BaseOtelService {
|
|
6
6
|
/**
|
|
7
7
|
* Bootstraps an Otel exporter which can send Otel metrics to a dedicated Shopify supported collector endpoint.
|
|
8
|
+
*
|
|
9
|
+
* @param root0
|
|
10
|
+
* @param root0.serviceName
|
|
11
|
+
* @param root0.prefixMetric
|
|
12
|
+
* @param root0.metrics
|
|
13
|
+
* @param root0.onRecord
|
|
14
|
+
* @param root0.meterProvider
|
|
8
15
|
*/
|
|
9
16
|
constructor({ serviceName, prefixMetric = false, metrics = {}, onRecord, meterProvider }) {
|
|
10
17
|
this.metrics = new Map();
|
|
@@ -28,6 +35,7 @@ export class BaseOtelService {
|
|
|
28
35
|
addView(viewOptions) {
|
|
29
36
|
// The API to register view is not yet exposed. We need to use the private
|
|
30
37
|
// property to register a new view after the initial instantiation.
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
39
|
;
|
|
32
40
|
this.meterProvider._sharedState?.viewRegistry?.addView?.(new View(viewOptions));
|
|
33
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseOtelService.js","sourceRoot":"","sources":["../../../../../../../src/public/node/vendor/otel-js/service/BaseOtelService/BaseOtelService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,kCAAkC,EAAE,IAAI,EAAC,MAAM,4BAA4B,CAAA;AAUnF,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAA;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAA;AAE3D,MAAM,oBAAoB,GAAG,8BAA8B,CAAA;AA8B3D,MAAM,OAAO,eAAe;IAQ1B;;OAEG;IACH,YAAY,EAAC,WAAW,EAAE,YAAY,GAAG,KAAK,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAyB;QAN3F,YAAO,GAAsC,IAAI,GAAG,EAAE,CAAA;QACtD,oBAAe,GAAG,IAAI,GAAG,EAAoB,CAAA;QAM9D,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;QAC9C,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAE9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,QAAQ;YAAE,IAAI,CAAC,WAAW,CAA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AC,UAAU,EAAE,GAAG,UAAU,CAAC,IAAI,UAAU,CAAA;QAC1D,CAAC,EACD,CAAC,YAAY,EAAE,aAAa,CAAC,CAC9B,CAAA;IACH,CAAC;CACF","sourcesContent":["import type {MetricAttributes} from '@opentelemetry/api'\nimport type {MeterProvider, ViewOptions} from '@opentelemetry/sdk-metrics'\nimport {ExplicitBucketHistogramAggregation, View} from '@opentelemetry/sdk-metrics'\n\nimport type {\n MetricDescriptor,\n MetricRecording,\n MetricsConfig,\n OnRecordCallback,\n OtelService,\n RecordMetricFunction,\n} from '../types.js'\nimport {MetricInstrumentType} from '../types.js'\nimport {isValidMetricName} from '../../utils/validators.js'\n\nconst instrumentationScope = 'opentelemetry-js-shopify-web'\n\nexport interface BaseOtelServiceOptions {\n /**\n * Service name is a unique name for an application/service.\n */\n serviceName: string\n\n /**\n * If this is set to true then the service name is prefixed to every metric.\n */\n prefixMetric?: boolean\n\n /**\n * Metrics to register on startup.\n */\n metrics?: MetricsConfig\n\n /**\n * Called when a metric is recorded. `addOnRecord` can also be used to add\n * listeners anytime.\n */\n onRecord?: OnRecordCallback\n\n /**\n * Override the default meter provider.\n */\n meterProvider?: MeterProvider\n}\n\nexport class BaseOtelService implements OtelService {\n readonly serviceName: string\n readonly prefixMetric: boolean\n\n protected readonly meterProvider: MeterProvider\n protected readonly metrics: Map<string, RecordMetricFunction> = new Map()\n protected readonly recordListeners = new Set<OnRecordCallback>()\n\n /**\n * Bootstraps an Otel exporter which can send Otel metrics to a dedicated Shopify supported collector endpoint.\n */\n constructor({serviceName, prefixMetric = false, metrics = {}, onRecord, meterProvider}: BaseOtelServiceOptions) {\n if (!serviceName) {\n throw new Error('Service name is required.')\n }\n this.serviceName = serviceName\n\n this.prefixMetric = prefixMetric\n if (onRecord) this.addOnRecord(onRecord)\n\n if (!meterProvider) {\n throw new Error('MeterProvider is required.')\n }\n this.meterProvider = meterProvider\n\n this.register(metrics)\n }\n\n getMeterProvider(): MeterProvider {\n return this.meterProvider\n }\n\n addView(viewOptions: ViewOptions) {\n // The API to register view is not yet exposed. We need to use the private\n // property to register a new view after the initial instantiation.\n ;(this.meterProvider as any)._sharedState?.viewRegistry?.addView?.(new View(viewOptions))\n }\n\n record(metricName: string, value: number, labels?: MetricAttributes): void {\n const recordMetric = this.metrics.get(metricName)\n if (!recordMetric) {\n throw new Error(\n `Service ${this.serviceName} has no metrics registered for name: ${metricName}. Can't record value for unknown metric.`,\n )\n }\n recordMetric(value, labels)\n }\n\n registerMetric(metricName: string, {type, ...options}: MetricDescriptor): void {\n if (this.metrics.has(metricName)) {\n return\n }\n const meter = this.meterProvider.getMeter(instrumentationScope)\n const name = this.prefixMetric ? `${this.serviceName}_${metricName}` : metricName\n\n if (!isValidMetricName(name)) {\n return\n }\n\n const createInstrument = () => {\n switch (type) {\n case MetricInstrumentType.Counter:\n return meter.createCounter(name, options)\n case MetricInstrumentType.UpDownCounter:\n return meter.createUpDownCounter(name, options)\n case MetricInstrumentType.Histogram: {\n if ('boundaries' in options) {\n this.addView({\n instrumentName: name,\n aggregation: new ExplicitBucketHistogramAggregation(options.boundaries, true),\n })\n }\n return meter.createHistogram(name, options)\n }\n }\n }\n\n // Lazy instantiate the instrument so we don't create it if we don't need to\n this.metrics.set(metricName, (firstValue: number, firstLabels?: MetricAttributes) => {\n const instrument = createInstrument()\n const record = (value: number, labels?: MetricAttributes) => {\n const [finalValue, finalLabels] = this.notifyRecordListeners(\n metricName,\n value,\n // ensures an new object is created so we don't mutate the original\n {...labels},\n )\n if ('record' in instrument) {\n instrument.record(finalValue, finalLabels)\n } else {\n instrument.add(finalValue, finalLabels)\n }\n // We flush metrics after every record - we do not await as we fire & forget.\n // Catch any export errors to prevent unhandled rejections from crashing the CLI\n void this.meterProvider.forceFlush({}).catch(() => {})\n }\n record(firstValue, firstLabels)\n this.metrics.set(metricName, record)\n })\n }\n\n register(metrics: MetricsConfig) {\n Object.entries(metrics).forEach(([metricName, options]) => {\n this.registerMetric(metricName, options)\n })\n }\n\n addOnRecord(onRecord: OnRecordCallback): () => void {\n this.recordListeners.add(onRecord)\n return () => {\n this.recordListeners.delete(onRecord)\n }\n }\n\n removeOnRecord(onRecord: OnRecordCallback): void {\n this.recordListeners.delete(onRecord)\n }\n\n shutdown(): Promise<void> {\n this.metrics.clear()\n this.recordListeners.clear()\n return this.meterProvider.shutdown()\n }\n\n protected notifyRecordListeners(metricName: string, initialValue: number, initialLabels: MetricAttributes) {\n return Array.from(this.recordListeners).reduce<MetricRecording>(\n (recordArgs, listener) => {\n return listener(metricName, ...recordArgs) || recordArgs\n },\n [initialValue, initialLabels],\n )\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BaseOtelService.js","sourceRoot":"","sources":["../../../../../../../src/public/node/vendor/otel-js/service/BaseOtelService/BaseOtelService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,aAAa,CAAA;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EAAC,kCAAkC,EAAE,IAAI,EAAC,MAAM,4BAA4B,CAAA;AAanF,MAAM,oBAAoB,GAAG,8BAA8B,CAAA;AA8B3D,MAAM,OAAO,eAAe;IAQ1B;;;;;;;;;OASG;IACH,YAAY,EAAC,WAAW,EAAE,YAAY,GAAG,KAAK,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAyB;QAb3F,YAAO,GAAsC,IAAI,GAAG,EAAE,CAAA;QACtD,oBAAe,GAAG,IAAI,GAAG,EAAoB,CAAA;QAa9D,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;QAC9C,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAE9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,QAAQ;YAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAA;QAExC,IAAI,CAAC,a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U,CAAC,IAAI,UAAU,CAAA;QAC1D,CAAC,EACD,CAAC,YAAY,EAAE,aAAa,CAAC,CAC9B,CAAA;IACH,CAAC;CACF","sourcesContent":["import {MetricInstrumentType} from '../types.js'\nimport {isValidMetricName} from '../../utils/validators.js'\nimport {ExplicitBucketHistogramAggregation, View} from '@opentelemetry/sdk-metrics'\nimport type {MetricAttributes} from '@opentelemetry/api'\nimport type {MeterProvider, ViewOptions} from '@opentelemetry/sdk-metrics'\n\nimport type {\n MetricDescriptor,\n MetricRecording,\n MetricsConfig,\n OnRecordCallback,\n OtelService,\n RecordMetricFunction,\n} from '../types.js'\n\nconst instrumentationScope = 'opentelemetry-js-shopify-web'\n\nexport interface BaseOtelServiceOptions {\n /**\n * Service name is a unique name for an application/service.\n */\n serviceName: string\n\n /**\n * If this is set to true then the service name is prefixed to every metric.\n */\n prefixMetric?: boolean\n\n /**\n * Metrics to register on startup.\n */\n metrics?: MetricsConfig\n\n /**\n * Called when a metric is recorded. `addOnRecord` can also be used to add\n * listeners anytime.\n */\n onRecord?: OnRecordCallback\n\n /**\n * Override the default meter provider.\n */\n meterProvider?: MeterProvider\n}\n\nexport class BaseOtelService implements OtelService {\n readonly serviceName: string\n readonly prefixMetric: boolean\n\n protected readonly meterProvider: MeterProvider\n protected readonly metrics: Map<string, RecordMetricFunction> = new Map()\n protected readonly recordListeners = new Set<OnRecordCallback>()\n\n /**\n * Bootstraps an Otel exporter which can send Otel metrics to a dedicated Shopify supported collector endpoint.\n *\n * @param root0\n * @param root0.serviceName\n * @param root0.prefixMetric\n * @param root0.metrics\n * @param root0.onRecord\n * @param root0.meterProvider\n */\n constructor({serviceName, prefixMetric = false, metrics = {}, onRecord, meterProvider}: BaseOtelServiceOptions) {\n if (!serviceName) {\n throw new Error('Service name is required.')\n }\n this.serviceName = serviceName\n\n this.prefixMetric = prefixMetric\n if (onRecord) this.addOnRecord(onRecord)\n\n if (!meterProvider) {\n throw new Error('MeterProvider is required.')\n }\n this.meterProvider = meterProvider\n\n this.register(metrics)\n }\n\n getMeterProvider(): MeterProvider {\n return this.meterProvider\n }\n\n addView(viewOptions: ViewOptions) {\n // The API to register view is not yet exposed. We need to use the private\n // property to register a new view after the initial instantiation.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(this.meterProvider as any)._sharedState?.viewRegistry?.addView?.(new View(viewOptions))\n }\n\n record(metricName: string, value: number, labels?: MetricAttributes): void {\n const recordMetric = this.metrics.get(metricName)\n if (!recordMetric) {\n throw new Error(\n `Service ${this.serviceName} has no metrics registered for name: ${metricName}. Can't record value for unknown metric.`,\n )\n }\n recordMetric(value, labels)\n }\n\n registerMetric(metricName: string, {type, ...options}: MetricDescriptor): void {\n if (this.metrics.has(metricName)) {\n return\n }\n const meter = this.meterProvider.getMeter(instrumentationScope)\n const name = this.prefixMetric ? `${this.serviceName}_${metricName}` : metricName\n\n if (!isValidMetricName(name)) {\n return\n }\n\n const createInstrument = () => {\n switch (type) {\n case MetricInstrumentType.Counter:\n return meter.createCounter(name, options)\n case MetricInstrumentType.UpDownCounter:\n return meter.createUpDownCounter(name, options)\n case MetricInstrumentType.Histogram: {\n if ('boundaries' in options) {\n this.addView({\n instrumentName: name,\n aggregation: new ExplicitBucketHistogramAggregation(options.boundaries, true),\n })\n }\n return meter.createHistogram(name, options)\n }\n }\n }\n\n // Lazy instantiate the instrument so we don't create it if we don't need to\n this.metrics.set(metricName, (firstValue: number, firstLabels?: MetricAttributes) => {\n const instrument = createInstrument()\n const record = (value: number, labels?: MetricAttributes) => {\n const [finalValue, finalLabels] = this.notifyRecordListeners(\n metricName,\n value,\n // ensures an new object is created so we don't mutate the original\n {...labels},\n )\n if ('record' in instrument) {\n instrument.record(finalValue, finalLabels)\n } else {\n instrument.add(finalValue, finalLabels)\n }\n // We flush metrics after every record - we do not await as we fire & forget.\n // Catch any export errors to prevent unhandled rejections from crashing the CLI\n void this.meterProvider.forceFlush({}).catch(() => {})\n }\n record(firstValue, firstLabels)\n this.metrics.set(metricName, record)\n })\n }\n\n register(metrics: MetricsConfig) {\n Object.entries(metrics).forEach(([metricName, options]) => {\n this.registerMetric(metricName, options)\n })\n }\n\n addOnRecord(onRecord: OnRecordCallback): () => void {\n this.recordListeners.add(onRecord)\n return () => {\n this.recordListeners.delete(onRecord)\n }\n }\n\n removeOnRecord(onRecord: OnRecordCallback): void {\n this.recordListeners.delete(onRecord)\n }\n\n shutdown(): Promise<void> {\n this.metrics.clear()\n this.recordListeners.clear()\n return this.meterProvider.shutdown()\n }\n\n protected notifyRecordListeners(metricName: string, initialValue: number, initialLabels: MetricAttributes) {\n return Array.from(this.recordListeners).reduce<MetricRecording>(\n (recordArgs, listener) => {\n return listener(metricName, ...recordArgs) || recordArgs\n },\n [initialValue, initialLabels],\n )\n }\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { BaseOtelService } from '../BaseOtelService/BaseOtelService.js';
|
|
|
2
2
|
import type { BaseOtelServiceOptions } from '../BaseOtelService/BaseOtelService.js';
|
|
3
3
|
export interface DefaultOtelServiceOptions extends BaseOtelServiceOptions {
|
|
4
4
|
/**
|
|
5
|
-
* What environment is being deployed (production, staging)
|
|
5
|
+
* What environment is being deployed (production, staging).
|
|
6
6
|
*/
|
|
7
7
|
env?: string;
|
|
8
8
|
/**
|
|
@@ -18,6 +18,17 @@ export interface DefaultOtelServiceOptions extends BaseOtelServiceOptions {
|
|
|
18
18
|
export declare class DefaultOtelService extends BaseOtelService {
|
|
19
19
|
/**
|
|
20
20
|
* Bootstraps an Otel exporter which can send Otel metrics to a dedicated Shopify supported collector endpoint.
|
|
21
|
+
*
|
|
22
|
+
* @param root0
|
|
23
|
+
* @param root0.throttleLimit
|
|
24
|
+
* @param root0.env
|
|
25
|
+
* @param root0.serviceName
|
|
26
|
+
* @param root0.prefixMetric
|
|
27
|
+
* @param root0.metrics
|
|
28
|
+
* @param root0.onRecord
|
|
29
|
+
* @param root0.meterProvider
|
|
30
|
+
* @param root0.useXhr
|
|
31
|
+
* @param root0.otelEndpoint
|
|
21
32
|
*/
|
|
22
33
|
constructor({ throttleLimit, env, serviceName, prefixMetric, metrics, onRecord, meterProvider, useXhr, otelEndpoint, }: DefaultOtelServiceOptions);
|
|
23
34
|
shutdown(): Promise<void>;
|
|
@@ -4,6 +4,17 @@ import { diag, DiagConsoleLogger, DiagLogLevel } from '@opentelemetry/api';
|
|
|
4
4
|
export class DefaultOtelService extends BaseOtelService {
|
|
5
5
|
/**
|
|
6
6
|
* Bootstraps an Otel exporter which can send Otel metrics to a dedicated Shopify supported collector endpoint.
|
|
7
|
+
*
|
|
8
|
+
* @param root0
|
|
9
|
+
* @param root0.throttleLimit
|
|
10
|
+
* @param root0.env
|
|
11
|
+
* @param root0.serviceName
|
|
12
|
+
* @param root0.prefixMetric
|
|
13
|
+
* @param root0.metrics
|
|
14
|
+
* @param root0.onRecord
|
|
15
|
+
* @param root0.meterProvider
|
|
16
|
+
* @param root0.useXhr
|
|
17
|
+
* @param root0.otelEndpoint
|
|
7
18
|
*/
|
|
8
19
|
constructor({ throttleLimit = 5000, env = 'local', serviceName, prefixMetric = false, metrics = {}, onRecord, meterProvider, useXhr = false,
|
|
9
20
|
// CLI addition
|
package/dist/public/node/vendor/otel-js/service/DefaultOtelService/DefaultOtelService.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultOtelService.js","sourceRoot":"","sources":["../../../../../../../src/public/node/vendor/otel-js/service/DefaultOtelService/DefaultOtelService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAC,eAAe,EAAC,MAAM,uCAAuC,CAAA;AACrE,OAAO,EAAC,IAAI,EAAE,iBAAiB,EAAE,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAsBxE,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IACrD
|
|
1
|
+
{"version":3,"file":"DefaultOtelService.js","sourceRoot":"","sources":["../../../../../../../src/public/node/vendor/otel-js/service/DefaultOtelService/DefaultOtelService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAC,eAAe,EAAC,MAAM,uCAAuC,CAAA;AACrE,OAAO,EAAC,IAAI,EAAE,iBAAiB,EAAE,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAsBxE,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IACrD;;;;;;;;;;;;;OAaG;IACH,YAAY,EACV,aAAa,GAAG,IAAI,EACpB,GAAG,GAAG,OAAO,EACb,WAAW,EACX,YAAY,GAAG,KAAK,EACpB,OAAO,GAAG,EAAE,EACZ,QAAQ,EACR,aAAa,EACb,MAAM,GAAG,KAAK;IACd,eAAe;IACf,YAAY,GACc;QAC1B,IAAI,CAAC,SAAS,CACZ,IAAI,iBAAiB,EAAE,EACvB,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CACjF,CAAA;QAED,KAAK,CAAC;YACJ,WAAW;YACX,aAAa,EACX,aAAa;gBACb,IAAI,oBAAoB,CAAC;oBACvB,WAAW;oBACX,GAAG;oBACH,aAAa;oBACb,MAAM;oBACN,eAAe;oBACf,YAAY;iBACb,CAAC;YACJ,YAAY;YACZ,OAAO;YACP,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAEQ,QAAQ;QACf,IAAI,CAAC,OAAO,EAAE,CAAA;QACd,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAA;IACzB,CAAC;CACF","sourcesContent":["import {DefaultMeterProvider} from './DefaultMeterProvider.js'\nimport {BaseOtelService} from '../BaseOtelService/BaseOtelService.js'\nimport {diag, DiagConsoleLogger, DiagLogLevel} from '@opentelemetry/api'\n\nimport type {BaseOtelServiceOptions} from '../BaseOtelService/BaseOtelService.js'\n\nexport interface DefaultOtelServiceOptions extends BaseOtelServiceOptions {\n /**\n * What environment is being deployed (production, staging).\n */\n env?: string\n /**\n * How much the export should be throttled in milliseconds.\n */\n throttleLimit?: number\n /**\n * Determines whether to send metrics via XHR or beacon. Defaults to false.\n */\n useXhr?: boolean\n\n // CLI addition\n otelEndpoint: string\n}\n\nexport class DefaultOtelService extends BaseOtelService {\n /**\n * Bootstraps an Otel exporter which can send Otel metrics to a dedicated Shopify supported collector endpoint.\n *\n * @param root0\n * @param root0.throttleLimit\n * @param root0.env\n * @param root0.serviceName\n * @param root0.prefixMetric\n * @param root0.metrics\n * @param root0.onRecord\n * @param root0.meterProvider\n * @param root0.useXhr\n * @param root0.otelEndpoint\n */\n constructor({\n throttleLimit = 5000,\n env = 'local',\n serviceName,\n prefixMetric = false,\n metrics = {},\n onRecord,\n meterProvider,\n useXhr = false,\n // CLI addition\n otelEndpoint,\n }: DefaultOtelServiceOptions) {\n diag.setLogger(\n new DiagConsoleLogger(),\n ['production', 'staging'].includes(env) ? DiagLogLevel.ERROR : DiagLogLevel.INFO,\n )\n\n super({\n serviceName,\n meterProvider:\n meterProvider ??\n new DefaultMeterProvider({\n serviceName,\n env,\n throttleLimit,\n useXhr,\n // CLI addition\n otelEndpoint,\n }),\n prefixMetric,\n metrics,\n onRecord,\n })\n }\n\n override shutdown(): Promise<void> {\n diag.disable()\n return super.shutdown()\n }\n}\n"]}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { Counter, Histogram, MeterProvider, MetricAttributes, MetricOptions, UpDownCounter } from '@opentelemetry/api';
|
|
2
2
|
import type { ViewOptions } from '@opentelemetry/sdk-metrics';
|
|
3
|
-
export type CustomMetricLabels<TLabels extends {
|
|
4
|
-
[key in TKeys]: MetricAttributes;
|
|
5
|
-
}, TKeys extends string = keyof TLabels & string> = {
|
|
3
|
+
export type CustomMetricLabels<TLabels extends Record<TKeys, MetricAttributes>, TKeys extends string = keyof TLabels & string> = {
|
|
6
4
|
[P in TKeys]: TLabels[P] extends MetricAttributes ? TLabels[P] : never;
|
|
7
5
|
};
|
|
8
|
-
export type MetricRecording<TAttributes extends MetricAttributes =
|
|
9
|
-
export type RecordMetricFunction<TAttributes extends MetricAttributes =
|
|
10
|
-
export type OnRecordCallback<TAttributes extends MetricAttributes =
|
|
6
|
+
export type MetricRecording<TAttributes extends MetricAttributes = MetricAttributes> = [value: number, labels?: TAttributes];
|
|
7
|
+
export type RecordMetricFunction<TAttributes extends MetricAttributes = MetricAttributes> = (...args: MetricRecording<TAttributes>) => void;
|
|
8
|
+
export type OnRecordCallback<TAttributes extends MetricAttributes = MetricAttributes> = (metricName: string, ...args: MetricRecording<TAttributes>) => MetricRecording<TAttributes> | void;
|
|
11
9
|
export type MetricInstrument = Histogram | Counter | UpDownCounter;
|
|
12
10
|
export declare enum MetricInstrumentType {
|
|
13
11
|
Histogram = "Histogram",
|
|
@@ -23,14 +21,12 @@ export type MetricDescriptor = MetricOptions & ({
|
|
|
23
21
|
} | {
|
|
24
22
|
type: MetricInstrumentType.Counter | MetricInstrumentType.UpDownCounter;
|
|
25
23
|
});
|
|
26
|
-
export
|
|
27
|
-
[key: string]: MetricDescriptor;
|
|
28
|
-
}
|
|
24
|
+
export type MetricsConfig = Record<string, MetricDescriptor>;
|
|
29
25
|
export interface OtelService {
|
|
30
26
|
readonly serviceName: string;
|
|
31
27
|
getMeterProvider(): MeterProvider;
|
|
32
28
|
addView(viewOptions: ViewOptions): void;
|
|
33
|
-
record<TAttributes extends MetricAttributes =
|
|
29
|
+
record<TAttributes extends MetricAttributes = MetricAttributes>(...args: Parameters<OnRecordCallback<TAttributes>>): void;
|
|
34
30
|
/**
|
|
35
31
|
* `onRecord` callback is called when a metric is recorded.
|
|
36
32
|
* Returns a function to unsubscribe.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/public/node/vendor/otel-js/service/types.ts"],"names":[],"mappings":"AA8BA,MAAM,CAAN,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC9B,+CAAuB,CAAA;IACvB,2CAAmB,CAAA;IACnB,uDAA+B,CAAA;AACjC,CAAC,EAJW,oBAAoB,KAApB,oBAAoB,QAI/B","sourcesContent":["import type {\n Counter,\n Histogram,\n MeterProvider,\n MetricAttributes,\n MetricOptions,\n UpDownCounter,\n} from '@opentelemetry/api'\nimport type {ViewOptions} from '@opentelemetry/sdk-metrics'\n\nexport type CustomMetricLabels<\n TLabels extends
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/public/node/vendor/otel-js/service/types.ts"],"names":[],"mappings":"AA8BA,MAAM,CAAN,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC9B,+CAAuB,CAAA;IACvB,2CAAmB,CAAA;IACnB,uDAA+B,CAAA;AACjC,CAAC,EAJW,oBAAoB,KAApB,oBAAoB,QAI/B","sourcesContent":["import type {\n Counter,\n Histogram,\n MeterProvider,\n MetricAttributes,\n MetricOptions,\n UpDownCounter,\n} from '@opentelemetry/api'\nimport type {ViewOptions} from '@opentelemetry/sdk-metrics'\n\nexport type CustomMetricLabels<\n TLabels extends Record<TKeys, MetricAttributes>,\n TKeys extends string = keyof TLabels & string,\n> = {\n [P in TKeys]: TLabels[P] extends MetricAttributes ? TLabels[P] : never\n}\n\nexport type MetricRecording<TAttributes extends MetricAttributes = MetricAttributes> = [value: number, labels?: TAttributes]\n\nexport type RecordMetricFunction<TAttributes extends MetricAttributes = MetricAttributes> = (\n ...args: MetricRecording<TAttributes>\n) => void\n\nexport type OnRecordCallback<TAttributes extends MetricAttributes = MetricAttributes> = (\n metricName: string,\n ...args: MetricRecording<TAttributes>\n) => MetricRecording<TAttributes> | void\n\nexport type MetricInstrument = Histogram | Counter | UpDownCounter\n\nexport enum MetricInstrumentType {\n Histogram = 'Histogram',\n Counter = 'Counter',\n UpDownCounter = 'UpDownCounter',\n}\n\nexport type MetricDescriptor = MetricOptions &\n (\n | {\n type: MetricInstrumentType.Histogram\n /**\n * Boundaries are required for Histograms.\n */\n boundaries: number[]\n }\n | {\n type: MetricInstrumentType.Counter | MetricInstrumentType.UpDownCounter\n }\n )\n\nexport type MetricsConfig = Record<string, MetricDescriptor>\n\nexport interface OtelService {\n readonly serviceName: string\n\n getMeterProvider(): MeterProvider\n\n addView(viewOptions: ViewOptions): void\n\n record<TAttributes extends MetricAttributes = MetricAttributes>(...args: Parameters<OnRecordCallback<TAttributes>>): void\n\n /**\n * `onRecord` callback is called when a metric is recorded.\n * Returns a function to unsubscribe.\n */\n addOnRecord(onRecord: OnRecordCallback): () => void\n\n removeOnRecord(onRecord: OnRecordCallback): void\n\n registerMetric(metricName: string, options: MetricDescriptor): void\n\n register(metrics: MetricsConfig): void\n\n shutdown(): Promise<void>\n}\n"]}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
type ThrottledFunction<T extends (...args:
|
|
1
|
+
type ThrottledFunction<T extends (...args: unknown[]) => unknown> = (...args: Parameters<T>) => ReturnType<T>;
|
|
2
2
|
interface ThrottleOptions {
|
|
3
3
|
leading?: boolean;
|
|
4
4
|
trailing?: boolean;
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param func
|
|
9
|
+
* @param wait
|
|
10
|
+
* @param root0
|
|
11
|
+
* @param root0.leading
|
|
12
|
+
* @param root0.trailing
|
|
13
|
+
*/
|
|
14
|
+
export declare function throttle<T extends (...args: unknown[]) => unknown>(func: T, wait: number, { leading, trailing }?: ThrottleOptions): ThrottledFunction<T>;
|
|
7
15
|
export {};
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param func
|
|
4
|
+
* @param wait
|
|
5
|
+
* @param root0
|
|
6
|
+
* @param root0.leading
|
|
7
|
+
* @param root0.trailing
|
|
8
|
+
*/
|
|
1
9
|
export function throttle(func, wait, { leading = true, trailing = true } = {}) {
|
|
2
10
|
let lastArgs;
|
|
3
11
|
let result;
|
|
@@ -13,6 +21,7 @@ export function throttle(func, wait, { leading = true, trailing = true } = {}) {
|
|
|
13
21
|
// prevent unhandled promise rejections (the caller already .catch()'d
|
|
14
22
|
// the leading-edge invocation and has no reference to trailing calls).
|
|
15
23
|
if (result && typeof result.catch === 'function') {
|
|
24
|
+
;
|
|
16
25
|
result.catch(() => { });
|
|
17
26
|
}
|
|
18
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throttle.js","sourceRoot":"","sources":["../../../../../../src/public/node/vendor/otel-js/utils/throttle.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,QAAQ,CACtB,IAAO,EACP,IAAY,EACZ,EAAC,OAAO,GAAG,IAAI,EAAE,QAAQ,GAAG,IAAI,KAAqB,EAAE;IAEvD,IAAI,QAA8B,CAAA;IAClC,IAAI,MAAqB,CAAA;IACzB,IAAI,
|
|
1
|
+
{"version":3,"file":"throttle.js","sourceRoot":"","sources":["../../../../../../src/public/node/vendor/otel-js/utils/throttle.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CACtB,IAAO,EACP,IAAY,EACZ,EAAC,OAAO,GAAG,IAAI,EAAE,QAAQ,GAAG,IAAI,KAAqB,EAAE;IAEvD,IAAI,QAA8B,CAAA;IAClC,IAAI,MAAqB,CAAA;IACzB,IAAI,OAAgB,CAAA;IACpB,IAAI,OAAO,GAAyC,IAAI,CAAA;IACxD,IAAI,QAAQ,GAAG,CAAC,CAAA;IAEhB,SAAS,KAAK;QACZ,QAAQ,GAAG,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;QAC7C,OAAO,GAAG,IAAI,CAAA;QACd,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAkB,CAAA;YACvD,qEAAqE;YACrE,sEAAsE;YACtE,uEAA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ptions {\n leading?: boolean\n trailing?: boolean\n}\n\n/**\n *\n * @param func\n * @param wait\n * @param root0\n * @param root0.leading\n * @param root0.trailing\n */\nexport function throttle<T extends (...args: unknown[]) => unknown>(\n func: T,\n wait: number,\n {leading = true, trailing = true}: ThrottleOptions = {},\n): ThrottledFunction<T> {\n let lastArgs: Parameters<T> | null\n let result: ReturnType<T>\n let context: unknown\n let timeout: ReturnType<typeof setTimeout> | null = null\n let previous = 0\n\n function later() {\n previous = leading === false ? 0 : Date.now()\n timeout = null\n if (lastArgs) {\n result = func.apply(context, lastArgs) as ReturnType<T>\n // If the throttled function returns a promise, swallow rejections to\n // prevent unhandled promise rejections (the caller already .catch()'d\n // the leading-edge invocation and has no reference to trailing calls).\n if (result && typeof (result as any).catch === 'function') {\n ;(result as any).catch(() => {})\n }\n }\n context = null\n lastArgs = null\n }\n\n return function (this: unknown, ...args: Parameters<T>): ReturnType<T> {\n const now = Date.now()\n if (!previous && leading === false) previous = now\n\n const remaining = wait - (now - previous)\n // eslint-disable-next-line @typescript-eslint/no-this-alias, consistent-this\n context = this\n lastArgs = args\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout)\n timeout = null\n }\n previous = now\n if (lastArgs) {\n result = func.apply(context, lastArgs) as ReturnType<T>\n }\n context = null\n lastArgs = null\n } else if (!timeout && trailing !== false) {\n timeout = setTimeout(later, remaining)\n }\n return result\n }\n}\n"]}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { diag } from '@opentelemetry/api';
|
|
2
2
|
const validMetricRegex = new RegExp('[^a-zA-Z_][^a-zA-Z0-9_]*');
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param value
|
|
6
|
+
*/
|
|
3
7
|
export function isValidMetricName(value) {
|
|
4
8
|
if (validMetricRegex.test(value)) {
|
|
5
9
|
diag.warn(`Metric name ${value} contains invalid characters and will be dropped.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../../../../src/public/node/vendor/otel-js/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAA;AAEvC,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,0BAA0B,CAAC,CAAA;AAE/D,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,IAAI,CACP,eAAe,KAAK;gGACsE,EAC1F,WAAW,CACZ,CAAA;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import {diag} from '@opentelemetry/api'\n\nconst validMetricRegex = new RegExp('[^a-zA-Z_][^a-zA-Z0-9_]*')\n\nexport function isValidMetricName(value: string): boolean {\n if (validMetricRegex.test(value)) {\n diag.warn(\n `Metric name ${value} contains invalid characters and will be dropped.\n Service Names and metric names must conform to the following regex %c[a-zA-Z_][a-zA-Z0-9_]*`,\n 'color:red',\n )\n return false\n }\n\n return true\n}\n"]}
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../../../../src/public/node/vendor/otel-js/utils/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,oBAAoB,CAAA;AAEvC,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,0BAA0B,CAAC,CAAA;AAE/D;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,IAAI,CACP,eAAe,KAAK;gGACsE,EAC1F,WAAW,CACZ,CAAA;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import {diag} from '@opentelemetry/api'\n\nconst validMetricRegex = new RegExp('[^a-zA-Z_][^a-zA-Z0-9_]*')\n\n/**\n *\n * @param value\n */\nexport function isValidMetricName(value: string): boolean {\n if (validMetricRegex.test(value)) {\n diag.warn(\n `Metric name ${value} contains invalid characters and will be dropped.\n Service Names and metric names must conform to the following regex %c[a-zA-Z_][a-zA-Z0-9_]*`,\n 'color:red',\n )\n return false\n }\n\n return true\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/node/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/node/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,SAAS,EAAC,MAAM,QAAQ,CAAA;AAChC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,SAAiB;IACrD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,EAAC,GAAG,EAAE,SAAS,EAAC,CAAC,CAAA;QACrF,OAAO,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;QACnD,qDAAqD;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,EAAC,GAAG,OAAO,CAAC,GAAG,EAAE,wBAAwB,EAAE,GAAG,EAAC,CAAA;QAC3D,2EAA2E;QAC3E,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,EAAC,GAAG,EAAE,IAAI,EAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAA;QAC3G,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;YAAE,OAAO,SAAS,CAAA;QACzC,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAC,GAAG,EAAC,CAAC,CAAA;QACjE,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAA;QAC5D,IAAI,YAAY,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;YACpC,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,CAAA;YAC/B,IAAI,SAAS,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;gBACnE,OAAO,OAAO,CAAA;YAChB,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAA;QAChB,qDAAqD;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,OAAO,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;AACpC,CAAC","sourcesContent":["import {captureOutput} from './system.js'\nimport which from 'which'\nimport {satisfies} from 'semver'\n/**\n * Returns the version of the local dependency of the CLI if it's installed in the provided directory.\n *\n * @param directory - Path of the project to look for the dependency.\n * @returns The CLI version or undefined if the dependency is not installed.\n */\nexport async function localCLIVersion(directory: string): Promise<string | undefined> {\n try {\n const output = await captureOutput('npm', ['list', '@shopify/cli'], {cwd: directory})\n return output.match(/@shopify\\/cli@([\\w.-]*)/)?.[1]\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return undefined\n }\n}\n\n/**\n * Returns the version of the globally installed CLI, only if it's greater than 3.59.0 (when the global CLI was introduced).\n *\n * @returns The version of the CLI if it is globally installed or undefined.\n */\nexport async function globalCLIVersion(): Promise<string | undefined> {\n try {\n const env = {...process.env, SHOPIFY_CLI_NO_ANALYTICS: '1'}\n // Both execa and which find the project dependency. We need to exclude it.\n const shopifyBinaries = which.sync('shopify', {all: true}).filter((path) => !path.includes('node_modules'))\n if (!shopifyBinaries[0]) return undefined\n const output = await captureOutput(shopifyBinaries[0], [], {env})\n const versionMatch = output.match(/@shopify\\/cli\\/([^\\s]+)/)\n if (versionMatch && versionMatch[1]) {\n const version = versionMatch[1]\n if (satisfies(version, `>=3.59.0`) || isPreReleaseVersion(version)) {\n return version\n }\n }\n return undefined\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return undefined\n }\n}\n\n/**\n * Returns true if the given version is a pre-release version.\n * Meaning is a `nightly`, `snapshot`, or `experimental` version.\n *\n * @param version - The version to check.\n * @returns True if the version is a pre-release version.\n */\nexport function isPreReleaseVersion(version: string): boolean {\n return version.startsWith('0.0.0')\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fileExists, writeFile, readFile, findPathUp } from './fs.js';
|
|
2
2
|
import { joinPath, cwd } from './path.js';
|
|
3
|
-
import { outputContent, outputToken, outputDebug } from '
|
|
3
|
+
import { outputContent, outputToken, outputDebug } from './output.js';
|
|
4
4
|
/**
|
|
5
5
|
* Check if user editor is VS Code.
|
|
6
6
|
*
|