@pact-foundation/pact-core 13.12.1 → 13.12.2
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 +7 -0
- package/build/Makefile +2 -2
- package/build/pact.target.mk +14 -14
- package/ffi/libpact_ffi.dylib +0 -0
- package/ffi/libpact_ffi.so +0 -0
- package/ffi/libpact_ffi.so.gz +0 -0
- package/ffi/linuxaarch64/libpact_ffi.so +0 -0
- package/ffi/osxaarch64/libpact_ffi.dylib +0 -0
- package/ffi/pact-cpp.h +267 -0
- package/ffi/pact.h +266 -0
- package/ffi/pact_ffi.dll +0 -0
- package/ffi/pact_ffi.dll.lib +0 -0
- package/package.json +1 -1
- package/src/ffi/index.d.ts +1 -1
- package/src/ffi/index.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [13.12.2](https://github.com/pact-foundation/pact-js-core/compare/v13.12.1...v13.12.2) (2022-11-28)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Fixes and Improvements
|
|
9
|
+
|
|
10
|
+
* upgrade to ffi 0.3.15 ([0da476d](https://github.com/pact-foundation/pact-js-core/commit/0da476dbd342f64234515572408fd43b28b5085b))
|
|
11
|
+
|
|
5
12
|
### [13.12.1](https://github.com/pact-foundation/pact-js-core/compare/v13.12.0...v13.12.1) (2022-11-24)
|
|
6
13
|
|
|
7
14
|
|
package/build/Makefile
CHANGED
|
@@ -318,8 +318,8 @@ ifeq ($(strip $(foreach prefix,$(NO_LOAD),\
|
|
|
318
318
|
endif
|
|
319
319
|
|
|
320
320
|
quiet_cmd_regen_makefile = ACTION Regenerating $@
|
|
321
|
-
cmd_regen_makefile = cd $(srcdir); /opt/hostedtoolcache/node/16.18.
|
|
322
|
-
Makefile: $(srcdir)/
|
|
321
|
+
cmd_regen_makefile = cd $(srcdir); /opt/hostedtoolcache/node/16.18.1/x64/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/home/runner/.cache/node-gyp/16.18.1" "-Dnode_gyp_dir=/opt/hostedtoolcache/node/16.18.1/x64/lib/node_modules/npm/node_modules/node-gyp" "-Dnode_lib_file=/home/runner/.cache/node-gyp/16.18.1/<(target_arch)/node.lib" "-Dmodule_root_dir=/home/runner/work/pact-js-core/pact-js-core" "-Dnode_engine=v8" "--depth=." "-Goutput_dir=." "--generator-output=build" -I/home/runner/work/pact-js-core/pact-js-core/build/config.gypi -I/opt/hostedtoolcache/node/16.18.1/x64/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/home/runner/.cache/node-gyp/16.18.1/include/node/common.gypi "--toplevel-dir=." binding.gyp
|
|
322
|
+
Makefile: $(srcdir)/build/config.gypi $(srcdir)/../../../.cache/node-gyp/16.18.1/include/node/common.gypi $(srcdir)/../../../../../opt/hostedtoolcache/node/16.18.1/x64/lib/node_modules/npm/node_modules/node-gyp/addon.gypi $(srcdir)/binding.gyp
|
|
323
323
|
$(call do_cmd,regen_makefile)
|
|
324
324
|
|
|
325
325
|
# "all" is a concatenation of the "all" targets from all the included
|
package/build/pact.target.mk
CHANGED
|
@@ -42,13 +42,13 @@ CFLAGS_CC_Debug := \
|
|
|
42
42
|
-Werror
|
|
43
43
|
|
|
44
44
|
INCS_Debug := \
|
|
45
|
-
-I/home/runner/.cache/node-gyp/16.18.
|
|
46
|
-
-I/home/runner/.cache/node-gyp/16.18.
|
|
47
|
-
-I/home/runner/.cache/node-gyp/16.18.
|
|
48
|
-
-I/home/runner/.cache/node-gyp/16.18.
|
|
49
|
-
-I/home/runner/.cache/node-gyp/16.18.
|
|
50
|
-
-I/home/runner/.cache/node-gyp/16.18.
|
|
51
|
-
-I/home/runner/.cache/node-gyp/16.18.
|
|
45
|
+
-I/home/runner/.cache/node-gyp/16.18.1/include/node \
|
|
46
|
+
-I/home/runner/.cache/node-gyp/16.18.1/src \
|
|
47
|
+
-I/home/runner/.cache/node-gyp/16.18.1/deps/openssl/config \
|
|
48
|
+
-I/home/runner/.cache/node-gyp/16.18.1/deps/openssl/openssl/include \
|
|
49
|
+
-I/home/runner/.cache/node-gyp/16.18.1/deps/uv/include \
|
|
50
|
+
-I/home/runner/.cache/node-gyp/16.18.1/deps/zlib \
|
|
51
|
+
-I/home/runner/.cache/node-gyp/16.18.1/deps/v8/include \
|
|
52
52
|
-I$(srcdir)/node_modules/node-addon-api \
|
|
53
53
|
-I/home/runner/work/pact-js-core/pact-js-core/native \
|
|
54
54
|
-I/home/runner/work/pact-js-core/pact-js-core/ffi
|
|
@@ -90,13 +90,13 @@ CFLAGS_CC_Release := \
|
|
|
90
90
|
-Werror
|
|
91
91
|
|
|
92
92
|
INCS_Release := \
|
|
93
|
-
-I/home/runner/.cache/node-gyp/16.18.
|
|
94
|
-
-I/home/runner/.cache/node-gyp/16.18.
|
|
95
|
-
-I/home/runner/.cache/node-gyp/16.18.
|
|
96
|
-
-I/home/runner/.cache/node-gyp/16.18.
|
|
97
|
-
-I/home/runner/.cache/node-gyp/16.18.
|
|
98
|
-
-I/home/runner/.cache/node-gyp/16.18.
|
|
99
|
-
-I/home/runner/.cache/node-gyp/16.18.
|
|
93
|
+
-I/home/runner/.cache/node-gyp/16.18.1/include/node \
|
|
94
|
+
-I/home/runner/.cache/node-gyp/16.18.1/src \
|
|
95
|
+
-I/home/runner/.cache/node-gyp/16.18.1/deps/openssl/config \
|
|
96
|
+
-I/home/runner/.cache/node-gyp/16.18.1/deps/openssl/openssl/include \
|
|
97
|
+
-I/home/runner/.cache/node-gyp/16.18.1/deps/uv/include \
|
|
98
|
+
-I/home/runner/.cache/node-gyp/16.18.1/deps/zlib \
|
|
99
|
+
-I/home/runner/.cache/node-gyp/16.18.1/deps/v8/include \
|
|
100
100
|
-I$(srcdir)/node_modules/node-addon-api \
|
|
101
101
|
-I/home/runner/work/pact-js-core/pact-js-core/native \
|
|
102
102
|
-I/home/runner/work/pact-js-core/pact-js-core/ffi
|
package/ffi/libpact_ffi.dylib
CHANGED
|
Binary file
|
package/ffi/libpact_ffi.so
CHANGED
|
Binary file
|
package/ffi/libpact_ffi.so.gz
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/ffi/pact-cpp.h
CHANGED
|
@@ -17,6 +17,36 @@
|
|
|
17
17
|
#include <ostream>
|
|
18
18
|
#include <new>
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* The type of value detected after parsing the expression
|
|
22
|
+
*/
|
|
23
|
+
enum class ExpressionValueType {
|
|
24
|
+
/**
|
|
25
|
+
* If the type is unknown
|
|
26
|
+
*/
|
|
27
|
+
ExpressionValueType_Unknown,
|
|
28
|
+
/**
|
|
29
|
+
* String type
|
|
30
|
+
*/
|
|
31
|
+
ExpressionValueType_String,
|
|
32
|
+
/**
|
|
33
|
+
* Numeric type
|
|
34
|
+
*/
|
|
35
|
+
ExpressionValueType_Number,
|
|
36
|
+
/**
|
|
37
|
+
* Integer numeric type (no significant figures after the decimal point)
|
|
38
|
+
*/
|
|
39
|
+
ExpressionValueType_Integer,
|
|
40
|
+
/**
|
|
41
|
+
* Decimal numeric type (at least one significant figure after the decimal point)
|
|
42
|
+
*/
|
|
43
|
+
ExpressionValueType_Decimal,
|
|
44
|
+
/**
|
|
45
|
+
* Boolean type
|
|
46
|
+
*/
|
|
47
|
+
ExpressionValueType_Boolean,
|
|
48
|
+
};
|
|
49
|
+
|
|
20
50
|
/**
|
|
21
51
|
* Request or Response enum
|
|
22
52
|
*/
|
|
@@ -81,6 +111,26 @@ enum class PactSpecification {
|
|
|
81
111
|
*/
|
|
82
112
|
struct Consumer;
|
|
83
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Trait to represent a generator
|
|
116
|
+
*/
|
|
117
|
+
struct Generator;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Set of all matching rules
|
|
121
|
+
*/
|
|
122
|
+
struct MatchingRule;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Result of parsing a matching rule definition
|
|
126
|
+
*/
|
|
127
|
+
struct MatchingRuleDefinitionResult;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* An iterator over the matching rules from a matching definition expression.
|
|
131
|
+
*/
|
|
132
|
+
struct MatchingRuleIterator;
|
|
133
|
+
|
|
84
134
|
/**
|
|
85
135
|
* Struct that defines a message.
|
|
86
136
|
*/
|
|
@@ -129,6 +179,11 @@ struct Mismatches;
|
|
|
129
179
|
*/
|
|
130
180
|
struct MismatchesIterator;
|
|
131
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Opaque type for use as a pointer to a Pact model
|
|
184
|
+
*/
|
|
185
|
+
struct Pact;
|
|
186
|
+
|
|
132
187
|
/**
|
|
133
188
|
* An iterator over messages in a pact.
|
|
134
189
|
*/
|
|
@@ -228,6 +283,65 @@ struct ProviderStateParamPair {
|
|
|
228
283
|
const char *value;
|
|
229
284
|
};
|
|
230
285
|
|
|
286
|
+
/**
|
|
287
|
+
* The matching rule or reference from parsing the matching definition expression.
|
|
288
|
+
*
|
|
289
|
+
* For matching rules, the ID corresponds to the following rules:
|
|
290
|
+
* | Rule | ID |
|
|
291
|
+
* | ---- | -- |
|
|
292
|
+
* | Equality | 1 |
|
|
293
|
+
* | Regex | 2 |
|
|
294
|
+
* | Type | 3 |
|
|
295
|
+
* | MinType | 4 |
|
|
296
|
+
* | MaxType | 5 |
|
|
297
|
+
* | MinMaxType | 6 |
|
|
298
|
+
* | Timestamp | 7 |
|
|
299
|
+
* | Time | 8 |
|
|
300
|
+
* | Date | 9 |
|
|
301
|
+
* | Include | 10 |
|
|
302
|
+
* | Number | 11 |
|
|
303
|
+
* | Integer | 12 |
|
|
304
|
+
* | Decimal | 13 |
|
|
305
|
+
* | Null | 14 |
|
|
306
|
+
* | ContentType | 15 |
|
|
307
|
+
* | ArrayContains | 16 |
|
|
308
|
+
* | Values | 17 |
|
|
309
|
+
* | Boolean | 18 |
|
|
310
|
+
* | StatusCode | 19 |
|
|
311
|
+
* | NotEmpty | 20 |
|
|
312
|
+
* | Semver | 21 |
|
|
313
|
+
* | EachKey | 22 |
|
|
314
|
+
* | EachValue | 23 |
|
|
315
|
+
*/
|
|
316
|
+
struct MatchingRuleResult {
|
|
317
|
+
enum class Tag {
|
|
318
|
+
/**
|
|
319
|
+
* The matching rule from the expression.
|
|
320
|
+
*/
|
|
321
|
+
MatchingRuleResult_MatchingRule,
|
|
322
|
+
/**
|
|
323
|
+
* A reference to a named item.
|
|
324
|
+
*/
|
|
325
|
+
MatchingRuleResult_MatchingReference,
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
struct MatchingRuleResult_MatchingRule_Body {
|
|
329
|
+
uint16_t _0;
|
|
330
|
+
const char *_1;
|
|
331
|
+
const MatchingRule *_2;
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
struct MatchingRuleResult_MatchingReference_Body {
|
|
335
|
+
const char *_0;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
Tag tag;
|
|
339
|
+
union {
|
|
340
|
+
MatchingRuleResult_MatchingRule_Body matching_rule;
|
|
341
|
+
MatchingRuleResult_MatchingReference_Body matching_reference;
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
|
|
231
345
|
/**
|
|
232
346
|
* Wraps a Pact model struct
|
|
233
347
|
*/
|
|
@@ -529,6 +643,21 @@ int pactffi_logger_apply();
|
|
|
529
643
|
*/
|
|
530
644
|
const char *pactffi_fetch_log_buffer(const char *log_id);
|
|
531
645
|
|
|
646
|
+
/**
|
|
647
|
+
* Parses the provided JSON into a Pact model. The returned Pact model must be freed with the
|
|
648
|
+
* `pactffi_pact_model_delete` function when no longer needed.
|
|
649
|
+
*
|
|
650
|
+
* # Error Handling
|
|
651
|
+
*
|
|
652
|
+
* This function will return a NULL pointer if passed a NULL pointer or if an error occurs.
|
|
653
|
+
*/
|
|
654
|
+
Pact *pactffi_parse_pact_json(const char *json);
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* Frees the memory used by the Pact model
|
|
658
|
+
*/
|
|
659
|
+
void pactffi_pact_model_delete(Pact *pact);
|
|
660
|
+
|
|
532
661
|
/**
|
|
533
662
|
* Get a copy of this consumer's name.
|
|
534
663
|
*
|
|
@@ -1766,6 +1895,144 @@ const ProviderState *pactffi_sync_http_get_provider_state(const SynchronousHttp
|
|
|
1766
1895
|
*/
|
|
1767
1896
|
ProviderStateIterator *pactffi_sync_http_get_provider_state_iter(SynchronousHttp *interaction);
|
|
1768
1897
|
|
|
1898
|
+
/**
|
|
1899
|
+
* Parse a matcher definition string into a MatchingRuleDefinition containing the example value,
|
|
1900
|
+
* and matching rules and any generator.
|
|
1901
|
+
*
|
|
1902
|
+
* The following are examples of matching rule definitions:
|
|
1903
|
+
* * `matching(type,'Name')` - type matcher with string value 'Name'
|
|
1904
|
+
* * `matching(number,100)` - number matcher
|
|
1905
|
+
* * `matching(datetime, 'yyyy-MM-dd','2000-01-01')` - datetime matcher with format string
|
|
1906
|
+
*
|
|
1907
|
+
* See [Matching Rule definition expressions](https://docs.rs/pact_models/latest/pact_models/matchingrules/expressions/index.html).
|
|
1908
|
+
*
|
|
1909
|
+
* The returned value needs to be freed up with the `pactffi_matcher_definition_delete` function.
|
|
1910
|
+
*
|
|
1911
|
+
* # Errors
|
|
1912
|
+
* If the expression is invalid, the MatchingRuleDefinition error will be set. You can check for
|
|
1913
|
+
* this value with the `pactffi_matcher_definition_error` function.
|
|
1914
|
+
*
|
|
1915
|
+
* # Safety
|
|
1916
|
+
*
|
|
1917
|
+
* This function is safe if the expression is a valid NULL terminated string pointer.
|
|
1918
|
+
*/
|
|
1919
|
+
const MatchingRuleDefinitionResult *pactffi_parse_matcher_definition(const char *expression);
|
|
1920
|
+
|
|
1921
|
+
/**
|
|
1922
|
+
* Returns any error message from parsing a matching definition expression. If there is no error,
|
|
1923
|
+
* it will return a NULL pointer, otherwise returns the error message as a NULL-terminated string.
|
|
1924
|
+
* The returned string must be freed using the `pactffi_string_delete` function once done with it.
|
|
1925
|
+
*/
|
|
1926
|
+
const char *pactffi_matcher_definition_error(const MatchingRuleDefinitionResult *definition);
|
|
1927
|
+
|
|
1928
|
+
/**
|
|
1929
|
+
* Returns the value from parsing a matching definition expression. If there was an error,
|
|
1930
|
+
* it will return a NULL pointer, otherwise returns the value as a NULL-terminated string.
|
|
1931
|
+
* The returned string must be freed using the `pactffi_string_delete` function once done with it.
|
|
1932
|
+
*
|
|
1933
|
+
* Note that different expressions values can have types other than a string. Use
|
|
1934
|
+
* `pactffi_matcher_definition_value_type` to get the actual type of the value. This function
|
|
1935
|
+
* will always return the string representation of the value.
|
|
1936
|
+
*/
|
|
1937
|
+
const char *pactffi_matcher_definition_value(const MatchingRuleDefinitionResult *definition);
|
|
1938
|
+
|
|
1939
|
+
/**
|
|
1940
|
+
* Frees the memory used by the result of parsing the matching definition expression
|
|
1941
|
+
*/
|
|
1942
|
+
void pactffi_matcher_definition_delete(const MatchingRuleDefinitionResult *definition);
|
|
1943
|
+
|
|
1944
|
+
/**
|
|
1945
|
+
* Returns the generator from parsing a matching definition expression. If there was an error or
|
|
1946
|
+
* there is no associated generator, it will return a NULL pointer, otherwise returns the generator
|
|
1947
|
+
* as a pointer.
|
|
1948
|
+
*
|
|
1949
|
+
* The generator pointer will be a valid pointer as long as `pactffi_matcher_definition_delete`
|
|
1950
|
+
* has not been called on the definition. Using the generator pointer after the definition
|
|
1951
|
+
* has been deleted will result in undefined behaviour.
|
|
1952
|
+
*/
|
|
1953
|
+
const Generator *pactffi_matcher_definition_generator(const MatchingRuleDefinitionResult *definition);
|
|
1954
|
+
|
|
1955
|
+
/**
|
|
1956
|
+
* Returns the type of the value from parsing a matching definition expression. If there was an
|
|
1957
|
+
* error parsing the expression, it will return Unknown.
|
|
1958
|
+
*/
|
|
1959
|
+
ExpressionValueType pactffi_matcher_definition_value_type(const MatchingRuleDefinitionResult *definition);
|
|
1960
|
+
|
|
1961
|
+
/**
|
|
1962
|
+
* Free the iterator when you're done using it.
|
|
1963
|
+
*/
|
|
1964
|
+
void pactffi_matching_rule_iter_delete(MatchingRuleIterator *iter);
|
|
1965
|
+
|
|
1966
|
+
/**
|
|
1967
|
+
* Returns an iterator over the matching rules from the parsed definition. The iterator needs to
|
|
1968
|
+
* be deleted with the `pactffi_matching_rule_iter_delete` function once done with it.
|
|
1969
|
+
*
|
|
1970
|
+
* If there was an error parsing the expression, this function will return a NULL pointer.
|
|
1971
|
+
*/
|
|
1972
|
+
MatchingRuleIterator *pactffi_matcher_definition_iter(const MatchingRuleDefinitionResult *definition);
|
|
1973
|
+
|
|
1974
|
+
/**
|
|
1975
|
+
* Get the next matching rule or reference from the iterator. As the values returned are owned
|
|
1976
|
+
* by the iterator, they do not need to be deleted but will be cleaned up when the iterator is
|
|
1977
|
+
* deleted.
|
|
1978
|
+
*
|
|
1979
|
+
* Will return a NULL pointer when the iterator has advanced past the end of the list.
|
|
1980
|
+
*
|
|
1981
|
+
* # Safety
|
|
1982
|
+
*
|
|
1983
|
+
* This function is safe.
|
|
1984
|
+
*
|
|
1985
|
+
* # Error Handling
|
|
1986
|
+
*
|
|
1987
|
+
* This function will return a NULL pointer if passed a NULL pointer or if an error occurs.
|
|
1988
|
+
*/
|
|
1989
|
+
const MatchingRuleResult *pactffi_matching_rule_iter_next(MatchingRuleIterator *iter);
|
|
1990
|
+
|
|
1991
|
+
/**
|
|
1992
|
+
* Get the JSON form of the matching rule.
|
|
1993
|
+
*
|
|
1994
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1995
|
+
*
|
|
1996
|
+
* # Safety
|
|
1997
|
+
*
|
|
1998
|
+
* This function will fail if it is passed a NULL pointer, or the iterator that owns the
|
|
1999
|
+
* value of the matching rule has been deleted.
|
|
2000
|
+
*/
|
|
2001
|
+
const char *pactffi_matching_rule_to_json(const MatchingRule *rule);
|
|
2002
|
+
|
|
2003
|
+
/**
|
|
2004
|
+
* Get the JSON form of the generator.
|
|
2005
|
+
*
|
|
2006
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
2007
|
+
*
|
|
2008
|
+
* # Safety
|
|
2009
|
+
*
|
|
2010
|
+
* This function will fail if it is passed a NULL pointer, or the owner of the generator has
|
|
2011
|
+
* been deleted.
|
|
2012
|
+
*/
|
|
2013
|
+
const char *pactffi_generator_to_json(const Generator *generator);
|
|
2014
|
+
|
|
2015
|
+
/**
|
|
2016
|
+
* Generate a string value using the provided generator and an optional JSON payload containing
|
|
2017
|
+
* any generator context. The context value is used for generators like `MockServerURL` (which
|
|
2018
|
+
* should contain details about the running mock server) and `ProviderStateGenerator` (which
|
|
2019
|
+
* should be the values returned from the Provider State callback function).
|
|
2020
|
+
*
|
|
2021
|
+
* If anything goes wrong, it will return a NULL pointer.
|
|
2022
|
+
*/
|
|
2023
|
+
const char *pactffi_generator_generate_string(const Generator *generator, const char *context_json);
|
|
2024
|
+
|
|
2025
|
+
/**
|
|
2026
|
+
* Generate an integer value using the provided generator and an optional JSON payload containing
|
|
2027
|
+
* any generator context. The context value is used for generators like `ProviderStateGenerator`
|
|
2028
|
+
* (which should be the values returned from the Provider State callback function).
|
|
2029
|
+
*
|
|
2030
|
+
* If anything goes wrong or the generator is not a type that can generate an integer value, it
|
|
2031
|
+
* will return a zero value.
|
|
2032
|
+
*/
|
|
2033
|
+
unsigned short pactffi_generator_generate_integer(const Generator *generator,
|
|
2034
|
+
const char *context_json);
|
|
2035
|
+
|
|
1769
2036
|
/**
|
|
1770
2037
|
* Delete a string previously returned by this FFI.
|
|
1771
2038
|
*
|
package/ffi/pact.h
CHANGED
|
@@ -16,6 +16,36 @@
|
|
|
16
16
|
#include <stdint.h>
|
|
17
17
|
#include <stdlib.h>
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* The type of value detected after parsing the expression
|
|
21
|
+
*/
|
|
22
|
+
typedef enum ExpressionValueType {
|
|
23
|
+
/**
|
|
24
|
+
* If the type is unknown
|
|
25
|
+
*/
|
|
26
|
+
ExpressionValueType_Unknown,
|
|
27
|
+
/**
|
|
28
|
+
* String type
|
|
29
|
+
*/
|
|
30
|
+
ExpressionValueType_String,
|
|
31
|
+
/**
|
|
32
|
+
* Numeric type
|
|
33
|
+
*/
|
|
34
|
+
ExpressionValueType_Number,
|
|
35
|
+
/**
|
|
36
|
+
* Integer numeric type (no significant figures after the decimal point)
|
|
37
|
+
*/
|
|
38
|
+
ExpressionValueType_Integer,
|
|
39
|
+
/**
|
|
40
|
+
* Decimal numeric type (at least one significant figure after the decimal point)
|
|
41
|
+
*/
|
|
42
|
+
ExpressionValueType_Decimal,
|
|
43
|
+
/**
|
|
44
|
+
* Boolean type
|
|
45
|
+
*/
|
|
46
|
+
ExpressionValueType_Boolean,
|
|
47
|
+
} ExpressionValueType;
|
|
48
|
+
|
|
19
49
|
/**
|
|
20
50
|
* Request or Response enum
|
|
21
51
|
*/
|
|
@@ -80,6 +110,26 @@ typedef enum PactSpecification {
|
|
|
80
110
|
*/
|
|
81
111
|
typedef struct Consumer Consumer;
|
|
82
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Trait to represent a generator
|
|
115
|
+
*/
|
|
116
|
+
typedef struct Generator Generator;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Set of all matching rules
|
|
120
|
+
*/
|
|
121
|
+
typedef struct MatchingRule MatchingRule;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Result of parsing a matching rule definition
|
|
125
|
+
*/
|
|
126
|
+
typedef struct MatchingRuleDefinitionResult MatchingRuleDefinitionResult;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* An iterator over the matching rules from a matching definition expression.
|
|
130
|
+
*/
|
|
131
|
+
typedef struct MatchingRuleIterator MatchingRuleIterator;
|
|
132
|
+
|
|
83
133
|
/**
|
|
84
134
|
* Struct that defines a message.
|
|
85
135
|
*/
|
|
@@ -128,6 +178,11 @@ typedef struct Mismatches Mismatches;
|
|
|
128
178
|
*/
|
|
129
179
|
typedef struct MismatchesIterator MismatchesIterator;
|
|
130
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Opaque type for use as a pointer to a Pact model
|
|
183
|
+
*/
|
|
184
|
+
typedef struct Pact Pact;
|
|
185
|
+
|
|
131
186
|
/**
|
|
132
187
|
* An iterator over messages in a pact.
|
|
133
188
|
*/
|
|
@@ -227,6 +282,63 @@ typedef struct ProviderStateParamPair {
|
|
|
227
282
|
const char *value;
|
|
228
283
|
} ProviderStateParamPair;
|
|
229
284
|
|
|
285
|
+
/**
|
|
286
|
+
* The matching rule or reference from parsing the matching definition expression.
|
|
287
|
+
*
|
|
288
|
+
* For matching rules, the ID corresponds to the following rules:
|
|
289
|
+
* | Rule | ID |
|
|
290
|
+
* | ---- | -- |
|
|
291
|
+
* | Equality | 1 |
|
|
292
|
+
* | Regex | 2 |
|
|
293
|
+
* | Type | 3 |
|
|
294
|
+
* | MinType | 4 |
|
|
295
|
+
* | MaxType | 5 |
|
|
296
|
+
* | MinMaxType | 6 |
|
|
297
|
+
* | Timestamp | 7 |
|
|
298
|
+
* | Time | 8 |
|
|
299
|
+
* | Date | 9 |
|
|
300
|
+
* | Include | 10 |
|
|
301
|
+
* | Number | 11 |
|
|
302
|
+
* | Integer | 12 |
|
|
303
|
+
* | Decimal | 13 |
|
|
304
|
+
* | Null | 14 |
|
|
305
|
+
* | ContentType | 15 |
|
|
306
|
+
* | ArrayContains | 16 |
|
|
307
|
+
* | Values | 17 |
|
|
308
|
+
* | Boolean | 18 |
|
|
309
|
+
* | StatusCode | 19 |
|
|
310
|
+
* | NotEmpty | 20 |
|
|
311
|
+
* | Semver | 21 |
|
|
312
|
+
* | EachKey | 22 |
|
|
313
|
+
* | EachValue | 23 |
|
|
314
|
+
*/
|
|
315
|
+
typedef enum MatchingRuleResult_Tag {
|
|
316
|
+
/**
|
|
317
|
+
* The matching rule from the expression.
|
|
318
|
+
*/
|
|
319
|
+
MatchingRuleResult_MatchingRule,
|
|
320
|
+
/**
|
|
321
|
+
* A reference to a named item.
|
|
322
|
+
*/
|
|
323
|
+
MatchingRuleResult_MatchingReference,
|
|
324
|
+
} MatchingRuleResult_Tag;
|
|
325
|
+
|
|
326
|
+
typedef struct MatchingRuleResult_MatchingRule_Body {
|
|
327
|
+
uint16_t _0;
|
|
328
|
+
const char *_1;
|
|
329
|
+
const struct MatchingRule *_2;
|
|
330
|
+
} MatchingRuleResult_MatchingRule_Body;
|
|
331
|
+
|
|
332
|
+
typedef struct MatchingRuleResult {
|
|
333
|
+
MatchingRuleResult_Tag tag;
|
|
334
|
+
union {
|
|
335
|
+
MatchingRuleResult_MatchingRule_Body matching_rule;
|
|
336
|
+
struct {
|
|
337
|
+
const char *matching_reference;
|
|
338
|
+
};
|
|
339
|
+
};
|
|
340
|
+
} MatchingRuleResult;
|
|
341
|
+
|
|
230
342
|
/**
|
|
231
343
|
* Wraps a Pact model struct
|
|
232
344
|
*/
|
|
@@ -523,6 +635,21 @@ int pactffi_logger_apply(void);
|
|
|
523
635
|
*/
|
|
524
636
|
const char *pactffi_fetch_log_buffer(const char *log_id);
|
|
525
637
|
|
|
638
|
+
/**
|
|
639
|
+
* Parses the provided JSON into a Pact model. The returned Pact model must be freed with the
|
|
640
|
+
* `pactffi_pact_model_delete` function when no longer needed.
|
|
641
|
+
*
|
|
642
|
+
* # Error Handling
|
|
643
|
+
*
|
|
644
|
+
* This function will return a NULL pointer if passed a NULL pointer or if an error occurs.
|
|
645
|
+
*/
|
|
646
|
+
struct Pact *pactffi_parse_pact_json(const char *json);
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Frees the memory used by the Pact model
|
|
650
|
+
*/
|
|
651
|
+
void pactffi_pact_model_delete(struct Pact *pact);
|
|
652
|
+
|
|
526
653
|
/**
|
|
527
654
|
* Get a copy of this consumer's name.
|
|
528
655
|
*
|
|
@@ -1764,6 +1891,145 @@ const struct ProviderState *pactffi_sync_http_get_provider_state(const struct Sy
|
|
|
1764
1891
|
*/
|
|
1765
1892
|
struct ProviderStateIterator *pactffi_sync_http_get_provider_state_iter(struct SynchronousHttp *interaction);
|
|
1766
1893
|
|
|
1894
|
+
/**
|
|
1895
|
+
* Parse a matcher definition string into a MatchingRuleDefinition containing the example value,
|
|
1896
|
+
* and matching rules and any generator.
|
|
1897
|
+
*
|
|
1898
|
+
* The following are examples of matching rule definitions:
|
|
1899
|
+
* * `matching(type,'Name')` - type matcher with string value 'Name'
|
|
1900
|
+
* * `matching(number,100)` - number matcher
|
|
1901
|
+
* * `matching(datetime, 'yyyy-MM-dd','2000-01-01')` - datetime matcher with format string
|
|
1902
|
+
*
|
|
1903
|
+
* See [Matching Rule definition expressions](https://docs.rs/pact_models/latest/pact_models/matchingrules/expressions/index.html).
|
|
1904
|
+
*
|
|
1905
|
+
* The returned value needs to be freed up with the `pactffi_matcher_definition_delete` function.
|
|
1906
|
+
*
|
|
1907
|
+
* # Errors
|
|
1908
|
+
* If the expression is invalid, the MatchingRuleDefinition error will be set. You can check for
|
|
1909
|
+
* this value with the `pactffi_matcher_definition_error` function.
|
|
1910
|
+
*
|
|
1911
|
+
* # Safety
|
|
1912
|
+
*
|
|
1913
|
+
* This function is safe if the expression is a valid NULL terminated string pointer.
|
|
1914
|
+
*/
|
|
1915
|
+
const struct MatchingRuleDefinitionResult *pactffi_parse_matcher_definition(const char *expression);
|
|
1916
|
+
|
|
1917
|
+
/**
|
|
1918
|
+
* Returns any error message from parsing a matching definition expression. If there is no error,
|
|
1919
|
+
* it will return a NULL pointer, otherwise returns the error message as a NULL-terminated string.
|
|
1920
|
+
* The returned string must be freed using the `pactffi_string_delete` function once done with it.
|
|
1921
|
+
*/
|
|
1922
|
+
const char *pactffi_matcher_definition_error(const struct MatchingRuleDefinitionResult *definition);
|
|
1923
|
+
|
|
1924
|
+
/**
|
|
1925
|
+
* Returns the value from parsing a matching definition expression. If there was an error,
|
|
1926
|
+
* it will return a NULL pointer, otherwise returns the value as a NULL-terminated string.
|
|
1927
|
+
* The returned string must be freed using the `pactffi_string_delete` function once done with it.
|
|
1928
|
+
*
|
|
1929
|
+
* Note that different expressions values can have types other than a string. Use
|
|
1930
|
+
* `pactffi_matcher_definition_value_type` to get the actual type of the value. This function
|
|
1931
|
+
* will always return the string representation of the value.
|
|
1932
|
+
*/
|
|
1933
|
+
const char *pactffi_matcher_definition_value(const struct MatchingRuleDefinitionResult *definition);
|
|
1934
|
+
|
|
1935
|
+
/**
|
|
1936
|
+
* Frees the memory used by the result of parsing the matching definition expression
|
|
1937
|
+
*/
|
|
1938
|
+
void pactffi_matcher_definition_delete(const struct MatchingRuleDefinitionResult *definition);
|
|
1939
|
+
|
|
1940
|
+
/**
|
|
1941
|
+
* Returns the generator from parsing a matching definition expression. If there was an error or
|
|
1942
|
+
* there is no associated generator, it will return a NULL pointer, otherwise returns the generator
|
|
1943
|
+
* as a pointer.
|
|
1944
|
+
*
|
|
1945
|
+
* The generator pointer will be a valid pointer as long as `pactffi_matcher_definition_delete`
|
|
1946
|
+
* has not been called on the definition. Using the generator pointer after the definition
|
|
1947
|
+
* has been deleted will result in undefined behaviour.
|
|
1948
|
+
*/
|
|
1949
|
+
const struct Generator *pactffi_matcher_definition_generator(const struct MatchingRuleDefinitionResult *definition);
|
|
1950
|
+
|
|
1951
|
+
/**
|
|
1952
|
+
* Returns the type of the value from parsing a matching definition expression. If there was an
|
|
1953
|
+
* error parsing the expression, it will return Unknown.
|
|
1954
|
+
*/
|
|
1955
|
+
enum ExpressionValueType pactffi_matcher_definition_value_type(const struct MatchingRuleDefinitionResult *definition);
|
|
1956
|
+
|
|
1957
|
+
/**
|
|
1958
|
+
* Free the iterator when you're done using it.
|
|
1959
|
+
*/
|
|
1960
|
+
void pactffi_matching_rule_iter_delete(struct MatchingRuleIterator *iter);
|
|
1961
|
+
|
|
1962
|
+
/**
|
|
1963
|
+
* Returns an iterator over the matching rules from the parsed definition. The iterator needs to
|
|
1964
|
+
* be deleted with the `pactffi_matching_rule_iter_delete` function once done with it.
|
|
1965
|
+
*
|
|
1966
|
+
* If there was an error parsing the expression, this function will return a NULL pointer.
|
|
1967
|
+
*/
|
|
1968
|
+
struct MatchingRuleIterator *pactffi_matcher_definition_iter(const struct MatchingRuleDefinitionResult *definition);
|
|
1969
|
+
|
|
1970
|
+
/**
|
|
1971
|
+
* Get the next matching rule or reference from the iterator. As the values returned are owned
|
|
1972
|
+
* by the iterator, they do not need to be deleted but will be cleaned up when the iterator is
|
|
1973
|
+
* deleted.
|
|
1974
|
+
*
|
|
1975
|
+
* Will return a NULL pointer when the iterator has advanced past the end of the list.
|
|
1976
|
+
*
|
|
1977
|
+
* # Safety
|
|
1978
|
+
*
|
|
1979
|
+
* This function is safe.
|
|
1980
|
+
*
|
|
1981
|
+
* # Error Handling
|
|
1982
|
+
*
|
|
1983
|
+
* This function will return a NULL pointer if passed a NULL pointer or if an error occurs.
|
|
1984
|
+
*/
|
|
1985
|
+
const struct MatchingRuleResult *pactffi_matching_rule_iter_next(struct MatchingRuleIterator *iter);
|
|
1986
|
+
|
|
1987
|
+
/**
|
|
1988
|
+
* Get the JSON form of the matching rule.
|
|
1989
|
+
*
|
|
1990
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
1991
|
+
*
|
|
1992
|
+
* # Safety
|
|
1993
|
+
*
|
|
1994
|
+
* This function will fail if it is passed a NULL pointer, or the iterator that owns the
|
|
1995
|
+
* value of the matching rule has been deleted.
|
|
1996
|
+
*/
|
|
1997
|
+
const char *pactffi_matching_rule_to_json(const struct MatchingRule *rule);
|
|
1998
|
+
|
|
1999
|
+
/**
|
|
2000
|
+
* Get the JSON form of the generator.
|
|
2001
|
+
*
|
|
2002
|
+
* The returned string must be deleted with `pactffi_string_delete`.
|
|
2003
|
+
*
|
|
2004
|
+
* # Safety
|
|
2005
|
+
*
|
|
2006
|
+
* This function will fail if it is passed a NULL pointer, or the owner of the generator has
|
|
2007
|
+
* been deleted.
|
|
2008
|
+
*/
|
|
2009
|
+
const char *pactffi_generator_to_json(const struct Generator *generator);
|
|
2010
|
+
|
|
2011
|
+
/**
|
|
2012
|
+
* Generate a string value using the provided generator and an optional JSON payload containing
|
|
2013
|
+
* any generator context. The context value is used for generators like `MockServerURL` (which
|
|
2014
|
+
* should contain details about the running mock server) and `ProviderStateGenerator` (which
|
|
2015
|
+
* should be the values returned from the Provider State callback function).
|
|
2016
|
+
*
|
|
2017
|
+
* If anything goes wrong, it will return a NULL pointer.
|
|
2018
|
+
*/
|
|
2019
|
+
const char *pactffi_generator_generate_string(const struct Generator *generator,
|
|
2020
|
+
const char *context_json);
|
|
2021
|
+
|
|
2022
|
+
/**
|
|
2023
|
+
* Generate an integer value using the provided generator and an optional JSON payload containing
|
|
2024
|
+
* any generator context. The context value is used for generators like `ProviderStateGenerator`
|
|
2025
|
+
* (which should be the values returned from the Provider State callback function).
|
|
2026
|
+
*
|
|
2027
|
+
* If anything goes wrong or the generator is not a type that can generate an integer value, it
|
|
2028
|
+
* will return a zero value.
|
|
2029
|
+
*/
|
|
2030
|
+
unsigned short pactffi_generator_generate_integer(const struct Generator *generator,
|
|
2031
|
+
const char *context_json);
|
|
2032
|
+
|
|
1767
2033
|
/**
|
|
1768
2034
|
* Delete a string previously returned by this FFI.
|
|
1769
2035
|
*
|
package/ffi/pact_ffi.dll
CHANGED
|
Binary file
|
package/ffi/pact_ffi.dll.lib
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pact-foundation/pact-core",
|
|
3
|
-
"version": "13.12.
|
|
3
|
+
"version": "13.12.2",
|
|
4
4
|
"description": "Core of @pact-foundation/pact. You almost certainly don't want to depend on this directly.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"homepage": "https://github.com/pact-foundation/pact-js-core#readme",
|
package/src/ffi/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LogLevel } from '../logger/types';
|
|
2
2
|
import { Ffi } from './types';
|
|
3
3
|
declare const ffiLib: Ffi;
|
|
4
|
-
export declare const PACT_FFI_VERSION = "0.3.
|
|
4
|
+
export declare const PACT_FFI_VERSION = "0.3.15";
|
|
5
5
|
declare let ffi: typeof ffiLib;
|
|
6
6
|
export declare const getFfiLib: (logLevel?: LogLevel) => typeof ffi;
|
|
7
7
|
export {};
|
package/src/ffi/index.js
CHANGED
|
@@ -23,7 +23,7 @@ exports.getFfiLib = exports.PACT_FFI_VERSION = void 0;
|
|
|
23
23
|
const logger_1 = __importStar(require("../logger"));
|
|
24
24
|
const bindings = require("bindings");
|
|
25
25
|
const ffiLib = bindings('pact.node');
|
|
26
|
-
exports.PACT_FFI_VERSION = '0.3.
|
|
26
|
+
exports.PACT_FFI_VERSION = '0.3.15';
|
|
27
27
|
let ffi;
|
|
28
28
|
let ffiLogLevel;
|
|
29
29
|
const initialiseFfi = (logLevel) => {
|