polarity-integration-utils 3.1.8 → 4.1.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.
Files changed (115) hide show
  1. package/dist/dts/errors/integration-error.d.ts +11 -11
  2. package/dist/dts/errors/integration-error.d.ts.map +1 -1
  3. package/dist/dts/errors/parse-error-to-readable-json.d.ts +2 -2
  4. package/dist/dts/errors/parse-error-to-readable-json.d.ts.map +1 -1
  5. package/dist/dts/index.d.ts +4 -3
  6. package/dist/dts/index.d.ts.map +1 -1
  7. package/dist/dts/index.docs.d.ts +5 -1
  8. package/dist/dts/index.docs.d.ts.map +1 -1
  9. package/dist/dts/lib/errors/integration-error.d.ts +11 -11
  10. package/dist/dts/lib/errors/integration-error.d.ts.map +1 -1
  11. package/dist/dts/lib/errors/parse-error-to-readable-json.d.ts +2 -2
  12. package/dist/dts/lib/errors/parse-error-to-readable-json.d.ts.map +1 -1
  13. package/dist/dts/lib/index.d.ts +4 -3
  14. package/dist/dts/lib/index.d.ts.map +1 -1
  15. package/dist/dts/lib/index.docs.d.ts +5 -1
  16. package/dist/dts/lib/index.docs.d.ts.map +1 -1
  17. package/dist/dts/lib/logging/logger.d.ts +3 -14
  18. package/dist/dts/lib/logging/logger.d.ts.map +1 -1
  19. package/dist/dts/lib/requests/polarity-request.d.ts +93 -68
  20. package/dist/dts/lib/requests/polarity-request.d.ts.map +1 -1
  21. package/dist/dts/lib/testing/enhanced-utils/create-entity.d.ts +17 -1
  22. package/dist/dts/lib/testing/enhanced-utils/create-entity.d.ts.map +1 -1
  23. package/dist/dts/lib/testing/enhanced-utils/create-mock-integration-context.d.ts +42 -2
  24. package/dist/dts/lib/testing/enhanced-utils/create-mock-integration-context.d.ts.map +1 -1
  25. package/dist/dts/lib/testing/index.d.ts +0 -3
  26. package/dist/dts/lib/testing/index.d.ts.map +1 -1
  27. package/dist/dts/lib/types.d.ts +88 -84
  28. package/dist/dts/lib/types.d.ts.map +1 -1
  29. package/dist/dts/logging/logger.d.ts +3 -14
  30. package/dist/dts/logging/logger.d.ts.map +1 -1
  31. package/dist/dts/requests/polarity-request.d.ts +93 -68
  32. package/dist/dts/requests/polarity-request.d.ts.map +1 -1
  33. package/dist/dts/testing/enhanced-utils/create-entity.d.ts +17 -1
  34. package/dist/dts/testing/enhanced-utils/create-entity.d.ts.map +1 -1
  35. package/dist/dts/testing/enhanced-utils/create-mock-integration-context.d.ts +42 -2
  36. package/dist/dts/testing/enhanced-utils/create-mock-integration-context.d.ts.map +1 -1
  37. package/dist/dts/testing/index.d.ts +0 -3
  38. package/dist/dts/testing/index.d.ts.map +1 -1
  39. package/dist/dts/tsdoc-metadata.json +1 -1
  40. package/dist/dts/types.d.ts +88 -84
  41. package/dist/dts/types.d.ts.map +1 -1
  42. package/dist/es/lib/errors/integration-error.js +7 -4
  43. package/dist/es/lib/index.docs.js +5 -1
  44. package/dist/es/lib/index.js +4 -5
  45. package/dist/es/lib/logging/logger.js +20 -9
  46. package/dist/es/lib/requests/polarity-request.js +103 -126
  47. package/dist/es/lib/testing/enhanced-utils/create-entity.js +31 -5
  48. package/dist/es/lib/testing/enhanced-utils/create-mock-integration-context.js +54 -27
  49. package/dist/es/lib/testing/index.js +0 -3
  50. package/dist/es/lib/types.js +1 -3
  51. package/dist/lib/errors/integration-error.js +7 -4
  52. package/dist/lib/index.docs.js +5 -1
  53. package/dist/lib/index.js +4 -5
  54. package/dist/lib/logging/logger.js +20 -9
  55. package/dist/lib/requests/polarity-request.js +103 -126
  56. package/dist/lib/testing/enhanced-utils/create-entity.js +31 -5
  57. package/dist/lib/testing/enhanced-utils/create-mock-integration-context.js +54 -27
  58. package/dist/lib/testing/index.js +0 -3
  59. package/dist/lib/types.js +1 -3
  60. package/dist/polarity-integration-utils.d.ts +266 -596
  61. package/package.json +6 -9
  62. package/dist/dts/context/cache.d.ts +0 -149
  63. package/dist/dts/context/cache.d.ts.map +0 -1
  64. package/dist/dts/context/index.d.ts +0 -3
  65. package/dist/dts/context/index.d.ts.map +0 -1
  66. package/dist/dts/context/integration-context.d.ts +0 -16
  67. package/dist/dts/context/integration-context.d.ts.map +0 -1
  68. package/dist/dts/lib/context/cache.d.ts +0 -149
  69. package/dist/dts/lib/context/cache.d.ts.map +0 -1
  70. package/dist/dts/lib/context/index.d.ts +0 -3
  71. package/dist/dts/lib/context/index.d.ts.map +0 -1
  72. package/dist/dts/lib/context/integration-context.d.ts +0 -16
  73. package/dist/dts/lib/context/integration-context.d.ts.map +0 -1
  74. package/dist/dts/lib/testing/enhanced-utils/mock-request.d.ts +0 -14
  75. package/dist/dts/lib/testing/enhanced-utils/mock-request.d.ts.map +0 -1
  76. package/dist/dts/lib/testing/enhanced-utils/validate-integration.d.ts +0 -8
  77. package/dist/dts/lib/testing/enhanced-utils/validate-integration.d.ts.map +0 -1
  78. package/dist/dts/lib/testing/test-factory/create-integration-tests.d.ts +0 -6
  79. package/dist/dts/lib/testing/test-factory/create-integration-tests.d.ts.map +0 -1
  80. package/dist/dts/lib/testing/test-factory/test-do-lookup.d.ts +0 -7
  81. package/dist/dts/lib/testing/test-factory/test-do-lookup.d.ts.map +0 -1
  82. package/dist/dts/lib/testing/test-factory/test-on-message.d.ts +0 -8
  83. package/dist/dts/lib/testing/test-factory/test-on-message.d.ts.map +0 -1
  84. package/dist/dts/lib/zod-types.d.ts +0 -278
  85. package/dist/dts/lib/zod-types.d.ts.map +0 -1
  86. package/dist/dts/testing/enhanced-utils/mock-request.d.ts +0 -14
  87. package/dist/dts/testing/enhanced-utils/mock-request.d.ts.map +0 -1
  88. package/dist/dts/testing/enhanced-utils/validate-integration.d.ts +0 -8
  89. package/dist/dts/testing/enhanced-utils/validate-integration.d.ts.map +0 -1
  90. package/dist/dts/testing/test-factory/create-integration-tests.d.ts +0 -6
  91. package/dist/dts/testing/test-factory/create-integration-tests.d.ts.map +0 -1
  92. package/dist/dts/testing/test-factory/test-do-lookup.d.ts +0 -7
  93. package/dist/dts/testing/test-factory/test-do-lookup.d.ts.map +0 -1
  94. package/dist/dts/testing/test-factory/test-on-message.d.ts +0 -8
  95. package/dist/dts/testing/test-factory/test-on-message.d.ts.map +0 -1
  96. package/dist/dts/zod-types.d.ts +0 -278
  97. package/dist/dts/zod-types.d.ts.map +0 -1
  98. package/dist/es/lib/context/cache.js +0 -2
  99. package/dist/es/lib/context/index.js +0 -18
  100. package/dist/es/lib/context/integration-context.js +0 -2
  101. package/dist/es/lib/testing/enhanced-utils/mock-request.js +0 -22
  102. package/dist/es/lib/testing/enhanced-utils/validate-integration.js +0 -159
  103. package/dist/es/lib/testing/test-factory/create-integration-tests.js +0 -53
  104. package/dist/es/lib/testing/test-factory/test-do-lookup.js +0 -24
  105. package/dist/es/lib/testing/test-factory/test-on-message.js +0 -24
  106. package/dist/es/lib/zod-types.js +0 -206
  107. package/dist/lib/context/cache.js +0 -2
  108. package/dist/lib/context/index.js +0 -18
  109. package/dist/lib/context/integration-context.js +0 -2
  110. package/dist/lib/testing/enhanced-utils/mock-request.js +0 -22
  111. package/dist/lib/testing/enhanced-utils/validate-integration.js +0 -159
  112. package/dist/lib/testing/test-factory/create-integration-tests.js +0 -53
  113. package/dist/lib/testing/test-factory/test-do-lookup.js +0 -24
  114. package/dist/lib/testing/test-factory/test-on-message.js +0 -24
  115. package/dist/lib/zod-types.js +0 -206
@@ -1,3 +1,43 @@
1
- import { IntegrationContext } from '../../context';
2
- export declare const createMockIntegrationContext: () => IntegrationContext;
1
+ import type { IntegrationContext } from '@polarityio/integration-types';
2
+ /**
3
+ * Factory function that creates mock functions. Pass `vi.fn` (Vitest)
4
+ * or `jest.fn` (Jest) to get spy capabilities. When omitted, plain
5
+ * no-op functions are used.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * // Vitest — enables toHaveBeenCalledWith() assertions
10
+ * const ctx = createMockIntegrationContext(vi.fn);
11
+ *
12
+ * // Jest
13
+ * const ctx = createMockIntegrationContext(jest.fn);
14
+ *
15
+ * // No framework — plain no-ops
16
+ * const ctx = createMockIntegrationContext();
17
+ * ```
18
+ */
19
+ export type MockFnFactory = () => (...args: any[]) => any;
20
+ /**
21
+ * Creates a mock `IntegrationContext`
22
+ * with stubbed logger, cache, and polling methods.
23
+ *
24
+ * Pass your testing framework's mock function factory to enable spy capabilities
25
+ * (e.g., `toHaveBeenCalledWith()`). When omitted, plain no-op stubs are used.
26
+ *
27
+ * @param createMockFn - A factory that creates mock functions (e.g., `vi.fn` or `jest.fn`)
28
+ * @returns A fully populated `IntegrationContext` with stubbed methods
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * // Vitest
33
+ * const ctx = createMockIntegrationContext(vi.fn);
34
+ *
35
+ * // Jest
36
+ * const ctx = createMockIntegrationContext(jest.fn);
37
+ *
38
+ * // No framework — plain no-ops
39
+ * const ctx = createMockIntegrationContext();
40
+ * ```
41
+ */
42
+ export declare const createMockIntegrationContext: (createMockFn?: MockFnFactory) => IntegrationContext;
3
43
  //# sourceMappingURL=create-mock-integration-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-mock-integration-context.d.ts","sourceRoot":"","sources":["../../../../lib/testing/enhanced-utils/create-mock-integration-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,eAAO,MAAM,4BAA4B,QAAO,kBAgC/C,CAAC"}
1
+ {"version":3,"file":"create-mock-integration-context.d.ts","sourceRoot":"","sources":["../../../../lib/testing/enhanced-utils/create-mock-integration-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAI1D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,4BAA4B,GACvC,eAAc,aAAoB,KACjC,kBAqCF,CAAC"}
@@ -1,6 +1,3 @@
1
- export * from './test-factory/create-integration-tests';
2
1
  export * from './enhanced-utils/create-entity';
3
2
  export * from './enhanced-utils/create-mock-integration-context';
4
- export * from './enhanced-utils/mock-request';
5
- export * from './enhanced-utils/validate-integration';
6
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,yCAAyC,CAAC;AACxD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kDAAkD,CAAC;AACjE,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uCAAuC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kDAAkD,CAAC"}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.58.2"
8
+ "packageVersion": "7.58.7"
9
9
  }
10
10
  ]
11
11
  }
@@ -1,101 +1,105 @@
1
- import { z } from 'zod';
2
- import { Logger as PolarityLogger } from './logging';
3
- import { ValidationErrorSchema, DoLookupUserOptionsSchema, ValidateOptionsUserOptionsSchema, ValidateOptionsUserOptionSchema, PossibleUserOptionValueSchema, DropdownUserOptionValueSchema, EntitySchema, EntityTypeSchema, StandardEntityTypeSchema, ChannelSchema, ResultSchema, IntegrationConfigSchema } from './zod-types';
4
1
  /**
2
+ * Integration config.json type
5
3
  * @public
6
4
  */
7
- export type ValidationError = z.infer<typeof ValidationErrorSchema>;
8
- /**
9
- * User options object passed into the integration's `doLookup` method.
10
- *
11
- * @example
12
- * Example of the user options object passed into `doLookup`
13
- * ```js
14
- * function doLookup(entities, options, cb){
15
- * // options here is of type DoLookupUserOptions
16
- * }
17
- * ```
18
- *
19
- * @example
20
- * As an example, if your integration has a user option with a `key` value of
21
- * `apiKey` within its `config.json`, the user options object passed into the `doLookup` method would look like:
22
- * ```json
23
- * {
24
- * "apiKey": "XXXXXXXXXX"
25
- * }
26
- * ```
27
- * @public
28
- */
29
- export type DoLookupUserOptions = z.infer<typeof DoLookupUserOptionsSchema>;
30
- /**
31
- * @public
32
- */
33
- export type ValidateOptionsUserOptions = z.infer<typeof ValidateOptionsUserOptionsSchema>;
34
- /**
35
- * @public
36
- */
37
- export type ValidateOptionsUserOption = z.infer<typeof ValidateOptionsUserOptionSchema>;
38
- /**
39
- * @public
40
- */
41
- export type PossibleUserOptionValue = z.infer<typeof PossibleUserOptionValueSchema>;
42
- /**
43
- * @public
44
- */
45
- export type DropdownUserOptionValue = z.infer<typeof DropdownUserOptionValueSchema>;
46
- /**
47
- * Represents a Polarity Entity object which is passed to an integration's
48
- * doLookup method.
49
- *
50
- * @public
51
- */
52
- export type Entity = z.infer<typeof EntitySchema>;
53
- /**
54
- * @public
55
- */
56
- export type Channel = z.infer<typeof ChannelSchema>;
57
- /**
58
- * Entity Types including custom types
59
- * @public
60
- */
61
- export type EntityType = z.infer<typeof EntityTypeSchema>;
62
- /**
63
- * List of supported entity type values
64
- * @public
65
- */
66
- export type StandardEntityType = z.infer<typeof StandardEntityTypeSchema>;
67
- /**
68
- * @public
69
- */
70
- export type Result<TDetails = unknown> = Omit<z.infer<typeof ResultSchema>, 'data'> & {
71
- data: {
72
- summary: string[];
73
- details: TDetails;
5
+ export interface IntegrationConfig {
6
+ polarityIntegrationUuid: string;
7
+ name: string;
8
+ acronym: string;
9
+ description?: string;
10
+ defaultColor?: string;
11
+ entityTypes?: string[];
12
+ dataTypes?: (string | CustomType)[];
13
+ customTypes?: CustomType[];
14
+ supportsAdditionalCustomTypes?: boolean;
15
+ styles?: string[];
16
+ block: ViewComponent;
17
+ summary?: ViewComponent;
18
+ onDemandOnly?: boolean;
19
+ copyOnDemand?: boolean;
20
+ logging?: {
21
+ level: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
74
22
  };
75
- };
23
+ request?: {
24
+ cert?: string;
25
+ key?: string;
26
+ passphrase?: string;
27
+ ca?: string;
28
+ proxy?: string;
29
+ rejectUnauthorized?: boolean;
30
+ };
31
+ options?: IntegrationOption[];
32
+ }
76
33
  /**
34
+ * Custom entity type definition for config.json
77
35
  * @public
78
36
  */
79
- export type DoLookupResult<TDetails = unknown> = Result<TDetails>[];
37
+ export interface CustomType {
38
+ type?: 'custom';
39
+ name?: string;
40
+ description?: string;
41
+ key: string;
42
+ regex: string;
43
+ editable?: boolean;
44
+ enabled?: boolean;
45
+ }
80
46
  /**
47
+ * View component reference in config.json
81
48
  * @public
82
49
  */
83
- export type IntegrationConfig = z.infer<typeof IntegrationConfigSchema>;
50
+ export interface ViewComponent {
51
+ component: {
52
+ file: string;
53
+ };
54
+ template: {
55
+ file: string;
56
+ };
57
+ }
84
58
  /**
59
+ * A select option item with display label and value
85
60
  * @public
86
61
  */
87
- export { PolarityLogger };
62
+ export interface SelectOptionItem {
63
+ value: string;
64
+ display: string;
65
+ }
88
66
  /**
67
+ * Integration option definition for config.json
89
68
  * @public
90
69
  */
91
- import { IntegrationContext } from './context';
92
- import { IntegrationError } from './errors';
93
- export { IntegrationContext, IntegrationError };
94
- export interface Integration<TStartupResult = unknown, TDetails = unknown> {
95
- startup: (logger: PolarityLogger) => Promise<TStartupResult>;
96
- doLookup: (entities: Entity[], options: DoLookupUserOptions, context: IntegrationContext) => Promise<DoLookupResult<TDetails> | IntegrationError | null | void>;
97
- onMessage?: (payload: unknown, options: DoLookupUserOptions, context: IntegrationContext) => Promise<unknown>;
98
- onDetails?: (lookupObject: Result<TDetails>, options: DoLookupUserOptions, context: IntegrationContext) => Promise<unknown>;
99
- validateOptions: (options: ValidateOptionsUserOptions, context: IntegrationContext) => IntegrationError[];
100
- }
70
+ export type IntegrationOption = {
71
+ type: 'text' | 'password';
72
+ key: string;
73
+ name: string;
74
+ description?: string;
75
+ default: string | null;
76
+ userCanEdit?: boolean;
77
+ adminOnly?: boolean;
78
+ } | {
79
+ type: 'boolean';
80
+ key: string;
81
+ name: string;
82
+ description?: string;
83
+ default: boolean | null;
84
+ userCanEdit?: boolean;
85
+ adminOnly?: boolean;
86
+ } | {
87
+ type: 'number';
88
+ key: string;
89
+ name: string;
90
+ description?: string;
91
+ default: number | null;
92
+ userCanEdit?: boolean;
93
+ adminOnly?: boolean;
94
+ } | {
95
+ type: 'select';
96
+ key: string;
97
+ name: string;
98
+ description?: string;
99
+ default: SelectOptionItem | SelectOptionItem[] | string | null;
100
+ options: SelectOptionItem[];
101
+ multiple?: boolean;
102
+ userCanEdit: boolean;
103
+ adminOnly: boolean;
104
+ };
101
105
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,gCAAgC,EAChC,+BAA+B,EAC/B,6BAA6B,EAC7B,6BAA6B,EAC7B,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,YAAY,EACZ,uBAAuB,EACxB,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAE1F;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF;;GAEG;AACH,MAAM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,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC;IAC/D,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC"}
@@ -31,7 +31,7 @@ class IntegrationError extends Error {
31
31
  code;
32
32
  /**
33
33
  * The `cause` property is used to specify the `cause` of the error. Typically,
34
- * this property is used to pass through a related Error instance.
34
+ * this property is used to pass through a related Error instance but can be any value.
35
35
  */
36
36
  cause;
37
37
  /**
@@ -63,7 +63,7 @@ class IntegrationError extends Error {
63
63
  if (typeof properties.status !== 'undefined') {
64
64
  this.status = properties.status;
65
65
  }
66
- if (properties.cause && properties.cause instanceof Error) {
66
+ if (typeof properties.cause !== 'undefined') {
67
67
  this.cause = properties.cause;
68
68
  }
69
69
  if (typeof properties.requestOptions !== 'undefined') {
@@ -101,8 +101,11 @@ class IntegrationError extends Error {
101
101
  if (this.help) {
102
102
  props.help = this.help;
103
103
  }
104
- if (this.cause) {
105
- props.cause = (0, parse_error_to_readable_json_1.parseErrorToReadableJson)(this.cause);
104
+ if (this.cause !== undefined) {
105
+ props.cause =
106
+ this.cause instanceof Error
107
+ ? (0, parse_error_to_readable_json_1.parseErrorToReadableJson)(this.cause)
108
+ : this.cause;
106
109
  }
107
110
  if (this.requestOptions) {
108
111
  props.requestOptions = this.requestOptions;
@@ -17,9 +17,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  /**
18
18
  * API Docs index. This is used by api-extractor given our package.json exports.
19
19
  * Monitoring: https://github.com/microsoft/rushstack/issues/3557
20
+ *
21
+ * Note: This includes ./testing which is intentionally excluded from the runtime
22
+ * index.ts. Testing helpers are available via the ./testing sub-path import
23
+ * (e.g., import \{ createEntity \} from 'polarity-integration-utils/testing').
20
24
  */
21
25
  __exportStar(require("./errors"), exports);
22
26
  __exportStar(require("./requests"), exports);
23
27
  __exportStar(require("./logging"), exports);
24
28
  __exportStar(require("./types"), exports);
25
- __exportStar(require("./context"), exports);
29
+ __exportStar(require("./testing"), exports);
@@ -36,15 +36,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.types = exports.context = exports.logging = exports.requests = exports.errors = void 0;
39
+ exports.logging = exports.requests = exports.errors = void 0;
40
40
  const errors = __importStar(require("./errors"));
41
41
  exports.errors = errors;
42
42
  const requests = __importStar(require("./requests"));
43
43
  exports.requests = requests;
44
44
  const logging = __importStar(require("./logging"));
45
45
  exports.logging = logging;
46
- const context = __importStar(require("./context"));
47
- exports.context = context;
48
- const types = __importStar(require("./types"));
49
- exports.types = types;
50
46
  __exportStar(require("./types"), exports);
47
+ __exportStar(require("./errors"), exports);
48
+ __exportStar(require("./requests"), exports);
49
+ __exportStar(require("./logging"), exports);
@@ -5,20 +5,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getLogger = exports.setLogger = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
- const loggingLevels = ['info', 'debug', 'trace', 'warn', 'error', 'fatal'];
9
- const writeToDevRunnerResults = (loggingLevel) => (...content) => fs_1.default.appendFileSync('devRunnerResults.json', '\n' + JSON.stringify({ SOURCE: `Logger.${loggingLevel}`, content }, null, 2));
10
- const defaultLogger = loggingLevels.reduce((agg, level) => ({
11
- ...agg,
12
- [level]: writeToDevRunnerResults(level)
13
- }), {});
14
- let _logger = defaultLogger;
8
+ const createLogMethod = (loggingLevel) => (...content) => {
9
+ if (content.length === 0)
10
+ return true;
11
+ fs_1.default.appendFileSync('devRunnerResults.json', '\n' + JSON.stringify({ SOURCE: `Logger.${loggingLevel}`, content }, null, 2));
12
+ };
13
+ function createDefaultLogger() {
14
+ const logger = {
15
+ child: () => logger,
16
+ trace: createLogMethod('trace'),
17
+ debug: createLogMethod('debug'),
18
+ info: createLogMethod('info'),
19
+ warn: createLogMethod('warn'),
20
+ error: createLogMethod('error'),
21
+ fatal: createLogMethod('fatal')
22
+ };
23
+ return logger;
24
+ }
25
+ let _logger = createDefaultLogger();
15
26
  /**
16
27
  * Set the logger object used by the integration.
17
28
  *
18
29
  * @example
19
30
  * Example of setting the logger within the integration's startup method:
20
31
  * ```js
21
- * const { setLogger } = require('polarity-integration-utils/logger');
32
+ * const { setLogger } = require('polarity-integration-utils');
22
33
  *
23
34
  * function startup(logger){
24
35
  * setLogger(logger);
@@ -40,7 +51,7 @@ exports.setLogger = setLogger;
40
51
  * @example
41
52
  * Example of using the integration's logging object:
42
53
  * ```js
43
- * const { getLogger } = require('polarity-integration-utils/logger');
54
+ * const { getLogger } = require('polarity-integration-utils');
44
55
  *
45
56
  * const logger = getLogger();
46
57
  * logger.trace('this is a trace message');