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.
- package/dist/dts/errors/integration-error.d.ts +11 -11
- package/dist/dts/errors/integration-error.d.ts.map +1 -1
- package/dist/dts/errors/parse-error-to-readable-json.d.ts +2 -2
- package/dist/dts/errors/parse-error-to-readable-json.d.ts.map +1 -1
- package/dist/dts/index.d.ts +4 -3
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/index.docs.d.ts +5 -1
- package/dist/dts/index.docs.d.ts.map +1 -1
- package/dist/dts/lib/errors/integration-error.d.ts +11 -11
- package/dist/dts/lib/errors/integration-error.d.ts.map +1 -1
- package/dist/dts/lib/errors/parse-error-to-readable-json.d.ts +2 -2
- package/dist/dts/lib/errors/parse-error-to-readable-json.d.ts.map +1 -1
- package/dist/dts/lib/index.d.ts +4 -3
- package/dist/dts/lib/index.d.ts.map +1 -1
- package/dist/dts/lib/index.docs.d.ts +5 -1
- package/dist/dts/lib/index.docs.d.ts.map +1 -1
- package/dist/dts/lib/logging/logger.d.ts +3 -14
- package/dist/dts/lib/logging/logger.d.ts.map +1 -1
- package/dist/dts/lib/requests/polarity-request.d.ts +93 -68
- package/dist/dts/lib/requests/polarity-request.d.ts.map +1 -1
- package/dist/dts/lib/testing/enhanced-utils/create-entity.d.ts +17 -1
- package/dist/dts/lib/testing/enhanced-utils/create-entity.d.ts.map +1 -1
- package/dist/dts/lib/testing/enhanced-utils/create-mock-integration-context.d.ts +42 -2
- package/dist/dts/lib/testing/enhanced-utils/create-mock-integration-context.d.ts.map +1 -1
- package/dist/dts/lib/testing/index.d.ts +0 -3
- package/dist/dts/lib/testing/index.d.ts.map +1 -1
- package/dist/dts/lib/types.d.ts +88 -84
- package/dist/dts/lib/types.d.ts.map +1 -1
- package/dist/dts/logging/logger.d.ts +3 -14
- package/dist/dts/logging/logger.d.ts.map +1 -1
- package/dist/dts/requests/polarity-request.d.ts +93 -68
- package/dist/dts/requests/polarity-request.d.ts.map +1 -1
- package/dist/dts/testing/enhanced-utils/create-entity.d.ts +17 -1
- package/dist/dts/testing/enhanced-utils/create-entity.d.ts.map +1 -1
- package/dist/dts/testing/enhanced-utils/create-mock-integration-context.d.ts +42 -2
- package/dist/dts/testing/enhanced-utils/create-mock-integration-context.d.ts.map +1 -1
- package/dist/dts/testing/index.d.ts +0 -3
- package/dist/dts/testing/index.d.ts.map +1 -1
- package/dist/dts/tsdoc-metadata.json +1 -1
- package/dist/dts/types.d.ts +88 -84
- package/dist/dts/types.d.ts.map +1 -1
- package/dist/es/lib/errors/integration-error.js +7 -4
- package/dist/es/lib/index.docs.js +5 -1
- package/dist/es/lib/index.js +4 -5
- package/dist/es/lib/logging/logger.js +20 -9
- package/dist/es/lib/requests/polarity-request.js +103 -126
- package/dist/es/lib/testing/enhanced-utils/create-entity.js +31 -5
- package/dist/es/lib/testing/enhanced-utils/create-mock-integration-context.js +54 -27
- package/dist/es/lib/testing/index.js +0 -3
- package/dist/es/lib/types.js +1 -3
- package/dist/lib/errors/integration-error.js +7 -4
- package/dist/lib/index.docs.js +5 -1
- package/dist/lib/index.js +4 -5
- package/dist/lib/logging/logger.js +20 -9
- package/dist/lib/requests/polarity-request.js +103 -126
- package/dist/lib/testing/enhanced-utils/create-entity.js +31 -5
- package/dist/lib/testing/enhanced-utils/create-mock-integration-context.js +54 -27
- package/dist/lib/testing/index.js +0 -3
- package/dist/lib/types.js +1 -3
- package/dist/polarity-integration-utils.d.ts +266 -596
- package/package.json +6 -9
- package/dist/dts/context/cache.d.ts +0 -149
- package/dist/dts/context/cache.d.ts.map +0 -1
- package/dist/dts/context/index.d.ts +0 -3
- package/dist/dts/context/index.d.ts.map +0 -1
- package/dist/dts/context/integration-context.d.ts +0 -16
- package/dist/dts/context/integration-context.d.ts.map +0 -1
- package/dist/dts/lib/context/cache.d.ts +0 -149
- package/dist/dts/lib/context/cache.d.ts.map +0 -1
- package/dist/dts/lib/context/index.d.ts +0 -3
- package/dist/dts/lib/context/index.d.ts.map +0 -1
- package/dist/dts/lib/context/integration-context.d.ts +0 -16
- package/dist/dts/lib/context/integration-context.d.ts.map +0 -1
- package/dist/dts/lib/testing/enhanced-utils/mock-request.d.ts +0 -14
- package/dist/dts/lib/testing/enhanced-utils/mock-request.d.ts.map +0 -1
- package/dist/dts/lib/testing/enhanced-utils/validate-integration.d.ts +0 -8
- package/dist/dts/lib/testing/enhanced-utils/validate-integration.d.ts.map +0 -1
- package/dist/dts/lib/testing/test-factory/create-integration-tests.d.ts +0 -6
- package/dist/dts/lib/testing/test-factory/create-integration-tests.d.ts.map +0 -1
- package/dist/dts/lib/testing/test-factory/test-do-lookup.d.ts +0 -7
- package/dist/dts/lib/testing/test-factory/test-do-lookup.d.ts.map +0 -1
- package/dist/dts/lib/testing/test-factory/test-on-message.d.ts +0 -8
- package/dist/dts/lib/testing/test-factory/test-on-message.d.ts.map +0 -1
- package/dist/dts/lib/zod-types.d.ts +0 -278
- package/dist/dts/lib/zod-types.d.ts.map +0 -1
- package/dist/dts/testing/enhanced-utils/mock-request.d.ts +0 -14
- package/dist/dts/testing/enhanced-utils/mock-request.d.ts.map +0 -1
- package/dist/dts/testing/enhanced-utils/validate-integration.d.ts +0 -8
- package/dist/dts/testing/enhanced-utils/validate-integration.d.ts.map +0 -1
- package/dist/dts/testing/test-factory/create-integration-tests.d.ts +0 -6
- package/dist/dts/testing/test-factory/create-integration-tests.d.ts.map +0 -1
- package/dist/dts/testing/test-factory/test-do-lookup.d.ts +0 -7
- package/dist/dts/testing/test-factory/test-do-lookup.d.ts.map +0 -1
- package/dist/dts/testing/test-factory/test-on-message.d.ts +0 -8
- package/dist/dts/testing/test-factory/test-on-message.d.ts.map +0 -1
- package/dist/dts/zod-types.d.ts +0 -278
- package/dist/dts/zod-types.d.ts.map +0 -1
- package/dist/es/lib/context/cache.js +0 -2
- package/dist/es/lib/context/index.js +0 -18
- package/dist/es/lib/context/integration-context.js +0 -2
- package/dist/es/lib/testing/enhanced-utils/mock-request.js +0 -22
- package/dist/es/lib/testing/enhanced-utils/validate-integration.js +0 -159
- package/dist/es/lib/testing/test-factory/create-integration-tests.js +0 -53
- package/dist/es/lib/testing/test-factory/test-do-lookup.js +0 -24
- package/dist/es/lib/testing/test-factory/test-on-message.js +0 -24
- package/dist/es/lib/zod-types.js +0 -206
- package/dist/lib/context/cache.js +0 -2
- package/dist/lib/context/index.js +0 -18
- package/dist/lib/context/integration-context.js +0 -2
- package/dist/lib/testing/enhanced-utils/mock-request.js +0 -22
- package/dist/lib/testing/enhanced-utils/validate-integration.js +0 -159
- package/dist/lib/testing/test-factory/create-integration-tests.js +0 -53
- package/dist/lib/testing/test-factory/test-do-lookup.js +0 -24
- package/dist/lib/testing/test-factory/test-on-message.js +0 -24
- package/dist/lib/zod-types.js +0 -206
|
@@ -1,3 +1,43 @@
|
|
|
1
|
-
import { IntegrationContext } from '
|
|
2
|
-
|
|
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,
|
|
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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kDAAkD,CAAC"}
|
package/dist/dts/types.d.ts
CHANGED
|
@@ -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
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
package/dist/dts/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,uBAAuB,E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AgB,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 (
|
|
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 =
|
|
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("./
|
|
29
|
+
__exportStar(require("./testing"), exports);
|
package/dist/es/lib/index.js
CHANGED
|
@@ -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.
|
|
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
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
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
|
|
54
|
+
* const { getLogger } = require('polarity-integration-utils');
|
|
44
55
|
*
|
|
45
56
|
* const logger = getLogger();
|
|
46
57
|
* logger.trace('this is a trace message');
|