@sailpoint/connector-sdk 1.2.0 → 1.2.1
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/lib/data-store.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Response } from './response';
|
|
2
2
|
import { Context } from './connector-handler';
|
|
3
3
|
/**
|
|
4
|
-
* A persistent key-value data store backed by
|
|
4
|
+
* A persistent key-value data store backed by source config attributes.
|
|
5
5
|
*
|
|
6
6
|
* Provides a simple API to read and write values that persist across connector invocations.
|
|
7
7
|
* Under the hood, changes are sent via `patchConfig` as JSON Patch operations targeting
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* `/<key>` directly. Only changed values are patched — if a value is set to the same thing
|
|
9
|
+
* it was before, no patch is emitted.
|
|
10
10
|
*
|
|
11
11
|
* During long aggregations, call `reload(context)` to pick up config changes that occurred
|
|
12
12
|
* mid-run (including values written by a previous `flush()` call in the same invocation).
|
|
@@ -40,20 +40,20 @@ export declare class ConnectorDataStore {
|
|
|
40
40
|
private readonly pending;
|
|
41
41
|
constructor(config: Record<string, any>, res: Response<any>);
|
|
42
42
|
/**
|
|
43
|
-
* Get a value from
|
|
43
|
+
* Get a value from the config.
|
|
44
44
|
* Returns the pending value if one has been set, otherwise the original config value.
|
|
45
45
|
* @param key Attribute key
|
|
46
46
|
*/
|
|
47
47
|
get<T = any>(key: string): T | undefined;
|
|
48
48
|
/**
|
|
49
|
-
* Set a value in
|
|
49
|
+
* Set a value in the config. The change is buffered until `flush()` is called.
|
|
50
50
|
* If the value is identical to the current stored value, no patch will be emitted.
|
|
51
51
|
* @param key Attribute key
|
|
52
52
|
* @param value Value to store (must be JSON-serializable)
|
|
53
53
|
*/
|
|
54
54
|
set(key: string, value: any): void;
|
|
55
55
|
/**
|
|
56
|
-
* Remove a key from
|
|
56
|
+
* Remove a key from the config. The change is buffered until `flush()` is called.
|
|
57
57
|
* If the key doesn't exist, no patch will be emitted.
|
|
58
58
|
* @param key Attribute key to remove
|
|
59
59
|
*/
|
|
@@ -92,7 +92,7 @@ export declare class ConnectorDataStore {
|
|
|
92
92
|
private deepEqual;
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
|
-
* Creates a persistent data store backed by
|
|
95
|
+
* Creates a persistent data store backed by source config attributes.
|
|
96
96
|
*
|
|
97
97
|
* @param config The connector config object (from `readConfig()`)
|
|
98
98
|
* @param res The response object from the current command handler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-store.d.ts","sourceRoot":"","sources":["../../lib/data-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"data-store.d.ts","sourceRoot":"","sources":["../../lib/data-store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAG7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2D;gBAEvE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC;IAK3D;;;;OAIG;IACH,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAQxC;;;;;OAKG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IASlC;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAQzB;;OAEG;IACH,IAAI,iBAAiB,IAAI,OAAO,CAE/B;IAED;;;;;;OAMG;IACH,KAAK,IAAI,IAAI;IAyCb;;;;;;;;;;;;;;;;;OAiBG;IACG,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,OAAO,CAAC,SAAS;CAOjB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAE5G"}
|
package/dist/lib/data-store.js
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.createConnectorDataStore = exports.ConnectorDataStore = void 0;
|
|
5
5
|
const response_1 = require("./response");
|
|
6
|
+
const logger_1 = require("./logger");
|
|
6
7
|
/**
|
|
7
|
-
* A persistent key-value data store backed by
|
|
8
|
+
* A persistent key-value data store backed by source config attributes.
|
|
8
9
|
*
|
|
9
10
|
* Provides a simple API to read and write values that persist across connector invocations.
|
|
10
11
|
* Under the hood, changes are sent via `patchConfig` as JSON Patch operations targeting
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* `/<key>` directly. Only changed values are patched — if a value is set to the same thing
|
|
13
|
+
* it was before, no patch is emitted.
|
|
13
14
|
*
|
|
14
15
|
* During long aggregations, call `reload(context)` to pick up config changes that occurred
|
|
15
16
|
* mid-run (including values written by a previous `flush()` call in the same invocation).
|
|
@@ -44,7 +45,7 @@ class ConnectorDataStore {
|
|
|
44
45
|
this.res = res;
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
47
|
-
* Get a value from
|
|
48
|
+
* Get a value from the config.
|
|
48
49
|
* Returns the pending value if one has been set, otherwise the original config value.
|
|
49
50
|
* @param key Attribute key
|
|
50
51
|
*/
|
|
@@ -53,16 +54,16 @@ class ConnectorDataStore {
|
|
|
53
54
|
if (pendingEntry) {
|
|
54
55
|
return pendingEntry.op === 'delete' ? undefined : pendingEntry.value;
|
|
55
56
|
}
|
|
56
|
-
return this.config?.
|
|
57
|
+
return this.config?.[key];
|
|
57
58
|
}
|
|
58
59
|
/**
|
|
59
|
-
* Set a value in
|
|
60
|
+
* Set a value in the config. The change is buffered until `flush()` is called.
|
|
60
61
|
* If the value is identical to the current stored value, no patch will be emitted.
|
|
61
62
|
* @param key Attribute key
|
|
62
63
|
* @param value Value to store (must be JSON-serializable)
|
|
63
64
|
*/
|
|
64
65
|
set(key, value) {
|
|
65
|
-
const current = this.config?.
|
|
66
|
+
const current = this.config?.[key];
|
|
66
67
|
if (this.deepEqual(current, value)) {
|
|
67
68
|
this.pending.delete(key);
|
|
68
69
|
return;
|
|
@@ -70,12 +71,12 @@ class ConnectorDataStore {
|
|
|
70
71
|
this.pending.set(key, { op: 'set', value });
|
|
71
72
|
}
|
|
72
73
|
/**
|
|
73
|
-
* Remove a key from
|
|
74
|
+
* Remove a key from the config. The change is buffered until `flush()` is called.
|
|
74
75
|
* If the key doesn't exist, no patch will be emitted.
|
|
75
76
|
* @param key Attribute key to remove
|
|
76
77
|
*/
|
|
77
78
|
delete(key) {
|
|
78
|
-
const exists = this.config?.
|
|
79
|
+
const exists = this.config?.hasOwnProperty(key);
|
|
79
80
|
if (!exists && !this.pending.has(key)) {
|
|
80
81
|
return;
|
|
81
82
|
}
|
|
@@ -98,35 +99,33 @@ class ConnectorDataStore {
|
|
|
98
99
|
if (this.pending.size === 0) {
|
|
99
100
|
return;
|
|
100
101
|
}
|
|
102
|
+
const log = logger_1.logger.child({ component: 'data-store' });
|
|
103
|
+
log.debug({ config: this.config ?? null }, 'data-store flush: config baseline');
|
|
101
104
|
const patches = [];
|
|
102
|
-
const hasConnectorAttributes = this.config?.connectorAttributes != null;
|
|
103
105
|
for (const [key, entry] of this.pending) {
|
|
104
106
|
if (entry.op === 'delete') {
|
|
105
|
-
patches.push({ op: response_1.PatchOp.Remove, path:
|
|
107
|
+
patches.push({ op: response_1.PatchOp.Remove, path: `/${key}` });
|
|
106
108
|
}
|
|
107
109
|
else {
|
|
108
|
-
const existed =
|
|
110
|
+
const existed = this.config?.hasOwnProperty(key);
|
|
109
111
|
patches.push({
|
|
110
112
|
op: existed ? response_1.PatchOp.Replace : response_1.PatchOp.Add,
|
|
111
|
-
path:
|
|
113
|
+
path: `/${key}`,
|
|
112
114
|
value: entry.value,
|
|
113
115
|
});
|
|
114
116
|
}
|
|
115
117
|
}
|
|
118
|
+
log.debug({ patches }, 'data-store flush: sending patches');
|
|
116
119
|
if (patches.length > 0) {
|
|
117
120
|
this.res.patchConfig(patches);
|
|
118
121
|
}
|
|
119
|
-
// Update the local config
|
|
120
|
-
// correctly detect changes rather than re-patching already-written values.
|
|
121
|
-
if (!this.config.connectorAttributes) {
|
|
122
|
-
this.config.connectorAttributes = {};
|
|
123
|
-
}
|
|
122
|
+
// Update the local config baseline so subsequent set() calls detect no change
|
|
124
123
|
for (const [key, entry] of this.pending) {
|
|
125
124
|
if (entry.op === 'delete') {
|
|
126
|
-
delete this.config
|
|
125
|
+
delete this.config[key];
|
|
127
126
|
}
|
|
128
127
|
else {
|
|
129
|
-
this.config
|
|
128
|
+
this.config[key] = entry.value;
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
this.pending.clear();
|
|
@@ -166,7 +165,7 @@ class ConnectorDataStore {
|
|
|
166
165
|
}
|
|
167
166
|
exports.ConnectorDataStore = ConnectorDataStore;
|
|
168
167
|
/**
|
|
169
|
-
* Creates a persistent data store backed by
|
|
168
|
+
* Creates a persistent data store backed by source config attributes.
|
|
170
169
|
*
|
|
171
170
|
* @param config The connector config object (from `readConfig()`)
|
|
172
171
|
* @param res The response object from the current command handler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-store.js","sourceRoot":"","sources":["../../lib/data-store.ts"],"names":[],"mappings":";AAAA,2EAA2E;;;AAE3E,yCAAqD;
|
|
1
|
+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FD,4DAEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sailpoint/connector-sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "JavaScript framework to build SailPoint Connectors",
|
|
5
5
|
"author": "SailPoint Technologies, Inc.",
|
|
6
6
|
"license": "Copyright (c) 2023. SailPoint Technologies, Inc. All rights reserved.",
|