@prismatic-io/spectral 10.3.12 → 10.4.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/index.d.ts CHANGED
@@ -54,7 +54,16 @@ export declare const connectionConfigVar: <T extends ConnectionConfigVar = Conne
54
54
  /**
55
55
  * For information on writing Code Native Integrations, see
56
56
  * https://prismatic.io/docs/code-native-integrations/#adding-config-vars.
57
- * @param definition A Customer Connection Config Var type object.
57
+ * @param definition A Customer-Activated Connection Config Var type object.
58
+ * @returns This function returns a connection config var object that has the shape the Prismatic API expects.
59
+ */
60
+ export declare const customerActivatedConnection: <T extends {
61
+ stableKey: string;
62
+ }>(definition: T) => OrganizationActivatedConnectionConfigVar;
63
+ /**
64
+ * For information on writing Code Native Integrations, see
65
+ * https://prismatic.io/docs/code-native-integrations/#adding-config-vars.
66
+ * @param definition An Organization-Activated Connection Config Var type object.
58
67
  * @returns This function returns a connection config var object that has the shape the Prismatic API expects.
59
68
  */
60
69
  export declare const organizationActivatedConnection: <T extends {
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.testing = exports.util = exports.componentManifests = exports.oauth2Connection = exports.onPremConnection = exports.connection = exports.input = exports.dataSource = exports.pollingTrigger = exports.trigger = exports.action = exports.component = exports.componentManifest = exports.organizationActivatedConnection = exports.connectionConfigVar = exports.dataSourceConfigVar = exports.configVar = exports.configPage = exports.flow = exports.integration = void 0;
25
+ exports.testing = exports.util = exports.componentManifests = exports.oauth2Connection = exports.onPremConnection = exports.connection = exports.input = exports.dataSource = exports.pollingTrigger = exports.trigger = exports.action = exports.component = exports.componentManifest = exports.organizationActivatedConnection = exports.customerActivatedConnection = exports.connectionConfigVar = exports.dataSourceConfigVar = exports.configVar = exports.configPage = exports.flow = exports.integration = void 0;
26
26
  const convertComponent_1 = require("./serverTypes/convertComponent");
27
27
  const convertIntegration_1 = require("./serverTypes/convertIntegration");
28
28
  /**
@@ -85,7 +85,17 @@ exports.connectionConfigVar = connectionConfigVar;
85
85
  /**
86
86
  * For information on writing Code Native Integrations, see
87
87
  * https://prismatic.io/docs/code-native-integrations/#adding-config-vars.
88
- * @param definition A Customer Connection Config Var type object.
88
+ * @param definition A Customer-Activated Connection Config Var type object.
89
+ * @returns This function returns a connection config var object that has the shape the Prismatic API expects.
90
+ */
91
+ const customerActivatedConnection = (definition) => {
92
+ return Object.assign(Object.assign({}, definition), { dataType: "connection" });
93
+ };
94
+ exports.customerActivatedConnection = customerActivatedConnection;
95
+ /**
96
+ * For information on writing Code Native Integrations, see
97
+ * https://prismatic.io/docs/code-native-integrations/#adding-config-vars.
98
+ * @param definition An Organization-Activated Connection Config Var type object.
89
99
  * @returns This function returns a connection config var object that has the shape the Prismatic API expects.
90
100
  */
91
101
  const organizationActivatedConnection = (definition) => {
@@ -4,6 +4,7 @@ exports.createDebugContext = createDebugContext;
4
4
  exports.logDebugResults = logDebugResults;
5
5
  const node_process_1 = require("node:process");
6
6
  const node_perf_hooks_1 = require("node:perf_hooks");
7
+ const MEMORY_USAGE_CONVERSION = 1024 * 1024;
7
8
  function createDebugContext(context) {
8
9
  const globalDebug = Boolean(context.globalDebug);
9
10
  return {
@@ -26,11 +27,13 @@ function createDebugContext(context) {
26
27
  },
27
28
  memoryUsage: (actionContext, label, showDetail) => {
28
29
  if (globalDebug) {
29
- // @ts-expect-error: memoryUsage.rss() is documented but not typed
30
- const usage = showDetail ? (0, node_process_1.memoryUsage)() : node_process_1.memoryUsage.rss();
30
+ const usage = showDetail
31
+ ? memoryUsageInMB()
32
+ : // @ts-expect-error: memoryUsage.rss() is documented but not typed
33
+ node_process_1.memoryUsage.rss() / MEMORY_USAGE_CONVERSION;
31
34
  actionContext.debug.results.memoryUsage.push({
32
35
  mark: label,
33
- rss: typeof usage === "number" ? usage / 1000000 : usage.rss / 1000000,
36
+ rss: typeof usage === "number" ? usage : usage.rss,
34
37
  detail: typeof usage === "number" ? undefined : usage,
35
38
  });
36
39
  }
@@ -47,3 +50,16 @@ function logDebugResults(context) {
47
50
  context.logger.metric(context.debug.results);
48
51
  }
49
52
  }
53
+ function memoryUsageInMB() {
54
+ const usage = (0, node_process_1.memoryUsage)();
55
+ return Object.keys(usage).reduce((accum, key) => {
56
+ accum[key] = usage[key] / MEMORY_USAGE_CONVERSION;
57
+ return accum;
58
+ }, {
59
+ rss: -1,
60
+ heapTotal: -1,
61
+ heapUsed: -1,
62
+ external: -1,
63
+ arrayBuffers: -1,
64
+ });
65
+ }
@@ -341,7 +341,7 @@ const convertInputValue = (value, collectionType) => {
341
341
  /** Converts a Config Var into the structure necessary for YAML generation. */
342
342
  const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
343
343
  var _a, _b, _c;
344
- if ((0, types_1.isOrganizationActivatedConnectionConfigVar)(configVar)) {
344
+ if ((0, types_1.isConnectionScopedConfigVar)(configVar)) {
345
345
  const { stableKey } = (0, pick_1.default)(configVar, ["stableKey"]);
346
346
  return {
347
347
  key,
@@ -49,15 +49,16 @@ interface DebugResult {
49
49
  memoryUsage: Array<{
50
50
  mark: string;
51
51
  rss: number;
52
- detail?: {
53
- rss: number;
54
- heapTotal: number;
55
- heapUsed: number;
56
- external: number;
57
- arrayBuffers: number;
58
- };
52
+ detail?: MemoryUsage;
59
53
  }>;
60
54
  }
55
+ export interface MemoryUsage {
56
+ rss: number;
57
+ heapTotal: number;
58
+ heapUsed: number;
59
+ external: number;
60
+ arrayBuffers: number;
61
+ }
61
62
  export type ExecutionFrame = ({
62
63
  invokedByExecutionJWT: string;
63
64
  invokedByExecutionStartedAt: string;
@@ -1,10 +1,14 @@
1
1
  import { type ConfigVar } from ".";
2
2
  import type { UnionToIntersection } from "./utils";
3
+ export type CustomerActivatedConnectionConfigVar = {
4
+ dataType: "connection";
5
+ stableKey: string;
6
+ };
3
7
  export type OrganizationActivatedConnectionConfigVar = {
4
8
  dataType: "connection";
5
9
  stableKey: string;
6
10
  };
7
- export type ScopedConfigVar = OrganizationActivatedConnectionConfigVar;
11
+ export type ScopedConfigVar = CustomerActivatedConnectionConfigVar | OrganizationActivatedConnectionConfigVar;
8
12
  /**
9
13
  * Root ScopedConfigVars type exposed for augmentation.
10
14
  *
@@ -25,5 +29,5 @@ type CreateScopedConfigVars<TScopedConfigVarMap> = keyof TScopedConfigVarMap ext
25
29
  [Key in TScopedConfigVarName]: TScopedConfigVarMap[TScopedConfigVarName];
26
30
  } : never : never : never>;
27
31
  export type ScopedConfigVarMap = CreateScopedConfigVars<IntegrationDefinitionScopedConfigVars>;
28
- export declare const isOrganizationActivatedConnectionConfigVar: (cv: ConfigVar) => cv is OrganizationActivatedConnectionConfigVar;
32
+ export declare const isConnectionScopedConfigVar: (cv: ConfigVar) => cv is OrganizationActivatedConnectionConfigVar;
29
33
  export {};
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isOrganizationActivatedConnectionConfigVar = void 0;
3
+ exports.isConnectionScopedConfigVar = void 0;
4
4
  const _1 = require(".");
5
- const isOrganizationActivatedConnectionConfigVar = (cv) => "dataType" in cv &&
5
+ const isConnectionScopedConfigVar = (cv) => "dataType" in cv &&
6
6
  cv.dataType === "connection" &&
7
7
  !(0, _1.isConnectionDefinitionConfigVar)(cv) &&
8
8
  !(0, _1.isConnectionReferenceConfigVar)(cv);
9
- exports.isOrganizationActivatedConnectionConfigVar = isOrganizationActivatedConnectionConfigVar;
9
+ exports.isConnectionScopedConfigVar = isConnectionScopedConfigVar;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "10.3.12",
3
+ "version": "10.4.0",
4
4
  "description": "Utility library for building Prismatic connectors and code-native integrations",
5
5
  "keywords": ["prismatic"],
6
6
  "main": "dist/index.js",