@gitlode/plugin-custom-field 0.2.0 → 0.4.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/README.md +22 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Add static custom fields to every gitlode output record under `extensions["custom-field"]`.
|
|
4
4
|
|
|
5
|
-
This plugin is
|
|
5
|
+
This plugin is intended as a simple, practical
|
|
6
6
|
session-labeling tool. Typical use cases include tagging extraction output with branch,
|
|
7
7
|
environment, run id, or other pipeline metadata.
|
|
8
8
|
|
|
@@ -60,6 +60,14 @@ Each emitted record will include:
|
|
|
60
60
|
|
|
61
61
|
`config` value schema for this plugin:
|
|
62
62
|
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"value": "<string|number|boolean>"
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
or
|
|
70
|
+
|
|
63
71
|
```json
|
|
64
72
|
{
|
|
65
73
|
"value": {
|
|
@@ -70,7 +78,9 @@ Each emitted record will include:
|
|
|
70
78
|
|
|
71
79
|
Rules:
|
|
72
80
|
|
|
73
|
-
- `value` is required and must be
|
|
81
|
+
- `value` is required and must be either:
|
|
82
|
+
- a scalar: `string`, finite `number`, or `boolean`, or
|
|
83
|
+
- an object containing at least one entry.
|
|
74
84
|
- Field names must match `^[A-Za-z_][A-Za-z0-9_-]*$`.
|
|
75
85
|
- Field values must be scalar JSON values only: `string`, `number`, `boolean`, or `null`.
|
|
76
86
|
- Number values must be finite (`NaN`, `Infinity`, and `-Infinity` are rejected).
|
|
@@ -89,7 +99,7 @@ This package declares:
|
|
|
89
99
|
|
|
90
100
|
```json
|
|
91
101
|
"peerDependencies": {
|
|
92
|
-
"gitlode": "^0.
|
|
102
|
+
"gitlode": "^0.8.0"
|
|
93
103
|
}
|
|
94
104
|
```
|
|
95
105
|
|
|
@@ -98,3 +108,12 @@ If the running gitlode version does not satisfy this range, gitlode emits a warn
|
|
|
98
108
|
## License
|
|
99
109
|
|
|
100
110
|
[MIT](LICENSE)
|
|
111
|
+
|
|
112
|
+
## Changelog
|
|
113
|
+
|
|
114
|
+
[Changelog](CHANGELOG.md)
|
|
115
|
+
|
|
116
|
+
All notable changes to this project will be documented in this file.
|
|
117
|
+
|
|
118
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
119
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAKd,MAAM,oBAAoB,CAAC;AAmG5B,QAAA,MAAM,OAAO,EAAE,aAmBd,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,26 @@ const FIELD_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]*$/;
|
|
|
2
2
|
function isRecord(value) {
|
|
3
3
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
4
|
}
|
|
5
|
+
function parseScalarValue(valueRaw) {
|
|
6
|
+
switch (typeof valueRaw) {
|
|
7
|
+
case "string":
|
|
8
|
+
case "boolean":
|
|
9
|
+
return { type: "ok", value: valueRaw };
|
|
10
|
+
case "number":
|
|
11
|
+
if (!Number.isFinite(valueRaw)) {
|
|
12
|
+
return {
|
|
13
|
+
type: "error",
|
|
14
|
+
message: 'Invalid plugin config: "value" must be a finite number.',
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
return { type: "ok", value: valueRaw };
|
|
18
|
+
default:
|
|
19
|
+
return {
|
|
20
|
+
type: "error",
|
|
21
|
+
message: 'Invalid plugin config: "value" must be an object, string, number, or boolean.',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
5
25
|
function parseConfig(rawConfig) {
|
|
6
26
|
if (!isRecord(rawConfig)) {
|
|
7
27
|
return {
|
|
@@ -11,10 +31,7 @@ function parseConfig(rawConfig) {
|
|
|
11
31
|
}
|
|
12
32
|
const valueRaw = rawConfig["value"];
|
|
13
33
|
if (!isRecord(valueRaw)) {
|
|
14
|
-
return
|
|
15
|
-
type: "error",
|
|
16
|
-
message: 'Invalid plugin config: "value" must be an object containing at least one entry.',
|
|
17
|
-
};
|
|
34
|
+
return parseScalarValue(valueRaw);
|
|
18
35
|
}
|
|
19
36
|
const entries = Object.entries(valueRaw);
|
|
20
37
|
if (entries.length === 0) {
|
|
@@ -46,6 +63,7 @@ function parseConfig(rawConfig) {
|
|
|
46
63
|
parsedValue[fieldName] = value;
|
|
47
64
|
break;
|
|
48
65
|
case "object":
|
|
66
|
+
// Top-level value does not allow null, but object field values may be null.
|
|
49
67
|
if (value === null) {
|
|
50
68
|
parsedValue[fieldName] = null;
|
|
51
69
|
break;
|
|
@@ -72,7 +90,7 @@ const factory = async (rawConfig) => {
|
|
|
72
90
|
? { type: "success", data: parsedConfig.value }
|
|
73
91
|
: { type: "success", data: {} };
|
|
74
92
|
return {
|
|
75
|
-
async init() {
|
|
93
|
+
async init(_runtime) {
|
|
76
94
|
return initResult;
|
|
77
95
|
},
|
|
78
96
|
async project() {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AAEvD,SAAS,QAAQ,CAAC,KAAc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C,CAAC;IAC5C,MAAM,UAAU,GACd,YAAY,CAAC,IAAI,KAAK,IAAI;QACxB,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;QACnB,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC;IACvD,MAAM,aAAa,GACjB,YAAY,CAAC,IAAI,KAAK,IAAI;QACxB,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,CAAC,KAAK,EAAE;QAC/C,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAEpC,OAAO;QACL,KAAK,CAAC,IAAI,CAAC,QAA8B;YACvC,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,KAAK,CAAC,OAAO;YACX,OAAO,aAAa,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlode/plugin-custom-field",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Official gitlode plugin for injecting static custom field into extensions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gitlode",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"test:coverage": "vitest run --coverage"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"gitlode": "^0.
|
|
35
|
+
"gitlode": "^0.8.1"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"gitlode": "^0.
|
|
38
|
+
"gitlode": "^0.8.0"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=22.0.0"
|