@pacp/spec 1.0.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.
@@ -0,0 +1,661 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://pacp.dev/spec/1.0.0/pacp.schema.json",
4
+ "title": "PACP v1.0.0",
5
+ "oneOf": [
6
+ {
7
+ "$ref": "#/$defs/catalogDocument"
8
+ },
9
+ {
10
+ "$ref": "#/$defs/productDocument"
11
+ }
12
+ ],
13
+ "$defs": {
14
+ "catalogDocument": {
15
+ "type": "object",
16
+ "required": ["spec", "document_type", "catalog", "rulesets"],
17
+ "additionalProperties": false,
18
+ "patternProperties": {
19
+ "^x-": true
20
+ },
21
+ "properties": {
22
+ "spec": {
23
+ "type": "string",
24
+ "const": "1.0.0"
25
+ },
26
+ "document_type": {
27
+ "type": "string",
28
+ "const": "CATALOG"
29
+ },
30
+ "catalog": {
31
+ "$ref": "#/$defs/catalog"
32
+ },
33
+ "product_refs": {
34
+ "type": "array",
35
+ "items": {
36
+ "$ref": "#/$defs/productRef"
37
+ }
38
+ },
39
+ "context": {
40
+ "$ref": "#/$defs/context"
41
+ },
42
+ "pricing": {
43
+ "$ref": "#/$defs/pricing"
44
+ },
45
+ "dictionaries": {
46
+ "type": "object",
47
+ "additionalProperties": true,
48
+ "patternProperties": {
49
+ "^x-": true
50
+ }
51
+ },
52
+ "rulesets": {
53
+ "type": "array",
54
+ "minItems": 1,
55
+ "items": {
56
+ "$ref": "#/$defs/ruleset"
57
+ }
58
+ },
59
+ "tables": {
60
+ "type": "array",
61
+ "items": {
62
+ "$ref": "#/$defs/table"
63
+ }
64
+ },
65
+ "dependencies": {
66
+ "type": "array",
67
+ "items": {
68
+ "$ref": "#/$defs/dependency"
69
+ }
70
+ },
71
+ "constraints": {
72
+ "type": "array",
73
+ "items": {
74
+ "$ref": "#/$defs/constraint"
75
+ }
76
+ },
77
+ "profiles": {
78
+ "type": "array",
79
+ "items": { "type": "string", "minLength": 1 }
80
+ }
81
+ }
82
+ },
83
+ "productDocument": {
84
+ "type": "object",
85
+ "required": ["spec", "document_type", "catalog_id", "product"],
86
+ "additionalProperties": false,
87
+ "patternProperties": {
88
+ "^x-": true
89
+ },
90
+ "properties": {
91
+ "spec": {
92
+ "type": "string",
93
+ "const": "1.0.0"
94
+ },
95
+ "document_type": {
96
+ "type": "string",
97
+ "const": "PRODUCT"
98
+ },
99
+ "catalog_id": {
100
+ "type": "string",
101
+ "minLength": 1
102
+ },
103
+ "product": {
104
+ "$ref": "#/$defs/product"
105
+ },
106
+ "rulesets": {
107
+ "type": "array",
108
+ "items": {
109
+ "$ref": "#/$defs/ruleset"
110
+ }
111
+ },
112
+ "tables": {
113
+ "type": "array",
114
+ "items": {
115
+ "$ref": "#/$defs/table"
116
+ }
117
+ },
118
+ "constraints": {
119
+ "type": "array",
120
+ "items": {
121
+ "$ref": "#/$defs/constraint"
122
+ }
123
+ },
124
+ "dependencies": {
125
+ "type": "array",
126
+ "items": {
127
+ "$ref": "#/$defs/dependency"
128
+ }
129
+ },
130
+ "profiles": {
131
+ "type": "array",
132
+ "items": { "type": "string", "minLength": 1 }
133
+ }
134
+ }
135
+ },
136
+ "productRef": {
137
+ "type": "object",
138
+ "required": ["id", "path"],
139
+ "additionalProperties": false,
140
+ "patternProperties": {
141
+ "^x-": true
142
+ },
143
+ "properties": {
144
+ "id": { "type": "string", "minLength": 1 },
145
+ "path": {
146
+ "type": "string",
147
+ "minLength": 1,
148
+ "description": "Relative path from catalog root to the product document file",
149
+ "examples": ["products/SOF-001.json", "products/MES-042.json"]
150
+ }
151
+ }
152
+ },
153
+ "catalog": {
154
+ "type": "object",
155
+ "required": ["id"],
156
+ "additionalProperties": false,
157
+ "patternProperties": {
158
+ "^x-": true
159
+ },
160
+ "properties": {
161
+ "id": { "type": "string", "minLength": 1 },
162
+ "name": { "type": "string", "minLength": 1 },
163
+ "default_price_list_id": { "type": "string", "minLength": 1 },
164
+ "price_lists": {
165
+ "type": "array",
166
+ "items": { "$ref": "#/$defs/priceList" }
167
+ }
168
+ }
169
+ },
170
+ "priceList": {
171
+ "type": "object",
172
+ "required": ["id", "currency"],
173
+ "additionalProperties": false,
174
+ "patternProperties": {
175
+ "^x-": true
176
+ },
177
+ "properties": {
178
+ "id": { "type": "string", "minLength": 1 },
179
+ "label": { "type": "string" },
180
+ "currency": { "type": "string", "minLength": 3, "maxLength": 3 },
181
+ "context_match": {
182
+ "type": "object",
183
+ "additionalProperties": { "$ref": "#/$defs/scalarValue" }
184
+ }
185
+ }
186
+ },
187
+ "context": {
188
+ "type": "object",
189
+ "additionalProperties": false,
190
+ "patternProperties": {
191
+ "^x-": true
192
+ },
193
+ "properties": {
194
+ "price_list_id": { "type": "string", "minLength": 1 },
195
+ "region": { "type": "string" },
196
+ "channel": { "type": "string" },
197
+ "customer": { "type": "string" },
198
+ "lot_id": { "type": "string", "minLength": 1 },
199
+ "requested_quantity": { "type": "number", "exclusiveMinimum": 0 },
200
+ "requested_unit": { "type": "string", "minLength": 1 }
201
+ }
202
+ },
203
+ "pricing": {
204
+ "type": "object",
205
+ "additionalProperties": false,
206
+ "patternProperties": {
207
+ "^x-": true
208
+ },
209
+ "properties": {
210
+ "calculation_mode": {
211
+ "type": "string",
212
+ "enum": ["CASCADE", "TABLE_LOOKUP", "OVERRIDE_BY_VARIANT", "COST_PLUS"]
213
+ }
214
+ }
215
+ },
216
+ "product": {
217
+ "type": "object",
218
+ "required": ["id", "options"],
219
+ "additionalProperties": false,
220
+ "patternProperties": {
221
+ "^x-": true
222
+ },
223
+ "properties": {
224
+ "id": { "type": "string", "minLength": 1 },
225
+ "name": { "type": "string" },
226
+ "sku": { "type": "string", "minLength": 1 },
227
+ "manufacturer": { "type": "string", "minLength": 1 },
228
+ "brand": { "type": "string", "minLength": 1 },
229
+ "description": { "type": "string" },
230
+ "category": { "type": "string", "minLength": 1 },
231
+ "gtin": { "type": "string", "pattern": "^\\d{8,14}$" },
232
+ "base_price": { "type": "number" },
233
+ "images": {
234
+ "type": "array",
235
+ "items": { "$ref": "#/$defs/imageRef" }
236
+ },
237
+ "tags": {
238
+ "type": "array",
239
+ "items": { "type": "string", "minLength": 1 }
240
+ },
241
+ "weight": { "$ref": "#/$defs/measure" },
242
+ "dimensions": { "$ref": "#/$defs/dimensionsObj" },
243
+ "lot_policy": { "$ref": "#/$defs/lotPolicy" },
244
+ "sales_unit": { "$ref": "#/$defs/salesUnit" },
245
+ "attributes": {
246
+ "type": "array",
247
+ "items": { "$ref": "#/$defs/attributeRef" }
248
+ },
249
+ "attribute_values": {
250
+ "type": "array",
251
+ "items": { "$ref": "#/$defs/attributeValue" }
252
+ },
253
+ "options": {
254
+ "type": "array",
255
+ "items": { "$ref": "#/$defs/option" }
256
+ },
257
+ "rulesetIds": {
258
+ "type": "array",
259
+ "items": { "type": "string", "minLength": 1 }
260
+ }
261
+ },
262
+ "allOf": [
263
+ {
264
+ "if": {
265
+ "properties": {
266
+ "lot_policy": {
267
+ "properties": {
268
+ "source": { "const": "ATTRIBUTE" }
269
+ },
270
+ "required": ["source"]
271
+ }
272
+ },
273
+ "required": ["lot_policy"]
274
+ },
275
+ "then": {
276
+ "properties": {
277
+ "lot_policy": {
278
+ "required": ["attributeId"]
279
+ }
280
+ }
281
+ }
282
+ }
283
+ ]
284
+ },
285
+ "lotPolicy": {
286
+ "type": "object",
287
+ "required": ["required", "source"],
288
+ "additionalProperties": false,
289
+ "patternProperties": {
290
+ "^x-": true
291
+ },
292
+ "properties": {
293
+ "required": { "type": "boolean" },
294
+ "source": { "type": "string", "enum": ["CONTEXT", "ATTRIBUTE"] },
295
+ "contextKey": { "type": "string", "minLength": 1 },
296
+ "attributeId": { "type": "string", "minLength": 1 }
297
+ },
298
+ "allOf": [
299
+ {
300
+ "if": { "properties": { "source": { "const": "CONTEXT" } } },
301
+ "then": { "required": ["contextKey"] }
302
+ },
303
+ {
304
+ "if": { "properties": { "source": { "const": "ATTRIBUTE" } } },
305
+ "then": { "required": ["attributeId"] }
306
+ }
307
+ ]
308
+ },
309
+ "salesUnit": {
310
+ "type": "object",
311
+ "required": ["requested_unit", "sell_unit", "quantity_per_sell_unit", "rounding"],
312
+ "additionalProperties": false,
313
+ "patternProperties": {
314
+ "^x-": true
315
+ },
316
+ "properties": {
317
+ "requested_unit": { "type": "string", "minLength": 1 },
318
+ "sell_unit": { "type": "string", "minLength": 1 },
319
+ "quantity_per_sell_unit": { "type": "number", "exclusiveMinimum": 0 },
320
+ "rounding": { "type": "string", "enum": ["CEIL"] },
321
+ "min_sell_units": { "type": "integer", "minimum": 1 }
322
+ }
323
+ },
324
+ "attributeRef": {
325
+ "type": "object",
326
+ "required": ["id"],
327
+ "additionalProperties": false,
328
+ "patternProperties": {
329
+ "^x-": true
330
+ },
331
+ "properties": {
332
+ "id": { "type": "string", "minLength": 1 },
333
+ "label": { "type": "string" }
334
+ }
335
+ },
336
+ "attributeValue": {
337
+ "type": "object",
338
+ "required": ["attributeId", "value"],
339
+ "additionalProperties": false,
340
+ "patternProperties": {
341
+ "^x-": true
342
+ },
343
+ "properties": {
344
+ "attributeId": { "type": "string", "minLength": 1 },
345
+ "label": { "type": "string" },
346
+ "value": { "$ref": "#/$defs/scalarValue" }
347
+ }
348
+ },
349
+ "option": {
350
+ "type": "object",
351
+ "required": ["id", "attributeId", "value"],
352
+ "additionalProperties": false,
353
+ "patternProperties": {
354
+ "^x-": true
355
+ },
356
+ "properties": {
357
+ "id": { "type": "string", "minLength": 1 },
358
+ "attributeId": { "type": "string", "minLength": 1 },
359
+ "label": { "type": "string" },
360
+ "value": { "$ref": "#/$defs/scalarValue" }
361
+ }
362
+ },
363
+ "ruleset": {
364
+ "type": "object",
365
+ "required": ["id", "target", "rules"],
366
+ "additionalProperties": false,
367
+ "patternProperties": {
368
+ "^x-": true
369
+ },
370
+ "properties": {
371
+ "id": { "type": "string", "minLength": 1 },
372
+ "target": {
373
+ "type": "string",
374
+ "enum": ["BASE", "SUBTOTAL", "TOTAL"]
375
+ },
376
+ "rules": {
377
+ "type": "array",
378
+ "items": { "$ref": "#/$defs/rule" }
379
+ }
380
+ }
381
+ },
382
+ "rule": {
383
+ "type": "object",
384
+ "required": ["id", "operation"],
385
+ "additionalProperties": false,
386
+ "patternProperties": {
387
+ "^x-": true
388
+ },
389
+ "properties": {
390
+ "id": { "type": "string", "minLength": 1 },
391
+ "priority": { "type": "integer" },
392
+ "enabled": { "type": "boolean" },
393
+ "when": { "$ref": "#/$defs/condition" },
394
+ "operation": {
395
+ "type": "string",
396
+ "enum": ["ADD", "PERCENT_OF", "OVERRIDE", "LOOKUP", "MAX_OF", "MIN_OF", "PICK", "ROUND", "CAP", "FLOOR"]
397
+ },
398
+ "value": { "type": "number" },
399
+ "percent": { "type": "number" },
400
+ "tableId": { "type": "string", "minLength": 1 },
401
+ "components": {
402
+ "type": "array",
403
+ "items": { "$ref": "#/$defs/component" }
404
+ },
405
+ "precision": { "type": "integer", "minimum": 0 },
406
+ "max": { "type": "number" },
407
+ "min": { "type": "number" },
408
+ "fallback": { "type": "number" },
409
+ "optionId": { "type": "string" },
410
+ "optionIds": {
411
+ "type": "array",
412
+ "items": { "type": "string" }
413
+ }
414
+ },
415
+ "allOf": [
416
+ {
417
+ "if": { "properties": { "operation": { "const": "ADD" } } },
418
+ "then": { "required": ["value"] }
419
+ },
420
+ {
421
+ "if": { "properties": { "operation": { "const": "PERCENT_OF" } } },
422
+ "then": { "required": ["percent"] }
423
+ },
424
+ {
425
+ "if": { "properties": { "operation": { "const": "OVERRIDE" } } },
426
+ "then": { "required": ["value"] }
427
+ },
428
+ {
429
+ "if": { "properties": { "operation": { "const": "LOOKUP" } } },
430
+ "then": { "required": ["tableId"] }
431
+ },
432
+ {
433
+ "if": { "properties": { "operation": { "enum": ["MAX_OF", "MIN_OF", "PICK"] } } },
434
+ "then": { "required": ["components"] }
435
+ },
436
+ {
437
+ "if": { "properties": { "operation": { "const": "ROUND" } } },
438
+ "then": { "required": ["precision"] }
439
+ },
440
+ {
441
+ "if": { "properties": { "operation": { "const": "CAP" } } },
442
+ "then": { "required": ["max"] }
443
+ },
444
+ {
445
+ "if": { "properties": { "operation": { "const": "FLOOR" } } },
446
+ "then": { "required": ["min"] }
447
+ }
448
+ ]
449
+ },
450
+ "component": {
451
+ "type": "object",
452
+ "additionalProperties": false,
453
+ "patternProperties": {
454
+ "^x-": true
455
+ },
456
+ "properties": {
457
+ "label": { "type": "string" },
458
+ "value": { "type": "number" },
459
+ "tableId": { "type": "string" },
460
+ "optionId": { "type": "string" }
461
+ },
462
+ "anyOf": [
463
+ { "required": ["value"] },
464
+ { "required": ["tableId"] }
465
+ ]
466
+ },
467
+ "condition": {
468
+ "type": "object",
469
+ "additionalProperties": false,
470
+ "patternProperties": {
471
+ "^x-": true
472
+ },
473
+ "properties": {
474
+ "all": {
475
+ "type": "array",
476
+ "items": { "$ref": "#/$defs/predicate" }
477
+ },
478
+ "any": {
479
+ "type": "array",
480
+ "items": { "$ref": "#/$defs/predicate" }
481
+ }
482
+ }
483
+ },
484
+ "predicate": {
485
+ "type": "object",
486
+ "required": ["fact", "operator"],
487
+ "additionalProperties": false,
488
+ "patternProperties": {
489
+ "^x-": true
490
+ },
491
+ "properties": {
492
+ "fact": { "type": "string" },
493
+ "operator": {
494
+ "type": "string",
495
+ "enum": ["EQ", "NEQ", "IN", "NOT_IN", "GT", "GTE", "LT", "LTE", "EXISTS"]
496
+ },
497
+ "value": { "$ref": "#/$defs/scalarValue" },
498
+ "values": {
499
+ "type": "array",
500
+ "items": { "$ref": "#/$defs/scalarValue" }
501
+ }
502
+ }
503
+ },
504
+ "table": {
505
+ "type": "object",
506
+ "required": ["id", "type", "dimensions", "rows"],
507
+ "additionalProperties": false,
508
+ "patternProperties": {
509
+ "^x-": true
510
+ },
511
+ "properties": {
512
+ "id": { "type": "string", "minLength": 1 },
513
+ "type": { "type": "string", "enum": ["LOOKUP"] },
514
+ "keys": {
515
+ "type": "array",
516
+ "items": {
517
+ "anyOf": [
518
+ { "type": "string" },
519
+ {
520
+ "type": "object",
521
+ "additionalProperties": false,
522
+ "properties": {
523
+ "optionId": { "type": "string" },
524
+ "id": { "type": "string" },
525
+ "name": { "type": "string" }
526
+ }
527
+ }
528
+ ]
529
+ }
530
+ },
531
+ "dimensions": {
532
+ "type": "array",
533
+ "minItems": 1,
534
+ "items": { "$ref": "#/$defs/dimension" }
535
+ },
536
+ "rows": {
537
+ "type": "array",
538
+ "minItems": 1,
539
+ "items": { "$ref": "#/$defs/tableRow" }
540
+ }
541
+ }
542
+ },
543
+ "dimension": {
544
+ "type": "object",
545
+ "required": ["key", "source"],
546
+ "additionalProperties": false,
547
+ "patternProperties": {
548
+ "^x-": true
549
+ },
550
+ "properties": {
551
+ "key": { "type": "string" },
552
+ "source": { "type": "string", "enum": ["ATTRIBUTE", "CONTEXT", "LITERAL"] },
553
+ "attributeId": { "type": "string" },
554
+ "contextKey": { "type": "string" },
555
+ "literal": { "$ref": "#/$defs/scalarValue" }
556
+ }
557
+ },
558
+ "tableRow": {
559
+ "type": "object",
560
+ "required": ["key", "value"],
561
+ "additionalProperties": false,
562
+ "patternProperties": {
563
+ "^x-": true
564
+ },
565
+ "properties": {
566
+ "key": {
567
+ "type": "object",
568
+ "additionalProperties": { "$ref": "#/$defs/scalarValue" }
569
+ },
570
+ "value": { "type": "number" }
571
+ }
572
+ },
573
+ "dependency": {
574
+ "type": "object",
575
+ "required": ["id", "type"],
576
+ "additionalProperties": false,
577
+ "patternProperties": {
578
+ "^x-": true
579
+ },
580
+ "properties": {
581
+ "id": { "type": "string", "minLength": 1 },
582
+ "type": { "type": "string", "enum": ["REQUIRES", "IMPLIES", "AVAILABLE_OPTIONS_WHEN"] },
583
+ "productId": { "type": "string" },
584
+ "optionId": { "type": "string" },
585
+ "requiresOptionIds": {
586
+ "type": "array",
587
+ "items": { "type": "string" }
588
+ },
589
+ "allowedOptionIds": {
590
+ "type": "array",
591
+ "items": { "type": "string" }
592
+ },
593
+ "when": { "$ref": "#/$defs/condition" }
594
+ }
595
+ },
596
+ "constraint": {
597
+ "type": "object",
598
+ "required": ["id", "type", "when", "message"],
599
+ "additionalProperties": false,
600
+ "patternProperties": {
601
+ "^x-": true
602
+ },
603
+ "properties": {
604
+ "id": { "type": "string", "minLength": 1 },
605
+ "type": { "type": "string", "enum": ["DENY"] },
606
+ "productId": { "type": "string" },
607
+ "optionIds": {
608
+ "type": "array",
609
+ "items": { "type": "string" }
610
+ },
611
+ "when": { "$ref": "#/$defs/condition" },
612
+ "message": { "type": "string", "minLength": 1 }
613
+ }
614
+ },
615
+ "imageRef": {
616
+ "type": "object",
617
+ "required": ["url"],
618
+ "additionalProperties": false,
619
+ "patternProperties": {
620
+ "^x-": true
621
+ },
622
+ "properties": {
623
+ "url": { "type": "string", "format": "uri" },
624
+ "label": { "type": "string" },
625
+ "type": {
626
+ "type": "string",
627
+ "enum": ["MAIN", "DETAIL", "AMBIANCE", "TECHNICAL", "OTHER"]
628
+ }
629
+ }
630
+ },
631
+ "measure": {
632
+ "type": "object",
633
+ "required": ["value", "unit"],
634
+ "additionalProperties": false,
635
+ "patternProperties": {
636
+ "^x-": true
637
+ },
638
+ "properties": {
639
+ "value": { "type": "number", "exclusiveMinimum": 0 },
640
+ "unit": { "type": "string", "minLength": 1 }
641
+ }
642
+ },
643
+ "dimensionsObj": {
644
+ "type": "object",
645
+ "required": ["unit"],
646
+ "additionalProperties": false,
647
+ "patternProperties": {
648
+ "^x-": true
649
+ },
650
+ "properties": {
651
+ "width": { "type": "number", "exclusiveMinimum": 0 },
652
+ "height": { "type": "number", "exclusiveMinimum": 0 },
653
+ "depth": { "type": "number", "exclusiveMinimum": 0 },
654
+ "unit": { "type": "string", "minLength": 1 }
655
+ }
656
+ },
657
+ "scalarValue": {
658
+ "type": ["string", "number", "boolean"]
659
+ }
660
+ }
661
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://pacp.dev/spec/1.0.0/profiles/fiscal-br.schema.json",
4
+ "title": "PACP Profile: Fiscal Brasil",
5
+ "description": "Extension profile para dados fiscais brasileiros. Define campos x-* recomendados para compliance fiscal no Brasil.",
6
+ "type": "object",
7
+ "properties": {
8
+ "x-ncm": {
9
+ "type": "string",
10
+ "pattern": "^\\d{8}$",
11
+ "description": "Codigo NCM (Nomenclatura Comum do Mercosul) com 8 digitos."
12
+ },
13
+ "x-origem": {
14
+ "type": "string",
15
+ "enum": [
16
+ "0", "1", "2", "3", "4", "5", "6", "7", "8"
17
+ ],
18
+ "description": "Codigo de origem da mercadoria (tabela CSOSN/CST): 0=Nacional, 1=Estrangeira importacao direta, 2=Estrangeira adquirida mercado interno, etc."
19
+ },
20
+ "x-cest": {
21
+ "type": "string",
22
+ "pattern": "^\\d{7}$",
23
+ "description": "Codigo CEST (Codigo Especificador da Substituicao Tributaria) com 7 digitos."
24
+ },
25
+ "x-cfop": {
26
+ "type": "string",
27
+ "pattern": "^\\d{4}$",
28
+ "description": "CFOP padrao para operacoes com o produto (4 digitos)."
29
+ },
30
+ "x-unidade_tributaria": {
31
+ "type": "string",
32
+ "minLength": 1,
33
+ "description": "Unidade tributaria para calculo de impostos (ex: 'UN', 'KG', 'M2')."
34
+ }
35
+ },
36
+ "additionalProperties": true
37
+ }