@atlaskit/web-config-client 0.2.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/CHANGELOG.md +1 -0
- package/LICENSE.md +11 -0
- package/README.md +9 -0
- package/dist/cjs/index.js +31 -0
- package/dist/cjs/main.js +69 -0
- package/dist/es2019/index.js +2 -0
- package/dist/es2019/main.js +20 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/main.js +62 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/main.d.ts +29 -0
- package/dist/types-ts4.5/index.d.ts +2 -0
- package/dist/types-ts4.5/main.d.ts +29 -0
- package/package.json +93 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @atlaskit/web-config-client
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Copyright 2023 Atlassian Pty Ltd
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
|
|
4
|
+
compliance with the License. You may obtain a copy of the License at
|
|
5
|
+
|
|
6
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
|
|
8
|
+
Unless required by applicable law or agreed to in writing, software distributed under the License is
|
|
9
|
+
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
10
|
+
implied. See the License for the specific language governing permissions and limitations under the
|
|
11
|
+
License.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# WebConfigClient
|
|
2
|
+
|
|
3
|
+
JavaScript Frontend Web Client for Dynamic Configuration.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
`import WebConfigClient from '@atlaskit/web-config-client';`
|
|
8
|
+
|
|
9
|
+
Detailed docs and example usage can be found [here](https://atlaskit.atlassian.com/packages/measurement/web-config-client).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ConfigClient", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _main.ConfigClient;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ConfigCollection", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _configCommonLibs.ConfigCollection;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "ConfigError", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _configCommonLibs.ConfigError;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "ConfigMapSchema", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _configCommonLibs.ConfigMapSchema;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var _main = require("./main");
|
|
31
|
+
var _configCommonLibs = require("@atlaskit/config-common-libs");
|
package/dist/cjs/main.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ConfigClient = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
+
var _configCommonLibs = require("@atlaskit/config-common-libs");
|
|
13
|
+
var ConfigClient = exports.ConfigClient = /*#__PURE__*/function () {
|
|
14
|
+
function ConfigClient() {
|
|
15
|
+
(0, _classCallCheck2.default)(this, ConfigClient);
|
|
16
|
+
}
|
|
17
|
+
(0, _createClass2.default)(ConfigClient, null, [{
|
|
18
|
+
key: "fetch",
|
|
19
|
+
value: function () {
|
|
20
|
+
var _fetch = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(options) {
|
|
21
|
+
var _options$fetch;
|
|
22
|
+
var fetch, response, valuesPayload;
|
|
23
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
24
|
+
while (1) switch (_context.prev = _context.next) {
|
|
25
|
+
case 0:
|
|
26
|
+
fetch = (_options$fetch = options.fetch) !== null && _options$fetch !== void 0 ? _options$fetch : globalThis.fetch;
|
|
27
|
+
_context.next = 3;
|
|
28
|
+
return fetch("".concat(options.ffsBaseUrl, "/api/v2/configurations"), {
|
|
29
|
+
method: 'POST',
|
|
30
|
+
body: JSON.stringify(options.context),
|
|
31
|
+
headers: {
|
|
32
|
+
'content-type': 'application/json',
|
|
33
|
+
'x-api-key': options.ffsApiKey
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
case 3:
|
|
37
|
+
response = _context.sent;
|
|
38
|
+
if (response.ok) {
|
|
39
|
+
_context.next = 12;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
_context.t0 = Error;
|
|
43
|
+
_context.t1 = "Unexpected response ".concat(response.status, ": ");
|
|
44
|
+
_context.next = 9;
|
|
45
|
+
return response.text();
|
|
46
|
+
case 9:
|
|
47
|
+
_context.t2 = _context.sent;
|
|
48
|
+
_context.t3 = _context.t1.concat.call(_context.t1, _context.t2);
|
|
49
|
+
throw new _context.t0(_context.t3);
|
|
50
|
+
case 12:
|
|
51
|
+
_context.next = 14;
|
|
52
|
+
return response.text();
|
|
53
|
+
case 14:
|
|
54
|
+
valuesPayload = _context.sent;
|
|
55
|
+
return _context.abrupt("return", _configCommonLibs.ConfigCollection.fromValues(valuesPayload));
|
|
56
|
+
case 16:
|
|
57
|
+
case "end":
|
|
58
|
+
return _context.stop();
|
|
59
|
+
}
|
|
60
|
+
}, _callee);
|
|
61
|
+
}));
|
|
62
|
+
function fetch(_x) {
|
|
63
|
+
return _fetch.apply(this, arguments);
|
|
64
|
+
}
|
|
65
|
+
return fetch;
|
|
66
|
+
}()
|
|
67
|
+
}]);
|
|
68
|
+
return ConfigClient;
|
|
69
|
+
}();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ConfigCollection } from '@atlaskit/config-common-libs';
|
|
2
|
+
export class ConfigClient {
|
|
3
|
+
static async fetch(options) {
|
|
4
|
+
var _options$fetch;
|
|
5
|
+
const fetch = (_options$fetch = options.fetch) !== null && _options$fetch !== void 0 ? _options$fetch : globalThis.fetch;
|
|
6
|
+
const response = await fetch(`${options.ffsBaseUrl}/api/v2/configurations`, {
|
|
7
|
+
method: 'POST',
|
|
8
|
+
body: JSON.stringify(options.context),
|
|
9
|
+
headers: {
|
|
10
|
+
'content-type': 'application/json',
|
|
11
|
+
'x-api-key': options.ffsApiKey
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
if (!response.ok) {
|
|
15
|
+
throw new Error(`Unexpected response ${response.status}: ${await response.text()}`);
|
|
16
|
+
}
|
|
17
|
+
const valuesPayload = await response.text();
|
|
18
|
+
return ConfigCollection.fromValues(valuesPayload);
|
|
19
|
+
}
|
|
20
|
+
}
|
package/dist/esm/main.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
+
import { ConfigCollection } from '@atlaskit/config-common-libs';
|
|
6
|
+
export var ConfigClient = /*#__PURE__*/function () {
|
|
7
|
+
function ConfigClient() {
|
|
8
|
+
_classCallCheck(this, ConfigClient);
|
|
9
|
+
}
|
|
10
|
+
_createClass(ConfigClient, null, [{
|
|
11
|
+
key: "fetch",
|
|
12
|
+
value: function () {
|
|
13
|
+
var _fetch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
|
|
14
|
+
var _options$fetch;
|
|
15
|
+
var fetch, response, valuesPayload;
|
|
16
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
17
|
+
while (1) switch (_context.prev = _context.next) {
|
|
18
|
+
case 0:
|
|
19
|
+
fetch = (_options$fetch = options.fetch) !== null && _options$fetch !== void 0 ? _options$fetch : globalThis.fetch;
|
|
20
|
+
_context.next = 3;
|
|
21
|
+
return fetch("".concat(options.ffsBaseUrl, "/api/v2/configurations"), {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
body: JSON.stringify(options.context),
|
|
24
|
+
headers: {
|
|
25
|
+
'content-type': 'application/json',
|
|
26
|
+
'x-api-key': options.ffsApiKey
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
case 3:
|
|
30
|
+
response = _context.sent;
|
|
31
|
+
if (response.ok) {
|
|
32
|
+
_context.next = 12;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
_context.t0 = Error;
|
|
36
|
+
_context.t1 = "Unexpected response ".concat(response.status, ": ");
|
|
37
|
+
_context.next = 9;
|
|
38
|
+
return response.text();
|
|
39
|
+
case 9:
|
|
40
|
+
_context.t2 = _context.sent;
|
|
41
|
+
_context.t3 = _context.t1.concat.call(_context.t1, _context.t2);
|
|
42
|
+
throw new _context.t0(_context.t3);
|
|
43
|
+
case 12:
|
|
44
|
+
_context.next = 14;
|
|
45
|
+
return response.text();
|
|
46
|
+
case 14:
|
|
47
|
+
valuesPayload = _context.sent;
|
|
48
|
+
return _context.abrupt("return", ConfigCollection.fromValues(valuesPayload));
|
|
49
|
+
case 16:
|
|
50
|
+
case "end":
|
|
51
|
+
return _context.stop();
|
|
52
|
+
}
|
|
53
|
+
}, _callee);
|
|
54
|
+
}));
|
|
55
|
+
function fetch(_x) {
|
|
56
|
+
return _fetch.apply(this, arguments);
|
|
57
|
+
}
|
|
58
|
+
return fetch;
|
|
59
|
+
}()
|
|
60
|
+
}]);
|
|
61
|
+
return ConfigClient;
|
|
62
|
+
}();
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ConfigCollection } from '@atlaskit/config-common-libs';
|
|
2
|
+
import type { IdentifierEnum } from '@atlassian/feature-gate-node-client-standalone';
|
|
3
|
+
export interface FetchOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Base URL of the feature-flag-service
|
|
6
|
+
*/
|
|
7
|
+
ffsBaseUrl: string;
|
|
8
|
+
/**
|
|
9
|
+
* Your fx3/feature-flag-service API Key
|
|
10
|
+
* You can get it from here: https://developer.atlassian.com/platform/frontend-feature-flags/resources/api-keys/
|
|
11
|
+
*/
|
|
12
|
+
ffsApiKey: string;
|
|
13
|
+
/**
|
|
14
|
+
* User context to evaluate against
|
|
15
|
+
*/
|
|
16
|
+
context: {
|
|
17
|
+
identifiers: {
|
|
18
|
+
[id in IdentifierEnum]?: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
metadata: Record<string, string | number | boolean>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Optional: use this to pass in your own `fetch` instance.
|
|
24
|
+
*/
|
|
25
|
+
fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
26
|
+
}
|
|
27
|
+
export declare class ConfigClient {
|
|
28
|
+
static fetch(options: FetchOptions): Promise<ConfigCollection>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ConfigCollection } from '@atlaskit/config-common-libs';
|
|
2
|
+
import type { IdentifierEnum } from '@atlassian/feature-gate-node-client-standalone';
|
|
3
|
+
export interface FetchOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Base URL of the feature-flag-service
|
|
6
|
+
*/
|
|
7
|
+
ffsBaseUrl: string;
|
|
8
|
+
/**
|
|
9
|
+
* Your fx3/feature-flag-service API Key
|
|
10
|
+
* You can get it from here: https://developer.atlassian.com/platform/frontend-feature-flags/resources/api-keys/
|
|
11
|
+
*/
|
|
12
|
+
ffsApiKey: string;
|
|
13
|
+
/**
|
|
14
|
+
* User context to evaluate against
|
|
15
|
+
*/
|
|
16
|
+
context: {
|
|
17
|
+
identifiers: {
|
|
18
|
+
[id in IdentifierEnum]?: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
metadata: Record<string, string | number | boolean>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Optional: use this to pass in your own `fetch` instance.
|
|
24
|
+
*/
|
|
25
|
+
fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
26
|
+
}
|
|
27
|
+
export declare class ConfigClient {
|
|
28
|
+
static fetch(options: FetchOptions): Promise<ConfigCollection>;
|
|
29
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/web-config-client",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "JavaScript Frontend Web Client for Dynamic Configuration.",
|
|
5
|
+
"author": "Atlassian Pty Ltd",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"registry": "https://registry.npmjs.org/"
|
|
9
|
+
},
|
|
10
|
+
"atlassian": {
|
|
11
|
+
"team": "MEP: Switcheroo",
|
|
12
|
+
"website": {
|
|
13
|
+
"name": "WebConfigClient",
|
|
14
|
+
"category": "Components"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"repository": "https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo",
|
|
18
|
+
"main": "dist/cjs/index.js",
|
|
19
|
+
"module": "dist/esm/index.js",
|
|
20
|
+
"module:es2019": "dist/es2019/index.js",
|
|
21
|
+
"types": "dist/types/index.d.ts",
|
|
22
|
+
"typesVersions": {
|
|
23
|
+
">=4.5 <5.4": {
|
|
24
|
+
"*": [
|
|
25
|
+
"dist/types-ts4.5/*",
|
|
26
|
+
"dist/types-ts4.5/index.d.ts"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"sideEffects": [
|
|
31
|
+
"*.compiled.css"
|
|
32
|
+
],
|
|
33
|
+
"atlaskit:src": "src/index.ts",
|
|
34
|
+
"af:exports": {
|
|
35
|
+
".": "./src/index.ts"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@atlaskit/config-common-libs": "*",
|
|
39
|
+
"@babel/runtime": "^7.0.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"react": "^16.8.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@af/integration-testing": "*",
|
|
46
|
+
"@af/visual-regression": "*",
|
|
47
|
+
"@atlaskit/ssr": "*",
|
|
48
|
+
"@atlaskit/visual-regression": "*",
|
|
49
|
+
"@atlassian/feature-gate-node-client-standalone": "^3.5.0",
|
|
50
|
+
"@testing-library/react": "^12.1.5",
|
|
51
|
+
"react-dom": "^16.8.0",
|
|
52
|
+
"typescript": "~5.4.2",
|
|
53
|
+
"wait-for-expect": "^1.2.0"
|
|
54
|
+
},
|
|
55
|
+
"techstack": {
|
|
56
|
+
"@atlassian/frontend": {
|
|
57
|
+
"code-structure": [
|
|
58
|
+
"tangerine-next"
|
|
59
|
+
],
|
|
60
|
+
"import-structure": [
|
|
61
|
+
"atlassian-conventions"
|
|
62
|
+
],
|
|
63
|
+
"circular-dependencies": [
|
|
64
|
+
"file-and-folder-level"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
"@repo/internal": {
|
|
68
|
+
"dom-events": "use-bind-event-listener",
|
|
69
|
+
"analytics": [
|
|
70
|
+
"analytics-next"
|
|
71
|
+
],
|
|
72
|
+
"design-tokens": [
|
|
73
|
+
"color"
|
|
74
|
+
],
|
|
75
|
+
"theming": [
|
|
76
|
+
"react-context"
|
|
77
|
+
],
|
|
78
|
+
"ui-components": [
|
|
79
|
+
"lite-mode"
|
|
80
|
+
],
|
|
81
|
+
"deprecation": [
|
|
82
|
+
"no-deprecated-imports"
|
|
83
|
+
],
|
|
84
|
+
"styling": [
|
|
85
|
+
"static",
|
|
86
|
+
"compiled"
|
|
87
|
+
],
|
|
88
|
+
"imports": [
|
|
89
|
+
"import-no-extraneous-disable-for-examples-and-docs"
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|