@sjunepark/fs 0.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.
Files changed (56) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +73 -0
  3. package/assets/guide/authoring.md +125 -0
  4. package/dist/application.js +34 -0
  5. package/dist/application.js.map +1 -0
  6. package/dist/assets.js +20 -0
  7. package/dist/assets.js.map +1 -0
  8. package/dist/bin.js +9 -0
  9. package/dist/bin.js.map +1 -0
  10. package/dist/cli.js +150 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/content.js +47 -0
  13. package/dist/content.js.map +1 -0
  14. package/dist/io.js +76 -0
  15. package/dist/io.js.map +1 -0
  16. package/dist/json.js +291 -0
  17. package/dist/json.js.map +1 -0
  18. package/dist/limits.js +15 -0
  19. package/dist/limits.js.map +1 -0
  20. package/dist/logger.js +26 -0
  21. package/dist/logger.js.map +1 -0
  22. package/dist/node-services.js +9 -0
  23. package/dist/node-services.js.map +1 -0
  24. package/dist/pathless.js +72 -0
  25. package/dist/pathless.js.map +1 -0
  26. package/dist/process.js +317 -0
  27. package/dist/process.js.map +1 -0
  28. package/dist/record-validation.js +44 -0
  29. package/dist/record-validation.js.map +1 -0
  30. package/dist/render.js +250 -0
  31. package/dist/render.js.map +1 -0
  32. package/dist/validation/calculate.js +102 -0
  33. package/dist/validation/calculate.js.map +1 -0
  34. package/dist/validation/decimal.js +63 -0
  35. package/dist/validation/decimal.js.map +1 -0
  36. package/dist/validation/identity.js +4 -0
  37. package/dist/validation/identity.js.map +1 -0
  38. package/dist/validation/model.js +10 -0
  39. package/dist/validation/model.js.map +1 -0
  40. package/dist/validation/schema.js +106 -0
  41. package/dist/validation/schema.js.map +1 -0
  42. package/dist/validation/semantic.js +179 -0
  43. package/dist/validation/semantic.js.map +1 -0
  44. package/dist/validation/snapshot.js +74 -0
  45. package/dist/validation/snapshot.js.map +1 -0
  46. package/dist/validation/validate.js +154 -0
  47. package/dist/validation/validate.js.map +1 -0
  48. package/dist/writer.js +107 -0
  49. package/dist/writer.js.map +1 -0
  50. package/examples/README.md +37 -0
  51. package/examples/manufacturing-group.json +439 -0
  52. package/examples/minimal.json +45 -0
  53. package/package.json +80 -0
  54. package/schema/fs-document.schema.json +335 -0
  55. package/schema/snapshot-diff.schema.json +96 -0
  56. package/schema/validation-result.schema.json +165 -0
@@ -0,0 +1,335 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://cpaikr.github.io/fs/schema/0.1/fs-document.schema.json",
4
+ "title": "FS V0 document",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["formatVersion", "entity", "scope", "units", "periods", "statements"],
8
+ "properties": {
9
+ "$schema": {
10
+ "const": "https://cpaikr.github.io/fs/schema/0.1/fs-document.schema.json"
11
+ },
12
+ "formatVersion": { "const": "0.1" },
13
+ "documentId": { "$ref": "#/$defs/id" },
14
+ "entity": { "$ref": "#/$defs/entity" },
15
+ "scope": { "$ref": "#/$defs/scope" },
16
+ "units": {
17
+ "type": "array",
18
+ "minItems": 1,
19
+ "items": { "$ref": "#/$defs/unit" }
20
+ },
21
+ "periods": {
22
+ "type": "array",
23
+ "minItems": 1,
24
+ "items": { "$ref": "#/$defs/period" }
25
+ },
26
+ "groupingColumns": {
27
+ "type": "array",
28
+ "uniqueItems": true,
29
+ "items": { "$ref": "#/$defs/id" }
30
+ },
31
+ "statements": {
32
+ "type": "array",
33
+ "minItems": 1,
34
+ "items": { "$ref": "#/$defs/statement" }
35
+ },
36
+ "validationSnapshot": { "$ref": "#/$defs/validationSnapshot" }
37
+ },
38
+ "$defs": {
39
+ "id": {
40
+ "type": "string",
41
+ "pattern": "^[A-Za-z][A-Za-z0-9._-]*$"
42
+ },
43
+ "nonEmptyString": {
44
+ "type": "string",
45
+ "minLength": 1
46
+ },
47
+ "decimal": {
48
+ "type": "string",
49
+ "pattern": "^(?:0|-?(?:[1-9][0-9]*)(?:\\.[0-9]*[1-9])?|-?0\\.[0-9]*[1-9])$"
50
+ },
51
+ "nonNegativeDecimal": {
52
+ "type": "string",
53
+ "pattern": "^(?:0|(?:[1-9][0-9]*)(?:\\.[0-9]*[1-9])?|0\\.[0-9]*[1-9])$"
54
+ },
55
+ "entity": {
56
+ "type": "object",
57
+ "additionalProperties": false,
58
+ "required": ["name"],
59
+ "properties": {
60
+ "id": { "$ref": "#/$defs/id" },
61
+ "name": { "$ref": "#/$defs/nonEmptyString" }
62
+ }
63
+ },
64
+ "scope": {
65
+ "type": "object",
66
+ "additionalProperties": false,
67
+ "required": ["label"],
68
+ "properties": {
69
+ "id": { "$ref": "#/$defs/id" },
70
+ "label": { "$ref": "#/$defs/nonEmptyString" }
71
+ }
72
+ },
73
+ "unit": {
74
+ "type": "object",
75
+ "additionalProperties": false,
76
+ "required": ["id", "label", "measure", "scale"],
77
+ "properties": {
78
+ "id": { "$ref": "#/$defs/id" },
79
+ "label": { "$ref": "#/$defs/nonEmptyString" },
80
+ "measure": { "$ref": "#/$defs/nonEmptyString" },
81
+ "scale": {
82
+ "type": "integer",
83
+ "minimum": -9007199254740991,
84
+ "maximum": 9007199254740991
85
+ },
86
+ "defaultTolerance": { "$ref": "#/$defs/nonNegativeDecimal" }
87
+ }
88
+ },
89
+ "date": {
90
+ "type": "string",
91
+ "pattern": "^[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])$"
92
+ },
93
+ "instantPeriod": {
94
+ "type": "object",
95
+ "additionalProperties": false,
96
+ "required": ["id", "kind", "date"],
97
+ "properties": {
98
+ "id": { "$ref": "#/$defs/id" },
99
+ "kind": { "const": "instant" },
100
+ "date": { "$ref": "#/$defs/date" }
101
+ }
102
+ },
103
+ "durationPeriod": {
104
+ "type": "object",
105
+ "additionalProperties": false,
106
+ "required": ["id", "kind", "start", "end"],
107
+ "properties": {
108
+ "id": { "$ref": "#/$defs/id" },
109
+ "kind": { "const": "duration" },
110
+ "start": { "$ref": "#/$defs/date" },
111
+ "end": { "$ref": "#/$defs/date" }
112
+ }
113
+ },
114
+ "period": {
115
+ "if": {
116
+ "type": "object",
117
+ "properties": { "kind": { "const": "instant" } },
118
+ "required": ["kind"]
119
+ },
120
+ "then": { "$ref": "#/$defs/instantPeriod" },
121
+ "else": { "$ref": "#/$defs/durationPeriod" }
122
+ },
123
+ "unavailableValue": {
124
+ "type": "object",
125
+ "additionalProperties": false,
126
+ "required": ["unavailable"],
127
+ "properties": {
128
+ "unavailable": { "const": true }
129
+ }
130
+ },
131
+ "valueCell": {
132
+ "if": { "type": "string" },
133
+ "then": { "$ref": "#/$defs/decimal" },
134
+ "else": {
135
+ "if": { "type": "null" },
136
+ "then": { "type": "null" },
137
+ "else": { "$ref": "#/$defs/unavailableValue" }
138
+ }
139
+ },
140
+ "groupingCell": {
141
+ "if": { "type": "string" },
142
+ "then": { "$ref": "#/$defs/nonEmptyString" },
143
+ "else": { "type": "null" }
144
+ },
145
+ "item": {
146
+ "type": "object",
147
+ "additionalProperties": false,
148
+ "required": ["id", "label", "unit", "values", "groupings"],
149
+ "properties": {
150
+ "id": { "$ref": "#/$defs/id" },
151
+ "label": { "$ref": "#/$defs/nonEmptyString" },
152
+ "description": { "$ref": "#/$defs/nonEmptyString" },
153
+ "unit": { "$ref": "#/$defs/id" },
154
+ "values": {
155
+ "type": "object",
156
+ "propertyNames": { "$ref": "#/$defs/id" },
157
+ "additionalProperties": { "$ref": "#/$defs/valueCell" }
158
+ },
159
+ "groupings": {
160
+ "type": "object",
161
+ "propertyNames": { "$ref": "#/$defs/id" },
162
+ "additionalProperties": { "$ref": "#/$defs/groupingCell" }
163
+ },
164
+ "rollupTo": { "$ref": "#/$defs/id" }
165
+ }
166
+ },
167
+ "statement": {
168
+ "type": "object",
169
+ "additionalProperties": false,
170
+ "required": ["id", "label", "periods", "items"],
171
+ "properties": {
172
+ "id": { "$ref": "#/$defs/id" },
173
+ "label": { "$ref": "#/$defs/nonEmptyString" },
174
+ "periods": {
175
+ "type": "array",
176
+ "minItems": 1,
177
+ "uniqueItems": true,
178
+ "items": { "$ref": "#/$defs/id" }
179
+ },
180
+ "items": {
181
+ "type": "array",
182
+ "minItems": 1,
183
+ "items": { "$ref": "#/$defs/item" }
184
+ }
185
+ }
186
+ },
187
+ "applicationKey": {
188
+ "type": "object",
189
+ "additionalProperties": false,
190
+ "required": ["statement", "parent", "period"],
191
+ "properties": {
192
+ "statement": { "$ref": "#/$defs/id" },
193
+ "parent": { "$ref": "#/$defs/id" },
194
+ "period": { "$ref": "#/$defs/id" }
195
+ }
196
+ },
197
+ "cellIdentity": {
198
+ "type": "object",
199
+ "additionalProperties": false,
200
+ "required": ["statement", "item", "period"],
201
+ "properties": {
202
+ "statement": { "$ref": "#/$defs/id" },
203
+ "item": { "$ref": "#/$defs/id" },
204
+ "period": { "$ref": "#/$defs/id" }
205
+ }
206
+ },
207
+ "satisfiedApplication": {
208
+ "type": "object",
209
+ "additionalProperties": false,
210
+ "required": ["key", "status", "actual", "expected", "difference", "tolerance"],
211
+ "properties": {
212
+ "key": { "$ref": "#/$defs/applicationKey" },
213
+ "status": { "const": "satisfied" },
214
+ "actual": { "$ref": "#/$defs/decimal" },
215
+ "expected": { "$ref": "#/$defs/decimal" },
216
+ "difference": { "$ref": "#/$defs/decimal" },
217
+ "tolerance": { "$ref": "#/$defs/nonNegativeDecimal" }
218
+ }
219
+ },
220
+ "unsatisfiedApplication": {
221
+ "type": "object",
222
+ "additionalProperties": false,
223
+ "required": ["key", "status", "actual", "expected", "difference", "tolerance"],
224
+ "properties": {
225
+ "key": { "$ref": "#/$defs/applicationKey" },
226
+ "status": { "const": "unsatisfied" },
227
+ "actual": { "$ref": "#/$defs/decimal" },
228
+ "expected": { "$ref": "#/$defs/decimal" },
229
+ "difference": { "$ref": "#/$defs/decimal" },
230
+ "tolerance": { "$ref": "#/$defs/nonNegativeDecimal" }
231
+ }
232
+ },
233
+ "errorApplication": {
234
+ "type": "object",
235
+ "additionalProperties": false,
236
+ "required": ["key", "status", "reason", "cell"],
237
+ "properties": {
238
+ "key": { "$ref": "#/$defs/applicationKey" },
239
+ "status": { "const": "error" },
240
+ "reason": { "enum": ["missing-value", "unavailable-value"] },
241
+ "cell": { "$ref": "#/$defs/cellIdentity" }
242
+ }
243
+ },
244
+ "applicationResult": {
245
+ "if": {
246
+ "type": "object",
247
+ "properties": { "status": { "const": "satisfied" } },
248
+ "required": ["status"]
249
+ },
250
+ "then": { "$ref": "#/$defs/satisfiedApplication" },
251
+ "else": {
252
+ "if": {
253
+ "type": "object",
254
+ "properties": { "status": { "const": "unsatisfied" } },
255
+ "required": ["status"]
256
+ },
257
+ "then": { "$ref": "#/$defs/unsatisfiedApplication" },
258
+ "else": { "$ref": "#/$defs/errorApplication" }
259
+ }
260
+ },
261
+ "validationSnapshot": {
262
+ "type": "object",
263
+ "additionalProperties": false,
264
+ "required": ["conformance", "calculations", "applications"],
265
+ "properties": {
266
+ "conformance": { "enum": ["conforming", "nonconforming"] },
267
+ "calculations": { "enum": ["not-run", "not-defined", "consistent", "inconsistent"] },
268
+ "applications": {
269
+ "type": "array",
270
+ "items": { "$ref": "#/$defs/applicationResult" }
271
+ }
272
+ },
273
+ "allOf": [
274
+ {
275
+ "if": {
276
+ "properties": { "conformance": { "const": "nonconforming" } },
277
+ "required": ["conformance"]
278
+ },
279
+ "then": {
280
+ "properties": { "calculations": { "const": "not-run" } }
281
+ },
282
+ "else": {
283
+ "properties": {
284
+ "calculations": { "enum": ["not-defined", "consistent", "inconsistent"] }
285
+ }
286
+ }
287
+ },
288
+ {
289
+ "if": {
290
+ "properties": { "calculations": { "enum": ["not-run", "not-defined"] } },
291
+ "required": ["calculations"]
292
+ },
293
+ "then": {
294
+ "properties": { "applications": { "type": "array", "maxItems": 0 } }
295
+ }
296
+ },
297
+ {
298
+ "if": {
299
+ "properties": { "calculations": { "const": "consistent" } },
300
+ "required": ["calculations"]
301
+ },
302
+ "then": {
303
+ "properties": {
304
+ "applications": {
305
+ "type": "array",
306
+ "minItems": 1,
307
+ "items": { "$ref": "#/$defs/satisfiedApplication" }
308
+ }
309
+ }
310
+ }
311
+ },
312
+ {
313
+ "if": {
314
+ "properties": { "calculations": { "const": "inconsistent" } },
315
+ "required": ["calculations"]
316
+ },
317
+ "then": {
318
+ "properties": {
319
+ "applications": {
320
+ "type": "array",
321
+ "minItems": 1,
322
+ "contains": {
323
+ "type": "object",
324
+ "properties": { "status": { "enum": ["unsatisfied", "error"] } },
325
+ "required": ["status"]
326
+ },
327
+ "minContains": 1
328
+ }
329
+ }
330
+ }
331
+ }
332
+ ]
333
+ }
334
+ }
335
+ }
@@ -0,0 +1,96 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://cpaikr.github.io/fs/schema/0.1/snapshot-diff.schema.json",
4
+ "title": "FS V0 validation snapshot diff",
5
+ "oneOf": [
6
+ {
7
+ "type": "object",
8
+ "additionalProperties": false,
9
+ "required": ["formatVersion", "status"],
10
+ "properties": {
11
+ "formatVersion": { "const": "0.1" },
12
+ "status": { "const": "not-recorded" }
13
+ }
14
+ },
15
+ {
16
+ "type": "object",
17
+ "additionalProperties": false,
18
+ "required": ["formatVersion", "status", "reason"],
19
+ "properties": {
20
+ "formatVersion": { "const": "0.1" },
21
+ "status": { "const": "not-comparable" },
22
+ "reason": { "const": "invalid-snapshot" }
23
+ }
24
+ },
25
+ {
26
+ "type": "object",
27
+ "additionalProperties": false,
28
+ "required": ["formatVersion", "status", "conformance", "calculations", "applications"],
29
+ "properties": {
30
+ "formatVersion": { "const": "0.1" },
31
+ "status": { "enum": ["match", "mismatch"] },
32
+ "conformance": { "$ref": "#/$defs/conformanceComparison" },
33
+ "calculations": { "$ref": "#/$defs/calculationComparison" },
34
+ "applications": {
35
+ "type": "array",
36
+ "items": { "$ref": "#/$defs/applicationChange" }
37
+ }
38
+ }
39
+ }
40
+ ],
41
+ "$defs": {
42
+ "conformanceComparison": {
43
+ "type": "object",
44
+ "additionalProperties": false,
45
+ "required": ["recorded", "current"],
46
+ "properties": {
47
+ "recorded": { "enum": ["conforming", "nonconforming"] },
48
+ "current": { "enum": ["conforming", "nonconforming"] }
49
+ }
50
+ },
51
+ "calculationComparison": {
52
+ "type": "object",
53
+ "additionalProperties": false,
54
+ "required": ["recorded", "current"],
55
+ "properties": {
56
+ "recorded": { "enum": ["not-run", "not-defined", "consistent", "inconsistent"] },
57
+ "current": { "enum": ["not-run", "not-defined", "consistent", "inconsistent"] }
58
+ }
59
+ },
60
+ "unchangedOrChanged": {
61
+ "type": "object",
62
+ "additionalProperties": false,
63
+ "required": ["change", "recorded", "current"],
64
+ "properties": {
65
+ "change": { "enum": ["unchanged", "changed"] },
66
+ "recorded": { "$ref": "fs-document.schema.json#/$defs/applicationResult" },
67
+ "current": { "$ref": "fs-document.schema.json#/$defs/applicationResult" }
68
+ }
69
+ },
70
+ "added": {
71
+ "type": "object",
72
+ "additionalProperties": false,
73
+ "required": ["change", "current"],
74
+ "properties": {
75
+ "change": { "const": "added" },
76
+ "current": { "$ref": "fs-document.schema.json#/$defs/applicationResult" }
77
+ }
78
+ },
79
+ "removed": {
80
+ "type": "object",
81
+ "additionalProperties": false,
82
+ "required": ["change", "recorded"],
83
+ "properties": {
84
+ "change": { "const": "removed" },
85
+ "recorded": { "$ref": "fs-document.schema.json#/$defs/applicationResult" }
86
+ }
87
+ },
88
+ "applicationChange": {
89
+ "oneOf": [
90
+ { "$ref": "#/$defs/unchangedOrChanged" },
91
+ { "$ref": "#/$defs/added" },
92
+ { "$ref": "#/$defs/removed" }
93
+ ]
94
+ }
95
+ }
96
+ }
@@ -0,0 +1,165 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://cpaikr.github.io/fs/schema/0.1/validation-result.schema.json",
4
+ "title": "FS V0 validation result",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["formatVersion", "conformance", "calculations"],
8
+ "properties": {
9
+ "formatVersion": { "const": "0.1" },
10
+ "conformance": { "$ref": "#/$defs/conformanceResult" },
11
+ "calculations": { "$ref": "#/$defs/calculationResult" }
12
+ },
13
+ "allOf": [
14
+ {
15
+ "if": {
16
+ "properties": {
17
+ "conformance": {
18
+ "type": "object",
19
+ "properties": { "status": { "const": "nonconforming" } },
20
+ "required": ["status"]
21
+ }
22
+ }
23
+ },
24
+ "then": {
25
+ "properties": {
26
+ "calculations": {
27
+ "type": "object",
28
+ "properties": { "status": { "const": "not-run" } },
29
+ "required": ["status"]
30
+ }
31
+ }
32
+ },
33
+ "else": {
34
+ "properties": {
35
+ "calculations": {
36
+ "type": "object",
37
+ "properties": {
38
+ "status": { "enum": ["not-defined", "consistent", "inconsistent"] }
39
+ },
40
+ "required": ["status"]
41
+ }
42
+ }
43
+ }
44
+ }
45
+ ],
46
+ "$defs": {
47
+ "diagnosticCode": {
48
+ "enum": [
49
+ "required-property",
50
+ "unknown-property",
51
+ "invalid-type",
52
+ "invalid-value",
53
+ "decimal-string-required",
54
+ "invalid-tolerance",
55
+ "scale-out-of-range",
56
+ "duplicate-id",
57
+ "duplicate-reference",
58
+ "duplicate-period-definition",
59
+ "invalid-date",
60
+ "invalid-duration",
61
+ "unresolved-reference",
62
+ "map-key-mismatch",
63
+ "self-rollup",
64
+ "cyclic-rollup",
65
+ "unit-mismatch",
66
+ "duplicate-application-key"
67
+ ]
68
+ },
69
+ "structuralError": {
70
+ "type": "object",
71
+ "additionalProperties": false,
72
+ "required": ["code", "path", "message"],
73
+ "properties": {
74
+ "code": { "$ref": "#/$defs/diagnosticCode" },
75
+ "path": { "type": "string", "pattern": "^(?:/(?:[^~/]|~[01])*)*$" },
76
+ "message": { "type": "string", "minLength": 1 }
77
+ }
78
+ },
79
+ "conformanceResult": {
80
+ "oneOf": [
81
+ {
82
+ "type": "object",
83
+ "additionalProperties": false,
84
+ "required": ["status", "errors"],
85
+ "properties": {
86
+ "status": { "const": "conforming" },
87
+ "errors": { "type": "array", "maxItems": 0 }
88
+ }
89
+ },
90
+ {
91
+ "type": "object",
92
+ "additionalProperties": false,
93
+ "required": ["status", "errors"],
94
+ "properties": {
95
+ "status": { "const": "nonconforming" },
96
+ "errors": {
97
+ "type": "array",
98
+ "minItems": 1,
99
+ "items": { "$ref": "#/$defs/structuralError" }
100
+ }
101
+ }
102
+ }
103
+ ]
104
+ },
105
+ "calculationResult": {
106
+ "oneOf": [
107
+ {
108
+ "type": "object",
109
+ "additionalProperties": false,
110
+ "required": ["status", "applications"],
111
+ "properties": {
112
+ "status": { "const": "not-run" },
113
+ "applications": { "type": "array", "maxItems": 0 }
114
+ }
115
+ },
116
+ {
117
+ "type": "object",
118
+ "additionalProperties": false,
119
+ "required": ["status", "applications"],
120
+ "properties": {
121
+ "status": { "const": "not-defined" },
122
+ "applications": { "type": "array", "maxItems": 0 }
123
+ }
124
+ },
125
+ {
126
+ "type": "object",
127
+ "additionalProperties": false,
128
+ "required": ["status", "applications"],
129
+ "properties": {
130
+ "status": { "const": "consistent" },
131
+ "applications": {
132
+ "type": "array",
133
+ "minItems": 1,
134
+ "items": {
135
+ "$ref": "fs-document.schema.json#/$defs/satisfiedApplication"
136
+ }
137
+ }
138
+ }
139
+ },
140
+ {
141
+ "type": "object",
142
+ "additionalProperties": false,
143
+ "required": ["status", "applications"],
144
+ "properties": {
145
+ "status": { "const": "inconsistent" },
146
+ "applications": {
147
+ "type": "array",
148
+ "minItems": 1,
149
+ "items": {
150
+ "$ref": "fs-document.schema.json#/$defs/applicationResult"
151
+ },
152
+ "contains": {
153
+ "oneOf": [
154
+ { "$ref": "fs-document.schema.json#/$defs/unsatisfiedApplication" },
155
+ { "$ref": "fs-document.schema.json#/$defs/errorApplication" }
156
+ ]
157
+ },
158
+ "minContains": 1
159
+ }
160
+ }
161
+ }
162
+ ]
163
+ }
164
+ }
165
+ }