@harborclient/sdk 0.7.0 → 1.0.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/build/index.d.ts +59 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +116 -0
- package/dist/client.d.ts +2 -2
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/portalToBody.d.ts +11 -0
- package/dist/components/portalToBody.d.ts.map +1 -0
- package/dist/components/portalToBody.js +15 -0
- package/dist/eslint/index.d.ts +9 -0
- package/dist/eslint/index.d.ts.map +1 -0
- package/dist/eslint/index.js +18 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/jsx-dev-runtime.d.ts +1 -1
- package/dist/runtime/jsx-runtime-host.d.ts +44 -0
- package/dist/runtime/jsx-runtime-host.js +42 -0
- package/dist/runtime/react-dom.d.ts +1 -0
- package/dist/runtime/react-dom.js +16 -0
- package/dist/runtime/react.d.ts +6 -0
- package/dist/runtime/react.js +70 -2
- package/dist/runtime/reactHost.js +52 -0
- package/dist/runtime/store.d.ts +106 -0
- package/dist/runtime/store.d.ts.map +1 -1
- package/dist/runtime/store.js +100 -0
- package/dist/runtime/store.ts +211 -0
- package/dist/runtime/viewHost.js +2 -1
- package/dist/runtime-utils.d.ts +59 -0
- package/dist/runtime-utils.d.ts.map +1 -1
- package/dist/runtime-utils.js +66 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +1 -0
- package/dist/storage/validate.d.ts +71 -0
- package/dist/storage/validate.d.ts.map +1 -0
- package/dist/storage/validate.js +111 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +37 -8
- package/tsconfig.base.json +15 -0
- package/dist/components/enhanceControl.test.d.ts +0 -2
- package/dist/components/enhanceControl.test.d.ts.map +0 -1
- package/dist/components/enhanceControl.test.js +0 -83
- package/dist/components/utils.test.d.ts +0 -2
- package/dist/components/utils.test.d.ts.map +0 -1
- package/dist/components/utils.test.js +0 -44
- package/dist/http/resolveRequest.test.d.ts +0 -2
- package/dist/http/resolveRequest.test.d.ts.map +0 -1
- package/dist/http/resolveRequest.test.js +0 -40
- package/dist/http/substitute.test.d.ts +0 -2
- package/dist/http/substitute.test.d.ts.map +0 -1
- package/dist/http/substitute.test.js +0 -93
- package/dist/pluginDatabaseApi.test.d.ts +0 -2
- package/dist/pluginDatabaseApi.test.d.ts.map +0 -1
- package/dist/pluginDatabaseApi.test.js +0 -65
- package/dist/runtime/index.test.d.ts +0 -2
- package/dist/runtime/index.test.d.ts.map +0 -1
- package/dist/runtime/index.test.js +0 -41
- package/dist/runtime/index.test.ts +0 -53
- package/dist/runtime-utils.test.d.ts +0 -2
- package/dist/runtime-utils.test.d.ts.map +0 -1
- package/dist/runtime-utils.test.js +0 -104
- package/dist/signing/signing.test.d.ts +0 -2
- package/dist/signing/signing.test.d.ts.map +0 -1
- package/dist/signing/signing.test.js +0 -100
- package/dist/storage/cappedList.test.d.ts +0 -2
- package/dist/storage/cappedList.test.d.ts.map +0 -1
- package/dist/storage/cappedList.test.js +0 -11
- package/dist/utilities.test.d.ts +0 -2
- package/dist/utilities.test.d.ts.map +0 -1
- package/dist/utilities.test.js +0 -16
- package/dist/variables/dynamic.test.d.ts +0 -2
- package/dist/variables/dynamic.test.d.ts.map +0 -1
- package/dist/variables/dynamic.test.js +0 -60
- package/dist/variables/tokens.test.d.ts +0 -2
- package/dist/variables/tokens.test.d.ts.map +0 -1
- package/dist/variables/tokens.test.js +0 -160
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from '@jest/globals';
|
|
2
|
-
import { getVariableTokenAtOffset, getVariableTooltipContent, resolveVariable, substituteVariables, tokenizeVariables } from './tokens.js';
|
|
3
|
-
/**
|
|
4
|
-
* Builds a test variable row.
|
|
5
|
-
*
|
|
6
|
-
* @param key - Variable name.
|
|
7
|
-
* @param value - Current value.
|
|
8
|
-
* @param defaultValue - Fallback when value is empty.
|
|
9
|
-
* @param share - Whether the variable is shared on export.
|
|
10
|
-
*/
|
|
11
|
-
const variable = (key, value, defaultValue = '', share = false) => ({
|
|
12
|
-
key,
|
|
13
|
-
value,
|
|
14
|
-
defaultValue,
|
|
15
|
-
share
|
|
16
|
-
});
|
|
17
|
-
describe('substituteVariables', () => {
|
|
18
|
-
it('replaces known variable tokens', () => {
|
|
19
|
-
const result = substituteVariables('https://{{host}}/api/{{version}}', [
|
|
20
|
-
variable('host', 'api.example.com'),
|
|
21
|
-
variable('version', 'v1')
|
|
22
|
-
]);
|
|
23
|
-
expect(result).toBe('https://api.example.com/api/v1');
|
|
24
|
-
});
|
|
25
|
-
it('leaves unknown tokens unchanged', () => {
|
|
26
|
-
const result = substituteVariables('https://{{host}}/{{missing}}', [
|
|
27
|
-
variable('host', 'api.example.com')
|
|
28
|
-
]);
|
|
29
|
-
expect(result).toBe('https://api.example.com/{{missing}}');
|
|
30
|
-
});
|
|
31
|
-
it('substitutes {{ host }} when token key has surrounding whitespace', () => {
|
|
32
|
-
const result = substituteVariables('https://{{ host }}/users', [
|
|
33
|
-
variable('host', 'api.example.com')
|
|
34
|
-
]);
|
|
35
|
-
expect(result).toBe('https://api.example.com/users');
|
|
36
|
-
});
|
|
37
|
-
it('trims variable keys when building the lookup', () => {
|
|
38
|
-
const result = substituteVariables('https://{{host}}', [
|
|
39
|
-
variable(' host ', 'api.example.com')
|
|
40
|
-
]);
|
|
41
|
-
expect(result).toBe('https://api.example.com');
|
|
42
|
-
});
|
|
43
|
-
it('ignores blank-key variables', () => {
|
|
44
|
-
const result = substituteVariables('https://{{host}}', [
|
|
45
|
-
variable(' ', 'ignored.example.com'),
|
|
46
|
-
variable('host', 'api.example.com')
|
|
47
|
-
]);
|
|
48
|
-
expect(result).toBe('https://api.example.com');
|
|
49
|
-
});
|
|
50
|
-
it('falls back to defaultValue when value is empty', () => {
|
|
51
|
-
const result = substituteVariables('https://{{host}}/api', [variable('host', '', 'localhost')]);
|
|
52
|
-
expect(result).toBe('https://localhost/api');
|
|
53
|
-
});
|
|
54
|
-
it('prefers value over defaultValue when both are set', () => {
|
|
55
|
-
const result = substituteVariables('https://{{host}}/api', [
|
|
56
|
-
variable('host', 'api.example.com', 'localhost')
|
|
57
|
-
]);
|
|
58
|
-
expect(result).toBe('https://api.example.com/api');
|
|
59
|
-
});
|
|
60
|
-
it('substitutes variables in collection header values', () => {
|
|
61
|
-
const result = substituteVariables('Bearer {{token}}', [variable('token', 'abc123')]);
|
|
62
|
-
expect(result).toBe('Bearer abc123');
|
|
63
|
-
});
|
|
64
|
-
it('resolves dynamic variables when no static variable is defined', () => {
|
|
65
|
-
const result = substituteVariables('id={{ $guid }}', []);
|
|
66
|
-
expect(result).not.toContain('{{');
|
|
67
|
-
expect(result).toMatch(/^id=[0-9a-f-]{36}$/i);
|
|
68
|
-
});
|
|
69
|
-
it('prefers static variables over dynamic variables with the same key', () => {
|
|
70
|
-
const result = substituteVariables('{{$randomInt}}', [variable('$randomInt', '42')]);
|
|
71
|
-
expect(result).toBe('42');
|
|
72
|
-
});
|
|
73
|
-
it('leaves unknown dynamic-style tokens unchanged', () => {
|
|
74
|
-
const result = substituteVariables('{{$notRegistered}}', []);
|
|
75
|
-
expect(result).toBe('{{$notRegistered}}');
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
describe('tokenizeVariables', () => {
|
|
79
|
-
it('returns a single plain-text token when no variables are present', () => {
|
|
80
|
-
expect(tokenizeVariables('https://api.example.com')).toEqual([
|
|
81
|
-
{ text: 'https://api.example.com' }
|
|
82
|
-
]);
|
|
83
|
-
});
|
|
84
|
-
it('splits text around variable tokens', () => {
|
|
85
|
-
expect(tokenizeVariables('https://{{host}}/api/{{version}}')).toEqual([
|
|
86
|
-
{ text: 'https://' },
|
|
87
|
-
{ text: '{{host}}', key: 'host' },
|
|
88
|
-
{ text: '/api/' },
|
|
89
|
-
{ text: '{{version}}', key: 'version' }
|
|
90
|
-
]);
|
|
91
|
-
});
|
|
92
|
-
it('tokenizeVariables extracts host key from {{ host }} token', () => {
|
|
93
|
-
expect(tokenizeVariables('https://{{ host }}/users')).toEqual([
|
|
94
|
-
{ text: 'https://' },
|
|
95
|
-
{ text: '{{ host }}', key: 'host' },
|
|
96
|
-
{ text: '/users' }
|
|
97
|
-
]);
|
|
98
|
-
});
|
|
99
|
-
it('tokenizeVariables recognizes dynamic variable keys with $ prefix', () => {
|
|
100
|
-
expect(tokenizeVariables('{{$randomUUID}}')).toEqual([
|
|
101
|
-
{ text: '{{$randomUUID}}', key: '$randomUUID' }
|
|
102
|
-
]);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
describe('resolveVariable', () => {
|
|
106
|
-
it('returns the resolved value for a known key', () => {
|
|
107
|
-
expect(resolveVariable('host', [variable('host', 'api.example.com')])).toBe('api.example.com');
|
|
108
|
-
});
|
|
109
|
-
it('falls back to defaultValue when value is empty', () => {
|
|
110
|
-
expect(resolveVariable('host', [variable('host', '', 'localhost')])).toBe('localhost');
|
|
111
|
-
});
|
|
112
|
-
it('returns undefined for unknown keys', () => {
|
|
113
|
-
expect(resolveVariable('missing', [variable('host', 'api.example.com')])).toBeUndefined();
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
describe('getVariableTokenAtOffset', () => {
|
|
117
|
-
const text = 'https://{{host}}/api/{{version}}';
|
|
118
|
-
it('returns the token when offset is inside a variable placeholder', () => {
|
|
119
|
-
expect(getVariableTokenAtOffset(text, 10)).toEqual({
|
|
120
|
-
key: 'host',
|
|
121
|
-
start: 8,
|
|
122
|
-
end: 16
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
it('returns null when offset is outside any token', () => {
|
|
126
|
-
expect(getVariableTokenAtOffset(text, 0)).toBeNull();
|
|
127
|
-
expect(getVariableTokenAtOffset(text, 7)).toBeNull();
|
|
128
|
-
});
|
|
129
|
-
it('matches at token start and end boundaries', () => {
|
|
130
|
-
expect(getVariableTokenAtOffset('{{host}}', 0)?.key).toBe('host');
|
|
131
|
-
expect(getVariableTokenAtOffset('{{host}}', 8)?.key).toBe('host');
|
|
132
|
-
});
|
|
133
|
-
it('matches tokens with whitespace around the key', () => {
|
|
134
|
-
expect(getVariableTokenAtOffset('https://{{ host }}/users', 10)).toEqual({
|
|
135
|
-
key: 'host',
|
|
136
|
-
start: 8,
|
|
137
|
-
end: 18
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
describe('getVariableTooltipContent', () => {
|
|
142
|
-
it('returns resolved static value without muted styling', () => {
|
|
143
|
-
expect(getVariableTooltipContent('host', [variable('host', 'api.example.com')])).toEqual({
|
|
144
|
-
text: 'api.example.com',
|
|
145
|
-
muted: false
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
it('returns dynamic description for registered dynamic variables', () => {
|
|
149
|
-
expect(getVariableTooltipContent('$guid', [])).toEqual({
|
|
150
|
-
text: 'Dynamic: A uuid-v4 style guid',
|
|
151
|
-
muted: true
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
it('returns Not defined for unknown keys', () => {
|
|
155
|
-
expect(getVariableTooltipContent('missing', [variable('host', 'api.example.com')])).toEqual({
|
|
156
|
-
text: 'Not defined',
|
|
157
|
-
muted: true
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
});
|